#advent-of-code
1 messages Β· Page 46 of 1
AOC_SESSION='...'
aoc() {
local year="$1" day="$2"
curl --cookie "session=${AOC_SESSION}" "https://adventofcode.com/${year}/day/${day}/input"
}
^^^ not my code, @north silo's
wow, thief
π
Ah okay I see, this may be a dumb question but does my session ID ever change?
It may change, but iirc, it'll live at least until the end of AoC 2021.
Ok awesome I'll test it cause I was planning on writing a script to just get the days input. I just started the challenges, how have y'all liked them so far?
very cool
man day 10 is prolly gonna be hard
is it just me
or are even days harder?
7,9 were way easier than 6,8
I've not even done day 6
weekend days are generally harder, so day 4, day 11, day 18 probably
30 minutes left
.aoc countdown
Day 10 starts <t:1639112400:R>.
oo a countdown
You taking part today Mina?
haha nope!
i haven't looked at aoc since last time with you
i shared your curl snippet above though
Ah right nice π
glhf!!!
GL everyone
Lx Try to get Rank 1 this time π
30 seconds left
GL everyone! 
gl
10 seconds 
<@&518565788744024082> Good morning! Day 10 is ready to be attempted. View it online now at https://adventofcode.com/2021/day/10. Good luck!
oops
lmao syntax errro
Syntax error in navigation subsystem on line: all of them
missing a semicolon
brainfuck moment
was it easy
could have gone faster but I'm still proud of it
Yes
nice finally back to the easy world of parsing
none of this recursive nonsense
actually i retract that, but whatever
does remind me of brainf, actaully
tho wont be able to do it today cuz procrastination + school ;-;
@earnest forge and @split niche Great job hitting the global leader board!
Tyty
11 minutes god damn
i hate when you submit a wrong answer but you find the error in 1 second
cooldown, please
@earnest forge @split niche Congrats! 
yeah I should add test input
would literally have taken me longer to set up the tests than it did to wait the minute
ty!
Tyty, still feel bad about my p2 score though haha
setting up the tests takes maybe 10s for me - copypasting the test and the answers into variables I have set up
I have a test template but rarely use it
Yeah but finding and reading the test
Not reading the question was the problem in the first place
for today those 10 seconds matter a lot
also can we like not use the bot just before aoc starts
as the problems get longer, repeatable tests will become more necessary
When you sent me that, It was 2 pm...
I got awaked by you
:(
2PM? Must be nice to live there, it's 5AM here
??? XD
ouch
oh my god
10:00pm for me, feels pretty optimal
Welp, time to finally look into Haskellβs ||parsing combinators||
Haha
man I kinda blundered for part 2
I got a pretty decent time for p1
but then i got all my loop logic mixed around π
10:30am for me :P
was it just me, or was this one super easy?
it was easy for me too
yeah it's an off day
both today's and yesterday's were things we specifically learned in data structures class
apparently I remembered the material for today a lot better than yesterday lol
is it possible to complete all 25 days without importing anything at all
probably
I mean technically yes, every language should be turing complete without imports. Practically, it might be a tall order
well, every popular language
up until now you dont really need to use libraries unless you want a elegant or short answer
ugh trying to figure out how ||parsing combinators|| work in Haskell is killing me
I feel like they should give me a really elegant solution but the docs are so confusing
i think regex is the only one you really want in the first place, and you don't need it
these feel like the kind of puzzles that would be in a puzzle book if they were only one of the lines of input, no?
this kind of puzzle belongs in a book like this one http://www.amazon.com/exec/obidos/ASIN/0387001638/thealgorithmrepo
I mean that they would be fun to do manually if it was only one line
in like a kid's puzzle book (or adults, tbh)
the travelling salesman is a kid's puzzle if we don't introduce any concept of scale or generalisation
oh yeah that too 
some people like to solve project euler problems with pen and paper
Project euler problems rapidly stop being feasibly solvable by hand after the first page
the elegant solution is just ||iterating through the string and using a list as a stack||
That's what I did. I just wanted to learn about ||parsing combinators||
thats fair
I'm coming up on my high score... last year was my first AoC and I got 25 stars
aiming for 40 stars this year
pog
i wanna get higher in the leaderboards this year
and next year i wanna aim for global
I want to create a code that Makes me a Group Admin on any group
that's impossible
No it is POSSIBLE
how??
print("By working and searching")
no
Why is {([(<{}[<>[]}>{[]{[(<()> incomplete and not corrupt?
what is this conversation
he wants to hack facebook groups
{([(<{}[<>[]}>{[]{[(<()>
^
That should have been a square bracket
right
this looks corrupt, yeah
so it's corrupt
Yeah, but the example says it's incomplete and I can just ignore it for now
oh wait
my bad
I didn't read the following line lmao
Thought the remaining 5 lines were examples of incomplete lines
what No!!
you want to gain admin on a facebook group without them knowing?
no I just want to Joke with my freinds so I will make myself an admin in the group that they made
do you understand me Now
??
i don't believew
and that's impossible
yes you are right that's impossible
We will not help with any project that attempts to do so in this server.
yes
who are you
??
a moderator
oh, my GOD!
Can you tell who made python that I thank him for making this lang
I love python as I learned it first
yaaaasss
!!!
~~so excited
this discussion is also off topic for this channel
u kinda weird lol
a reminder that aoc 2021 started with santa claus losing his sleigh keys
does the sleigh even have doors?
Todays task was fairly easy actually π Compared to the last two days, phew
i need these to be harder or i have no chance of making up the ground to the people above me
i feel like
its easier to just make a new sleigh in 25 days than finding the keys
and even easier to just break down the key system
the key system uses RSA AES and every single cryptographically secure hash function in existence
you have access to the machine
that is teh sleight, nothing stops you from literally just
taking all the circuity that connects to the keyhole
the key has 1MB length
lmao
they dropped it from a server packet
packets cant drop physically smh
also the "key" cant be like
a pen drive or sth like that
since the water would just ruin it and thus ther would be no point searching for them in the first place
maybe the keys operate the reindeer
thankfully, christmas was saved by --preserve-root
it's sudo mode, what did you expect
Can we not share destructive commands please
people might run it without knowing what it does
k
It's not for the door, it's for the antimatter engine.
Beautiful! π
todays was easy and yet i was so slow lmao
yes
i wouldnt say that works well
Lmao we need an aoc-lore channel
can i ask my qn for aoc here?
apparently today's puzzle is easier than the past 2 days, I'm skeptical
or maybe it's just because I don't know parsing
it is easier
haven't-yet-plunged-into-language-design moment
if you have ever touched a parser-like thing, it is trivial. If you haven't, it is kind of tough
i nearly didnt solve day 8
woohoo, time to be tough then
bring it on. I've tore my hair out for so many days, I ain't gon be stopped by a trivial parser puzzle (famous last words)
thank you, but not for now lol, I haven't even tried the puzzle yet
oh
yeah, I just recursed, no fancy queue searching
ye same
Ooh, a parser
haven'tyettouchedlanguagedesign moment
gl
this just shows how much aoc teaches me lmao
thanks! today is the beginning of the weekend, so I'll have 3.5 available hours to solve
should be enough
my usual puzzle completion time is 2 to 2.5 hours
How ironic: this happened while working on today's puzzle:
xd
LMAO
Lmfao
hah
Wait what's the joke?
corrupted line lmao
I haven't started today yet so this flew right over me
lol
the question is about incorrect parens
wdym
the inputs are either corrupt or incomplete. There's no OK ones
well.. I say that... if there are OK ones I managed to filter them out by accident π
||a simple stack would work ngl||
i dont think there were any ok since i had an enum for correct and none got caught by it
||i might have done this maybe||
One more question, if there's something like:
((<) would there be two syntax errors for an unclosed < and an unclosed (?
read the puzzle
you just need to catch the first one
it requires only the first one
as it is stipulated in the puzzle
I'm fairly sure a line is either corrupt or incomplete. You won't get a combination
even if it is both, you'll need to catch corrupt first
no, it would say no > found, ) found instead
Initial impressions of Day 10 looks pretty fun - this is more my kind of challenge
ye
I really do wonder if we will just have parsing AOC
yea
I wonder if I should go overboard today and make a full parser for it
thats its own category of problems
I did briefly try to dig into my lex and yaccc memories... but quickly gave up
Lark Parser is pretty awesome - but probably overkill for this π
It made one of the previous years problems ridiculously easy though
I am not sure Larks error reporting is powerful enough to be useful here
rotated counterclockwise 45 degrees
thus far, the hardest one for me was the bits, though that was mostly because I was using a very slow language and was trying a clever solution, which was wrong
stupid like a fox!
the bits one for me as well, i made every possible off by one error
exactly
i kinda dont comprehend what to do in day5
I've seen people already mention "pathfinding" in connection with day 9, I don't think day 9 really qualifies as pathfinding
pathfinding is usually about figuring out the shortest way to get between two points, given some data that specifies the cost of moving to intermediate paths. e.g. shortest paths algorithms on graphs.
I don't quite see how that applies to day 9 but maybe I'm missing something
day 9 for me was a bit of a fluke
i tried something and it apparently worked
it is similar to pathfinding in the way that it goes to every cell around it
except there are no walls (except for 9s)
that's a lot of algorithms though
true
it's not really pathfinding, there's no path
pathfinding usually involves, finding a path π We don't do that here
hehe
ninja'ed
i guess this is exploration
well, maybe, that's a super loaded term but I don't have enough CS expertise to know if it's appropriate here
that's what I mean, you ninja'ed me
oop
π
π©
@copper totem what have you tried, where are you stuck?
well im kidna new to programming and im kinda confused what it wants me to do
flood fill seems like a more correct term
it's literally filling basins with a fluid
What direction can I head in for day 9?
Hello
Part 1 or 2?
1
Tricky to give a light hint without spoiling too much π
wrong day π³
Oof RIP
haha
||You just need to look at every point in turn and find some way to extract its neighbours and compare.|| Again, more info would be spoilers, so happy to discuss in spoilers channel if necessary
yay got both of the answers first try
Is it just me or does the AOC this year really make me want labeled break and continue
What exactly is that? labelled break and continue?
basically means if you have a double for loop you can break out of both loops at once, or jump to the end of the outer loop from the inside of the inner for loop
something like:
for _ in iterable as a_loop:
for item in iterable as b_loop:
break a_loop # breaks out of the first and second loop
There was a PEP for this but it got rejected ;(
ah right yes
I had this issue yesterday
I could have moved this into a function and use a return instead
i don't think I really encountered it much
but I got lazy
Oh wait.. I could've done that too
you can do the oh so lovely and definitely not confusing
for _ in iterable:
for item in iterable:
break
else:
continue
break
yeah, always using itertools.product when it's applicable is a good move
Yup. So there's two solution here π
!d itertools.product
itertools.product(*iterables, repeat=1)```
Cartesian product of input iterables.
Roughly equivalent to nested for-loops in a generator expression. For example, `product(A, B)` returns the same as `((x,y) for x in A for y in B)`.
The nested loops cycle like an odometer with the rightmost element advancing on every iteration. This pattern creates a lexicographic ordering so that if the inputβs iterables are sorted, the product tuples are emitted in sorted order.
To compute the product of an iterable with itself, specify the number of repetitions with the optional *repeat* keyword argument. For example, `product(A, repeat=4)` means the same as `product(A, A, A, A)`.
Oh nice
in actual code, you can try refactoring one loop into a generator
........ I feel AoC should check if the answer you put is the answer to the sample input, so it could then tell you "That looks like the answer for the sample data. Are you using your actual input data?"
If you use proper unit tests you'll never have that problem π
i mindlessly clicked on spoiler, then i realized and i scrolled away at the speed of light π€£
alright, time for aoc day 10
also, i have no idea how i'm having so much fun with solving puzzles lmao
i'm obsessed with collections
collections and itertools are key for AOC IMO
Good luck!
thanks fiddle!
What's been your favourite day so far?
I think it's because you love aoc
definitely day 8, such a fun puzzle and so many ah-ha moments
least favourite is day 7, still extremely fun, but it was one of those "if you know the math, you can solve it; if you don't, well... good luck (or cheese with bf)" imo
That was a good one but my solution was very inelegant lol
same lol
Well, if you get the answer, is it really cheese? :)
cheese is getting the answer but in a cheesy way xD
i consider brute force cheese, but then again, If It Works, It Works β’οΈ
Everyone has their own rules :)
true true
For me - it's only cheating if I look up a solution that's specifically linked to AOC
that's my own personal rule
If I write any solution to solve it, or I Google about resources not linked to AOC, then I'm happy :)
ah yes, same here :D
Hahaha... I've submitted the sample "answer" twice
I kind of agree. I do think it should try to catch onto that
else I'm stuck with 10 minutes of pure shame
10 minutes? is that the cooldown for submitting the third wrong answer?
I think they mean 2 x 5 mins? I don't recall having had to wait 10 minutes, but it's been a while since I gave two wrong answers
insane nesting lmao (code scribbled out to avoid spoilers)
the most important thing i learned from this year's aoc is that syntax checkers and autocompleters have scoring contests
||lmao i love how part two's text is half explaining the actual puzzle (finding completion sequences) and half trying to combine all the results into one submittable answer π€£||
Four levels is rookie numbers :P
oh no, this is just four levels consecutive (as in, nest one right after the previous' line)
the actual nesting is 6 (not counting def level)
lol yeah, in one of the days (8? 4? forgot) i got 8
8+ nests consecutive
after programming i can never watch inception the same again lmao
So, not sure if you are familiar with unittest.mock
no, i'm not familiar with any unit testing, it is a topic i'm planning to learn after aoc 2021 ends
Ah cool cool
along with numpy, async programming, and web dev
Well, it might be worth learning testing during AOC
yeah, currently i just test using the sample input (sometimes even reducing it further down to just one line)
Right. You can use that to write a test that you run using a unit test runner
Anyway, the reason I bring this up
similar to one used in pydis codejam with the qualifier thing? that's really cool
I think so, yes
Anyway, with mock you can replace any function or class with a mock object. That stops the function or class from doing what it usually does
oh
Typically you use it if you had a function that connected to an outside resource, like a database. You don't want to connect to a database during a test so you mock that code out
Anyway - you can use it with the with statement
Which introduces one level of nesting
ahhh understood
okay. i assume this is going to go ugly real quick
oh god
with:
with:
with:
with:
```withception
Yup exactly that
!otn a withception π₯Ί
Nowadays there is better syntax for this
ah nice nice
You can do with a as b, c as d, e as f, etc
But even that would get long and you'd have to use backslashes to deal with them
With Py3.10 you can use parens instead, finally
oh right, and with 3.10 you can parenthesize
Yup yup
making it much more readable
The with statements I saw were in 2.6
Which had none of those syntax additions
So it was that staircase
oof π must be a pain to read through
Yes so much lol
quick question, is there an efficient way to implement bidirectional dicts without creating a special class? instead of just making two dicts (or combining them into one, which is what i'm doing)
I was wondering a similar thing
||i have to use this data struct for today's puzzle lol||
I think there's a third party package that basically just does the work for you behind the scenes of using double storage
if you're not mutating it after creation, just create both dicts and call it a day
the storage overhead is irrelevant
ah, i see
bidict
okay, thanks! this is exactly what i need, my bidict is a constant lookup table
!pypi bidict
I'm not even sure how much more efficient a bidirectional dictionary is actually going to be
thanks for the resource! i'll check it out
the real reason to actually use a bidirectional dict is once you start mutating it after creation
then it's just a headache to keep them synced. both in terms of efficiency and in terms of just forgetting
ah yes
like, how do you efficient delete?
you pass something that's a key into the first dict, and delte it there, but now you have to delete in the second dict where its a value
so naively you do linear search which is horrible
with a bidict you'd want to solve this properly, but solving this properly involves extra storage and indirections, so in reality a bidict isn't likely to be more efficient than two dictionaries for the simple case of not mutating after creation
For what we are doing, bidict is really not necessary unless you want to be super lazy lol
even if you're lazy. foo_to_bar = { ... } bar_to_foo = {v: k for k, v in foo_to_bar.items()} hard to beat
i had something like this for one of the problems
this should be ok naively, right? because keys and values should all be unique
(within their respective sets)
okay, is it just easy for me or is today's puzzle so unstressful and uncomplicated
nice!
agreed. this was one of the stackoverflow suggestions
Today was very nice. Makes me fearful for tomorrow.
same, it's probably a breather
I think I encountered this problem years ago, when I was already well into my programming journey. But I had no clue how to do it (efficiently)! I feel like the bar is much higher now, or maybe I just didn't know anything
i also have no clue how to do it efficiently :P
by efficiently I mean ||O(n)|| in this case, maybe you're already doing it this way
i am not xD
i think i may have done O(nm^2), where n is the amount of lines and m is the amount of chars per line (here being the worst case, so taking the longest line)
so yes, i'm you a few years ago
what do you mean?
I guess they mean that in todays puzzle, because you have unique values, this code works fine
Had there not been unique values, you couldn't do that
yeah, but their comment was in response to another point I made
about how the naive solution doesn't work well once mutation gets involved
im so confused by today, part 1. How can I know whats the first illegal char if a line is incomplete? Im looking at the examples provided and im clueless
I mean you can use k to find v from the first map, and delete v from the second map (in which v is a key)
If you have something like [} then the } is illegal
ah yeah that's true
I understand the concept of it, I just don't understand how I do with incomplete lines
I'm looking at the first line the example and it's just doesn't click
It seems to me like for the first wrong char it should expect ) and get something else but that's not the case
So, a line that is corrupt - it doesn't matter if it was complete or incomplete. If it's corrupt, it's corrupt, that's all the matters
{([(<{}[<>[]}>{[]{[(<()> - Expected ], but found } instead.
This is the example
{([(<{}[<>[]} - the last } doesn't match with anything
For the line to be valid, it would need to be a ]
Hmm I think I went about this backwards
Do you understand the ask now, though?
I think the linear solution just takes a flash of insight, or for somebody to tell you the solution and say "the problem becomes easy if you think about it [this way]". After that you'll remember it for the rest of your life 
also, reading and deeply understanding other people's solutions helps a lot
Still not sure how I would achieve to be quite honest, the opening tags that are never closed throwing me off
Understanding the problem is one thing. Wondering how to solve it is another. At least you understand the former, yes?
Yea at least I understand the exmaple now ty
Great. If you wish to discuss further we can go to #advent-of-code-spoilers-archive - let me know if you wish to do that
Thanks, I'm gonna try for a bit more
that's probably a bit spoiler-y for this channel
That's definitely a spoiler lol - no doubt about it
Probably best to spoiler tag this or delete it
sorry I'll delete it
No worries - all good now :)
Phew, ive caught up from day 4 to day 10 in about 5 hours total
||[::-1]|| spoiler
i'm tired af, def not gonna have a good time today
.aoc countdown
Day 11 starts <t:1639198800:R>.
Who's ready? π
i'll be code-streaming to a commodore 64 discord i'm in, even though i'm doing it in python
who's ready for first weekend puzzle
Oh crap yeah π¬
first weekend puzzle of this weekend
not me π
next weekend will be the hardest problems of the month probably
i'm already scared
checks out
.aoc c
Day 11 starts <t:1639198800:R>.
GL!
gl π
gl
<@&518565788744024082> Good morning! Day 11 is ready to be attempted. View it online now at https://adventofcode.com/2021/day/11. Good luck!
oops
damn octopuses
hope its easy gl people who actually have time management skills
cool problem tho, seems like an optimization problem like the lantern fish
||β¨ coordinate dictionary time||
ezpz
you done messed up
the octopuses bursting dont get incremented ?
by 1 energy level after burst
idts
Finally, any octopus that flashed during this step has its energy level set to 0, as it used all of its energy to flash.
that was a complicated ruleset
Honestly the rules were fine I was just a dumbass who indented to the wrong level and flashed every octopus every step anyway
I'm getting recursion error-
oh weait
nevermind
nvm the nvm
im still getting recursion err
make sure they aren't reproccing
this doesn't feel like a weekend puzzle - it seems too easy for a weekend
π
did you miss that a given octopus can only flash once per turn?
can't be it, I think
since even if an octopus would be allowed to flash twice, that'd never happen I think (only 8 neighbours, needs to gain 10 energy to flash again)
yea, feels weird that the test-input is so similar to actual input
like it feels like it should have a harder input or something
does that mean extra hard one tomorrow

your problem isn't efficiency, your problem is something about how or where you're using recursion. Nothing should require enough recursion to go above the recursion limit
huh
even if you're, say, using recursion to propagate flashes - since no octopus can flash twice per turn, that means that a flash can propagate at worst 100 tiles (from top right to bottom left corner, say), so no way that can hit the recursion limit
yea, I did OOP + recursion (did get stuck for like 30 minutes on a missing corner case), but yeah there's no way there is recursion limit without multiple flashes of same octo
i think i know whats wrong... 
Maybe this is to trick us for tomorrow 
i over-engineered mine by writing automated test cases first
but yeah i was a little paranoid, wondering if there'd be some weird exponential growth thing
i've been bit before
For this one I'd advise breaking up your code into exactly the steps the algorithm recommends
Don't try to do too many things at once. The more individual steps the better I think
i literally pasted the puzzle description into comments
that likely helped
i'm going to keep doing that because i'm terrible at naming variables
GAAAAAAAAAAAAH
typo π
now i need to wait for the timeout lmao
but im done finally π
remember: test it on example input for sanity check
Here, how does the 1 in the top left become 3? Since the 9 to the bottom right of it flashes once, shouldn't it be 2?
11111
19991
19191
19991
11111```
34543
40004
50005
40004
34543```
am done π
all the 1's become 2 "First, the energy level of each octopus increases by 1." and then 1 more for each 9 they neighbor
oh right π¬ thank you
Is there an input which it will never sync?
never all flash at once I guess
never flash all at once
no i mean
is there an input
where it can't flash
all at the same time
hey does anyone know a library to create applications
you can use numpy
for number stuff
use IPython/Python in itself if you're a REPL chad
jupyter notebook because yes
ok
Today is an unexpectedly small input π
not any that is used by aoc. they're all tested and vetted.
just as a reminder
last year' y2020d23 (the crab puzzle) did actually have inputs that could be solved without taking into account certain constraints
i say this cause i had to be a witness of such problem in my own input
here's visualization, it looks like the octopi sync up pretty quickly
what tools are there for making visualisations for aoc, specifically for types of days that are suitable for a 2d array input
you could use anything for plotting. like matplotlib
altho for animations that might be a bit mroe complicated
what's altho?
"although"
in case your seriously asking: it's probably short for the word although, and not actually the name of software.
should i add a way to paint on the grid real quick
yes
i feel like i should slow it down some too
I figured like a minute after I sent the message
What did you use to make this?
nurses_2
It took me so long of debugging though, but wasnβt very hard in the end
Especially the bridge from part 1 to part 2
with some mouse input
nice
Doesn't really move past the boundaries much.
^ seizure warning
yeah, maybe i should reduce the contrast in the gradient so it isn't so bad
can we not represent it as black background , and white flash
when it turns to zero
i did that and it's not as interesting to look at
oh
terminals have rectangle grids :<
this is just the flashing ones -- i slowed the rendering down a bit so it's a little bit easier to see
i mean one square to represent one octo
damn
actually, i highlighted the wrong one
no, for random grids, the whole thing doesn't sync up
there are borders between synced spots
like certain regions get synced
i see
there is the correct one highlighted
you can see the regions that are synced
our input was just specific input that ended up as entirely synced
yeah
some are out of sync
well its the same way as a monitor refreshes horizontally changing pixels from top to bottom, but their rate is too fast for it to not look asynced
π I'm finally done with today's challenge
Me too, just finished
Part 1 was a pain
Took longer than expected
Same
yes, for me too
@wide garnet Mine took a long time because I forgot to put the flashing octopus at 0 ^^'
Oh
Mine actually had 2 issues lmao
First one is I took the || code from getting adjacent blocks from a previous solution but it didn't gihve diagonals ||
Second is something was wrogg || with setting the octopus at 0 for me too iy only worked for some. Luckily I had an array of visited nodes so I just set it at the end of the step after iterating through it again ||
Doing day 4 part 1 and my unit tests are passing but my code is giving me the wrong answers... How the hell am I supposed to correct that
I actually printed all the steps from the sample input and started comparing them
To see if it matched
Because I got 204 from the sample input for 10 steps but it didn't work for 100 steps
Gah, I'm so far behind. π
I'm stuck on 4A, although I plan to skip day 5 and go on to day 6 because it sounds relatively easier
suggestion: to make stuff really smooth, instead of using 10 possible jellyfish states use 100 (or 50)
er, the timer for each... jellyfish?
octopuses
20 states
100 states
we could also increase the amount of energy flashing octopuses give to their neighbors
pulsating octopuses...
this is 100 states, but flashing octopuses give 10 energy to their neighbors
looks similar to 20 states version
really neat looking when you start taking energy away from neighbors instead
Now that's what I call smooth.
"states"?
Probably means it counts till 20/100 before it flashes
Ah
Though I'm kinda disappointed none of the videos stay till they synchronize
Is each pixel just the energy level of the squid, nothing else?
yes
Is it common for states to repeat exactly?
they don't all sync, that get these cyclic states with regions that are synced
and if so, how long till that happens?
it happens pretty quickly
Actually, it's guaranteed they repeat since there's a finite number of states
ah
That's cool how it looks like layers are out on top of each others
for large NSTATES and low energy sharing, it stays more chaotic
Yeah but I assumed over infinite time it always syncs
it doesn't
for a 10x10 grid, it will almost always sync
but this grid is much bigger
look at the boundaries
Yeah but shouldn't the fact it adds +1 to the edges slowly advance the regions?
I don't quite see why they stay how they are
i don't know either, but the boundaries are stable
Consider the states A, B, C and D and the following transitions:
A -> B
B -> C
C -> D
D -> B
If you start at A, you never loop back to A
It will always be cyclic but you can't guarantee it will loop back to where you started
and there are some states in cellular automata that can never be stepped to
ceil
yes.
111?
yes.
what leaderboard is the staff leaderboard?
we are in @minor cave's, dennis' and one named PythonDiscord
can play with the number of states and the energy sharing with some sliders
cool
i think kat's is the staff leaderboard
is today an off day? will tomorrow and the day after be much harder?
tomorrow should be harder, sunday will probably be easier? it's all kind of subjective anyway
true, if you didn't know what a ||stack|| was yesterday it was probably pretty rough
i think the iterative replacement is probably about as easy to write, even if it's a lot less efficient
can someone give me any link for practicing python questions for beginer level please?
Amazing! What UI library you used?
his own
Damn
From my narrow perspective this is probably the neatest advent of code yet
This kind of thing is related to rust I studied in grad school
i think i'll probably be partial to 2019 forever
Avalanching behavior
It's a whole thing in non equilibrium statistical physics
Barkhausen noise, random field ising models
@mossy basin does it work with iTerm2 (Mac)?
it should if iterm uses vt100 escape codes, but i haven't tested it
Question about today part 1.
If a flash causes another flash does the original octopus get a value of 0 or 1?
wait would that be a spoiler? Tell me if it is i will take it down
nvm i looked at the examples cloesr
once an octopus flashes, it will stay 0 until the next iteration
π thx
I saw someone using replace and base chunks. That was really elegant, but I'm not sure if it's linear or not
||also, octopus π puzzle really just seems like a combination of basin and lanternfish lmao||
pog
hey i have a noob question why do people who solve aoc in python use classes in the solution?
for which day
generally for solutions
oh
some people put everything in classes
its just an easier way of encapsulating data
like for the crab one
every crab has the same data
so its easier for some people to throw that data into a class
Probably people coming from oo languages
who don't know how to use simple data structures
we don't need your linked lists, array [T; N] is life
@heady nexus Today I used a class because it made the processing much more neat
Yeah, [T; N] or Vec<T>
Vec<T>
too much abstraction!
Lol
C arrays were clearly the pinnacle of computer science
malloc it yourself then
let static RAM = [0usize; 1024*1024];
done
classes are used to group properties and behavior together. If you want to keep application state organized, it's the natural thing to do in OOP langs
'tis not
you need to specify the type for global statics
Doesn't it have to be static RAM: [usize; 1048576] = [0; 1048576]
with const generics, I think you can specify N as a const expr
which 1024*1024 would be
Fair but 1048576 is fun to type
goes back to powershell 1mb ahhh nice.
oh that's spoiler probably
appreciate the removal, I haven't solved beyond day 3 yet
can't wait for my vacation to start
just cut into your sleep time smh
my kids already do that. my 2y/o has been waking up like 3 minutes earlier day by day for the past month
already doing that because of school
For me aoc is 5am so I have time to wake up, do it, and sleep again before anything happens in the day
for me it's 6 am so it's not that bad
ah, ability to wake up at 5am, must be nice π I'm usually asleep by midnight and then kids wake us up by 7AM
and aoc releases at midnight my time
Nah I have 4 alarms set
I tried to stay up for it last year and compete, but I had no brain power at the end of my day
so I gave up about 10 days in
I did manage to be top 1000 several times, so that felt nice
My dad's given up on doing it at 5am this year
So far every year I've completed I've got points which is nice
2019 was especially good because of intcode
those intcode challenges are what got me interested in building compilers
I don't think it's possible to compile intcode because of its self-modifying nature
right, but the idea of turning instructions into something executable via the intcode vm
was cool, inspired me
Ah, as a compile target
Yeah that's a neat idea
compile python to intcode so I can interpret intcode while I interpret intcode
one more question how do you handle input? do you load it directly from the file?
either embedded in the script or via file, yes
in Rust, I just use include_str! and be done with it
I use a (cached) input fetcher
which will compile a file content into the binary
I'm used to sys.stdin.readlines() and then parsing the input inside the terminal like python file.py < input.txt but I think it's unnecessary for AOC
That reminds me of the c/c++ solution that #included their input into an array
Is that bad? Not very experienced in C++.
i mean this
if it works, I wouldn't consider it bad
it's just a different way
oh okay thx
an alternative would be taking the input file as an argument to your script and learning how argparse or click or some other package works
well I like to manually enter input because I can test the solution easily on those shorter inputs provided in the puzzle
ah, I use unit testing with pytest for the test inputs
thanks I'll check it out
the built-in unittest module might meet your needs as well
oh okay
!d unittest
Source code: Lib/unittest/__init__.py
(If you are already familiar with the basic concepts of testing, you might want to skip to the list of assert methods.)
The unittest unit testing framework was originally inspired by JUnit and has a similar flavor as major unit testing frameworks in other languages. It supports test automation, sharing of setup and shutdown code for tests, aggregation of tests into collections, and independence of the tests from the reporting framework.
To achieve this, unittest supports some important concepts in an object-oriented way:
!d argparse
New in version 3.2.
Source code: Lib/argparse.py
Tutorial
This page contains the API reference information. For a more gentle introduction to Python command-line parsing, have a look at the argparse tutorial.
The argparse module makes it easy to write user-friendly command-line interfaces. The program defines what arguments it requires, and argparse will figure out how to parse those out of sys.argv. The argparse module also automatically generates help and usage messages and issues errors when users give the program invalid arguments.
the simplest would be hard-coding the path to look for your input in your working directory
import pathlib
wd = pathlib.Path.cwd()
input_txt = (wd / 'input.txt').read_text()
yeah that's true
My 16-month old often wakes up at 5.30am and the puzzle releases at 6am here, so I often get up and do the puzzle while watching her and let my wife sleep in.
Just finished day 11
Was worried that part 2 ||would be one of those ones where they ask you to simulate a bazillion steps|| but it was not
"Find a closed form solution to day N"
is it even possible lol
yes, it is possible
there's only a finite number of days, so the value of the function is only constrained at af inite number of points (25)
(well, or 50, if you considered part a) and b), you could make f(1) == day 1 part a), f(1.5) == day 1 part b) )
so e.g. a polynomial with 50 terms would do it
for any N and arbitrary grid -sizes
you lost me
also: ugh, they changed the definition of "neighbor" from day 9 to include diagonals π¦
update your KERNEL!
||recursion again?? big bruh moment||
i didnt use ||recursion|| today heh
||no recursion for me||
||guess i just need to get good then lmao||
||ever since i used recursion on day 6 my brain keeps on jumping to recursion||
||i use way too much list comprehension to the point that it made up like 50% of day 8||
I try to avoid ||recursion|| as much as I can lol. And then the one time I used it this year, turns out I didn't need to....
ugh so much boilerplate for identifying adjacent items of an item in a matrix
wonder if there's a simple, pythonic way of doing it (other than 8 if statements or an unreadable loop)
linalg π
why are there ||so many attempts at using recursion today, on an obvious devouring algorithm||
what's ||devouring algorithm||
||its actually not Exactly a devouring algorithm but i feel like the logic behind its code structure is similar. you can just take a set of all candidates to be processed (aka the flashy squids), process em and keep going until its empty. you may add candidates during the process, while ignoring the already visited candidates||
||my point is that recursion overcomplicates the problem in this case||
also we should discuss this in #advent-of-code-spoilers-archive
i didn't see if any of those solutions were simpler or not
you could create a utility for future aoc problems, like neighbor8 and neighbor4 functions that yield neighbors of some point x, y from some 2d list
that's what i'm doing right now, thanks! also, this aoc is the first ever event/problem that made me understand the power of generators. before you replied to my comment, i naturally started using yield, which i never used before... AOC IS AMAZING
turns out the unreadable loop wasn't so unreadable and turned out quite clean :D
i just did ugly nested lists and for loops
I should start making my solutions elegant tbh
i was gonna do OOP yesterday but i thought i was going to get ruined with a naive solution
i often think the OOP solutions are over-engineered
lol
oh right, because lexicographical comparison sucks
sadge
back to ugly ands and deleting my amazing tuples
yeah they tend to be
Hey
I've been struggling, can someone point me in a direction of what I should learn to take on the challenge today?
yes. yes it does.
If I had
4 7 5
9 9 9```
I see how i'd increment each by 1 to get ```
9 10 10
5 8 6
10 10 10``` but then seeing which would flash?
ok cool
I tried looping for ints above 9 and then looking at adjacent positions and doing += 1
But then for those that spark I'd also have to += 1 to the adjacent ones to those as well
So I tried it via recursion and got a recursion limit error
perhaps use a data structure to keep track of what needs to be processed instead of recursion
I also tried that
A list of coords which need to increment by one and then incrementing them all by 1 afterwards
But then some of those became >9 so wouldn't that just lead to an infinite loop?
when you process a new point in the grid you might have to add yet more stuff to the data structure to process later
there should not be an infinite loop (if you do it correctly, ofc), every octopus flashes at most once per step and there are a finite number of octopuses
I'm pretty guilty of this lol
But I can't help myself Β―_(γ)_/Β―
one thing that helped me was to use an object for the octopuses
one variable was their energy level
and the other was a bool for whether they've already flashed
you can also do it with a list, but I wanted a little extra clarity
in what I was doing
Yup, I did the same thing
I knew I could use a tuple but I like classes - nicer to use attribute access
i think you don't need to keep separate track of whether each one has flashed if you schedule a point to flash when you see it hits exactly 9 energy (ie, if you increment its energy from 10 to 11 you know you've already scheduled it so no need to do so again)
but i suppose it doesn't hurt
just had an array of booleans keeping track of flashed
But what if there's a grid like this
8 9
9 9
that 8 will go straight up to 11 but it will never be exactly 9
But it still flashes
i guess this depends on the details of how you do it; on my implementation the top left would have to go through 9
imo if it's confusing the suggestion to keep track with an array of bools or whatever is fine too
k fk recursion, i'm solving this iteratively
That's my attempt so far
AY YO
But what's confusing is that it's returning values way too high
#advent-of-code-spoilers-archive please, there can't be major spoilers in this channel :)
that's probably too much for this channel lol
it's alright
how's that going for you?
i tried recursion at first because this seemed suspiciously similar to day 9 ||and i solved that beautifully with recursion||, but now i'm having second thoughts since i'm not making any progress
me brain is also lagging today for some reason (not enough sleep? idk, just not very clear)
so now i'm trying iteration. if that doesn't work then i'll look back to recursion :D
only on ||day 6 and day 9||, i feel like my mind likes to jump to recursion ever since that ||lanternfish nightmare||
scoff really enlightened me, perhaps a bit too much
you spoilered the days but give it away at the end of your sentence anyway π
Yeah I was 1st on my college leaderboard every day up to today, dropped to 5th
And I've still not solved d11
oops lol
Recursion is cool but it's not typically the way you do things in Python
My brain's just stuck in limbo rn
I've rewritten the same(ish) structure of code out abt 6 times since morning
And no luck
Python is basically - use iteration unless it would be awkward to, then use recursion
we can look at your code... if you post it in spoilers π
same. i'm going back to square one after a walk, attempt 2 will be an iterative approach
fwiw I think recursion is super natural on today's problem, regardless of language
And yeah, it is extremely extremely similar to day 9
For some reason I really struggled today. Didn't help I have been a bit distracted. Wasted a couple of hours debugging only to realise I got two variables backwards. Annoyingly my solution actually worked up to about 10 steps on the example input, so couldn't work out what had gone wrong!
I decided on a more OO approach (not perfect, but let me move some logic out of the way). Turns out doing that made part 2 trivial.
Moral of the story: Maybe don't do a coding puzzle when busy π
Yah
I struggled a bit when I tried to do it at night when it first released, then after a good nights sleep I managed to do both parts in like 10 min
i'm having a bruh moment day
my logic is fuzzy, i'm tired, everything is bruh
i'll attempt 11 and 12 tomorrow
Yeah - I was expecting more difficult today
yeah same
Hopefully tomorrow if it's harder will be parsing
and we don't need another board
frankly i'm getting tired with these board puzzles
yeah....
that is precisely why I used numpy today instead of looping around 2d lists of lists
today I think I just used a dictionary
why everyone keeps saying today is so easy if Im nowhere near start

