diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2022-03-19 10:10:20 +0100 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2022-03-19 10:10:20 +0100 |
| commit | d8fadfce927ded515784f96676111b3c1f93ec37 (patch) | |
| tree | dea9eb3eec382c3e620f79fb6c88f2a090826ff1 | |
| parent | 44dee40a00e0f597c3a62e791549220d2e1d262e (diff) | |
| download | perlweeklychallenge-club-d8fadfce927ded515784f96676111b3c1f93ec37.tar.gz perlweeklychallenge-club-d8fadfce927ded515784f96676111b3c1f93ec37.tar.bz2 perlweeklychallenge-club-d8fadfce927ded515784f96676111b3c1f93ec37.zip | |
feat(challenge-156/lubos-kolouch/ch-1.py): Challenge 156 Task 1 Python LK
| -rw-r--r-- | challenge-156/lubos-kolouch/python/ch-1.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-156/lubos-kolouch/python/ch-1.py b/challenge-156/lubos-kolouch/python/ch-1.py new file mode 100644 index 0000000000..66576b2f52 --- /dev/null +++ b/challenge-156/lubos-kolouch/python/ch-1.py @@ -0,0 +1,22 @@ +""" Challenge 156 Task 1 LK """ +import re + +from sympy import isprime + + +def get_pernicious(what: int) -> list: + """Get the pernicious numbers""" + + nums: list[int] = [] + + num = 0 + while len(nums) < what: + num += 1 + bin_num = f"{num:b}" + bin_num = re.sub("0", "", bin_num) + if isprime(len(bin_num)): + nums.append(num) + return nums + + +assert get_pernicious(10) == [3, 5, 6, 7, 9, 10, 11, 12, 13, 14] |
