#advent-of-code
1 messages · Page 45 of 1
what da heck is today's puzzle
it is fun
YAY
almost definitely harder than the previous days, but that's to be expected at this point
part 1 is trivial, but part 2 requires some planning :p
alright, so the first ten combinations on each line are here to help you figure out what is the wire mapping, and you only count the last four digits when calculating the output?
yeah
Agh
I see
i also recommended day 8 to some people too 🙃
Day 8 is really simple?
I was thinking after 4 I'd skip 5 and go to 6, but in that case, I might do 8 before 6
day 8 isnt simple
Ouch, ok
6 is the one where ||you have to do 80 iterations for part 1 and 256 for part 2||, right?
yea
yep
tbf day 6 aint that bad
||like theres at least 3 or 4 ways to improve the solution to something that can be computed||
I haven't tried it yet, but I did hear that doing it in the most obvious way will just result in overflow errors, so I need to make sure I bounce of some folks to get this right
Meanwhile, I need to knock out day 4 first, I've only just started
Just want to make sure but for day 8 part 2 the 7-segment they give you in the example would be different for each line of the input?
Yes
You can basically throw out what you had for other lines bc it doesn’t matter except result
OK thanks
I have no idea what I am doing lmao
insert jpeg of dog here
Here is my algo so far for part 2:
||1. Run a loop for every possible mapping of each number to an actual 7-segments number||
||2. For each of those numbers, constraint the segments that makes it to only the output segments that made the number||
||3. If each segment is constrained to a single other segment, we won||
I don't know if the technique or the implementation is faulty
Actually
7! = 5040
it isn't that hard to bruteforce
bad akarys
Alright, my algorithm only works on edge cases
For real, are you supposed to be able to solve that without a constraint solver?
@mossy stream Have you tried to use part 1 ?
Is there a python leaderboard json parser?
ive gotten the json file, just trying to parse it
How does this look?
import json
with open('file.json', 'r') as f:
content = json.load(f)
I mean I guess I can guess the top digit easily using the first part
wow
That's as far as I can get
Holy crap is that in python?
yep
and wtf salt you are insulting me at that point
in python and in my terminal
damn did you post it on subreddit visualization
I don't like you salt
not yet
Also please add some sound effects
mom?
imagine food without it
Any lib that can simplify a colors and basic shapes in a terminal was used there?
Through little deduction
I don't know if this is an euphemism or if I'm really over complicating things
@mossy stream Try making relationships between numbers
no, but it can load animations and images directly
its not trivial by any means
Could you share some links about it? I've never been using any terminal graphic, only GTK or wxWindows taff visualisation
dont know much about it, it's super esoteric library no one has ever heard of: https://github.com/salt-die/nurses_2
man i really enjoyed day 8, a nice combo of thinking and coding
yeahh
i spent several hours trying to figure out how to implement a back-tracker for it, but since the order of the digits can change it gets complicated
i had a cipher solver sitting around, but it doesnt work without the order
if you make an array like:
# a b c
1 1 0 # 0
0 1 0 # 1
0 0 1 # 2
but for the segments and digits, call it A
then you can try to solve:
P @ A @ Q = B
where P and Q are permutation matrices
but i didn't discover any tricks to solving this way, only brute force
"super esoteric and no one has heard of it" links to own github
lol
Did you end up brute forcing?
my initial solution was brute force, i did make a smarter version
was trying to finish fast though, which was not very successful
WOW, that's really cool
Alright, so non bruteforcy solutions aren't that trivial
yeah lol they definitely arent trivial
this is a call for help :')
I do not get what even the questions asks in part 1
day 8
can anyone help?
pls
!aoc
Calling vs. Referencing functions
When assigning a new name to a function, storing it in a container, or passing it as an argument, a common mistake made is to call the function. Instead of getting the actual function, you'll get its return value.
In Python you can treat function names just like any other variable. Assume there was a function called now that returns the current time. If you did x = now(), the current time would be assigned to x, but if you did x = now, the function now itself would be assigned to x. x and now would both equally reference the function.
Examples
# assigning new name
def foo():
return 'bar'
def spam():
return 'eggs'
baz = foo
baz() # returns 'bar'
ham = spam
ham() # returns 'eggs'
# storing in container
import math
functions = [math.sqrt, math.factorial, math.log]
functions[0](25) # returns 5.0
# the above equivalent to math.sqrt(25)
# passing as argument
class C:
builtin_open = staticmethod(open)
# open function is passed
# to the staticmethod class
.aoc
**```
.adventofcode
**Can also use:** `aoc`
*All of the Advent of Code commands.*
**Subcommands:**
**`about `**
*Learn about Advent of Code*
**`countdown `**
*Return time left until next day*
**`dayandstar [maximum_scorers_day_and_star=10]`**
*Get a view that lets you filter the leaderboard by day and star*
**`global `**
*Get a link to the global leaderboard*
**`join `**
*Learn how to join the leaderboard (via DM)*
**`leaderboard [aoc_name]`**
*Get a snapshot of the PyDis private AoC leaderboard*
**`link [aoc_name]`**
*Tie your Discord account with your Advent of Code name.*
**`stats `**
*Get daily statistics for the Python Discord leaderboard*
**`subscribe `**
*Notifications for new days*
thanku
ok I got it lmao
reading thoroughly will solve the problem
solve the problem of not understanding the problem
😶🌫️
thx and will do! 👍
what da heck am I looking at
akarys
his code is.. interesting lmao
I mean the new version is fine
but lmao what is this commented out code
where is the code smh
day6part2
for a second i thought you are really printing the day at which the code finished executing
lmfao
appropriate
seems to be
It took like 20s at the 120th iteration, after which I killed it
I'll time a full run in the background out of curiosity
We should keep links to solutions, especially for the latest day in #advent-of-code-spoilers-archive
aye aye captain
yes ma'am
is it fine with a spoiler tag @minor cave ?
In #advent-of-code-spoilers-archive ? Sure!
that's not too bad
Also more lines != worse
19m23s
wait
oh lol it got killed by the OS I think
on day 166
after taking 890s to compute a single day
I don't know how much ram this VM has
4 or 8 GB I think
Someone calculated that you need at least 700GB of ram to do that solution naively
So no big surprise there :P
1.56 terabyte (when using an array with one byte per element), 8 times that (12.52 TB) if using a Python list 🥴
(well, based on what my answer was; I don't know the distribution of answers.)
I have the most convoluted solution for part 2 today, and it doesn't even work yet 😦
Yeah, but you could get fancy and store an int in 4 bits in this case, because it never goes over 16
It was a best-case scenario :P
hehe
I also have access to a 256 gig box, but it's a bit overkill for these challenges :P
anyone mind explaining to me what the day 8 part 2 is asking me for?
that's the most difficult part of these for me, getting specifically what its asking
Adding all of the output values in this larger example produces 61229.
For each entry, determine all of the wire/segment connections and decode the four-digit output values. What do you get if you add up all of the output values?
like it says that
but here's part of the example
fdgacbe cefdb cefbgd gcbe: 8394
fcgedb cgb dgebacf gc: 9781
cg cg fdcagb cbg: 1197
efabcd cedba gadfec cb: 9361
so is each one an individual number
or
how does that work
yes, each word is a digit
ohhhh
mkmk
that makes a lot more sense lol
gotta remove spaces-
yeah i'm dumb, lol
||What's your solution using recursion? Did you use recursion for permutations? Or backtracking||
||I did a backtracking search to find a function which maps all of the segments in the signals to valid digits||
||I don't think it's optimal but it's kinda cool||
||Ah, in #advent-of-code-spoilers-archive would you mind showing your solution? I'm wondering how people did it with backtracking||
fair warning, I have yet to make it nice at all. this is a first working example. also it's in Haskell
Advent of Code (AoC) is a series of small programming puzzles for a variety of skill levels, run every year during the month of December.
They are self-contained and are just as appropriate for an expert who wants to stay sharp as they are for a beginner who is just learning to code. Each puzzle calls upon different skills and has two parts that build on a theme.
Sign up with one of these services:
GitHub
Google
Twitter
Reddit
For the global leaderboard, the first person to get a star first gets 100 points, the second person gets 99 points, and so on down to 1 point at 100th place.
For private leaderboards, the first person to get a star gets N points, where N is the number of people on the leaderboard. The second person to get the star gets N-1 points and so on and so forth.
Come join the Python Discord private leaderboard and compete against other people in the community! Get the join code using .aoc join and visit the private leaderboard page to join our leaderboard.
Yes, finally... done for today
Anyone kind to explain what I have to do in the day 8 part 1?
Count the occurrence unique digits (1, 4, 7, 8) @marble minnow
@marble minnow I can explain in more detail in #advent-of-code-spoilers-archive , if you want
yeah, would be great
Not sure if you guys saw it, but day 7 input is a valid intcode program:
C:\scratch\AdventOfCode>py scratch.py
Ceci n'est pas une intcode program
Done
neat little 🥚
oh shit, nice
no the real input
post in in the subreddit for some free karma, if noone did yet
i think everyone's starts with the same intcode program
then it's just unused junk memory after that
It's where i found it
ah
I wonder if there's any other easter eggs that would require some sort of code to reveal
...just so i can bake it into my aoc framework
unoptimized solution (||you probably actually simulated lanternfish using a list||): a few hours to days, given 12 or 20 TB of memory
optimized solution: about a second
I'll have you know the unoptimized solution can be done in as little as 780GB of memory!
12TB if using a list though, yes.
wowowowow then my computer can stand it?!?!?!? lol
all you'll need is to represent each fish as half a byte
oh wait, memory not storage
yeah. Well, of course you could use a memory-mapped file 🥴
that'll extend the time to weeks, though, probably.
weeks-
this just shows how astounding the difference is between an unoptimized algorithm and an optimized one
actually, good question, how long will it take... assuming you can read at 20MB/s, it'll take you around 39 000s for each read of the list in the later days
i wrote two ||recursive functions|| and i even tested 512, works in a second
with a normal list, it'll probably take months
or maybe even years
or decades
wait no
so we can roughly estimate the time as ~50 hours hmm, hold on, is that right...
yeah, about right actually - 76 hours is my estimate based on 20MB/s disk read/write speed, and assuming you store each fish as half a byte
in other words, if you have a 1TB hard drive, you can totally solve part2 the naive way in only 3 days!
relatable
I was opening the puzzle on my phone this morning and I just saw the wall of text and I was like "Nope. I'm not doing this"
turns out all that text was just for quite an easy P1
Hopefully today’s problem is a bit more straightforward lol
Agreed, I had a bit of fun with today's problem though tbh
right after frying my brain
satisfying input
It was cool enough but definitely a brain-fryer
For sure
Hoping tomorrow is something nicer
I spent half my class time in school working on AOC so it was quite brain frying
um part one is way too easy i'm scared
i still have homework to do i can only spare two more hours
BRO NO WAY
||I WAS PRAYING FOR AOC TO NOT THROW ME A PUZZLE WHERE I HAVE TO AUTOMATE DEDUCTION|| (minor spoilers for pt 2)
AHHHHHHHHH
||Tip: take a brain break so you know what you're gonna do before jumping in, so you don't have code that you're not sure what it does (that happened to me :P)||
||my thought process is always to play with a few values first. i'll deduct a few input/output correspondences by hand and see if i can find a pattern, then i'll try to automate it||
||good idea!||
||i tried doing a thing where i checked the values in whatever string evaluated to 1, eg: dg and then checking if that was in a string of length five, this should result in the number 3, because the values in 1, dg must be present in 3, but sometimes it returned empty? why the hecc is that?||
Let's move this to #advent-of-code-spoilers-archive , and then you can post your code there and we can figure out what's wrong
ok
so that you don't construct the list each time:
next(e for e in mylist if e)
are the 10 things on the left of the pipe always numbers 0 to 9?
(ik that they're shuffled, but does it always have 0 to 9?)
that wasn't a real number lol
ty
god i use too many sets for part 2 lmao
never in my life have i found such abundance usage of sets until now
how fitting, there's only one s because the emojis are a set!
what about the gold shiny bags last year 😳
~~you mean shiny gold 😔 ~~
Shiny bags was fun
fun stats: my most used import statement (besides from a get input helper module) in this event is from collections import Counter
it's just so useful
i was so confused by what it was asking, it was so easy but i parsed the problem statement wrong
⭐ 👜
Yesterday I pretty much had part 2 solved when I double checked to see what exactly part one was asking for.
I used to be a public figure for a company where I was (name of company)_elf, after I left I became xelf.
so, to me it's ex-elf. 🙂
I don't think I'm meant to brute force day 7... yet here I am :)
Part 1 I managed not to brute force... just
Part 2 ... not so much lol. I was close to an efficient solution, but not close enough, so I did the brute force
huh, what is the brute force solution? honestly i'm having trouble thinking of a bad-time-complexity solution that would be easy to think of... unless you're not talking about day 8? (maybe show me in #advent-of-code-spoilers-archive ?)
Kat was talking about Day 7
ah ok
i was just confused because i don't see how you could not brute force part 1 but then brute force part 2 lol
brute force is fine. it's the quickest way to code it, even if execution time is slower than others.
I was gonna brute force Part 1 but I may or may not have heard before hand that the ||median is the O(n) way||
so i just used that
Yeah, someone in another forum posted some edge cases that can be done quickly, but with the size of test cases that AOC provides just brute forcing it is fine
It's weird to see a brute-forceable Part 2 in AOC though
I wonder if there are people who do AoC "by hand"
But I read on the subreddit that someone did one by hand that was crazy to me
Someone did Reservoir Research manually, the crazy person
don't mind me, just blasting o fortuna at full volume to hype myself as i commence to program the last step towards solution
holy shit, 3 hours
i've been working on part 2 for three hours
so hyped
How close are you to the solution?
ehh, only n^2, and there's like less than 10000
still brute forceable :P
I tried ||mean|| and then ||mode|| and then realized I was too lazy to do it properly and brute forced it
i guessed ||mean|| after correctly guessing ||median|| for part 1, i just rounded wrong
||Because I also rounded wrong but didn't know that rounding the other way would fix it, I just rewrote it as brute force||
I did bf, and then tried the clever approaches after.
I did the same thing 🙂
It's frequently easier to figure out the harder approaches if you have an already working solution.
i paid for the whole speedometerprocessor, i'm gonna use the whole processor
Or as much as the GIL lets you use.
here, you have a success, an Objectivitix beyond the purest joy, and o fortuna's climax playing in background
meeeeeeeeeee
yeah, esp for day 6
this RAM can fit so many lanternfish in it
AOC Day 6 Part 2
lmfao
||I seriously thought it wouldn't take that long for 256 iterations but then someone in here said it would take 11 TB of RAM and then I realized||
exponential growth
Even though I know how exponential growth works, it still surprises me when things take long because of it, even though it feels like it shouldn't
||For pt 2, 1 -> 112 is super speedy, it then grows exponentially for each additional day. I killed mine at day 200, when it was chewing through like... I think 2 Gb RAM?||
||Ditto at around 150 - I could tell I was going to need to euthanise the process, put it out of its misery||
I think that the RAM requirement for a naïve implementation of day 6 grows like e^(1.09n) or so
i didn't even try part two with initial solution, i knew the solution we were lead to in part 1 was bait even while i wrote it
||i thought it wouldn't take that long as well, until i realized i had to iterate over 26984457539+ fishes at one point lmfao||
ditto at around 120 😂 me potato computer blew up after that, had to hard restart
just realized i don't need spoilers for that lmao
1) 496 470 | 54.75% 51.88%
2) 454 444 | 50.11% 49.01%
3) 424 366 | 46.80% 40.40%
4) 319 301 | 35.21% 33.22%
5) 288 281 | 31.79% 31.02%
6) 287 272 | 31.68% 30.02%
7) 269 265 | 29.69% 29.25%
8) 243 196 | 26.82% 21.63%
```here's your daily dose of falloff stats
lmao the difference on day 8.
pt1: that was fun!
pt2: .... I'll come back to that later
at this rate, we'll have 10 by christmas
Day 3 still proves to be the bigger culling between pt1 and pt2
because people couldn't be bothered to crunch numbers I assume?
What's that? Completion stats? Some people take a while, or wait for weekends, so the number will tweak a little as time passes.
right, but i think most the people who will ever complete it have completed it
Pretty sure there is evidence to the contrary from previous years. But the numbers might be small relatively.
hmm 🤔 , would be cool to graph that data
We can query the API since it gives completion times, create a chart from that
generally goes up each year, but so far last year had more than this year, so I see that as meaning there are still more coming this year.
yes I would like to think that AoC is growing more than it is dying
at least I hope so
definitely still growing https://twitter.com/ericwastl/status/1466462582034817029
ples give points for more than top 100. top 1000 at least 🥺
hahaha, other people are thinking the same https://twitter.com/ShaneHuntley/status/1466464352974770176
@ericwastl Congrats! With this growth in users, does it now make sense to give points to more than the first 100 on each problem?
with top 1000 i'd have points 😔
Hey, this is the first year i'm solving AOC, can someone tell me if this year is being in general easier or harder or equally difficulty to other years? What year was the hardest? thanks 🙂
in your opinion of course
pt 1: 10 minutes
pt 2: 2 ~ 3 hours
the difference lmao
sea monster doesn't seem that brutal
i haven't done the previous years, so i'm not sure, but apparently 2020 and 2021 are slightly easier than the rest
but still, the days generally get harder as they progress
what if today's problem is the hardest thing we've ever seen
Really? I think it's the single hardest puzzle he's had in any year.
no way
You mean you've seen? Today wasn't that bad relatively. (unless like me you didn't read the problem and tried to solve part 2 first)
One stat you can look at, completion time for the top 100.
2020.20 #100: 1 hour 13min, 2021.8 #100: 20 min
today meaning tomorrow 
my bad, i meant by looking at the completion rate, it isn't that brutal
2019.18: #100 1hour 57 minutes.
(that was the keys/gates one)
https://adventofcode.com/2019/day/18
ah, that one was fun
i solved sea and keys with no hints, i can't consider them toughest
but can;t argue with lb times
What's your thoughts on toughest?
I think I lucked out on the CRT one as I had just the day before been explaining CRT to a /r/learnpython user.
i also solved crt with no hints, i didn't know it's even called that
i also lucked out because earlier I noticed that's how lcm of 2 numbers works
But probably not this much lucked out:
print('part 1:', bus*(time-t), 'part 2:', sympy.ntheory.modular.crt(m,r)[0])
.aoc unsubscribe
Okay! You have been unsubscribed from notifications about new Advent of Code tasks.
TIL sympy has crt lol
is today's part 2 just figuring out how to figure out where each letter is
my brain cant function rn
yeah
Try debugging it
DAY 9 APPROACHETH
i got it eventually
lol
i think youve just seen part 1
part 1 was hella easy with a trick
but part 2 required you to do both the prev part and the jigsaw solving "legit"
GL everyone!
gl
.aoc countdown
Day 9 starts <t:1639026000:R>.
<@&518565788744024082> Good morning! Day 9 is ready to be attempted. View it online now at https://adventofcode.com/2021/day/9. Good luck!
oops
ah nice
I keep forgetting about these
h
the locations that are lower than any of its adjacent locations
any location touching the item in question, I'd imagine
Yep, except diagonals
like
4 5 6
7 8 9```
1 is the lowpoint?
yes
question, in my test input it gives 98789, why is 7 not a low point?
Yes, 1 is the only low point there. Keep in mind there are multiple in your actual answer
it's lower than both numbers next to it
Don't just consider those left and right of the number, you also need to check those up and down from it
OHHH
the advent questions now looks harder now
Yep, they get harder.
yeah ramping up
still easier than yesterday imo
No problem, reading is crucial as you get further along in these
i got 100 lines of input...
Mhm?
the worst part is i don't know how many times i reread up, down, left, right but somehow thought it meant the adjacent is up and down lmao
do you have any idea?
I'm sure #advent-of-code-spoilers-archive will have some soon
im sure there is a wayy smarter method to do this 😔
and what is the height?
What do you mean?
i mean rn i'm gonna do the dirty method of putting it all in a numpy array
it's ugly but it'll work
The height is the number itself
yeah
Each number corresponds to the height of a particular location, where 9 is the highest and 0 is the lowest a location can be.
the risk levels are 2,1,6,6 because the heights are 1,0,5 and 5 respectively
i dont understand, can you gimme an example?
ah
There is one, in the problem.
how to part 1
what is the question
The point of the event is to learn, give it a shot!
ok!
and
this question sounds weird
but
if i do for x in range, for the first loop is x = 0?
!e ```py
for x in range(3):
print(x)
@signal grotto :white_check_mark: Your eval job has completed with return code 0.
001 | 0
002 | 1
003 | 2
By the way, solutions should be discussed in #advent-of-code-spoilers-archive 😉
question, i'm basically trying to put the entire input file into a 2d array of ints
I have this solution and it works fine
with open(file) as f:
fdata = f.readlines()
data = []
for line in fdata:
line = line.strip()
l = []
for n in line:
l.append(int(n))
data.append(l)
but is there any way to do it that's more concise and less ugly?
bc i'm basically building each item manually
See this please
that was messy
||for part 2, are we supposed to assume that every basin will be surrounded by 9s?||
||and that something that goes like (lowpoint)1 2 6 4 is a basin?||
Please only discuss part 2 and any solutions in #advent-of-code-spoilers-archive, people can't see part 2 at first so it's a spoiler 🙂
oh my bad
No worries!
I solved it :D
Nice, good job!
Part 1 is fortunately very straightforward. Having some friends over tonight, but I’ll take a crack at it before bed
hows sthe latests day
Part 1 looks very straightforward. Can’t speak for part 2.
ill catch up soon (few yrs later)
I’ll see if I wind up wasting a lot of time today. Often I write one internal representation of the data for part 1 then I get to part 2 and realise that I need a completely different representation
oh, ok
How do i see the puzzle for today?
hmm my code works for the in-page example but for the input it gives an answer for a different input set 
What is the puzzle?
ik i am bounds checking in 2d list properly
day 9
and i am getting the right answer in the sample input
I got a 10x5 set from the actual input and it works for that too =_=
Quick tip for anyone who is having trouble debugging and is using a regular 1-dimensional array: make sure you're calculating ALL of your map boundaries correctly
There's a particular case that the sample doesn't run into
oops
tyvm
i am literally so close with finishing part 2
||i have the basin size calculating complete but idk how to find the largest 3 numbers|| 😭
one of these days im going to do all parts of a day within the first hour that its out
i wish you the best
thank you
ikr
there is some edge case
yea
what happens when theres two equal heights
to count the low point
OH I always forget this
hmm
Yeah, found this weird - the sample makes it seem like all of the boundaries need to be exactly 1 higher for it to flow down (part 2)
im in the same boat

My mistake was ||forgetting that list[-1] is valid||
😔
inb4 people on the global leaderboard figure out a polynomial time algorithm and end up solving it in 3:46 minutes
man... I was so confused as to why something wasn't working
it turns out, I was making a tensor of height 0
lmao
inb4 aoc solves p=np????
they should just throw in some random unsolved problem once in a while
LMAO for a second i fell for it
it's never been done, even without that large bound, no one has found any at all
and yet it's not known to be impossible
gotta love the "next aoc puzzle is a yet-to-be-solved/unsolvable problem"
welp... I've absolutely confused myself
this is quickly becoming more and more unfun
welp... here we pray
:faint: that wasn't it
perhaps you meant to post in #advent-of-code-spoilers-archive
anyways...
yeehaw
oh lord. part 2 ;-;
sorry, yeah
again it works for the example but not the input ;_;
had the same thing for part 1 haha
I think one part that gave my code problem was an area with || all 9s, and I did > instead of >= accidentally||
I had wrong sign in day 3 at first
Yesterday I forgot to do len and I got wrong order ~sometimes~
rip
is there a way to find out what's wrong short of going through the entire input manually 😩
You can cut your input to one line and do it manually and compare
I like how the user is lcollatz 😄
I printed the neighbours of every basin I checked (I had too many) and looked if anything was weird
btw, does advent of code have an API?
yeah
it would be nice to run a function that downloads your input given the day number
docs?
i tried looking at the fetch/xhr in network, but i couldn't find anything
There are repos dedicated to that already
There's a Python package that does that.
I think salt has one
aoc_helper I think
ah, so a wrapper for it
I use one for Rust as well
aoc_helper is repo name?
Yeah, and pypi package
ah wow
So you can install it with pip
nice
As long as you auth (and oauth is kinda hard to do manually) you can just fetch input by url. So wrappers are nice because you skip the hard part
ye
not sure why they didn't make a public documentation for it?
why would they? it's not their problem. and oath has a lot of docs already
How does authentication work? Advent of Code uses OAuth to confirm your identity through other services. When you log in, you only ever give your credentials to that service - never to Advent of Code. Then, the service you use tells the Advent of Code servers that you're really you. In general, this reveals no information about you beyond what is already public; here are examples from Reddit and GitHub. Advent of Code will remember your unique ID, names, URL, and image from the service you use to authenticate.
I was wondering, I see a lot of solutions that find basins starting from the low points. But that's not guaranteed to find all basins right? Because a basin could have two minima next to each other that wouldn't be counted as a low point.
I don't think that exists in our input
But yes technically thay would be missed I suppose
low points - the locations that are lower than any of its adjacent locations
if they are equal, then they are not lower
Exactly. So if you only start at low points, you'd miss a basin like this:
99999
92229
99999```
that type of a basin doesn't exist
Can you be sure of that?
according to the input
ah I see
lol
A basin is all locations that eventually flow downward to a single low point.
So it doesn't say that my proposed basin doesn't exist, but just that that wouldn't be counted as a basin
Is something like
6875
5134
3847```
a basin or do they need to have consecutive numbers from the minimum?
I literally quotes the task just above you.
low points - the locations that are lower than any of its adjacent locations
and said: "if they are equal, then they are not lower"
and further from the task:
A basin is all locations that eventually flow downward to a single low point
single low point
and your example is not a low point because of the first quote
example with size of 14 has 5 surrounded with 2 8s, so any higher should be okay
oh i thought that 8 came from the 5 > 6 > 7 path
I think they mean the other quote "all other locations will always be part of exactly one basin"
Ok you're right. Reading is hard. This has previously broken me up 😄
Looks like they have to be consecutive. In the first example, there's are 8s next to the 1 and 3 not counted
I'm just staring blankly at today's problem
there are 9s
not 8s
no
no. even first part was without diagonals
🤦♂️ thanks
.xkcd 323 you missed your peak
Yeah I know I overshot the Ballmer peak by a few daiquiris
F
just means I have to try less daiquiris next time and hone my optimal BAC for top programming
it's an optimisation problem 😎
||The problem description specifically said diagonals don't count, y'know.||
.aoc join
Also, please save discussions of the current problem for #advent-of-code-spoilers-archive .
sorry
representing 2D spaces can be such a pain in the ass...
omg finally...
Nice!
4 hours...
grats
uh
oh no
lord, I hate these
tbf
My code is so unholy
nth arrays are a very convenient way to represent data
but for example ||today you could use dicts in order to represent positions||
:)
convenient if you can wrap your head around them 
lol they're the worst in Haskell
Part 3 is a 7d version where the 7th dimension is time.
oh yes. part 3
those are lists tho
well yes
which is slightly different due to time complexity and how theyre structure in memory blah blah
structured*
and evne how theyre used
Yeah I know, just makes representing multi-dimensional data kind of a pain
Like yesterday was pretty bad
ye
hmm
experience mostly
I think there's a library that provides those
I think most of the time ||representing grids with sets of positions rather than multidimensional arrays is way easier||
My plan was to do something like ||Map (Integer, Integer) Integer|| but that makes parsing a pain in the ass
theres a mutable version in the sense that its managed thru an IO monad
I did that, it was easy in Rust
:o
ah I'll try again tomorrow morning once I'm sober
That was not a good day for me
maybe my brain is just not seeing it
Should be easy honestly but yeah idk
ugh i'm behind so many days on AoC, but uni is shoving so many things about programming down our throat i'm starting to burn me out
makes me sad
Oh nice, today sounds fun
part 1 looks deceptively easy
perhaps part 2 would be to construct a quantum algo determining the most efficient way to escape the cave system while simultaneously avoiding smoke
I may as well work on part 1 at school lmao
i’m doing part 2 at school lmao
It's to create an accurate simulation of smoke physics in 3D space.
on the ||networkx|| docs
you can persevere for 4 hours
idk how you do this
jokes aside, you're doing amazing if you're continuing for 4 hours and finally finding the solution
wtf.
lmfao
C'mon, this is baby stuff.
(Just for the sake of Poe's law, I'm being facetious)
: meant to be humorous or funny : not serious
my function for that was the same as the previous part
i found it:
||
def convolve_dimension_(n):
KERNEL = np.ones((3, ) * n, dtype=np.uint8)
KERNEL[(1, ) * n] = 0
universe = data[(None, ) * (n - 2) + (..., )]
for _ in range(6):
neighbors = convolve(universe, KERNEL)
universe = (neighbors == 3) | (np.pad(universe, 1) & (neighbors == 2))
return universe.sum()
def part_one():
return convolve_dimension_(3)
def part_two():
return convolve_dimension_(4)
||
lol
i remember doing a generic n-d game of life
i found it
||`import sys, os, re, math, hashlib, itertools, string
from collections import namedtuple, defaultdict, Counter
import numpy as np
def hyperconway(raw, G=100,N=2):
if N < 2 or G < 1: raise ValueError()
adj_coords = list(filter(any, itertools.product((-1, 0, 1), repeat=N)))
m1 = {(i,j,*([0]*(N-2))) for j,y in enumerate(raw.split("\n")) for i,x in enumerate(y) if x == "#"}
print(f"Gen 0, count={len(m1)}")
for g in range(1,G+1):
neighbours = Counter(tuple(v+dv for v,dv in zip(V,dV)) for dV in adj_coords for V in m1)
m1={p for p in neighbours if neighbours[p]==3 or (p in m1 and neighbours[p]==2)}
print(f"Gen {g}, count={len(m1)}")
return len(m1)
def one(raw):
return hyperconway(raw,G=6,N=3)
def two(raw):
return hyperconway(raw,G=6,N=4)`||
python is too slow
it is taking 2min to calculate one number
for aoc 2021
day 8
that's not python's fault :P
Python may be a bit slower than some of its peers, but there's nothing in day 8 that should require anything that would take it more than a few milliseconds
maybe its just my bad code
i will try to optomise
A good call!
looks like i found the culprit
permutations
are they slow?
I mean there are a lot of permutations
ok im so lost
I can't imagine there'd be enough to choke up python, it takes a lot of inputs before things start to slow down. Maybe head on over to #advent-of-code-spoilers-archive if you need some help diagnosing your code
If it's not a logical error, there is at least almost certainly some way to do what you're doing with less data to manage
well i was looping over stuff for no reason instead of removing them from the stack
so maybe not python or perm fault
is it running faster now?
What's up?
yes
Nice! Good a lesson as any to double check your logic if things are going slower than expected. It might be fun to play around with operations on various sized datasets to see what kind of numbers cause python to slow down
part 2 solution is breaking after only a few points
so im going to redo the whole thing
#advent-of-code-spoilers-archive is here for you if you need any help!
good luck and godspeed
thank you

