[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
▼ Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: grids.png (1.22 MB, 1448x1502)
1.22 MB PNG
>Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as a speed contest, interview prep, company training, university coursework, practice problems, or to challenge each other.
https://adventofcode.com/

/g/ leaderboard join code:
224303-2c132471
anonymous-only leaderboard:
383378-dd1e2041

you are holding it upside down-edition

previous >>110521545
>>
File: solve.png (420 KB, 2237x2414)
420 KB PNG
idiomatic Rust solution
>>
File: carbeuwn.png (796 KB, 1280x5729)
796 KB PNG
>>110530524
Idiomatic intcode solution with beef host.
>>
>>110530217
Careful, AoC used to permanently lock you out of answering if you had too many incorrect guesses (like 10+).
Not sure if there's a limit anymore, or if the delay between attempts just gets stupidly long.
>>
>>110530574
highly doubt it is permanent but I could see it being like an hour
>>
>>110530574
it scales 1,2,3,5,10,15 and they stays on 15 forever
>>
>>110530587
>stays on 15 forever
Wonder when that happened, used to go up into the hours.
>>
File: d6.png (543 KB, 1104x2546)
543 KB PNG
Part 1
>>
>>110530574
that was never the case, why do you spread lies?
>>
File: d62.png (442 KB, 1222x2136)
442 KB PNG
Part 2
>>
File: file.png (84 KB, 636x815)
84 KB PNG
unidiomatic rust solution
>>
File: day6.png (963 KB, 2073x4768)
963 KB PNG
Truly the year of the math-chad; my retarded head hurts.
>>
bigboy #6
size: 22M
url: https://files.catbox.moe/77t23t.7z
silver: 755047
gold: 134,5
>>
>>110530788
>bfs
you can't be serious anon...
>>
File: im-1796572252-245.png (50 KB, 673x1139)
50 KB PNG
repostin my gross solve
found the corners, picked one, filled-in the graph, transformed til it fit.
2020d20 vibes
>>
Godawful solution, not washing this shit.
Walks the perimeter, fills, tries all 8 orientations
from collections import defaultdict
from math import sqrt
data = open("Day 06 input.txt", "r").read().strip().split("\n")
conn = defaultdict(list)
for line in data:
root, nodes = line.split("-")
for node in nodes.split(","):
conn[root].append(node)
conn[node].append(root)
lengths = [set(),set(),set()]
for i in conn:
lengths[len(conn[i])-2].add(i)
corners, edges, fill = lengths
grid = {}
seen = set()
pending = [(corners.pop(), (0,0))]
step = [1,0]
while pending:
num, pos = pending.pop()
grid[pos] = num
seen.add(num)
for opt in conn[num]:
if opt in seen: continue
if opt in edges:
pending.append((opt, (pos[0]+step[0], pos[1]+step[1])))
break #edge case
if opt in corners:
pending.append((opt, (pos[0]+step[0], pos[1]+step[1])))
step = [-step[1], step[0]]

gridsize = int(sqrt(len(conn)))
for y in range(1, gridsize-1, 1):
for x in range(1, gridsize-1, 1):
new = set(conn[grid[(x-1,y)]]) & set(conn[grid[(x,y-1)]]) - seen
new = new.pop()
grid[(x,y)] = new
seen.add(new)

print grid[(gridsize/2, gridsize/2)]
targets = {"1":[47,30], "2":[29,59], "3":[56,35]}

for flip in range(2):
for rot in range(4):
ref = {}
for i in grid:
if grid[i] in ["1","2","3","7","2026"]: ref[grid[i]] = i
print ref
if ref["2"][0]-ref["1"][0] == targets["2"][0]-targets["1"][0] and ref["3"][0]-ref["1"][0] == targets["3"][0]-targets["1"][0] and ref["2"][1]-ref["1"][1] == targets["2"][1]-targets["1"][1] and ref["3"][1]-ref["1"][1] == targets["3"][1]-targets["1"][1]: #assign "1" as reference point
offsetx = ref["1"][0]-targets["1"][0]
offsety = ref["1"][1]-targets["1"][1]
print str(ref["2026"][0]-offsetx) + "," + str(ref["2026"][1]-offsety)
raw_input()

newgrid = {}
for i in grid:
newgrid[(gridsize-1-i[1], i[0])] = grid[i]
grid = newgrid

newgrid = {}
for i in grid:
newgrid[(gridsize-1-i[0], i[1])] = grid[i]
grid = newgrid
>>
File: bigboy_time.png (136 KB, 409x231)
136 KB PNG
Not great, not terrible.
>>
did eric not do the "possible 2026 is a line" input twist or was I just lucky picking a location
>>
>>110530789
why .7z
>>
>>110530789
I get 55,50 for part 2.
>>
File: 46bbw2zk26g51.jpg (27 KB, 680x378)
27 KB JPG
>>110530808
I mean this in total earnestness, what's stupid about using a bfs here? Isn't it the easiest way to find the distance from the corners?
>>
>>110530921
nevermind, I accidentally used the example coords
>>
>>110530935
There is probably some gay esoteric mathfag thing, but yes for a non-weighted graph bfs is the way to go to find shortest distances.
>>
>>110530935
bfs is fine, it gets you stars
>>
>>110530935
>find the distance from the corners
I don't see why you would need that
pick a corner
assign 0, 0
take its neighbors
assign 0,1 and 1, 0
mutual neighbor is 1, 1
and so on
>>
so the only way to get the correct answer is to effectively build the actual pattern, huh?
>>
>>110530997
No, I didn’t. I just used the corners and the distances to those corners for each point of interest. I never built the full grid.
>>
>>110530789
772ms with >>110530526
>>
File: day6.png (193 KB, 1569x1038)
193 KB PNG
Icky icky icky Javashitscript.
>>110530997
Worked for me.
>>110530789
1155ms.
>>
>>110531013
Being within a factor of 2 of Javascript is fucking embarrassing.
>>
>>110530789
stop using 7z
>>
>>110531047
>hurr durr what is differing hardware
I'm doing these puzzles on my old chinkpad.
>>
File: 2026_6.png (311 KB, 1088x902)
311 KB PNG
>>110530789
C, memory mapped file, building the grid and algebra to calculate the correct coordinates.
part1: 755047
part2: 134,5

Time: 0.222
>>
>>110530993
Yeah, that's a bfs, no?

>>110530976
>>110530982
This was my reasoning as well.

>>110530997
I tracked Manhattan distance from each point to two corners and then just used a formula to convert that coordinate system to (X,Y) when needed.
>>
File: 1662940045851106.jpg (237 KB, 853x1000)
237 KB JPG
>>110531056
no
>>
>>110530820
Wait, this is really smart!

I used two corner searches (>>110530788) with distance arithmetic but would have never thought to use neighbor intersection. So we're both O(n) but yours looks way cooler.
>>
>>110531071
>that's a bfs, no?
ah, okay then. I thought you used it for something stupid, sorry anon
>>
>>110531066
>building the grid and algebra
slopper detected
>>
>>110531138
nta, but why?
>>
>>110530530
this is unfathomably based but i don't understand a thing about it
>>
>>110531159
no one talks like that which means a thing is behind it
>>
>>110530997
no >>110530681
fill in the gaps in the input (so if 1 has connection to 7, 7 also has a connection to 1)
calculate distances from 2026 to 1, 2, 3
there's probably some algorithm to figure out the position, but you can just go in the "circle" around 1 or 2 or 3 at that distance until you find a point that matches 2026's distances to them
>>
>>110531224
>but you can just go in the "circle" around 1 or 2 or 3
isn't this trilateration? that's what I did, but I got lucky and only had two 3-intersections so I had a 50:50 chance of getting it right.
>>
>>110531138
>>110531193
>ai le bad
back to lesswrong
>>
bigboy fails to find a connecting node on 0,0 for me
>>
>>110531253
ye
if you have more than 1 candidate you can literally just pick out a different value at random, find it, and check against 1, 2, 3 and that one, repeat if doesn't work
>>
I had to do a literal change of basis calculation in order to solve part 2. Fucking crazy man.
>>
File: the-great-filter.png (371 KB, 1000x1000)
371 KB PNG
leaderboard data fetched ~19:00 UTC
gold: all solved within each day
silver: one or more solved after each day
>>
File: slow brain.gif (49 KB, 256x256)
49 KB GIF
>>110531193
>>
>>110530789
3.27s, quite happy with that
>>
>>110531323
>me on the bottom of golds below several silvers
Eastern timezone has it the worst.
>>
>>110531323
we previously did not keep people who caught up silver like they were allowed to be gold again
life happens you know
>>
>>110531414
Calm down, no one cares about imaginary internet points
>>
>>110531224
You can calculate the correct coordinates calculating an offset, and checking if you get the 3 points by subtracting from or adding to the offset, both in the x and y coordinates. Also you need to check swapping x with y. That is 4 x 2 = 8 cases.
>>
Does anyone know how the leaderboard ranking actually works and not just how eric explains it? since I have been solving every problem at +12 hours so far and yet every time I check the leaderboard i'm in like the top 10-ish, so something else must be going on?
>>
File: sigma.jpg (249 KB, 1280x720)
249 KB JPG
>>110531414
picrel

>>110531417
the colour is only to distinguish fast or lucky solvers from slow or unlucky solvers
silvers are still shown to complete each day
only those who never completed a day are filtered
>>
File: day6-1.png (688 KB, 1682x2570)
688 KB PNG
part 1. I am doing terrible, horrible things to this language. I am sure a smart person can produce nice code. I can only create a mess with this functional, immutable nonsense.
>>
File: 1765651200719746.png (614 KB, 942x4419)
614 KB PNG
extremely lazy C edition
>>
>>110531465
>I have been solving every problem at +12 hours so far and yet every time I check the leaderboard i'm in like the top 10-ish
Doesn't seem like it should be possible. What's your username/ID?
>>
from collections import deque

with open("input","r") as f:
lines = f.read().strip().split()
g = {}
for line in lines:
a,bs = line.split("-")
for b in bs.split(","):
g[a] = g.get(a, []) + [b]
g[b] = g.get(b, []) + [a]

def dist(s,t):
visited = {s}
q = deque([(s,0)])
while q:
u, d = q.pop()
if u == t:
return d
for v in g[u]:
if v not in visited:
visited.add(v)
q.appendleft((v, d + 1))
raise Exception()

def alleq(vs):
u = next(iter(vs))
return all(u==v for v in vs)

corners = [k for k in g if len(g[k]) < 3]
s1 = [u for u in g if alleq(dist(u, c) for c in corners)][0]

def taxid(a,b):
return abs(b[0]-a[0])+abs(b[1]-a[1])

def findcs(light, cs):
ds = {x: dist(x, light) for x in cs.keys()}
candidates = []
c1,d1 = cs["1"],ds["1"]
for i in range(c1[0]-d1,c1[0]+d1+1):
for j in range(c1[1]-d1,c1[1]+d1+1):
c = (i,j)
if all(taxid(c,cs[k])==ds[k] for k in cs.keys()):
candidates.append(c)
return candidates

coords = {"1": (47, 30), "2": (29, 59), "3": (56, 35)}
def find2026():
c2026 = set(findcs("2026", coords))
visited = {"2026"}
def trav(u):
if len(c2026) == 1:
return
for v in g[u]:
if v not in visited:
cv = set(findcs(v, coords))
d2026 = dist(v, "2026")
upd = [ca for ca in c2026 if any(taxid(ca, cb) == d2026 for cb in cv)]
c2026.intersection_update(upd)
visited.add(v)
trav(v)
trav("2026")
return c2026.pop()

s2 = find2026()

print(s1)
print(s2)


feels bad man
>>
File: 324234324324.png (13 KB, 353x233)
13 KB PNG
>>110531572
you're right, i'm retarded. when it says: this is the leaderboard of anonymous user #XXXXXX i thought that was me but it's not
>>
>>110531466
>only those who never completed a day are filtered
so if somebody completed all days upto now they would be gold? because that is how it used to work
>>
>>110531661
the graphs by the original filteranon had blue and grey
grey were filtered, and blue were not
my gold and silver, combined, correspond to blue in the old graphs

refactoring my code as we speak;
i will be able to produce more versions
>>
>>110531193
I noticed a lot of sloppers do talk like that. They pick it up from their machine, and it takes over their soul.
>>
File: carbon (2).png (2.02 MB, 1754x2890)
2.02 MB PNG
>>110530789
upgraded my >>110530681
to handle overlaps
Day 6 Part 1 (393.5125ms): 755047
Day 6 Part 2 (404.6745ms): (134, 5)

I don't like this bigboy, you made the tricky overlap too big, so the speed with the triliterating solution is entirely dependent on picking which extra points select
I get times from 400ms to 9s
>>
In terms of efficiency is it better to put the grid together fully or just find the coordinates of the corners and points 1,2,3, and 2026? I did the latter, but it seems like most people have done the former. Will try to post a washed version later.
>>
>>110531778
>They pick it up from their machine, and it takes over their soul.
that's not too surprising, people adopt mannerisms from others they interact with regularly. if an ai acts as a substitute for social connection, they will likely adopt the ai's mannerisms too. such is the nature of humanity.
>>
>>110531739
yeah but original filteranon unfiltered anyone who caught up
it did not matter how long it took
you were only filtered if you had incomplete puzzles

so you could be filtered on say day 9 when that filter was posted
but if you did days 1-9 and 10 before 10 was posted you would be unfiltered again
>>
>>110531798
i seem to remember he posted different versions
whatever, i can add a key that, by my literalwho authority, silvers are officially not filtered
>>
File: imatree.jpg (201 KB, 2000x2000)
201 KB JPG
im an idiot can someone tell me what part 2 is asking? I thought it was asking to rotate and flip the grid until I lined up these:

>The light with ID 1 goes at coordinates 47,30.
>The light with ID 2 goes at coordinates 29,59.
>The light with ID 3 goes at coordinates 56,35.

but my grid is only 41x41 so that doesn't make sense. 1681 nodes total
>>
>>110531909
The grid doesn't have to start at 0,0
>>
>>110531909
hint: use relative coordinates
>>
>>110531909
yeah you'll have to offset the entire grid accordingly
or something else...
>>
>>110531909
The example square is only 2x2 yet he explains how it works just fine. Read it again.
>>
>>110531928
those are some big 2s
>>
>>110531928
Sorry I meant 3x3. Still, the point stands.
>>
>>110531916
>>110531922
>>110531926
>>110531928
ohh dang okay thanks guys!
>>
File: 1795676453041286.png (1.92 MB, 1402x1122)
1.92 MB PNG
>>110531795
>she's socially connected with h*mans in 2022+4
>>
>>110530789
~600ms
time to sleep now
>>
File: qwq5pivaolgh1.png (1.39 MB, 1254x1254)
1.39 MB PNG
>>110531975
hey it's that ojousama who keeps bullying the fish girl
>>
>>110531975
God, the frontier labs need to hurry up and start shipping robot women already.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.