Jan-28-2018, 11:04 PM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
def my_prisoners(p): for i in range ( 6 ): attempt = 0 idx = i found = False while attempt< 3 : if p[idx] = = i + 1 : found = True break else : idx = p[idx] - 1 attempt + = 1 if not found: return False return True |