aboutsummaryrefslogtreecommitdiff
path: root/challenge-173
diff options
context:
space:
mode:
authorWalt Mankowski <waltman@pobox.com>2022-07-16 20:41:38 -0400
committerWalt Mankowski <waltman@pobox.com>2022-07-16 20:41:38 -0400
commit30ccbd6b2aa92693bd2cd6dce4bce71ae9d7dd5e (patch)
treef084b7859be918db3b7d729302c74681cfdaa46e /challenge-173
parentc04831d7a245601dae441b8cd2993e1cc8c999cb (diff)
downloadperlweeklychallenge-club-30ccbd6b2aa92693bd2cd6dce4bce71ae9d7dd5e.tar.gz
perlweeklychallenge-club-30ccbd6b2aa92693bd2cd6dce4bce71ae9d7dd5e.tar.bz2
perlweeklychallenge-club-30ccbd6b2aa92693bd2cd6dce4bce71ae9d7dd5e.zip
Python solutions to challenge 173
Diffstat (limited to 'challenge-173')
-rw-r--r--challenge-173/walt-mankowski/python/ch-1.py14
-rw-r--r--challenge-173/walt-mankowski/python/ch-2.py9
2 files changed, 23 insertions, 0 deletions
diff --git a/challenge-173/walt-mankowski/python/ch-1.py b/challenge-173/walt-mankowski/python/ch-1.py
new file mode 100644
index 0000000000..f987ce2eff
--- /dev/null
+++ b/challenge-173/walt-mankowski/python/ch-1.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+import sys
+
+def is_esthetic(n):
+ d = [int(c) for c in str(n)]
+ for i in range(1, len(d)):
+ if abs(d[i-1]-d[i]) != 1:
+ return False
+ return True
+
+n = int(sys.argv[1])
+print(f'{n} {"is" if is_esthetic(n) else "is not"} an esthetic number')
+
+
diff --git a/challenge-173/walt-mankowski/python/ch-2.py b/challenge-173/walt-mankowski/python/ch-2.py
new file mode 100644
index 0000000000..e12d79a883
--- /dev/null
+++ b/challenge-173/walt-mankowski/python/ch-2.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+from functools import reduce
+
+sylvester = []
+while len(sylvester) < 10:
+ sylvester.append(reduce(lambda x,y: x*y, sylvester, 1) + 1)
+
+for syl in sylvester:
+ print(syl)