Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Rotate Hole by Michal_Cichy
def obr(lista, oile):
pom=[0 for x in range(len(lista))]
for i in range(len(lista)):
pom[(i+oile)%len(lista)]=lista[i]
return pom
def rotate(state, pipe_numbers):
wynik=[]
for i in range(len(state)):
niepasi=False
lista=obr(state,i)
for j in range(len(pipe_numbers)):
if lista[pipe_numbers[j]]==0:
niepasi=True
break
if niepasi==False:
wynik.append(i)
return wynik
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"
Dec. 9, 2016