aboutsummaryrefslogtreecommitdiff
path: root/challenge-157/lubos-kolouch/python/ch-2.py
blob: b3a11b0c3cffa6e3d8b633d2efbd92a6c7c7ab2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
""" Challenge 157 Task 2 LK """

import re

import numpy as np


def is_brazilian(what: int) -> bool:
    """Test if the num is brazilian"""

    for i in range(2, what - 1):

        base_rep = np.base_repr(what, i)

        if re.match(r"^(.)\1+$", base_rep):
            return True

    return False


assert is_brazilian(7) == 1
assert is_brazilian(6) == 0
assert is_brazilian(8) == 1