aboutsummaryrefslogtreecommitdiff
path: root/challenge-126/stuart-little/python/ch-1.py
diff options
context:
space:
mode:
authorchirvasitua <stuart-little@users.noreply.github.com>2021-08-16 19:30:03 -0400
committerchirvasitua <stuart-little@users.noreply.github.com>2021-08-16 19:30:03 -0400
commit77013f6f7abb61a1a79cf2db66632b16f94b9e9a (patch)
tree1c9ab7034a0892ceb92bf1c4fd93d886d0100149 /challenge-126/stuart-little/python/ch-1.py
parent0186b33e4bdd1a813adfb3a07e125887a5a0ccc5 (diff)
downloadperlweeklychallenge-club-77013f6f7abb61a1a79cf2db66632b16f94b9e9a.tar.gz
perlweeklychallenge-club-77013f6f7abb61a1a79cf2db66632b16f94b9e9a.tar.bz2
perlweeklychallenge-club-77013f6f7abb61a1a79cf2db66632b16f94b9e9a.zip
1st commit on 126_python
Diffstat (limited to 'challenge-126/stuart-little/python/ch-1.py')
-rwxr-xr-xchallenge-126/stuart-little/python/ch-1.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/challenge-126/stuart-little/python/ch-1.py b/challenge-126/stuart-little/python/ch-1.py
new file mode 100755
index 0000000000..aea89f2b33
--- /dev/null
+++ b/challenge-126/stuart-little/python/ch-1.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+
+# run <script> <number>
+
+import sys
+
+def no1(nr):
+ if len(nr)==0:
+ return 0
+ if nr[0] == '1':
+ return 9**(len(nr)-1)
+ return (int(nr[0])-1) * 9**(len(nr)-1) + no1(nr[1:])
+
+print(no1(sys.argv[1]) if '1' not in sys.argv[1] else (no1(sys.argv[1])-1))