diff options
| author | Walt Mankowski <waltman@pobox.com> | 2022-07-17 10:56:32 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-17 10:56:32 -0400 |
| commit | 45f08a5e1866678d6ac9e42e30afd3a1d5d53fe6 (patch) | |
| tree | 3f77242a19900a639e6cbc7e6074958bfc465c35 /challenge-173/sgreen/python | |
| parent | 37698ededed833b0c0d49ac0e44d5d01025e8b0e (diff) | |
| parent | ef0acd3af69b9cc99dea234b2ab4670e52bb506e (diff) | |
| download | perlweeklychallenge-club-45f08a5e1866678d6ac9e42e30afd3a1d5d53fe6.tar.gz perlweeklychallenge-club-45f08a5e1866678d6ac9e42e30afd3a1d5d53fe6.tar.bz2 perlweeklychallenge-club-45f08a5e1866678d6ac9e42e30afd3a1d5d53fe6.zip | |
Merge branch 'master' into branch-for-challenge-173-python
Diffstat (limited to 'challenge-173/sgreen/python')
| -rwxr-xr-x | challenge-173/sgreen/python/ch-1.py | 21 | ||||
| -rwxr-xr-x | challenge-173/sgreen/python/ch-2.py | 18 |
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-173/sgreen/python/ch-1.py b/challenge-173/sgreen/python/ch-1.py new file mode 100755 index 0000000000..ab78b2aa42 --- /dev/null +++ b/challenge-173/sgreen/python/ch-1.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +import sys + + +def main(n): + # The first character is 0 .. len(n)-2 + for i in range(len(n)-1): + # Calculate the difference between that number and the next + diff = abs(int(n[i]) - int(n[i+1])) + if diff != 1: + # This is not a esthetic number + print('0') + return + + # This is a esthetic number + print('1') + + +if __name__ == '__main__': + main(sys.argv[1]) diff --git a/challenge-173/sgreen/python/ch-2.py b/challenge-173/sgreen/python/ch-2.py new file mode 100755 index 0000000000..fb5a135067 --- /dev/null +++ b/challenge-173/sgreen/python/ch-2.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +import math + + +def main(): + # Set S0 of 2 + solutions = [2] + while len(solutions) < 10: + # The next value is the product of the current array plus one + solutions.append(math.prod(solutions)+1) + + # Print the solution + print(*solutions, sep='\n') + + +if __name__ == '__main__': + main() |
