aboutsummaryrefslogtreecommitdiff
path: root/challenge-173
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-173')
-rw-r--r--challenge-173/lubos-kolouch/python/ch-1.py15
-rw-r--r--challenge-173/lubos-kolouch/python/ch-2.py28
2 files changed, 43 insertions, 0 deletions
diff --git a/challenge-173/lubos-kolouch/python/ch-1.py b/challenge-173/lubos-kolouch/python/ch-1.py
new file mode 100644
index 0000000000..d644b5fe30
--- /dev/null
+++ b/challenge-173/lubos-kolouch/python/ch-1.py
@@ -0,0 +1,15 @@
+""" Challenge 173 Task 1 LK """
+
+
+def is_esthetic_number(what: int) -> bool:
+ """Check if the number is esthetic"""
+
+ for pos, num in enumerate(str(what)[0:-1]):
+ if abs(int(num) - int(str(what)[pos + 1])) != 1:
+ return False
+
+ return True
+
+
+assert is_esthetic_number(5456) == 1
+assert is_esthetic_number(120) == 0
diff --git a/challenge-173/lubos-kolouch/python/ch-2.py b/challenge-173/lubos-kolouch/python/ch-2.py
new file mode 100644
index 0000000000..7e58fa2192
--- /dev/null
+++ b/challenge-173/lubos-kolouch/python/ch-2.py
@@ -0,0 +1,28 @@
+""" Generate Sylvestver numbers """
+
+
+def generate_sylvestver_numbers(limit: int) -> list:
+ """Generate the Sylvester numbers"""
+
+ items = [2]
+ product = items[0]
+
+ while len(items) < limit:
+ items.append(product + 1)
+ product *= items[-1]
+
+ return items
+
+
+assert generate_sylvestver_numbers(10) == [
+ 2,
+ 3,
+ 7,
+ 43,
+ 1807,
+ 3263443,
+ 10650056950807,
+ 113423713055421844361000443,
+ 12864938683278671740537145998360961546653259485195807,
+ 165506647324519964198468195444439180017513152706377497841851388766535868639572406808911988131737645185443,
+]