aboutsummaryrefslogtreecommitdiff
path: root/challenge-113/lubos-kolouch/python/ch-1.py
blob: 883f53eae12040db32c0384ad59251d0ea67a548 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def represent_integer(N, D):
    str_N = str(N)
    if str(D) not in str_N:
        return 0
    sum_N = sum(int(digit) for digit in str_N if digit == str(D))
    return sum_N == N


# Testing
print(represent_integer(25, 2))  # Outputs: 0
print(represent_integer(22, 2))  # Outputs: 1