diff --git a/Python/p019.py b/Python/p019.py new file mode 100644 index 0000000..1cb1577 --- /dev/null +++ b/Python/p019.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 + +import datetime + +from timeit import default_timer + +def main(): + start = default_timer() + + count = 0 + + for year in range(1901, 2001): + for month in range(1, 13): + if datetime.datetime(year, month, 1).weekday() == 6: + count = count + 1 + + end = default_timer() + + print('Project Euler, Problem 19') + print('Answer: {}'.format(count)) + + print('Elapsed time: {:.9f} seconds'.format(end - start)) + +if __name__ == '__main__': + main() diff --git a/Python/p020.py b/Python/p020.py new file mode 100644 index 0000000..5ec0692 --- /dev/null +++ b/Python/p020.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 + +from math import factorial + +from timeit import default_timer + +def main(): + start = default_timer() + + n = str(factorial(100)) + + sum_ = 0 + + for i in range(len(n)): + sum_ = sum_ + int(n[i]) + + end = default_timer() + + print('Project Euler, Problem 20') + print('Answer: {}'.format(sum_)) + + print('Elapsed time: {:.9f} seconds'.format(end - start)) + +if __name__ == '__main__': + main()