[root@www ~]# python thirtyone.py
73682
Started at: Sun Oct 12 18:26:02 2008 Ended at: Sun Oct 12 18:26:02 2008
[root@www ~]# cat thirtyone.py
# -*- coding: utf-8 -*-
"""
<+ MODULE_NAME +>
Project Euler Problem Set
<+ DESCRIPTION +>
Solutions in Python to the problems at http://projecteuler.net
Licensed under the Creative Commons license; see http://creativecommons.org for more details. In short, this means you can freely reuse, modify and distribute this program, also commercially, for as long you provide a proper attribution.
Copyright by Jonathan Mark, jonathanmark.com/aristede.com, jmark@aristede.com
>>> print 881 + 1
882
"""
import time
starttime = time.asctime()
count = 0
# 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).
for p5 in range(41):
for p10 in range (21):
for p20 in range(11):
for p50 in range(5):
for p100 in range(3):
for p200 in range(2):
sum = p5*5 + p10*10 + p20*20 + p50*50 + p100*100 + p200*200
if (sum <= 200):
count += (200 -sum)//2 + 1
print count
print "Started at: ", starttime, " Ended at: ",time.asctime()
if __name__ == "__main__":
import doctest
doctest.testmod()
Sunday, October 12, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment