diff --git a/day24/sol.py b/day24/sol.py index 8ba9f5c..fc303d6 100644 --- a/day24/sol.py +++ b/day24/sol.py @@ -8,13 +8,6 @@ import astar #print(*data, sep="\n") -blizzards = {'>': {}, '<': {}, '^': {}, 'v': {}} -for y in range(len(data)): - for x in range(len(data[y])): - c = data[y][x] - if c in blizzards: - blizzards[c][x,y] = 1 - def show(t): H = len(data)-2 for y in range(len(data)): @@ -27,19 +20,19 @@ def show(t): else: bliz = [] u = 1 + ((x - t)-1)%W - if (u,y) in blizzards['>']: + if data[y][u] == '>': bliz.append('>') u = 1 + ((x + t)-1)%W - if (u,y) in blizzards['<']: + if data[y][u] == '<': bliz.append('<') v = 1 + ((y - t)-1)%H - if (x,v) in blizzards['v']: + if data[v][x] == 'v': bliz.append('v') v = 1 + ((y + t)-1)%H - if (x,v) in blizzards['^']: + if data[v][x] == '^': bliz.append('^') if len(bliz) == 0: @@ -65,19 +58,19 @@ def blocked(x,y,t): W = len(data[y])-2 u = 1 + ((x - t)-1)%W - if (u,y) in blizzards['>']: + if data[y][u] == '>': return True u = 1 + ((x + t)-1)%W - if (u,y) in blizzards['<']: + if data[y][u] == '<': return True v = 1 + ((y - t)-1)%H - if (x,v) in blizzards['v']: + if data[v][x] == 'v': return True v = 1 + ((y + t)-1)%H - if (x,v) in blizzards['^']: + if data[v][x] == '^': return True return False