Okay need some help 
so this is the situation. you have a deck fo cards in your hand which is represented as a list. You place it down in a list, then you compare it to the card left of it one spot. If the suit or the number match, you add it on top of that card. Same thing for card 3 to the left, if it matches suit or number, add on top of it. otherwise, you just leave it and draw another card. I worked up some code/pseudo code so far and i was wondering what you guys think in means of it solving my problem?
input would look like
meaning queen of spades and 3 of clubs and so forth
#move on means the next card from your hand will be placed
I guess i just want to know if the setup looks good and im not that sure about all the else if's, but
thanks for the help guys, and i know the code for the if's worked because i tested that much.
cheers!
Edited by protzman - 11/7/12 at 5:57pm

so this is the situation. you have a deck fo cards in your hand which is represented as a list. You place it down in a list, then you compare it to the card left of it one spot. If the suit or the number match, you add it on top of that card. Same thing for card 3 to the left, if it matches suit or number, add on top of it. otherwise, you just leave it and draw another card. I worked up some code/pseudo code so far and i was wondering what you guys think in means of it solving my problem?
input would look like
meaning queen of spades and 3 of clubs and so forth
Code:
def play(list):
for k in list:
a = 0
#insert into the pile
pile[a] = list[k]
#check if the new card in the pile is compatible to the card to the left
#check in terms if the first char of each card is compatible
if( ((pile[a])[0]) = ((pile[a-1])[0]) ):
#add card to the top of the card to the left
#and increase a and move on
#check in terms if the last char of each card is compatible
else if(((pile[a])[(len((pile[a])))-1]) = ((pile[a-1])[(len((pile[a-1])))-1]) ):
#add card to the top of the card to the left
#and increase a and move on
#check if the new card in the pile is compatible to the card 3 to the left
#check in terms if the first char of each card is compatible
else if( ((pile[a])[0]) = ((pile[a-3])[0]) ):
#add card to the top of the card 3 to left
#and increase a and move on
#check in terms if the last char of each card is compatible
else if(((pile[a])[(len((pile[a])))-1]) = ((pile[a-3])[(len((pile[a-3])))-1]) ):
#add card to the top of the card 3 to left
#and increase a and move on
else:
#increase a and move on
#move on means the next card from your hand will be placed
I guess i just want to know if the setup looks good and im not that sure about all the else if's, but
thanks for the help guys, and i know the code for the if's worked because i tested that much.
cheers!
Edited by protzman - 11/7/12 at 5:57pm







because the extensive commenting hurts my eyes.
Seriously, don't go overboard with the comments.
