#advent-of-code
1 messages ยท Page 48 of 1
The thing is most of the top scorer have already solved a problem like that so they don't think how to solve it they just modify the solution they have to fit the question
some of them do look like certain classical problems I've heard of, I suppose if you know a lot of those you can fit them over a lot of different things
I definitely get the sense of intuition about certain puzzles, which is cool to get some introspection into
Yup that's the thing
Just grind the question, and we'll get there ๐
I'm so damn close to the answer, I can feel it at the tip of my brain meat. Common brain make that connection
I think the questions people might also have existing code
||Like last year with modifying pemdas if I did it this year I already have code for making a calculator so I would just edit it||
||I liked the solutions to that one - seeing people do it properly vs doing it jankily||
||Also I went back and did that one with Lark Parser which was also very fun and very easy to do||
||Ooh, I should get more familiar with the grammar that Lark used tbh. I'd use my lexer/parser/interpreter for a calculator if we had something like that this year though||
||Lark Parser has a calculator as one of their tutorials so using Lark for that problem was embarrassingly easy||
||Ah, I've seen the JSON tutorial, but never the calculator once. sounds fun to use Lark though for a problem, I'm hoping we get a parsing problem like that this year||
We're living up to the name of #ot0-psvmโs-eternal-disapproval lmao
lol
Probably there will be
And thx for telling about lark it looks some serious gourmet thing
If so, I can't wait for that type of problem.
And yeah, lark is awesome!
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH I THINK I GOT SOMETHING
Shit sometimes using regex for stuff can be a real nightmares sometimes ( looking at you web scraping )
Letssss gooo
to be fair, that's more the fault of english than regex
I don't quite know WHY it works but it does so now I just have to code it
Just do it !
Whoooo!
@low condor Where's the || calculator tutorial|| on Lark Parser?
I can't find it
||https://github.com/lark-parser/lark/blob/master/examples/calc.py|| - || not a tutorial but an example||
Ahh it's in the GitHub I see, thanks
i had to go get something, now after a naive solution on part 1 i arrive at part 2
this shall be fun.
same lol
Yet tragically I could not code Part 1 in a way that would help me for 2
until I actually did it naively
i was like, hm, exponential growth? part 1 also seems deceptively easy...
It's like I have to do it the dumb way until I can realise the smart way
yeah, sometimes that happens to me as well
||okay, so similar to lanternfish, any array/string simulation is out of the question. i'll have to find a purely mathematical solution (unless there is optimization on the naive sol??? this is so fun lmao)||
For this ?
LOL
@low condor i have been dragged into recursion hell
Goddamn
this might not even be the right approach, but I'm yoloing at this point lmao
oh gosh. y'all write in code
okay now time to โค๏ธ generalize โค๏ธ
respect pep 8, even when writing :D
programming is a way of life lmao
๐ฉ
Should this be here though?
If software development had a tagline lol
Niceeeee!
the feeling of finishing a day is just ๐
3 hours and a half.
it's recursion all the way down
i finally did it...
did you use recursion?
yes, all the way
i still have homework to do, will share my solution later :P i have quite a lot of stuff to deal with at the moment, a bruh moment just happened, brb
Advent of Recursion
lol
I didn't use recursion, I used the same method I did with the fish problem - as I learned with previous AoCs - the secret is Dictionaries
yeah how do you learn a language without a dictionary
posted my solution in aoc spoilers lol. although be warned, it's pure, unedited spaghetti
i was so desperate at hour 3 that i just didn't care about readability anymore
35 minutes
change of priorities during aoc
-> imma type fast , directly use puzzle input also make it one liner
-> what
-> ok lemme test sample input , time to add more stuff
-> hmm sample input didn't work either
-> 2 hours of confused debugging
-> JUST WORKKRKRKK !! ๐ฉ
7 minutes left
hopefully no more memory opt. questions
if anyone wants to get on a call and work on it together at midnight feel free to hmu
im willing to
use pycharm and sublime text bruh
gl
35 seconds
<@&518565788744024082> Good morning! Day 15 is ready to be attempted. View it online now at https://adventofcode.com/2021/day/15. Good luck!
oops
oh hell yes now this is in my wheelhouse
oh god
(famous last words)
im not liking this at all
i see ||weighted pathfinding|| 
anyway, time to sleep
this'll be a fun one to do in the morning
Less go
points!
I suck at Aoc's lol
Moving up is allowed, right?
dammm u got in under < ~ 6 mins i guess ?
basically ||A*||
niiice
edge case
yeah no i dont have time for this
i will take on this later, but i guess this means losing a lot of positions
i think solving them alone is big achievement
i mean sure, but its kinda frustrating that ive already visited this exact problem twice and yet i cant solve it
more practice, more practice
does day 15 required graphs?
i did it without
no its not necessary
Yes
Hmm I naively thought I could do ||DFS for all paths|| :/
Now I have to sit around and figure out the optimal solution
Why the heck is ||DFS so intensive for such a small graph||
I can't go to the spoiler channel because I want to figure out the solution myself
Believe it or not the channel isn't entirely solutions lmao
Do I need to implement ||seam carving|| or is there another optimal solution I'm missing
How to activate the easter egg in day 12?
how do i even day 15
wat theres an easter eggโฝ
Ya, when you hover over submarine's subterranean subsystems subsisting suboptimally, you get sublime shown up, but I feel there's something more to that.
@jade root
ahh
That's just one of the things that gets highlighted after day 25
It's just because it's alliterative
Usually those aren't left in until after you've completed the year though
They are there before completion just not highlighted
I mean I've looked at the page source for a few days and it literally wasn't there
Maybe it depends on the day
I havent seen any in todays or yesterdays but they were there on other days in source code
hmmm. This one seems a bit time consumming. I would like to know some information from those who already did it : Is there cases where the least resistance path goes away from the ending point ?
it's possible
you can't assume it will always just go down and right
So brute force it is !
That will take far too long, you need a better approach
please no spoilers here
within reasonable limits at least
it's hardly a spoiler to say that brute force is the wrong approach to an aoc problem
not necessarily, there's been quite a few problems where naive brute force has been fine
Yeah but at the same time it's far from the status quo
There have been at least 4 problems I remember where part was just 'ok now do it a ludicrous amount of times'
sure, but let people figure that out themselves if they want to try a brute force approach
at least if it's not the spoilers channel
So, telling someone that it's not going to work for a particular problem saves them effort they might otherwise have put in, which means it's definitely a spoiler.
Can we cross over an already visited cell in this exercise? They don't exclude it but also don't give how we should handle those cases
or is it too early and I need a coffee and to read again the exercise
It's not disallowed but ||it's also not useful||
Imma use co pilot jk
Yeah || I'm trying to find an edge case where crossing would be a less riskier path but not sure it exists||
If you think about it, ||if you're returning to an already-visited cell you could cut out the path between the two visits to reduce the cost||
Definitely need a coffee lol
||is it supposed to be 17 or 16?||
LMAO, I didn't notice that
after the first fold only, there are 17 in the first
Ah right that's after the whole set of instructions
ah
forgot bout that
I'm on day 15, getting the correct answer for the sample puzzle, but the wrong answer for the input :-(. Anyone else have the same problem?
||Presumably, your solution is somehow implicitly dependent on the size of the example grid||
||Not deliberately. I aimed for Dijkstra's algorithm, and it iterates across the whole grid as far as I know. ๐ฆ ||
Did you ||forget that you can go up and left too||?
|| it chooses the lowest cost cell (so far) finds adjacent cells and updates the costs of those before putting those adjacent cells back onto the priority queue. So I think it should try all directions. ||
|| I suppose i'll have to try and create some other samples that break ||
||make sure you count the end but not the start||
Here, I made this for you:
||
1991111111
1991999991
1991199991
1999199991
1999199991
1111199991
9999999991
9999999991
9999999991
||
@bright spindle thanks, much appreciated
Guess my cap for AOC will always be day 10 haha
I'm late by 6 problems Idt I'll catch up at this rate
Day 10 is essentially building a bracket pair colorizer
I think you could solve Day 13 pretty easily. It could be a good day to come back on tracks.
As long as it doesn't involve too many nodes (mostly because I've hardly practiced those without bashing my ehad against the wall)
It is about folding a piece a paper ^^
More about moving on a map. Day 9 part 2 was a nightmare
I''m sad
I wanted to implement a weird algorithm I know of for fun
but because the numbers are so tiny it's actually reallly bad
even if there are no errors which I am not sure since it never finishes

