Poker Game

This is the place for queries that don't fit in any of the other categories.

Poker Game

Postby lovecodecakes » Wed Mar 13, 2013 1:30 pm

Provided a list of int+str
like hand=['2S', '10D', '3H']

Q1. I want to disassociate int in a list by key=max s.t.
ranks=[10,3,2] and
suits=['D','H','S'] where indices of suits follow sequence as in ranks, mapped in other words
so that when i zip(ranks,suits)==> hand back again in the descending order as

hand=['10D','3H','2S']

Q2. Is there a way to use to For loops in a single statement?
Eg: For s in something and r in something or For r,s in name1,name2:
for the 2nd 1 error is too many elements to unpack
Last edited by lovecodecakes on Wed Mar 13, 2013 7:33 pm, edited 2 times in total.
lovecodecakes
 
Posts: 56
Joined: Mon Feb 11, 2013 8:19 pm

Re: Poker Game

Postby Yoriz » Wed Mar 13, 2013 5:38 pm

Unit one of this free online course deals with poker hands.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 789
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Poker Game

Postby lovecodecakes » Wed Mar 13, 2013 5:55 pm

It is from its Problem Set 1 that I am asking for clarification if the mentioned lines could be fixed
Yoriz wrote:Unit one of this free online course deals with poker hands.
lovecodecakes
 
Posts: 56
Joined: Mon Feb 11, 2013 8:19 pm

Re: Poker Game

Postby Yoriz » Wed Mar 13, 2013 6:24 pm

My solution was to use itertools.permutations to get the possible combination of hands and then i looped through those using the 'hand_rank' function to find the best hand score. hand_rank is provided for you in the code.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 789
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to General Coding Help

Who is online

Users browsing this forum: Baldyr and 4 guests