From f91b16b09f8db78df9bdfee2da0cebe468d36699 Mon Sep 17 00:00:00 2001 From: Lubos Kolouch Date: Sat, 16 Jul 2022 18:26:28 +0200 Subject: feat(challenge-173/lubos-kolouch/python/ch-{1,2}.py): Challenge 173 LK Python Task 1 2 --- challenge-173/lubos-kolouch/python/ch-1.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 challenge-173/lubos-kolouch/python/ch-1.py (limited to 'challenge-173/lubos-kolouch/python/ch-1.py') 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 -- cgit