Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Rotate Hole by rolandp
#from collections import deque
def rotate(state, pipe_numbers):
return [ i for i in range(len(state)) \
if all( state[(p - i)%len(state)] == 1 for p in pipe_numbers ) ]
## Long version using circular data structures:
# circ = deque( state, maxlen=len(state) )
# res = []
# for i in range(0, len(state)):
# if all( circ[p] == 1 for p in pipe_numbers ):
# res.append(i)
# circ.rotate(1)
# return res
Sept. 22, 2015