I was keeping track of closed_set in array, so my "Has this node been visited already?" checks got slower and slower.. oops.
/aocg/ - Advent of Code 2018 General #39
I still cannot find an error in the path of weight 942 it seems legit.
from functools import lru_cache
TAR=(13,704)
DEPTH=9465
M=20183
#%%
@lru_cache(maxsize=10**8)
def f(x,y):
if (x,y) in [TAR,(0,0)]:
return 0
if y==0:
return (x*16807) %M
if x==0:
return (y*48271) %M
return (g(x-1,y)*g(x,y-1))%M
@lru_cache(maxsize=10**8)
def g(x,y):
return ((f(x,y)+DEPTH)%M)
def region(x,y):
return g(x,y)%3
#%%
res=0
for x in range(TAR[0]+1):
for y in range(TAR[1]+1):
res+=region(x,y)
print(res)
#%%
#third number encodes tool
# 0=None
# 1=climbing gear
# 2=torch
def getVertices(x,y):
reg=region(x,y)
#print(reg)
if reg==0:
return [(x,y,1),(x,y,2)]
if reg==1:
return [(x,y,0),(x,y,1)]
if reg==2:
return [(x,y,0),(x,y,2)]
raise
def getEdges(x,y):
v1s=getVertices(x,y)
res=[]
for dx,dy in (1,0),(0,1):
nx,ny=x+dx,y+dy
if nx
ok, found the mistake. I allowed for movement between zone1 and zone2 even if the gear equipped in zone2 was not equipable in zone1.
day 21 part 1 in verilog, requires an external assembler
I'm not sure how to do part 2 though
Ah, I see. I'm surprised that only saves 2 minutes.
>think "heh, that's easy" (minus goofing up and debugging runtime before finally putting in memoization)
>part 2
FUCK. I've been filtered on half of the problems now, just terrible
this is the face of a man that has been thoroughly defeated by himself
Time to brush up on your graph algos
>verilog
fucking kek
That is what I'm here for. Tapeout when?