mirror of
https://github.com/jlengrand/project_euler.git
synced 2026-03-10 08:41:20 +00:00
Implements the stripping routine> Everything is sequential, but as we dont have much data this is not really an issue
This commit is contained in:
23
e_54.py
23
e_54.py
@@ -38,13 +38,32 @@ def load_data(filename):
|
||||
file.close()
|
||||
return hands
|
||||
|
||||
def sort_n_strip(hands):
|
||||
"""
|
||||
As description indicates data is correct, we can ignore the color of the
|
||||
cards. (and hence strip the value)
|
||||
We also want to sort the players hands (to be worked with easier later)
|
||||
"""
|
||||
# just keeping the first element of the cards
|
||||
stripped_hands = [[[val[0] for val in h] for h in hand] for hand in hands]
|
||||
|
||||
sorted_hands = stripped_hands
|
||||
#need to sort now
|
||||
return sorted_hands
|
||||
|
||||
def winning_hands(filename):
|
||||
"""
|
||||
Returns the first of the firs num consecutive primes.
|
||||
"""
|
||||
hands = load_data(filename)
|
||||
for val in hands:
|
||||
print val
|
||||
|
||||
data = sort_n_strip(hands)
|
||||
print hands
|
||||
print data
|
||||
|
||||
#for val in hands:
|
||||
|
||||
#print val
|
||||
|
||||
if __name__ == '__main__':
|
||||
winning_hands("./e_54_poker.txt")
|
||||
|
||||
Reference in New Issue
Block a user