Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
ZenD'oh solution in Clear category for Mind Switcher by veky
def mind_switcher(journal): # I'm afraid we need to use... PYTHON
fix, swap, todo, N, S = [], False, set.union(*journal), "nikola", "sophia"
def brain(x):
for a, b in reversed(journal):
x = {a: b, b: a}.get(x, x)
return x
while todo:
step, first = [], todo.pop()
second = current = brain(first)
while current != first:
step.append({S, current})
todo.remove(current)
current = brain(current)
if step:
fix.extend([{N, first}] + step + [{N, second}, {S, first}])
swap = not swap
return fix + [{N, S}]*swap
July 25, 2014
Comments: