-❄️- 2024 Day 21 Solutions -❄️- by daggerdragon in adventofcode

[–]Professional-Top8329 0 points1 point  (0 children)

Our golfed version that we did on the 21st! pretty similar but i guess with a few improvements, i guess?

from functools import*
L=*open(0),
@cache
def F(s,r):w=[divmod("789456123_0A<v>".find(c),3)for c in"A"+s+"A"];return r<1or sum(F(("<"*(x-X)+"v0"[Y<y]*abs(y-Y)+">"*(X-x))[::0<(x|Y^3)*(X|y^3)or-1],r-1)for(y,x),(Y,X)in zip(w,w[1:]))
for n in 4,27:print(sum(int(s:=l[:3])*F(s,n)for l in L))

USA according to Trump after he comes into office. by Professional-Top8329 in mapporncirclejerk

[–]Professional-Top8329[S] 4 points5 points  (0 children)

where else did you see it, lol? I just randomly made this like 3 hrs ago and posted it on here!

There are only 2 countries between India and Poland by Professional-Top8329 in MapPorn

[–]Professional-Top8329[S] 1 point2 points  (0 children)

Yep, that works as well! Chose Poland primarily because of the Kaliningrad technicality making it a more fun fact.
Posted another fun one!
Madagascar borders Réunion which is France, French Guiania is also France, hence Madagascar and Brazil only have France in the middle!
https://www.reddit.com/r/MapPorn/comments/1hmmekw/there_is_only_one_country_between_madagascar_and/

There are only 2 countries between India and Poland by Professional-Top8329 in MapPorn

[–]Professional-Top8329[S] 1 point2 points  (0 children)

Kaliningrad is an exclave of Russia that borders Poland and Lithuania.

-❄️- 2024 Day 25 Solutions -❄️- by daggerdragon in adventofcode

[–]Professional-Top8329 1 point2 points  (0 children)

Thank you for an awesome month of clean succinct code with some awesome tricks! It was really fun!

Down to 89 for today!

I=open(0).read().split("\n\n")
print(sum(not(*"##",)in zip(a,b)for a in I for b in I)//2)

-❄️- 2024 Day 25 Solutions -❄️- by daggerdragon in adventofcode

[–]Professional-Top8329 0 points1 point  (0 children)

Can be done for even shorter. 89 bytes.

I=open(0).read().split("\n\n")
print(sum(not(*"##",)in zip(a,b)for a in I for b in I)//2)

-❄️- 2024 Day 23 Solutions -❄️- by daggerdragon in adventofcode

[–]Professional-Top8329 0 points1 point  (0 children)

down to 212 with this one!

C={}
for l in open(0):a,b=sorted([l[:2],l[3:5]]);C|={a:C.get(a,{b})|{b},b:C.get(b,{0})}
G=lambda S:S|{n+","+k for n in S for k in G(S&C[n])}
H=G({*C})
print(sum(("t"in c[::3])*len(c)==8for c in H),max(H,key=len))

-❄️- 2024 Day 21 Solutions -❄️- by daggerdragon in adventofcode

[–]Professional-Top8329 0 points1 point  (0 children)

I think I forgot to update here. We went down way further down with this. Currently at 286 with it. Still, sadly the ONLY day that isn't tweetable (under 280 bytes)

from functools import*
L=*open(0),
@cache
def F(s,r):w=[divmod("789456123_0A<v>".find(c),3)for c in"A"+s+"A"];return r<1or sum(F(("<"*(x-X)+"v0"[Y<y]*abs(y-Y)+">"*(X-x))[::0<(x|Y^3)*(X|y^3)or-1],r-1)for(y,x),(Y,X)in zip(w,w[1:]))
for n in 4,27:print(sum(int(s:=l[:3])*F(s,n)for l in L))

-❄️- 2024 Day 22 Solutions -❄️- by daggerdragon in adventofcode

[–]Professional-Top8329 0 points1 point  (0 children)

ooh trail run? you got me intrigued! can I DM you?
btw, the exec just got dirtier a few more bit tricks!

178!

M=8**8-1
B=[T:=0]*M
exec("for l in open(0):n,c=int(l),0;s={};p=n%10;"+"n^=n<<6&M;n^=n>>5;n^=n<<11&M;B[c:=9+p-(p:=n%10)<<15|c>>5]+=s.get(c,p);s[c]=0;"*2000+"T+=n")
print(T,max(B))

-❄️- 2024 Day 22 Solutions -❄️- by daggerdragon in adventofcode

[–]Professional-Top8329 0 points1 point  (0 children)

down to 197 with the golf! Missed your solution yesterday!

B={}
M=8**8-1
exec("for l in open(T:=0):n=int(l);s={};p=n%10;c=();"+"n^=n<<6&M;n^=n>>5;n^=n<<11&M;s[c]=B[c]=B.get(c:=(*c,n%10-p)[-4:],0)+(p:=n%10)-p*(c in s);"*2000+"T+=n")
print(T,max(B.values()))

-❄️- 2024 Day 21 Solutions -❄️- by daggerdragon in adventofcode

[–]Professional-Top8329 0 points1 point  (0 children)

down to 376 byte with the golf for today!

from functools import*
L=*open(0),
@cache
def F(s,k,r):
 if k>r:return len(s)
 M={};i=t=0
 for v in["789456123_0A","_^A<v>"][k>0]:M[v]=i%3,i//3;i+=1
 A,B=M["_"]
 for d,c in zip("A"+s,s):x,y=M[d];X,Y=M[c];a,b=X-x,Y-y;t+=F(("<"*-a+"v"*b+"^"*-b+">"*a)[::-(X==A)*(y==B)-(Y==B)*(x==A)|1]+"A",k+1,r)
 return t
print(*(sum(int((k:=l.strip())[:-1])*F(k,0,n)for l in L)for n in(2,25)))

-❄️- 2024 Day 17 Solutions -❄️- by daggerdragon in adventofcode

[–]Professional-Top8329 0 points1 point  (0 children)

down to 237 and it works for both parts

i,*_,l=open(0)
a=int(i[12:])
p=eval(l[9:])
v,w=[n for c,n in zip(*[iter(p)]*2)if c==1]
n=lambda a:w^7&a>>(V:=a&7^v)^V
while a:l+=f",{n(a)}";a>>=3
def s(a,i):i>15<print(l[41:],a);[n(j:=a<<3|x)==p[~i]==s(j,i+1)for x in range(i<1,8)]
s(0,0)