My Day 9 part two works with the sample but doesn't with the real data 😕
Head over to #advent-of-code-spoilers-archive if you need any help!
I'll try to solve it by my own first but yeah
If you have come to say this kind of things, you are already seeking help. You can post a bit of code and discuss about hints in spoilers
you can complain about things and not want help at the same time
is there a better way to check neighbour digits than recursion
iteration!
👀
i am thinking of collecting all the 9's indices
and doing some sorcery with it
😩
but it is not that simple
yeah
9's are walls
thats why made a class
hm
btw i am assuming that the recursion does not go simultaneously if we deployed multiple function calls right
like
def re(p):
if con:
...
return re(hm) + re(ok) + re(bruh)
so re(hm) should finish his complete dynasty of recursions before moving to the next
or is it
vsauce moosic plays
yes, it should
ok
.aoc join
Got the right answer for the test-data for P1 and P2, but only P1 for the real data 🙃
I dont understand how finding the lower points works, the example confuses me
If all "neighbours" are greater than the current number, it is a lower point
for a basin it doesn't have to have adjacent numbers that are either one higher or one lower it just has to be adjacent nums not 9?
correct
Oh so like 0, 2, 6, is a valid basin?
yea as long as they are connected
Jeez
the examples just show that bc all of our inputs have consecutive numbers anyways
you want find like 026 connected
only num that doesn't apply is 9 whiuch is the wall
Here I am checking for increments of 1 only 😄
yea, that got me
Woo, got the right answer then 😄
Time to refactor the horrendous code and remove all the prints 😄
ay, we solved day 8
quite happy with it, it runs in only 1.8s
I feeeeeelll like day 9 without numpy will probably push CPython to its limit
my both parts finish in 14 ms....
without numpy..
yeah input isn't that big
20ms to parse? that's a lot!
oop that should prolly go to spoilers
I'm trying to guess what part 2 may be
so I don't lock myself
oh well
a rewrite never killed anyone, did it
every grid is 100x100?
there is only one
fun
well that's a problem
I get the right answer on the sample
if not (0 <= x < SIZE and 0 <= y < SIZE) why doesn't this work correctly 
oh my god the sample isn't a square
@hollow wharf yes it is I think
@hollow wharf I think you did not read the riddle correctly
and all other locations will always be part of exactly one basin.
That's a bit concerning, considering assigning a location to a basin or another will give you a different output
wdym?
I also tried/did a general one but mine was huge.. amazing you did that so easily haha
If it were to have overlap though there would be many different answers to the puzzle
Today is my favorite day so far, ||I've never actually had to use recursion for a problem so it's refreshing to use it
||
same
used recursion for continuous 2 days
@woven sable I used iteration for that one 🙂
How'd you do it? (what was your solution? btw you might wanna send it to #advent-of-code-spoilers-archive )
Well I'll just say this...there's usually an iterative way to solve common ||graph search problems||. I'd suggest Googling it a bit if you're not already familiar. It can be really handy if you're ever doing it for real and you have a huge graph that will blow up your stack (unless you have tail recursion)
Man i gave up on advent of code
I couldnt do day 3 then i forgot about the other days and when i checked it was too complicated for me
I withdrew from the leaderboard I was in. It was making me feel stupid not being able to finish as quickly as the others
Want to see my journal entry from Tuesday?
Quit Advent of Code. Just too stupid and slow to keep up.
My poor performance last night knocked me from 7th place on the discord leaderboard to 14th... ouch, that is a huge impact for just a single day's problem
i did today's one after 10 hrs of being uploaded due to some work , lost 19 places
¯_(ツ)_/¯
oof
I seem to have gone up several places since day 3 or 4. I guess due to some people having dropped out rather than any skill on my part 😄
Although I got kinda lucky today. My solution is very close to an algo I used in a minesweeper game (for the cascade of squares being revealed if you reveal an empty tile).
damn
perks of game development
Ohh I think I get what you did
you always gotta work around matrix and stuffs
It was a little toy project I did a few years ago for the lols. Wasn't very good overall, but I guess it came in useful 😄
I think the leaderboards are probably not a good thing....unless you reveal them at the end, maybe. But it doesn't encourage good code. It encourages fast code
consistency matters at end
The leaderboard is very much a "oh nice" thing for me. I don't even look at the day's puzzle until several hours after it's unlocked, so not storming to the top of any leader boards any time soon 😄
so its fine not to be worried about your pos because why should you
i think it's fun to try to solve it as fast as possible at first, and then make your code better later
i like racing against my friends :D
The leaderboard definitely scratches the itch of the competitive programmers out there lol
cough cpp
https://www.youtube.com/watch?v=CFWuwNDOnIo
even the creator agrees. He believes that analyzing, understanding and solving a problem in a creative way is what should matter
Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as a speed contest, interview prep, company training, university coursework, practice problems, or to challenge each other. In this talk, the creator of Advent of ...
but the thing is that we cant compare codes on the basis of beautification or approach so the only way left is speed 🥴
Well, the competition could be to see who completes all the challenges...not that many people do that
I mean, does the top person on the leaderboard win anything?
uh people dont do things to win something
they are just doing their competitive grindset
why would my code get the right answer on the example input but not on the actual input
for todays thing
is there something weird about the example input
did you hardcode some critical points
no
we shall discuss in #advent-of-code-spoilers-archive
github copilot can determine a list of codes to output depending on some attributes...They could perhaps define beauty as a parameter to classify codes.
This is dumb, I am rambling, I should sleep, don't read what I just said...
if u didnt want us to read it then why did u send it
What means "advent of code"?
Lol I wonder how many people are using copilot on this
And how useful it is
8 and 9 are probably a 3-4 IMO
check out #911684406605930496! It should answer your questions~
👀 interesting
lel
lol, where you @?
just for experimental purpose after finishing
india
ahh cool
cdfbe: 5
gcdfa: 2
fbcad: 3
dab: 7
cefabd: 9
cdfgeb: 6
eafb: 4
cagedb: 0
ab: 1``` i dont understhis at all what is the logic applied when decoding the digits
i get that 8 is for 7 and 7 for 3 and 2 for 1 etc
but how are others decided
For that one....there's more than one way of comparing digits, or rather comparing the data that makes up the digits. One way is a lot more useful than the other
So you see the diagram of the seven segments above?
fbcad light up to form 3
hey, this is a more general question, let me know if I'm in the incorrect channel. Last year (and this one) I've seen people use libraries like networkx for their solutions . Where did you guys learn to use those for your problems? Do they have common implementations? If so, for what? I knew a bit about numpy and its linear algebra library, but never thought that I could use linear algebra for solving the problem from AoC.
what if I told you those are libraries made to solve real-world problems that people use in their regular day to day work?
I don't mean to be rude or pick on you, it is just a bit funny
I wouldn't be surprised. I don't mean that those libraries are meant only for AoC problems.
networkx in specific is widely used for working with graph networks in python, which makes some kind of problems easier
I haven't studied graph theory nor any field of computer science (I know some basic introductions but nothing else), I was asking for resources to learn what kinds problems do they solve to see where I can apply them as well.
thank you
in my case, it's just having some knowledge of the underlying math. It's the same as with any math problem, you just sometimes see the relation to a math concept you already know and solve it that way
yeah... most of the time on these cases, it is about recognising that a determined problem is related to a topic you already know.
usually things like "find the shortest distance between two points"
(oversimplifying it a little bit)
yeah, I did recognise something in day7 about that
not specifically about the points, just about maths
I guess I'll have to research more on graph theory
genuinely interested
yeah - even though not every problem is related to graph theory, it can be fun to learn some things about it and play around with graphs a bit
sure!
there are even some "NoSQL" databases based on graph theory (such as Neo4J) if you want to mess around with it
Graph theory is one of the most useful parts of CS overall. Most fields have at least some GT problems
an unexpected-ish place is register allocation in compilers
welp, that is REALLY interesting
I'm making my own C compiler, and already made a sort of working register allocator, never knowing it actually follows a known pattern
graph coloring is afaik the more specific description
This channel is for Advent of Code. Please open a help channel
You're looking for the functions -
list.count() , list.index() , and probably list-comprehensions .
Yep.
hi
||part 2 is one of those searching algorithms, exactly what i'm inexperienced with lmao 😔||
though this is why i LOVE aoc
learn so much new stuff
||oh it's a recursive solution again isn't it||
Not necessarily
||my mind just flew to recursion lmao||
would probably work
||sure, you can probably solve it iteratively, but why when you can recurse :D||
||Some advantages to doing it iteratively usually||
true true
|| BFS is terrible recurisvely as far as I know, DFS is easy though||
Hello 🙂
2019 was the year of intcode, right? I've heard that that year was particularly fun and want to do it.
Yea
i heard that recursion gets a bad rep for being inefficient, but then again you have @cache
ty
Poor cache person
I have to actually do 2019 at some point
i stopped cause it was a bit too much for my skills

dont use recursion please
i'm doing 2019 right after 2021 lol
if my output number takes more than the full length of the my terminal to show up, do you think I messed up?
If it's a single number and you're doing day 9
yes
The maximum you could get (which isn't even possible) is every single input data
unlikely (read won't happen) and not sure that'd fill it 
||Find the three largest basins||
it would help if I were to read the prompt
1825553075572295861000688390570293789728808334688285126417584321133963999289062138010144228311094741155009439264911024135120900171851405879947173198105108715459217161078552924894715943887311121450728850201515251664265399503302964559270002842643988480000000000000000000000000000000000000000000000000000000000 would have been an interesting output though
what even is spoily here
part 2 question
||yeah, i think it's called BFS from what I"ve heard||
okay i need to stop clicking on spoilers now
luckily, i don't know how to do breadth-first search
well, I got it wrong on the input but right on the sample
so that spoiler doesn't affect me :D
so like
I had the same thing

some things aren't covered
Oops sorry
For example I believe || if you did not include ONLY lower than all adjacent ones (so <= is fine)|| is not covered (wrong)
I also learned about BFS today though
If anybody has any clue what's going on: ||https://paste.pythondiscord.com/nujasehute.py||
recursion is breaking my brain
today's puzzle reminds me of trees
i hate trees
thus, i hate this puzzle
but i also love it
did anyone discover a super optimal solution for day 7
There are some nice solutions for both of them
So yes someone did do things that could fit that criteria
are there no spoilers allowed here? Can you point me to anywhere those solutions are posted?
#advent-of-code-spoilers-archive is for spoilers
Wow, you hate the trees that pump out oxygen? /j
i take it back
today's puzzle is so fun
trees are amazing
Exactlyy
@hidden musk
im kinda confused at what edge case the sample input doesnt have that the actual does
nvm
thats so stupid
the history an AoC doer
bfs generally isn't implemented recursively
dfs is commonly implemented both recursively and iteratively
it took me an embarrassingly long time to notice that my solution wasn't working because ||I had made a graph with a cycle in it||
it worked on the sample. I was losing my mind
anyone on day 3? 
I made such a mess of day 3 lol
me!
I've been skimming and coming up with half-solutions that don't completely work, but not actually doing them all
I basically attempt all of them, but if they'll take more than 15 minutes for me, then I'll wait to come up with a complete solution (which is all of them beyond the second)
I might do them over break
Does anyone know how I can use curl to get my input file from the website? When I pull the file it says Puzzle inputs differ by user. Please log in to get your puzzle input.
You need to use your session token as a cookie
already midnight

