aboutsummaryrefslogtreecommitdiff
path: root/challenge-164/lubos-kolouch/python/ch-1.py
blob: 0cd7729f7b339881ecc1a9e1dcb3c557d693f013 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
""" Challenge 164 Task 1 """
from sympy import nextprime


def get_palindrome_numbers() -> list:
    """Get the palindrome numbers as requested"""
    prime = 0

    output = []

    while (prime := nextprime(prime)) < 1000:
        if str(prime) == str(prime)[::-1]:
            output.append(prime)

    return output


assert get_palindrome_numbers() == [
    2,
    3,
    5,
    7,
    11,
    101,
    131,
    151,
    181,
    191,
    313,
    353,
    373,
    383,
    727,
    757,
    787,
    797,
    919,
    929,
]