-
-
Save llimllib/f1281fae2ad2f8612f39550207db1a63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numba import jit | |
@jit | |
def run(cmds): | |
location = 0 | |
counter = 0 | |
l = len(cmds) | |
while 1: | |
cmd = cmds[location] | |
if cmd >= 3: | |
cmds[location] -= 1 | |
else: | |
cmds[location] += 1 | |
location += cmd | |
if location < 0 or location > l: | |
print(counter) | |
break | |
counter += 1 | |
if __name__=="__main__": | |
text = open("input.txt").read().strip().split("\n") | |
cmds = [int(cmd) for cmd in text] | |
run(cmds) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment