Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Rotate Hole by Andreas_Strus
def rotate(state, pipe_numbers):
posible = []
check = 0
for m in pipe_numbers:
if state[m] == 1:
check = check + 1
if check == len(pipe_numbers):
posible = posible + [0]
print(posible)
for n in range(len(state) - 1):
state1 = []
for m in range(len(state)):
if m != 0:
state1.append(state[m - 1])
else:
state1.append(state[len(state) - 1])
state = state1[:]
check = 0
for m in pipe_numbers:
if state[m] == 1:
check = check + 1
if check == len(pipe_numbers):
posible = posible + [n + 1]
print(posible)
return posible
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert rotate([1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1], [0, 1]) == [1, 8], "Example"
assert rotate([1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1], [0, 1, 2]) == [], "Mission impossible"
assert rotate([1, 0, 0, 0, 1, 1, 0, 1], [0, 4, 5]) == [0], "Don't touch it"
assert rotate([1, 0, 0, 0, 1, 1, 0, 1], [5, 4, 5]) == [0, 5], "Two cannonballs in the same pipe"
Nov. 12, 2016