diff --git a/15.py b/15.py index 399955c..0b424af 100755 --- a/15.py +++ b/15.py @@ -1,13 +1,15 @@ -import sys; - -def factorial(num): - result = 1; - for x in range (num,1,-1): - result *= x; - return result; - -def binomial(m,n): - return factorial(m)/(factorial(n)*factorial(m-n)); - -dimension = int(sys.argv[1]); -print "Result is: " + str(binomial(dimension*2,dimension)); +#!/usr/bin/python + +import sys; + +def factorial(num): + result = 1; + for x in range (num,1,-1): + result *= x; + return result; + +def binomial(m,n): + return factorial(m)/(factorial(n)*factorial(m-n)); + +dimension = int(sys.argv[1]); +print "Result is: " + str(binomial(dimension*2,dimension)); diff --git a/16.py b/16.py index 2dbbe74..efb196e 100755 --- a/16.py +++ b/16.py @@ -1,12 +1,14 @@ -import math; -import sys; - -def sumDigits(num): - sum = 0; - for i in range (0,len(num)): - sum += int(num[i]); - - return sum; - - -print "Result is: " + str(sumDigits(str(int(math.pow(int(sys.argv[1]),int(sys.argv[2])))))) +#!/usr/bin/python + +import math; +import sys; + +def sumDigits(num): + sum = 0; + for i in range (0,len(num)): + sum += int(num[i]); + + return sum; + + +print "Result is: " + str(sumDigits(str(int(math.pow(int(sys.argv[1]),int(sys.argv[2])))))) diff --git a/17.py b/17.py deleted file mode 100755 index f8c28ce..0000000 --- a/17.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/python - -S = [0,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8] -D = [0,3,6,6,5,5,5,7,6,6] -H = 7 -T = 8 - -total = 0 -for i in range(1,1000): - c = i % 10 # singles digit - b = ((i % 100) - c) / 10 # tens digit - a = ((i % 1000) - (b * 10) - c) / 100 # hundreds digit - - if a != 0: - total += S[a] + H # "S[a] hundred - if b != 0 or c != 0: total += 3 # "and" - if b == 0 or b == 1: total += S[b * 10 + c] - else: total += D[b] + S[c] - -total += S[1] + T - -print "Result is: " + str(total)