Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Rotate Hole by aieozn
def rot(tab):
tabl=[]
w=tab[-1]
tabl.append(w)
tabl+=(tab[:-1])
return tabl
def rotate(state, pipe_numbers):
wynik=[]
blad=0
for i in range(len(state)):
for z in pipe_numbers:
if state[z]!=1:
blad=blad+1
if blad==0:
wynik.append(i)
blad=0
state=rot(state)
print(wynik)
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"
Nov. 27, 2016