Pretty sure that solution needs to go through all points I visited before once for every value of that number
so it's probably like hyperexponential
Good stuff
The sickness got the best of me. I can clearly visualize the algorithm but implementing it is hell.
How do I get Advent of Code role?
send help i'm strugling
todays problem will be my โ ๏ธ
mostly because it takes a hard thing (pathfinding in this way) and combines it with a super hard thing (optimization for memory) fuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
You will get a temporary role after new years if you complete all 50 puzzles.
I wanted to do the same thing because ||idk any path finding algorithm||
lmao
||It doesn't work because the stack gets too big||
Type in #bot-commands
!subscribe
Thanks man ๐
Oh right, there's a participant role as well, forgot about that, sorry
Np
Question regarding day7 puzzle. Crab at some position with value 0 can't be moved anywhere, because he has no fuel, correct?
he whole value 0 just implies its at position 0
are you sure? based on the example you are incorrect
Move from 0 to 2: 2 fuel

how would it move 2 spaces using 2 fuel if 0 meant 0 fuel
Ou. I am blind
On the other hand Move from 16 to 2: 14 fuel so it reads, I had 16 fueld, I moved 2 positions to the left to reach closest 2 and now I have 14 fuel
Or maybe I am missing something
@proud cosmos
No it moved from 16 to 2
using 14 fuel
The example starts with this line
For example, consider the following horizontal positions:
16,1,2,0,4,2,7,1,2,14
Okay
But it also says "Each change of 1 step in horizontal position of a single crab costs 1 fuel"
So where did it move 16 in this example for it to cost 14 fuel?
I feel it is like abs(move what position - to what position)
Therefore 1 -> 2 = 1 and 0 -> 2 => 2 as is 4 -> 2 = 2
It doesn't move 16 steps, it moves from position 16 to position 2, which is 14 steps costing 14 fuel.
Okay. So it doesn't mean
16,1,2,0,4,2,7,1,2,14
0,1,2,3,4,5,6,7,8,9
And that 16 at position 0 moves to position 2
-----^
?
Sorry then. Understood it wrong way
No, each number is a position along a number line
So like, 16,1,2,0,4,2,7,1,2,14 would be
*
* *
* * * * * * *
_________________________________________________
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
What are *?
Crabs
Ou. Gotcha
I was trying to approach it that way, but doesn't seem to work. I calculated position frequencies aka how many crabs at each position.
I selected 2, that had max.
But both of them give too high fuel costs
I mean, I'm just illustrating what the numbers mean, I'm not saying a frequency distribution is the way to go
||The least-fuel position is probably not just the position with the most crabs at it||
^ that is true. Was just my assumption based on example, but now I see, that it is wrong.
I have idea for other approach, will try that one.
||Yeah, it's just a coincidence that it happens to be the case for the example||
Mhm. Thank you @bright spindle
This channel is for discussion of the Advent of Code event. If you need help, please check out #โ๏ฝhow-to-get-help.
ok tq
today was too hard
80% sure there won't be another hard one this year
this was the peak
screen it pack it whatever the phrase is
Isn't day 20 usually the hardest one?
@bright spindle one more question regarding it. Is my understanding correct, that available positions where crabs can move are from lowest present position to highest present position? Or can they be completely random and be outside the range of given positions? Also can they be only positions of mentioned crabs or in case of such example 1,2,5,7 I can consider moving them to position 4?
||crabs can in theory move anywhere, but the optimal position is guaranteed to be between min(positions) and max(positions).||
I see.
Today's problem is out of reach for me... I have no idea how to make a path finding algorithm
||Look into Dijkstra's algorithm, there are lots of articles and tutorials online||
i dont even know what's the question yet
I've done 25/25 on AOC 2020, whats the order of difficulties of the other years?
i dont feel like, if youre doing any of the previews years without the time limit, theres any particular order tbh
you could try to do puzzles as you see fit from several years at the same time
harder
2019 was very tricky
earlier ones i don't know tbh
2019 was the one you had to write your own computer for intcodes and it built on your logic each day, right?
(note: I've not done aoc19, that's all hearsay)
For todays challenge do we need to use A* or Dijkstra's algo?
o.o
๐
i am very suspicious about the fact that the dijkstar algo will cover all nodes without getting blocked by four already visited nodes
does it always work \๐ค
why would it get blocked
you are restricted to 4 movements up right left bottom , everytime you leave a node it is marked in visited
try A*
so how is it ensured that we will never end up getting all moves blocked
if four visited nodes are neighbors, then their neighbors would be on the priority queue
you don't get blocked
oh understandable
so can we call this as a direct implementation of this algo or some tweaks are required
probably should ask in spoilers
yes lol
Hey guys, im pretty new to AoC, so where can i know project to do for the AoC ?
Sorry if this isnt right place to question
it was a large number of days returned to intcode, but not all of them, and never consecutive days. It was fun returning to it and making little advancements.
i really love aoc2019
May have inserted myself into the list of interpreters, yes :P
hey folks. trying to pick back up AOC somewhat, had a question day 6 part 2. (dont want answers). im guessing brute force wont really work? I've currently* got it brute forcing and i've got a bad feeling about it
Day 6 is lanternfish?
I think it was calculated before that a naive brute force answer would require around 11 TB of RAM to work
so probably not
yes fish
Yeah then this
Darr right now: brb buying 11TB of ram
Yeah, if it's taking longer than 30 seconds, it'll get to like... iteration 200 and then really start slowing down and then really start consuming RAM
you know, i thought about it ๐
Or you could spin up an aws instance
https://www.theregister.com/2017/05/16/aws_ram_cram/
do you want a hint?
not yet, ty. let me bang my head for a bit
fuuuuuuuck day 14 part 2
and of course day 15 is ||path finding||
fuuuuuuuuuuuuuuck
I was so happy about my part 1 solution
yes, but half the tasks were unrelated to that
but still hard
MemoryError i take it we lost a lot of folks on day 6
That's actually quite a lot when comparing to the day before and after. Many people didn't complete pt 2
But day 6 in that screenshot has the most people who completed 1 star but didn't complete the second. There will be a natural decrease as the days go on due to increasing difficulty but also people not having as much time available
i did it.. i created some kind of frankenstein monster that still took a few years to run but it got me an answer
now i need to figure out what was the right way to do it.
Is this Day 15?
mine? no, im on day 6 now ๐
ah ok XD
what was your hint going to be?
oh no, part 1 or part 2?
part 2. i did do it, but my solution is terrible
we can give spoilers over in #advent-of-code-spoilers-archive
im afraid to click that to be honest..tricky
i dont wish to get spoiled for anything i havent done yet
โ That's me. I struggled with 3B quite a lot - and even now it only worked for one account instead of both of mine. And I'm still working on 4B here
This is the hardest one yet for me
because I've never touched pathfinding ever
oh, it is once again a ||if you haven't optimised your solution get rekt|| thing isn't it
rip
||yep exactly||
||actually your computer won't die if you didn't optimize your solution so||
||It's not quite that bad - nothing like Mating Habits of the Lantern Fish Simulator or Hull Polymerisation||
I think my solution is good enough here
at least I hope
I hardly see how I can make it faster
yeah you'll be fine
Someone had a 0.2 second sol and it ran in 6.1 seconds
It's probably easier just to code it separately than use modulo - that's what I did
pain
If you are like us and don't remember the prompt of each day, hey, I made an index: https://github.com/Akarys42/aoc-2021#index
(crossposting from the spoiler chat)
@cache enters the chat
||you did it with recursion?||
the current image right now
Why am I seeing a crocodile wearing sunglasses
The crocodile I see, the sunglasses not really haha
crocodile I can see, but a dragon?
oh wait no I see it
a dragon with snot coming out?
yes
Doesn't help, unfortunately.
.aoc join
Congrats!
sigh realizes I just spoiled day 15 for me lmao, now I know to not do recursion
You'll probably exceed the recursion limit
I bet there's a Ghost Leviathan in there, somewhere...
make it bigger ๐
stack overflow? who's she
just finished a big school project due tomorrow holy crap
took 3 hours
I won't have time to do today's aoc puzzle 
heh, sets recursion limit to 99999969
although that is true, in the previous puzzles I used recursion but the call stack was never thousands upon thousands
i'm tired, spent 30 minutes on d13 bc silly me thought it was easy
me brain is unresponsive, the latency is too high
turns out a naive solution won't cut it
ahhhhhh
i shall sleep now, goodbye
There is a smart way to do today's puzzle
I did not do the smart way.
I am currently at 190000 nodes visited. Only about 20 more minutes until I can know if I got it right. ๐
Im confused on day 13, what should the output for part 2 be?
it says 8 letters but my data is not showing any letters
nvm my code has a bug
lol i still had all the code still only looking at the first instruction when comparing when looping though all the instructions
Finished day 15 after my poor computer crunched numbers for the better part of an hour. ๐ Can't wait to see what's the not-dumb way to do this.
i did that too and the answer turned out to be wrong ๐ข
the sheer patience and dedication to let the program run for an hour- amazing
but i found the slightly more optimized version
while it was running?

after, lol
I mean I have multiple cores, I could still use my computer ๐
i was working my job while it was running
oh, nice job, still
while I was showering my brain randomly started thinking about aoc day 13 and I came up with what seems to be a working mathematical solution-
why do ideas come to me at the weirdest times
still haven't got part 1 done. my code works with the example but gives a too high answer on the real puzzle
but my real puzzle answer was off by 1...
i know i'm not counting the origin point. where could the extra one be coming from
the extra point isn't there in the example
once again, in part 2, the example works but the puzzle answer is wrong. but it's off by more than 1 this time
i remember i also got off by one on the sample at first
for me it's not the sample
like you should just set the first cell to 0 to be safe
i'm doing that. in two places, even, both my starting seed before the loop, and in __getitem__
indeed... i'm doing a variation of the flood fill thing i did during the basin detection
let me get it on github
i'll post the link to #advent-of-code-spoilers-archive since it almost works
can't wait only 50 minutes left
I just joined and saw you guys doing this. Didnt realize it was so active. Just starting
would it be a good idea to store useful general-use functions in a module to use for next year's aoc
bc that's what im planning on doing once this year is done
to make next year easier if theres any similar problems
Why not? And if not AoC, you might have them as a reference anyway for something else.
gl
.aoc c
Day 16 starts <t:1639630800:R>.
<@&518565788744024082> Good morning! Day 16 is ready to be attempted. View it online now at https://adventofcode.com/2021/day/16. Good luck!
oops
second
o.o
good morning, im supprised im still awake
damn this is a long read
yep
what are we supposed to do exactly?
ok this looks difficult but fun
For now, parse the hierarchy of the packets throughout the transmission and add up all of the version numbers.
holy, this might require a good sleep to start this one
yep im definitely starting this tomorrow
so basically convert hexadecimal to binary right?
i like this
i have the same question actually. i thought the input would be multiple lines of the hex transmissions in the examples
OHH nvm I got it
each "operation" bit has several sub-packages
and each sub-package can be another operation packet
and so on
oh ๐ฌ thanks
What level of challenge should I expect through this
Day 1 and 2 have obviously been easy. But I dont feel like getting into this then suddenly day 14 takes 8 hours of intense thought and algorithms research
4 hrs is acceptable /s
I guess what im getting at: does it become "a second job" or a fun programming exercise for after dinner
why do we split the next 27 bits of data into 11 and 16?
AoC has been second job territory for the last few problems for me :/
they arent??
:stress:
what the fuck
Yea I'm not understanding how to break up the subpackets lengthwise
Why is it 11 and 16!?!?
Maybe it's supposed to be 11 bits per packet but you're not allowed to leave off bits at the end....so they do 11, then 16 are left but they can't just do 11 and leave 5 dangling? Must be combined with the last packet?
how will be decide how many packets are there
like differentiate every single hexadecimalcode
for the 11 packet, you get version=6 from first 3 bits of AAAAAAAs, then type=4 (literal) from next 3 bits, and then you parse in 5 bit chunks until you get a chunk where the first bit of those 5 bits is a 0
all together this is 3 bits + 3 bits + 5 bits (because first such chunk starts with a 0)
therefore 11 bits, continue parsing next packet from there
Ohhh right
(for a total of 27 bits at max, since the parent pack said all together the children at 27 bits)
Nested parsing
yeah this is a recursive problem
hey
can someon tell me
what literals this is supposed to contain
getting 13 instead of 12 and i'm dying
12 this the sum of versions
also how do you know the size of each individual sub packet in a operator packet with type 0?
ie you know the length of the subpackets
ohh nevermind
i got it
is it just me or the question is worded weirdly?
it sure is a reading challenge
gosh this is confuuuuusing
This was so tedious
it's a heavy problem, especially if you don't have any experience with parsing binary data streams
Completely different style of problem from every other one this month
you have to finish parsing the subpacket according to its rules, it will end itself
Literally just a bunch of subclauses to waste time
Million different rules and miles of reading
its really fun
The other ones you could blaze through after you figure them out
This one was pure slogging
the rules were pretty simple, but they had a lot of example text
i spent 15 minutes today debugging some shitcode because i had == instead of !=
I assume to help out people unfamiliar with this kind of stuff
man my first implementation of this was absolutely garbage because i wasn't passing around a mutable object
i haven't really done much parsing before
one ques, if length type is 0 and
if the 15 bits length is an operator packet then is it assured that the complete length is an operator packet
or can it include like some length of operator + some length of another operator
or some length operator + another literal
looks at day16
sees computer networking
ah shit, here we go again
its parsing a subpacket of type id 4
Oh
Wait do subpackets have subpackets within them or do I not need to worry about that?
Do I just need to look at VVVTTT for the subpackets?
yes, theres packages within packages
can someone explain the "8A004A801A8002F478" example case in detail. I am thoroughly confused
๐ข
||convert it to binary, write it in a sheet of paper, and parse it by hand, that's what helped me understand how it should be done||
nice
how do we know when literal packets end?
like it says theres a trail of zeros
yeah but there will be a trail of zeros
oh
yes
ok thanks
REDACTED
okie
Please refrain from discussing solutions to the current day's problem in this channel.
||It translates to min([min([min([15])])])||
||what is 15 here||
||A literal||
||There are a lot of different rules, even if each one is individually simple, so lots of possible points of failure. In a real-world scenario, I would shore that up by writing a lot of tests, so it makes sense that there would be a lot of examples in order to cover all the rules.||
I feel like today's puzzle is closer to what real-world software development is generally like than most.
Assuming you don't work in a particularly math-heavy domain, I mean.
And even then you probably often have to do stuff like this, anyway.
||how is that literal calculated here , can you explain in #advent-of-code-spoilers-archive ๐ค ||
For those who didn't understand the question and want a hint. Here it manually shown on an example case
Hey @devout tusk!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
โข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
โข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
f
wtf
DO IT I NEED THAT EXAMple
lemme dm it to you then
can you dm it to me? i still dont get it
oh, I doubt I know the context for this lol
I... uh... um... perhaps head to #advent-of-code-spoilers-archive, where someone who might know what they're doing can help D:
Mb sorry
yeah
!rule 9
We do not allow asking for paid work.
so, packet has sub-packets, which can contain sub packets and so on?
yes
OMG I LOVE LOVE LOVE LOVE LOVE AOC
PARSING BINARY
BRO WHY ARE THESE PUZZLES SO GENIUS
and this one is so real-life as well...
wut
Parsing! ๐
why did i drop aoc yesterday today's problem seems interesting ๐
You can still do it
i suppose i could
To me today's problem seems like such a grind
@noble skiff yeah it seems like a lot but it's honetsly not that much worse than previous days
It's just a lot of explaining
Hah yeah. I was losing interest a bit halfway down the page
(and I have a sneaking suspicion we're gonna extend this in the coming days)
Also for those who are curious, this isn't realistic, no
These things are not recursive in real life
I could feel my 12AM brain start shutting down after the first packet type explanation. I imagine it'll be like the 7-segment problem where it's not really that complicated, but it's a lot for my already fizzled brain to try and comprehend rn
i woke up this morning and tried reading through todayโs puzzle.. that was horrible lol
yeah, same
first thing I do is scroll down to get the input and I thought "damn, I scrolled for way longer than usual"
That's a worrying sign
why do I feel like I'm reading the USB docs once again
Well that surely isn't the last puzzle on this
TCP/IP packet stacks are recursive
One packet at one layer can contain multiple packets for a higher layer.
This is not that different from unwrapping such packets, though there's a lot less detail in the AoC case of course.
Good old internet packets
takes me back to writing a dns resolver for my networking class
don't forget to profile your code! https://news.ycombinator.com/item?id=29579085
I know that packets at different layers can contain multiple packets from another layer
but that's not the same as it being recursive
I don't have much experience with parsing raw TCP/IP, just other protocols, so it's possible TCP/IP is recursive, I just never heard it described that way
also, the first part, and every single one of the given tests work perfectly, but I'm off on part b)... feel like I'm too tired to tackle this
Are we at the peak of AOC? Sure feels like it
what books would people recommend for learning Python real quick?
automate the boring stuff with python, 100%
!resources we have a nice list of resources here
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
awesome thanks! ๐
why am I unable to convert hex into a string of 0 and 1
that's just crazy
I mean I could convert to an int but it doesn't seem very efficient
I mean, it sort of is, lots of protocols support carrying same or lower-level protocols, like, you can carry link-layer frames inside IP packets, like a VPN, and you could connect to an arbitrary number of VPNs stacked on top of each other.
guess I could do that in chunks?
||I converted each hex character to a binary string in turn and concatted them together to form the whole string, by converting to and from an int||
right...
lol spoilers
that seems like a bad solution and yet I think that's what I'll be going for haha
You're a bad solution
it's not production code
never said the opposite 
You could do that, but it's not intrinsically so. Usually what you have is that various users may wrap the packets, i.e. nest it one layer, and then unpack that one layer at some subsequent point
What do you mean "not intrinsically"? EIther the protocol supports it or it doesn't.
TCP packets will carry arbitrary payloads which could themselves be TCP packets
hides BinaryFromHexViaIntFactoryHelper behind back
How is that not a recursive structure?
Because it's not? :-) it could be used recursively, it might not be, many of the people parsing said packets (most) will not be parsing recursively
If you have a class Foo with a Foo member, it's definitely recursive in structure
If you have a class Foo with an object member, I don't see that as intrinsically recursive
I mean, by that logic, the AoC packets aren't intrinsically recursive because it could be a type 4 packet which contains no subpackets.
no, not really
Or a min packet can contain a max packet, which are not the same type.
That's like a Foo object containing a Bar.
The schema explicitly says that it can contain itself
Okay, then that I was not aware of wrt IP
just as a reminder
python has a profiler in the stdlib
I don't see how it's relevant though, because any protocol totally can contain itself.
The spec doesn't forbid it.
much like how python has a debugger as well
(I think it's also a case of "exception" vs "rule")
well, like I said, then it comes back to whether you consider
class foo:
data: object
to be recursive
(For these packets it's the rule to contain themselves, for IP it's an exception)
i definitely would not simply say "foo is a recursive type"
and I don't think most people would say that
Well, it feels like a meaningless distinction.
I'm pretty sure that most people will not think it's a meaningless distinction between foo and e.g.
class bar:
next: Optional[bar]
one is explicitly recursive, there's no discussion or room for how a specific person uses it.
the other may or may not be recursive, it's a question of what additional schema is being attached to it, because obviously an "additional" schema beyond just the types specified here are required to interpret foo
Well, the original issue was whether today's problem is realistic or not, and while an explicitly recursive binary format may not be super common, decoding a nested and possibly recursive binary format is, which I'd argue is almost the same thing.
if a decent number of people have to actually take into account the recursiveness of IP packets, i.e. they have to consider what to do for that specific type ID, then I definitely agree with you
i don't have much firsthand experience with decoding raw IP packets
most config formats these days are also recursive, and while you try to not implement a parser for those, sometimes a thing just uses a weird one you don't have a library for.
parsing is generally of recursive nature anyways ๐ค
also maybe we shouldnt talk about this in here but im not sure
i don't think there's any spoilers here
but it requires instrumentation and adds overheads ๐
ยฏ_(ใ)_/ยฏ
Another common scenario where you might have to deal with decoding a nested and possible recursive binary format is when you serialize or deserialize application-layer objects for network transfer.
How do you make your Python code faster? The first step is measuring what part is actually slow. We do this using a profiler, such a cProfile. The profiler measures how much time all your function calls take and then you can print or save these statistics to determine where you should spend your time improving. Take your profiling to the next le...
idk
if you're sending objects without a schema, then yes
if the client knows the type to expect it won't really look recursive
(unless the type itself is recursive ๐ )
On day 6, should I be making my test data different days with the lists, or just use the day 18 with the int that the test data gives us?
I just got finished with day 6 solution 1 and the provided test data was more than adequate
Am I right in thinking day 6 solution two is all about optimisation? Trying to find out how many fish there would be after 256 days but my machine is on Day 152 now and it's almost ground to a halt ๐
You are right in thinking about that
I'm confused about today's exercise
Why there are trailing 0 in the literal packets?
the only trailing 0s in mine are only because hex sttrings can only encode bits in multiples of four
ohh
To do this, the binary number is padded with leading zeroes until its length is a multiple of four bits, and then it is broken into groups of four bits.
"its" length means the WHOLE binary, right?
so it can be converted to hex
ok it makes sense
I think so
after all this insane pathfinding and battling with factorial time, it's nice to have a good old-fashioned serial parser with an arcane format
truee
Exactly, nested and possibly recursive.
Day 6 Solution 2 wasn't as hard as I thought it would be ๐
All about finding a solution idea
Man I havenโt done AoC in ages. Stupid finals taking up all of my time.
Now that's unfortunate... My program calculates the example of Day 15 Part 2 correctly, but the result to the input is wrong ๐ฆ
Hey guys. I am struggling with Day 7 Part 2. Can anyone explain how those numbers are produced (fuel cost numbers)?
- Move from
16to5:66fuel- Move from
1to5:10fuel- Move from
2to5:6fuel- Move from
0to5:15fuel- Move from
4to5:1fuel- Move from
2to5:6fuel- Move from
7to5:3fuel- Move from
1to5:10fuel- Move from
2to5:6fuel- Move from
14to5:45fuel
||
I did read explanation and my assumption was from this "Move from 16 to 5: 66 fuel"
That ABS(move_from_fuel_present - move_to) * (move_to + 1)
But I get results different from what example shows and when I looked at line 2, my assumption went into a trash.
||
See if this example works: #advent-of-code message
||In part 2, the cost increases by one for each step, so if you have to move 1 step, it costs 1, if you have to move 2 steps, it's 1 + 2 = 3, if you have to move 3 steps, it's 1 + 2 +3 = 6, etc.||
For that example I get: 1433
||I mean, without expanding the grid||
||It tests whether your pathfinder can find paths that go up and left.||
Its 315
||The correct answer is 29||
||So your pathfinder probably has trouble with paths that go up and left||
Thanks for the tip, I will look into that
oof
yeah, this is about where people start dropping off in bulk
I gave up after about 45 minutes last night, just can't keep dedicating this much time
I see what's wrong, and I feel like I already know the solution.
||I think i have to first check every neighbour, and then choose the least risky way to visit next (instead of going line by line like I started with)||
Am I on the right track?
i went to bed early last night, and woke up to this very long problem
most of it is just test cases, so dw about it
the only part that really matters is the first two paragraphs i think
the one that details operator packets and literal packets
i did finish it, i made a nice ast printer for it
ahhh
nice
i should've gone with the ast way, i just did a ||recursive func||
Day โญ โญโญ | %โญ %โญโญ
================================
1) 522 493 | 56.13% 53.01%
2) 479 468 | 51.51% 50.32%
3) 445 389 | 47.85% 41.83%
4) 347 330 | 37.31% 35.48%
5) 320 313 | 34.41% 33.66%
6) 319 305 | 34.30% 32.80%
7) 308 305 | 33.12% 32.80%
8) 285 251 | 30.65% 26.99%
9) 265 237 | 28.49% 25.48%
10) 248 240 | 26.67% 25.81%
11) 213 213 | 22.90% 22.90%
12) 199 190 | 21.40% 20.43%
13) 204 202 | 21.94% 21.72%
14) 202 183 | 21.72% 19.68%
15) 161 149 | 17.31% 16.02%
16) 113 104 | 12.15% 11.18%
we're almost reaching the amount of people last year (last year 90 people or so made it through AOC)
used ||StringIO|| to make the parser a little cleaner
||how did you use StringIO? oh did you use it with the seek method and what not to made it nicer||
just use .read
oh
I used a string iterator in a similar way. But the code's probably cleaner when you can choose a number of chars to read
it was paaaaaiiiinful
surprises me that more people got 14 than 12
14 was pain but so fun
okay wtf is that drop from 15 to 16
16 is still in progress
might be since the day isn't done yet
I'd say, don't overinterpret the stats too much
in the global AOC stats, there is a dip for day 5 and day 12
but both those days are Sundays
that itself could be factor
yeah, good point
alright. 30 mins of finishing final homework before christmas break then it's advent of code time
that's probably where all the beginners said "i'm out" lol
well, at least they tried the first three
true
I loved it but just for the Star Wars ref
quit a huge drop of people overall since day 1! Almost 150k+!
otherwise, yeah, was not a huge fan of that one
i loved it because it is the first puzzle that made me feel the amazingness of advent
is this your first year?
yep! that's why i love discovering aoc so much
i always hate having to deal with 2D lists
probably because i've never used numpy
i hate and love them, such a fun puzzle but the suffering is bruh
(same with recursion)
my favorite days so far have been recursion days
learned a lot about recursion with AOC
did you solve 14 with recursion?
no, i'm pretty sure the stack would die haha
oh, it didn't for me
I quite liked Day 12 this year
wait ,i mixed 14 with 15
mainly cos I did pretty well on that one XD
i loved it, i spent an hour drawing a call stack that helped me flawlessly (ofc not completely flawlessly, but flawless enough for me) complete the puzzle lmao
I loved it because it's one of the few ones that I got a pretty concise solution
i agree
I loved day 12 too
then you look at salt who only writes a few lines (at least for the first 10 days) lmao
i love every single day
I only hate the days I get stuck on XD
lol
yeah, this year is really fun
so far, none this year, though day 14 part 2 took me a little while
took me 3 hours to do part 2 lmao
I got kind of stuck on bits, and hard stuck on today
Index of each day and its prompt: https://github.com/Akarys42/aoc-2021#index
hmm, maybe not stuck
hey akarys! may i ask if you stepped down from mod? (only if you feel comfortable to answer, of course :D)
ah, i see
What's the star wars reference, just "let the giant squid win"? Because that's barely a reference
let the wookie win
if you hover over the text, there's hover text that confirms it
Nope, I'm getting a complete different thing in my hover
"That's cuz a submarine don't pull things antennas out of their sockets when they lose. Giant squid are known to do that"
Very readable, thank you! I think I'm finally getting day 16
hahaha, my pleasure
C-3PO and R2-D2 learn an important lesson in how to play holographic chess against Chewbacca.
Facebook: https://www.facebook.com/StarWars.my
Instagram: https://www.instagram.com/StarWarsMalaysia
passed day 13 as a warm-up :p
now for the real challenge: day 16.
i feel like d15 is when shit started to get real
total days spent in cave: 8
I need to go back and finish 4 and 5 ๐
I tried to do a naive brute force of 4 and got frustrated when figuring out how to read the data took me all day.
plus it's on my home laptop and not my work laptop
day 4 and day 5?
yeah
thanks, things are a bit over my head now so I'm just having fun reading solutions and asking questions day-of. though I should probably do actual work during my working hours..
it's alright, sometimes i get stuck on the puzzles as well or i don't have time to do them. you still have the entirety until christmas to try and get as much stars as you can!
(ofc, you can get stars after, but the christmas spirit is now lol)
haha, yeah, I don't know if I'm going to have the combination of time and ambition. the magic of christmas also includes the obligations and whatnot.
true true ๐
maybe I'll just stop with the evening vidyagames and focus on aoc instead.
it is funny how games lose my attention due to the FOMO of reading this channel on the day of a new problem
do whichever you think matters more to you
also why is day 16 so complicated-
i spent 15 mins just reading the prompt
yep
time to spend an hour and a half with pen and paper programming
tbh most of it is just test cases I think
true
psuedocode: the world's most powerful programming lanugage!
it is so helpful though
helped me figure out my bug in my code
turing complete as well ||\s||
lmao
Could you post your code in #advent-of-code-spoilers-archive? I can take a look at it and try and see what's wrong
Happy to do the same as well ๐
i can now parse several literal packets in a row
but the operator packets... AHHHHHHH
an operator packet is a header and some literal packets in a row
no... it can also be enclosing other operator packets
true
your name applies well here
recursion is my best friend
i solved so many aoc days with recursion lmao
for some reason i rarely use it
my brain gets confused lol
same
well, it's a recursive data type
so, this is a very very intrinsically recursive problem, compared to any other day so far
other days, recursion was one good approach, but here the data itself will be recursive, no matter what approach you use to parse it, but obviously a recursive approach matches up especially well when you have recursive data
man today was tough
NO WAY AHAHAHHAHAHAAAHHHHA
BRO
TWO HOURS AND A HALF WOOHOO
lord forgive me, i just wrote down the most horrendous spaghetti code i've ever written in my entire life
the euphoria is insane-
ON TO PART TWO!
this is the best christmas ever
godspeed
SDAFJHLSDKJAFHKASJFHAKSJFHASKDJFHSKLJFH
HOLY INSANITY
I NEVER THOUGHT I'D GET THIS FAR INTO AOC
30 STARS
Nice!
okay need sleep no time to unwind spaghetti
More than half way
still gonna post the spaghetti code though lol, perhaps some experts can actually read it
thank you so much!
My friend and I get on a call every night and work on AoC, it's actually pretty nice, if anyone wants to join feel free to add me / hmu
tysm y'all, this server and aoc are both absolutely amazing and y'all helped me so much during this adventure
30 stars, more than i ever wanted
i am euphoric
(is 40 within my reach? mayhaps...)
You can do 40!
lol, i'm already spending average 3 hours on each puzzle now, i wonder how this will evolve once christmas break starts for me
i'll have no more homework and school so a lot more time to do aoc, but the puzzles are going to be so hard
same!
If this year is like last year, it shouldn't be so bad
cough day 20 cough
love your name
hate day 20 gang
I really enjoyed today's puzzle tbh I love bit fiddling

