aboutsummaryrefslogtreecommitdiff
path: root/challenge-195/sgreen/python/ch-1.py
diff options
context:
space:
mode:
authorJames Smith <js5@sanger.ac.uk>2022-12-26 14:20:09 +0000
committerGitHub <noreply@github.com>2022-12-26 14:20:09 +0000
commitae146d8ac3d7fd8a856be32a4367693d574d914d (patch)
treedf39baa009d2f572ebc6a3d2d1f5cc0a953d60e7 /challenge-195/sgreen/python/ch-1.py
parentdae0a10e23b470229e2440cd0683b3a90a1e4ca4 (diff)
parent63fb76188e132564e50feefd2d9d5b8491568948 (diff)
downloadperlweeklychallenge-club-ae146d8ac3d7fd8a856be32a4367693d574d914d.tar.gz
perlweeklychallenge-club-ae146d8ac3d7fd8a856be32a4367693d574d914d.tar.bz2
perlweeklychallenge-club-ae146d8ac3d7fd8a856be32a4367693d574d914d.zip
Merge branch 'manwar:master' into master
Diffstat (limited to 'challenge-195/sgreen/python/ch-1.py')
-rwxr-xr-xchallenge-195/sgreen/python/ch-1.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/challenge-195/sgreen/python/ch-1.py b/challenge-195/sgreen/python/ch-1.py
new file mode 100755
index 0000000000..4b3831a16c
--- /dev/null
+++ b/challenge-195/sgreen/python/ch-1.py
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+
+import sys
+
+
+def is_simple_number(n):
+ # Determine if the number is simple
+ seen = {}
+ for i in str(n):
+ if i in seen:
+ # We've seen the digit before. It's not simple
+ return False
+ seen[i] = 1
+
+ # It is simple
+ return True
+
+
+def main(n):
+ # Iterate through the list counting the number of simple numbers
+ simple_count = 0
+ for i in range(1, n+1):
+ if is_simple_number(i):
+ simple_count += 1
+
+ # Print the result
+ print(simple_count)
+
+
+if __name__ == '__main__':
+ main(int(sys.argv[1]))