-1

I have a poker table with 9 seats represented as a list of players and the button position. I have to calculate the position of Hero(UTG, Middle Position, Late Position, CO, BB, SB...). Some seats could be empty, in this case the place is filled with "".

table=["Player_1","Player_2","","","Hero","","","","Player_3"]
button_position=1#Player_2 is the Button

In this case Hero is the Small Blind.

Any idea on how to solve the problem?

F. Noe
  • 21
  • 3

1 Answers1

0

I solved with 2 for(cycling first from button to the end, and then cycling from start to button-1):

def position(table,button_position):

 temp = [x for x in table if x!=""]
 contatore=0
 relative_position=0

 for i in range(button_position,len(table)):
  if(table[i]!=""):
      contatore=contatore+1
  if(table[i]=="Hero"):
   relative_position=contatore

 if(relative_position==0):
  for i in range(0,button_position-1):
   if(table[i]!=""):
    contatore=contatore+1
   if(table[i]=="Hero"):
    relative_position=contatore

 return relative_position
F. Noe
  • 21
  • 3