euler/e054.py
Correl Roush 5bbf86c6c3 Renaming exercise files so functions can be imported into other scripts
git-svn-id: file:///srv/svn/euler@31 e5f4c3ec-3c0c-11df-b522-21efaa4426b5
2010-04-12 15:53:10 +00:00

28 lines
837 B
Python

from p054 import poker
if __name__ == '__main__':
wins = 0
counter = 0
with open('p054/poker.txt', 'r') as f:
while True:
line = f.readline()
if not line:
break
counter = counter + 1
cards = line.strip().split()
one = poker.Hand(cards[:5])
two = poker.Hand(cards[-5:])
result = cmp(one, two)
if result > 0:
wins = wins + 1
outcome = 'Player One wins'
elif result == 0:
outcome = 'Tie'
else:
outcome = 'Player Two wins'
print "Hand #{0}: {1}\n {2}\n {3}".format(
counter,
outcome,
one,
two)
print "Player one won {0} hands".format(wins)