aboutsummaryrefslogtreecommitdiff
path: root/challenge-173/lubos-kolouch/python/ch-1.py
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2022-07-16 17:48:35 +0100
committerGitHub <noreply@github.com>2022-07-16 17:48:35 +0100
commit7e4d17cc4e4296afa964a04eebb69a95850e06b1 (patch)
treec69dbd5ffef3eac6dd35f068bcc3ca482a04266a /challenge-173/lubos-kolouch/python/ch-1.py
parentedf94eeec3c29a9cfdf35792f43096a5cebae6bf (diff)
parentf91b16b09f8db78df9bdfee2da0cebe468d36699 (diff)
downloadperlweeklychallenge-club-7e4d17cc4e4296afa964a04eebb69a95850e06b1.tar.gz
perlweeklychallenge-club-7e4d17cc4e4296afa964a04eebb69a95850e06b1.tar.bz2
perlweeklychallenge-club-7e4d17cc4e4296afa964a04eebb69a95850e06b1.zip
Merge pull request #6451 from LubosKolouch/master
Challenge 173 LK Perl Python
Diffstat (limited to 'challenge-173/lubos-kolouch/python/ch-1.py')
-rw-r--r--challenge-173/lubos-kolouch/python/ch-1.py15
1 files changed, 15 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