Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Rotate Hole by Mahoter
def rotate(state, pipe_numbers):
res = []
a = 0
while a < len(state):
c = 0
for b in pipe_numbers:
if state[b] == 1:
c += 1
if c == len(pipe_numbers):
res += [a]
temp = state.pop()
state = [temp] + state
a += 1
return res
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"
Jan. 18, 2016