Permalink
Browse files

script to find the final number

  • Loading branch information...
1 parent 8161264 commit b6ee478d5f644242942fe4c33b9fd29f940ffe24 Matthew Hooker committed May 16, 2010
Showing with 12 additions and 14 deletions.
  1. +1 −0 17/answer.sh
  2. +11 −14 17/numbers.py
View
@@ -0,0 +1 @@
+python numbers.py | sed 's/[^a-zA-Z]//g' | wc -m
View
@@ -1,32 +1,29 @@
-def ones():
- return 'one two three four five six seven eight nine'.split()
+ONES = 'one two three four five six seven eight nine'.split()
-def to_twenty():
- return 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen'.split()
+TO_TWENTY = 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen'.split()
-def twenty_to_ninety():
- return 'twenty thirty forty fifty sixty seventy eighty ninety'.split()
+TWENTY_TO_NINETY = 'twenty thirty forty fifty sixty seventy eighty ninety'.split()
def one_to_99():
numbers = []
- for i in to_twenty():
+ for i in TO_TWENTY:
numbers.append(i)
- for tens in twenty_to_ninety():
+ for tens in TWENTY_TO_NINETY:
numbers.append(tens)
- for one in ones():
+ for one in ONES:
numbers.append("%s-%s" % (tens, one))
return numbers
if __name__ == "__main__":
for i in one_to_99():
- print "%s, " % i
+ print "%s, " % i,
- for hundred in ones():
- print "%s-hundred, " % hundred
+ for hundred in ONES:
+ print "%s hundred, " % hundred,
for other in one_to_99():
- print "%s-hundred and %s," % (hundred, other)
+ print "%s hundred and %s," % (hundred, other),
- print "one-thousand"
+ print "one thousand",

0 comments on commit b6ee478

Please sign in to comment.