aboutsummaryrefslogtreecommitdiff
path: root/challenge-174/sgreen/python/ch-1.py
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2022-07-24 10:06:19 +0100
committerGitHub <noreply@github.com>2022-07-24 10:06:19 +0100
commitdccad79fb3738429d8cb704663cbbc012a6a4e6d (patch)
tree200cc0746ee3445d0d4a76b990ba44762abc31c0 /challenge-174/sgreen/python/ch-1.py
parent35c6f5200e28d661dc3142cfca919ebd93f5e073 (diff)
parentaa833882a1c8cc63273b16e326718460e200fa21 (diff)
downloadperlweeklychallenge-club-dccad79fb3738429d8cb704663cbbc012a6a4e6d.tar.gz
perlweeklychallenge-club-dccad79fb3738429d8cb704663cbbc012a6a4e6d.tar.bz2
perlweeklychallenge-club-dccad79fb3738429d8cb704663cbbc012a6a4e6d.zip
Merge pull request #6487 from simongreen-net/master
sgreen solutions to challenge 174
Diffstat (limited to 'challenge-174/sgreen/python/ch-1.py')
-rwxr-xr-xchallenge-174/sgreen/python/ch-1.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-174/sgreen/python/ch-1.py b/challenge-174/sgreen/python/ch-1.py
new file mode 100755
index 0000000000..cf3ae3c075
--- /dev/null
+++ b/challenge-174/sgreen/python/ch-1.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+def is_disarium(n):
+ sum = 0
+
+ for count, value in enumerate(str(n)):
+ sum += int(value) ** (count+1)
+
+ return sum == n
+
+
+def main():
+ solutions = []
+ number = 0
+
+ while len(solutions) < 19:
+ if is_disarium(number):
+ solutions.append(number)
+ number += 1
+
+ print(*solutions, sep=', ')
+
+
+if __name__ == '__main__':
+ main()