thanks!
I think 50 is in your reach, you're awesome at programming
Everyone complains about d20 lol
Parsing is awesome
Wasn't even the one I got stuck on that year
thank thank thank thank thank :DDDD this means a lot!
Parsing can easily be made super tedioua
But today was like a good mix of once you get the general idea it's not too tedious
Lol
Day 23 Part 2 is the one I struggled with
It was more about figuring it out than actually implementing every edge case
I think day 20 took me like 12 hours or smth stupid and I am not sure why cause it honestly isn't that insane
It just didn't want to work
:(

Day 20 took a while but wasn't that difficult for me
What was Day 20 in short?
Day 20 for 2020? I'm tempted to give it a try now
Ah shit wait is that the backtracking grid placement one
I've heard about that
You have a bunch of tiles that you need to assemble into a picture. Edges of tiles match up but you may need to rotate or flip tiles to do it
Oh
Yeah lol I'm good
o_O
Yeah the first message i can find of me struggling was 22:04
And I finished day 20 at 5:30

Pretty sure that was already hours in though
What a mess that was
No one else complains about 2020 D23 P2 - only I got stuck on that one ๐ญ
Needed a hint in the end to progress it
not sure i can relate
Seems I still took a while
but not that bad
(i prob started really late not that weird for me)
I wish it had the date you first opened the prompt or smth
would be nice
oh it was the cups one
that one was nice
you can see where I got stuck on lol
Oh no, I hope the 24th and 25th aren't hard this year
yeah I refuse to move forward if I'm stuck
I don't want to spend my Christmas killing my mind

usually 25th is easy
Eric is aware people have other things to do on Xmas Day lol
I'll probably finish the problems off at 12 AM
Honestly idk if it's anyone else but one of my main motivations rn is the role icon
to finish AOC
I'd only care if I got a new colour with it as well :3
Role icon is cool
Oh I wonder if there will be a new color for it, prob not
tho it's temporary
Yeah true
They might as well it's 1 month
Clearly they should've made it a 1 year thing though
I kinda hope they leave the role after but just remove the icon/color

kinda cool to have
re a discussion here, was discussing in another python chat, about the multi part parsing problems/computers/calculators vs other types of problems, and someone else who wasn't crazy about those problems offered this gem
If I wanted confusing requirements and having to worry about my previous solutions I might as well be working lol
@ every general-knowledge coding competition in existence
wording is what makes the questions tough
If the requirements were simple then AOC would be too easy
I think it would also lose its charm as well
i think there's some over-generalizing going on

