#advent-of-code

1 messages · Page 15 of 1

cyan sleet
#

someone good at math?

In [20]: def f(a, k):
    ...:     inc = a.pop(0)
    ...:     for i in range(k):
    ...:         a[i] += inc
    ...:     return inc
    ...:

In [21]: a = [1]*100; [f(a, 0) for i in range(10)]
Out[21]: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

In [22]: a = [1]*100; [f(a, 1) for i in range(10)]
Out[22]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

In [23]: a = [1]*100; [f(a, 3) for i in range(10)]
Out[23]: [1, 2, 4, 8, 15, 28, 52, 96, 177, 326]

In [24]: a = [1]*100; [f(a, 4) for i in range(10)]
Out[24]: [1, 2, 4, 8, 16, 31, 60, 116, 224, 432]

In [25]: a = [1]*100; [f(a, 5) for i in range(10)]
Out[25]: [1, 2, 4, 8, 16, 32, 63, 124, 244, 480]

In [26]: a = [1]*100; [f(a, 6) for i in range(10)]
Out[26]: [1, 2, 4, 8, 16, 32, 64, 127, 252, 500]
lusty rover
#

Not I

cyan sleet
#

oh, k=2 is fibonacci - 1

#

so I guess it would grow quickly if we actually had full matches all the time

#

but in reality we probably don't have that many most of the time

hidden musk
#

hmm. could probably make a fun matrix operator solution thing for shuffling the numbers around

leaden tartan
#

Ok im losing my mind

lusty rover
#

Welcome to the club

leaden tartan
#

I feel I am going insane

#

I cannot compare 2 numbers

lusty rover
#

Hey, comparison is hard

leaden tartan
#

why does if (num1) in [list of numbers] not work

royal gull
marsh currentBOT
#

@royal gull :white_check_mark: Your 3.12 eval job has completed with return code 0.

Yes it is
royal gull
#

but, perhaps you have a list of strings?

leaden tartan
#

Ive tried converting them

#

Ive tried direct comparing them 1 by 1

#

Ive tried copying the numbers out of the debug window and comparing those (it works)

royal gull
jovial jay
#

unrelated, but i just discovered the reason why text files ends with a new line even if i didn't want that when doing the advent of code

weary kelp
#

What's the reason?

low condor
#

Mostly because Unix systems said so - that’s how they define a line

#

But there’s good historical reason why they did that - which someone else can explain :)

jovial jay
jovial jay
# weary kelp What's the reason?

because some programs wouldn't parse text files correctly if it didn't end in new line. I figured some of my code wouldn't work if I had to account for the lack of new line at the end.

low condor
#

Files ending in a new lines make sense IMO

#

If you concat 2 files together it just works

bronze vault
#

aoc is awesome

weary kelp
#

indeed tis

bright laurel
#

i feel like the purpose of the site is to teach you how to make parsers. the questions themselves are easily solvable if they were more organized

jovial jay
#

Yeah, it's all about parsing

#

There should be other things imo

bright laurel
#

indeed

weary kelp
#

advent of parsing

hidden musk
#

the early days this is true. theoretically, the problems will get harder until parsing becomes just the easy part

low condor
#

Also only two out of four days has had difficult parsing. The other two were very easy

#

I’m more a oneight fan :)

somber trench
#

twone 🔛🔝

noble skiff
#

Wait which days had difficult parsing

peak dock
#

d1p2 and d3

noble skiff
#

Feel like everything so far was pretty trivial to parse

#

What made d3 challenging to the degree it was, was not the parsing

#

Organizing the data and writing the algorithm over it in a clean way was

#

Day 1 had the one edge case in the parsing I suppose that got a lot of people (myself included)

#

I don't think AOC is generally trying to make parsing hard, generally the data is pretty cleanly separated and you can just split() your way through.
The days with recursive parsing are the only ones I think where it's challenging to parse really

lapis pilot
#

that was absolutely nasty today for me

#

recursion makes me v emotional

muted aurora
#
Timing execution for all 4 days...

real    0m0.024s
user    0m0.011s
sys     0m0.009s

Pretty happy with that so far

honest nacelle
#

Was Day 3 weirdly difficult for this early on? Or did I just miss an easy solution?

#

Also, how are the resident golfers doing?

peak dock
honest nacelle
#

Thank you, my head already hurts

jovial jay
#

how bad can day 5 be? i'm waiting for that

honest nacelle
#

Setting myself a strict 30 min time limit before I have to go to sleep

sharp panther
#

Language Roulette: Day 5
The language is ... Prolog

honest nacelle
#

I don't even know what prolog is...

sharp panther
#

Prolog is a logic programming language, which is a paradigm that's probably vastly different than anything you've seen before

honest nacelle
#

Maybe I'll make it my goal to go back after the event and do the daily language stuff

#

@.@ yeah that'll have to wait

hexed axle
covert arrow
#

glhf

earnest forge
#

GLHF

shut trellisBOT
honest nacelle
jovial jay
#

ok, day 5 is confusing

honest nacelle
#

Oh god...

jovial jay
#

you find it confusing too?

sharp panther
#

this explanation is quite long

honest nacelle
jovial jay
#

you're getting it? wow

sharp panther
#

zero part 2s yet, with over 70 part 1s

#

sounds like part 2 is a doozy

hexed axle
#

It looks like it's really easy to make a time inefficient solution, I bet part two ruins that

sharp panther
#

and now the p1 leaderboard is filled. first time so far this year.

hexed axle
#

with a single 2 star person

covert arrow
#

what is this p2 😭

jovial jay
#

i'm getting p1 and the leaderboard is filled?

sharp panther
#

yep, 08:15 for p1 #100

honest nacelle
#

I need to stop looking at how fast y'all are getting this before I get discouraged lol

naive stone
#

what did i just read

compact wasp
#

why is this so cringe

wet yoke
#

Curious now what pt 2 is though I'm only doing the code during work hours. 😦

jovial jay
#

pt 2 is probably really bad to deal with. i bet.

wet yoke
#

I see a solve in my head for 1, so eh

earnest forge
#

My vscode crashed wtf

woven solar
#

huh, wrong answer.
EDIT: dumb mistake, nevermind

jovial jay
#

i think i'll probably drop off AoC after this

magic oxide
#

wow that's a long problem description

pine tiger
#

oh god wth is p2

velvet stag
#

F

livid gull
honest nacelle
woven solar
#

oh no, ||sure hope I won't need sympy for this||

earnest forge
hexed axle
earnest forge
#

I'm kinda wondering if Z3 is a good fit

sharp panther
#

and it's done!

naive stone
#

no matter how many times i read this prompt, i don't get it

hexed axle
#

26 minutes on day 5, it's shaping up to be quite the AoC this year

pine tiger
#

lmao

#

that was hell

flat sequoia
#

man I trolled so hard

#

I advanced the stage BEFORE calculating things

#

so I was looking at all the wrong ranges

pine tiger
#

💀

compact wasp
#

💀

pine tiger
#

idk it took me way too long to realize ranges were needed

#

wonderful code right here tbh

naive stone
#

I don't understand, why in the example does the seed to soil map have 2 lines? why does it have 2 destinations and 2 sources? which is the right one? am i stupid?

pine tiger
#

it's a set of mappings

#

like "transform this range by an offset to that range"

#

each 3-set of numbers is that

naive stone
#

i'm still not getting it

woven solar
#

this is like the third time I see an "ugh, it's fucking ||interval intersections|| again" task in AoC, yet for some reason I have yet to make utilities for that. smh, past-reptile

honest nacelle
#

man y'all are nuts

stable shale
#

My brain can't math this late at night

honest nacelle
#

I'mma sleep on it, night y'all and good luck

stable shale
#

Yupppp

woven solar
gentle cape
#

My day one solution is a mix of a web api, python, and Haskell

magic oxide
#

today looks interesting

#

looking forward to it

woven solar
#

aoc day5 be like: ||calculate the minimum of the image of a union of sets under a given transform||

spice tiger
#

AHHHHH IM MISSING RANGES

#

my nums are skipping over way too much

naive stone
ripe scroll
#

how do they even come up with this kind of problems

wet yoke
# naive stone i'm still not getting it

A contrived example: ```
10 5 2
3 1 3

This means a source range starting at 5 of length 2 (so 5 and 6) maps to destination range of the same length starting at 10 (10, 11).
There's also a range starting at 1 length 3 (1,2,3) mapping to destination starting at 3 (3,4,5).
Any numbers not covered by a source range are just 1:1 mappings.

So you would have:

1 -> 3
2 -> 4
3 -> 5
4 -> 4 # not covered, 1:1
5 -> 10
6 -> 11
7 -> 7 # also 1:1

and so on

Essentially you map a seed from the source to the given destination. And then keep doing that through like 6 other maps to end up in a "location".
For all of those starting seeds, find their resultant locations and then find the one that's lowest.
livid gull
#

i've just solved part 1 after using a for loop to add the maps to my map lol, which froze pc obv

wet yoke
woven solar
naive stone
#

these ranges overlap don't they?

50 98 2
52 50 48
#

how would that not matter? that would mean that a source has 2 different destinations

wet yoke
#

No, 50 length 48 stops at 97

#

50 is included as the first

woven solar
#

the length is the third number

naive stone
#

right, ok. So ranges never overlap then, this is just multiple ranges

woven solar
#

yup, source ranges should never overlap. destination ranges... I think it wouldn't be a problem if they overlap (haven't checked if they do in my input)

wet yoke
#

I figure some destinations may overlap? Don't think that part matters.
Sources should not, though

livid gull
#

if destinations overlap thats a problem

#

right?

#

2 seeds could go to same spot

woven solar
#

yeah, but I don't see why that'd be a problem for this task

wet yoke
#

As long as there's a direct source -> destination with a single answer, it should be fine

naive stone
#

ok so then the first range only tells you where seeds 98 and 99 go, the second range tells you all seeds from 50 to 97, all other seeds are identical to its source number?

pine tiger
#

lmao my code is so garbage

pine tiger
#

i'm gonna delete it and start again tomorrow

#

for actually presentable code

naive stone
#

alright, thanks guys

wet yoke
#

Go forth and beat me to it as I won't start for at least 10 hours 🙃

naive stone
#

lol

pine tiger
#

i find it somewhat amusing
that even though i'm 72 on global
i'm #2 on this place

humble copper
#

for the record: ||i hate range splitting||

woven solar
#

i suspect that the fact the destination start number comes first is a chatgpt measure, btw. it's just such a weird order to put them in 🥴

pine tiger
#

ok but i hardly believe chatgpt could do that parsing thing

pine tiger
naive stone
humble copper
#

am i looking at the wrong leaderboard

pine tiger
#

uh idk

#

#aoc-bot-commands message

placid lake
#

caching the brute force way is too slowww :))))

#

sigh

humble copper
#

ah that one

placid lake
#

this was predicted to happen

woven solar
placid lake
#

smh

pine tiger
#

i wonder is there a way to get the constant factor down enough

#

so that brute force works

placid lake
#

that's what i was hoping for

royal gull
placid lake
#

okay i guess time to try the other way

humble copper
#

if i wasnt doing importless i'd write a custom lib for problems SPECIFICALLY like this

covert arrow
#

I need to have a custom Range class with unions/intersects/etc. in my utils

livid gull
#

im now implementing that

#

its now my idea

earnest forge
compact wasp
#

man what is eric cooking for future days 😭

#

this is not day 5

humble copper
#

day 19 is actually just gonna be "here's input for a conversation, write a LLM that can reasonably pass the turing test"

earnest forge
#

LMAO

sharp panther
#

in 2022, the first day to take longer than today's (to fill up the second star leaderboard) was day 15

wet yoke
#

"So it's AI, is it? Let's see you do this!"

#

Honestly I wouldn't be surprised if they ran a couple of these through GPT early to test whether it knew how to interpret the text...

humble copper
magic oxide
brazen bridge
#

For someone who isn't math-savvy at all, does anyone have any hints for part 2? I can't seem to figure it out at all blobthinkmad

humble copper
flat sequoia
compact wasp
#

😔

flat sequoia
#

I spent so long trying to figure out how to use it but for some reason I couldn't figure out range subtraction was the thing that was missing

#

so i ended up just wasting a ton of time lol

candid berry
humble copper
#

out of curiosity, on average how many people participate in AOC every year?

sharp panther
humble copper
#

(genuinely slipped my mind that that page exists, ty!)

placid lake
#

yay p2 done

#

damn ||intersecting ranges||

#

all too familar from past years

candid berry
#

these problems are feeling a lot less bite sized than usual for this early in

royal gull
#

P1 done after doing it twice. (In sql)

candid berry
#

ooh boy, get ready for part 2

#

actually, if you can get part 2 working in SQL, I'd be very curious to see it

compact wasp
#

no shot eric doesn't know what he's doing here

#

nor his beta testers

royal gull
#

I guess I know what to do, I just don’t want to.

candid berry
compact wasp
#

yeah for sure

brazen bridge
covert arrow
#

yes it is

earnest forge
#

Multiranges are neat but I don't think they should be the default for 'range'

covert arrow
#

I initially had a normal range but then changed it later

compact wasp
candid berry
compact wasp
#

they're probably traumatized

lime fulcrum
#

Wtf is wrong today

compact wasp
#

lmao

wet yoke
#

If this was old WoW days I'd call this a gear check.

woven solar
#

No, that was day 3.

lime fulcrum
#

Duh

royal gull
#

Ok, im going to bed. I know -how- to approach part 2, but, boy I don’t want to.

worldly raven
#

haha, i feel that

edgy hearth
#

this advent of code is so hard wtf

#

puzzle questions

#

I did day 2 p1 wrong and I don't have the will to keep going idk how yall doing all this its gibberishhh

magic oxide
#

another day where i wish python had a bst built in

broken dock
#

(day 5 part 2 spoilers) holy hell that was some ||nasty backtracking||

#

wasn't expecting to see something like that this early on

broken dock
#

i didn't find days 1 and 3 difficult per se, more so immensely tedious

atomic cairn
#

God damn this is a whole book to solve

naive stone
#

i feel like i need an extremely light hint for part 2. I don't want to be spoiled, but i'm failing to come up with any ideas

broken dock
#

the word alone won't give much insight into the approach I came up with

#

but it at least tells you what general type of approach I went with

earnest forge
candid berry
naive stone
#

hmm

broken dock
#

rofl

earnest forge
#

I do

broken dock
#

i'll dm u

placid lake
#

||backtracking??||

broken dock
#

actually i think i'll hold off

broken dock
#

i didn't know that existed FeelsGoodMan but still, i'll abstain for the time being

timber glacier
broken dock
#

||normal backtracking will run in time just fine||

placid lake
#

||interesting.. i'm not even sure how that'd work ngl||

broken dock
#

actually i'll post my solution wtv

placid lake
#

||i understood today as intersecting ranges||

timber glacier
long jacinth
#

D5P1 evaluation taking so long....

#

i better go shovel snow!

broken dock
bright laurel
#

anyone knows edge cases for day 4, sample input gives right answer, unlike the actual input

long jacinth
#

python taking over 8 gigs

#

whew

#

i need more ram, lmao

ripe scroll
#

My laptop hanged lmao

#

it works though

somber crow
#

is it bad if my solution triggers the OOM killer on and hangs a 32gb machine?

ripe scroll
#

yep my fan sounds like a jet engine rn

#

let me try an Online interpreter. hope it doesn't DOS it.

long jacinth
#

yeah, also using dicts lol

zinc kindle
#

Ouch. I banged my head against a wall for over an hour in part2. and I figured out a correct approach more or less instantly (I have literally used elements of said approach for my job) it kept being buggy and giving the wrong answer on the sample input, and that's when it didn't enter an infinite loop.
Then I went and had dinner, rewrote part 2 in python, and after one trivial bugfix got the correct answer.

long jacinth
#

ill have to rewrite it later, work time now

rich delta
#

anyone tried using dicts and worked??

long jacinth
#

it works

#

if you have enough ram

finite stag
#

any bruteforcing works in that matter :D

rich delta
long jacinth
#

ive gotten over 12gb before i just killed it

finite stag
#

i had 16 and still crashed my program

rich delta
#

bruhh

#

backtracking it is

zinc kindle
#

Ugh. Turns out the issue wasn't due to a logic error in the code, it was because when converting the seeds in part 2, I used vec.windows instead of vec.chunks, resulting in my input being read incorrectly. My actual algorithm was fine. Can't belive I didn't notice that.
(equivalent of itertools.pairwise vs itertools.batches)

rancid creek
#

If your answer in python takes longer than a few seconds you might want to consider a different algorithm.

#

I don't think this is a brute force ish sort of solution. You could spin a long time.

digital whale
#

someone

#

hel pme

#

i dont understand day 3 at all

#

just doesnt make sense

#

so apparently from what they have said

#

they say that numbers adjacent to a symbol and diagonally

#

what do they mean by diagonally do they mean like

#

lets say the number is in line 1 at the 4th position

#

the symbol should be in the 3rd or the 5th position in the next line?

#

and

#

why is 58 not correct?

#

it is adjacent to a symbol no?

bitter osprey
#

If there is a symbol on line 41, position 121, a number on line 42, position 120, 121 and 122 would be correct.

ripe scroll
#
xxxx
x58x
xxxx

here 'x' is adjacent to 58 diagonally as well as from sides.

digital whale
#

then why is 114 not correct?

#

it is in the 4th position

ripe scroll
#

In the above case 58 isn't part of the adjacent area.

bitter osprey
#

no

digital whale
#

and * is in the 4th position on the second line

digital whale
ripe scroll
#

No it should be close to it. (touch it)

digital whale
bitter osprey
#

467..114

4: index 1
6: index 2
7: index 3
first ".": index 4
and so on

digital whale
#

so in 467

#

4 is an individual number and so and so?

#

when we are adding should we add it as

#

4+6+7

#

or 467 +....+

cyan sleet
#

467 is one number

digital whale
bitter osprey
#

467, the "7" is within the "*" symbol, so then the full number "467" gets caugth

digital whale
#

this is my first time doing advent of code sad i didnt know it will be this hard

ripe scroll
#

114 and 58 are not the part numbers here

digital whale
#

i guess i have an idea for now lets see sad

#

lemme sum up the idea

#

so basically here adjacent part number means it should touch it

#

not like left hanging in there

#

and for other numbers

#

one of the digits in that number

#

should touch the symbol

bitter osprey
#

atleast one yes

digital whale
#

as in to its side or directly or to the other side

#

alright

#

thanks for the help i wish it was worded a bit better is very weird

lime fulcrum
#

so I just read through day 5 again. I'm still not understanding it XD

edgy hearth
#

I don't understand what day 2 part 2 is asking wth

digital whale
#

even if it was worded better i dont think i can solve it anytime soon

edgy hearth
digital whale
edgy hearth
#

I don't unerstand the example

#

is it creating rules for each game or its based off power? which it says in bottom paragraph

digital whale
#

the max cubes needed

#

of each color per game

#

and then

edgy hearth
#

so add all the colors?

digital whale
#

do red*green*blue for each game

#

and add em up

edgy hearth
#

like game 1 (add red), (add green), (add blue) then sum it ?

digital whale
#

not add red

#

do you understand whats max cube needed per game?

#

the minimum amount of cubes you need to have to play all the sets in each game

edgy hearth
#

so max(green), max(blue), max(red), where each respective color is a list of all the color values?

digital whale
#

per game yes

#

you could do it that way as well

edgy hearth
#

given Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
Green = 3, Blue = 15, red = 14

digital whale
#

yes

#

and also keep that

#

first game constraints in mind

#

god day 3 keeps going worse and worse now

lime fulcrum
rocky spire
#

Code passes the example inputs & actual input part 1 but not part 2:
oh no

modern terrace
#

day 5 is ||dp||?

rocky spire
modern terrace
long jacinth
#

do i wait for part 2 to take howevver long it wishes or do i come up with something smarter

#

i have work to do instead, can just let it run meanwhile lol

rocky spire
modern terrace
#

i mean

rocky spire
long jacinth
#

i have time 👀

modern terrace
obsidian swallow
#

any hints on where to start on 5?

rocky spire
long jacinth
#

i know what must be done but i dont know if i have the strength to do it

rocky spire
long jacinth
#

ill let the first range run, see if it gets solved, if it doesnt within an hour ill stop it and rework it after work

#

although im doing it in pure python

#

so its likely to take 100s of years

nocturne blaze
obsidian swallow
obsidian swallow
nocturne blaze
#

day5 part2

silver karma
obsidian swallow
#

wth

obsidian swallow
nocturne blaze
long jacinth
#

alright i stopped it after 20 minutes

#

ill just do the smart thing and rewrite a thing

slate berry
#

I have risen

slate berry
nocturne blaze
edgy hearth
#

WHY D2P2 EASIER THAN P1

slate berry
#

oh wait d2 nvm

rancid creek
#

Am I overthinking it, or is the last part of this a red herring:

Every type of seed, soil, fertilizer and so on is identified with a number, but numbers are reused by each category - that is, soil 123 and fertilizer 123 aren't necessarily related to each other.
As long as you apply them in the correct order.

spice hemlock
#

Wow

rocky spire
#

Can't debug for the life of me
I guess I'll try sacrificing performance

modern terrace
halcyon pulsar
#

Mm part two seems tricky

#

What is the longest it would take the top speedrunners to solve the hardest problem?

halcyon pulsar
#

It took pretty much everyone in this leaderboard 20 minutes to do part 2 today

#

Would you say part 2 is difficult?

modern terrace
#

yep

covert arrow
#

wayyy too difficult for day 5

modern terrace
#

took me a few minutes to figure out traversing in reverse doesn't work the way i thought it would

digital whale
#

which day yall in?

cyan sleet
#

doing this in prolog sounds fun

#

I'll probably make a program to generate prolog code though 🥴

digital whale
#

hello people

#

can someone run through my day 3 text file and let me know what the answer is, i seem to get 531267 for my text file but its not the right answer apparently

#

i want to know where i missed

thin blaze
#

Part 2 is killing my brain.

digital whale
#

which day?

thin blaze
#

Day 5.

#

I managed to manually split ranges and succeed.

#

But my brain hurts.

earnest forge
#

Same here lool

digital whale
#

;-;

#

my brain hurts too

silver karma
silver karma
digital whale
#

my answer is off by -1000 well i did check with someone on whats the answer, not because i want to enter the answer

#

i want to know where im going wrong

#

but id love to get help yea

silver karma
digital whale
#

but it seems something is wrong with my code

#

and.. im not so familiar with libraries

#

people use a lot of libraries to get their work done simply

#

im doing it full vanilla way with basic functions

digital whale
sleek cave
#

today's problem looks fun

hidden musk
#

giving prolog today is evil ngl

lusty rover
hidden musk
#

i know exactly what i want to do, and i have no idea how to express it

#

the previous 3 days were "fine" compared to this 😩

median juniper
#

i accidentally allocated too many memory while solving AoC

lusty rover
#

Counted out the numbers I see

hidden musk
#

ok actually this might be fun to do

median juniper
#

second part is not that hard i think
||i can implement naive solution and just wait for several hours for it to complete||

sinful pewter
#

Day03 just kicks buttocks. And day05 is even harder. What's happening?

vestal breach
#

years

magic oxide
#

possibly a countermeasure against AI?

#

i'm up for the challenge tho

sinful pewter
#

Yeah, I am on day03 and churning out code like crazy. Exponential stretch in brain muscles

median juniper
#

i need roughly 100gb of ram

lusty rover
#

Ask Eivl to borrow some

hidden musk
#

clausal logic is based

zenith elbow
hidden musk
#
$ sh run.sh
hello world
``` only took an hour 😩
sinful pewter
hidden musk
#

@cyan sleet what if i ||preprocess the input into facts and rules|| 😳

median juniper
hidden musk
#

i found some resource from 2002

cyan sleet
#

like, I have a decent plan, I can't really try it until after work though

hidden musk
#

this is similar to another from last year i think

jade atlas
#

is there any good data structure / algorithms to break down / merge n-dimensional ranges?

#

i hate the code I just wrote for the range method and I don't know how I could improve

onyx flicker
#

i'm not gonna lie

#

that's hella reading for the problem today

noble skiff
#

IMHO day 5 part 2 is a perfect example of a problem where you derive benefit from using a fast language/are penalized for using python

#

just using my part 1 solution to brute force part 2 takes about a minute. Not great, but okay.
in python it would probably take over an hour

#

sometimes constant factors matter

onyx flicker
#

i'm curious now
ig i'll have to read

hollow wharf
hidden musk
#

is it cheating if i preprocess the input in not prolog pithink

cyan sleet
#

I do not want to try to use prolog to generate rules based on a file, at least not on a first iteration 🥴

simple raven
cyan sleet
#

I'll probably do python to generate prolog code

simple raven
terse comet
hidden musk
cyan sleet
terse comet
simple raven
cyan sleet
#

that's the only real annoyance with range

#

if step is positive, then things are nice and simple

#

negative is also simple, but a special case

jade atlas
bronze vault
#

That moment when the test case works but the puzzle output is incorrect

simple raven
terse comet
#

part 1 is easy
part 2 is a numerical hell that requires knowing how to work with ranges effectively (spoiler: ||ranges of seeds with total length of 10e10 or so||)

simple raven
#

ah, so just like yesterday, take a breather in part1 and then get shut down in part2

terse comet
#

yesterday's part 2 was really not that bad?

#

did you ||use recursion instead of just keeping track with a dict/hashmap|| or something

bronze vault
rocky spire
#

Depends on how you did it
My solution in part 1 allowed me to seamlessly transition into part 2 on day 4

simple raven
terse comet
rocky spire
simple raven
bronze vault
#

hold on lol I was reading the wrong input

#

ok i got it 🤦‍♂️

#

i made a mental note to change it when i get to the real input and then forgot

jade pecan
#

Guys I need help in dynamic programming.Executor June15 converts a number on the screen. The executor has two commands which are assigned numbers:

  1. Add 1
  2. Multiply by 2

The first command increases the number on the screen by 1, the second multiplies it by 2. The program for the June15 executor is a sequence of commands. How many programs exist for which, given an initial number 2, the result is the number 34 and yet the computation path contains the number 10 and does not contain the number 28?

terse comet
# simple raven tbf now that you mention it, it would make sense that this would just be a ||mem...

ignoring the parsing and matches/scoring logic, I did something like || ```py

part 1

sum(Game.parse_line(line).get_score() for line in input.splitlines())

part 2

counts = {}
for line in input.splitlines():
game = Game.parse_line(line)
card_count = counts.setdefault(game.id, 1)
matches_count = game.get_matches_count();
for next_id in range(game.id+1, game.id+count+1):
counts[next_id] = counts.get(next_id, 1) + card_count
sum(counts.values())

jade pecan
onyx flicker
#

i did 0 reading of this channel. but isn't the first example for day 5 wrong? (partially)
shouldn't this not have 99

#

wait nvm im dumb
idk how to read

onyx flicker
#

yeye i misread and thought that that range was source, not destination

dense osprey
#

the thought of doing aoc was way more appealing than actually doing it

#

i feel like last year was way more fun or maybe i just dont like doing problems anymore

digital whale
#

this is my first aoc

#

i actually thought it was going to be fun but oh boy its a sweaty challenge ngl

#

for beginners ig

naive stone
#

have you done all the days so far? I agree (i think most do), this year has gotten quite difficult a lot sooner than previous years

solid gust
digital whale
#

now making my brain into a mush for this part 2

#

part 1 ate up almost half of my day

naive stone
#

that's quite good i would say, well done

digital whale
#

i thought ill encounter stuff like this

#

around day 15 or 16 lol

#

well nothing can be done

naive stone
#

lol yea, usually that is when you'd encounter it

digital whale
#

chose the wrong year this time ig shouldve joined last time

#

i thought i could binge till day 5 today but alas

#

had to miss out on the chance yesterday thanks to a storm over here

dense osprey
digital whale
#

waw pro

dense osprey
#

oh no sorry

#

i meant like

digital whale
#

i do agree the input is a lot

dense osprey
#

the reason it is difficult isnt because there is some algorithm needed which people may not know

digital whale
#

like i spent way too much time not being able to find the bug cuz its not on the syntax

#

i was going through the input file for so long

#

until i found it luckily

dense osprey
#

maybe my implementation was just suboptimal (probably the reason)

digital whale
#

no i did write a lot of cases too

#

some people just wrote very very simple code that i wish i could spent time analysing bit by bit

#

but there is no time when day 6 is already here xd_iitmbs

dense osprey
#

havent done day 5 yet

#

fell asleep yesterday

#

solved it today

vestal token
#

do you think that aoc is hard this year so that people cant just use AI to get the whole solution? isn't chatgpt against the rules anyway?

digital whale
#

yea its hard due to that ig

dense osprey
#

idk how using chatgpt would be fun

#

but i dont think that it is against the rules as long as you dont use it for the main leaderboard

vestal token
dense osprey
#

and it is impossible to detect it i think

digital whale
#

but because they made it hard so we wont use chatgpt

#

it doesnt feel fun, its more exhausting

#

:(

dense osprey
digital whale
#

oh

#

then?

dense osprey
#

i dont know the reason

#

i dont even know if they tried to make it extra difficult this year

digital whale
#

i cant imagine what day 25 is going to be

vestal token
#

can i use python for day 5 part 2 or will it take too long to run?

digital whale
#

like you can see such a big drop from day 2 to day 3

#

which day saki?

#

if day 5 idk BrunoCryCat

weary kelp
digital whale
naive stone
naive stone
#

idk if the difficulty jump is enough to consider it objectively extra difficult than previous years

#

i've been stumped by early days before

compact wasp
#

look at leaderboard times though

magic oxide
#

yeah this year's odd days have definitely been a step up from previous years

#

day 5 was really fun tho at least for me

naive stone
#

i mean, 2019 was an extremely difficult year

#

which would have also probably been very difficult if not impossible for LLMs

magic oxide
#

I wonder how many people will quit day 5 this year

naive stone
compact wasp
#

ty sunglas

naive stone
#

day 5? day 3 has already been the killer for people

compact wasp
#

i know someone who said stuff before day 10 would be easy, and recommended beginners to try aoc up to that point

#

his credibility is in shambles

naive stone
#

lmao

magic oxide
#

I used to say that as well PensiveCat

naive stone
#

i've gotten countless people into aoc and i kind of just avoid talking about the difficulty lol. I'm very vague about it

compact wasp
#

good strat

naive stone
#

well enough stalling, i have to go back to inventing a way to solve part 2 today somehow

magic oxide
#

that's a good strat for a lot of things now that I think about

hidden musk
#

day 7 in some past years used some dfs iirc

#

shiny gold bags

minor cave
#

shiny gold bags was an iconic puzzle tbh

hidden musk
#

so true

naive stone
#

i'd love a path finding problem right about now. I can write bfs in my sleep

#

idk what to do with this nightmare of a day 5

hidden musk
#

||isn't that today though||

magic oxide
#

||you did bfs today?||

naive stone
#

i hate how tempting it is to click spoiler tags

magic oxide
#

resist the temptation

minor cave
#

||pop||

simple raven
#

I also told a couple friends who have never done any CS-style programming (they are scientists) about AoC and I don't think they have done day1 yet 😦

minor cave
#

I have a friend who's been doing cs/software stuff since foreveeeer and yet has never done AoC. He loves a challenge so I've been trying to get him into this year because of the weird sort-of spike in difficulty

hidden musk
compact wasp
simple raven
#

I think if you get into this with a solid CS understanding you will enjoy using your toolbox to solve these problems, for the rest of us we are forced to learn new things 😄

hidden musk
#

yeah, so far it's been pretty much fundamentals

#

except some people have to relearn all the fundamentals in a new lang 😩

#

today might be the first day I don't complete it before the next opens

compact wasp
#

😔

simple raven
#

I can't even read the language Nahita's using, crazy stuff

naive stone
#

i do wish i could complete an entire year without a single >24h sullying my times. That is unlikely though

weary kelp
#

What year was shiny gold bags?

tepid cairn
#

school’s been keeping me busy 😩 I have to grind the days I’ve missed on the weekend

hidden musk
compact wasp
#

only 24h was day 1

simple raven
#

have you solved everything else?

compact wasp
#

yeah

simple raven
#

nice

compact wasp
#

i was just not worried about leaderboards

#

so i didn't start as soon as they released

naive stone
magic oxide
#

I'm honestly somewhat glad I can't make time for aoc right when it drops tbh
not having the pressure of trying to leaderboard is nice

compact wasp
#

i just need to get to like 700 pts to guarantee i stay within top 100

#

after that i might stop trying

magic oxide
#

and I'm not good enough to leaderboard anyways, so it's a good excuse to not feel sad

naive stone
#

trying for global leaderboard? or in general?

compact wasp
#

for global

#

i.e. might just do it the next day

magic oxide
#

devote everything to the golf instead

compact wasp
#

i know i already turned off my brain by the time aoc starts

#

so i can only leaderboard on the easy ones anyways

naive stone
#

@compact wasp did you know exactly how to solve part 2 of today instantly?

compact wasp
#

so i took a shower before trying it lmao

naive stone
#

lol

magic oxide
#

did you brute force p2?

compact wasp
#

no

magic oxide
#

oh did you not leaderboard p2 today

compact wasp
#

i didn't

magic oxide
#

ah

compact wasp
#

as i said i took a shower in between

#

so my time ended up being 50 mins or something

magic oxide
#

given your skill level I wouldn't be surprised if you could afford a shower

compact wasp
#

i probably could've leaderboarded if i didn't shower

#

given how slow others were

weary kelp
#

I'm looking forward to the dijkstra problem

dense osprey
#

(i cant)

naive stone
dense osprey
dense osprey
woven sable
#

i'm worried about part 2 after hearing about it

#

ky@solutions too slow for part 1 LMAO

#

my*

#

i know what to do tho i'll do it when i have time

dense osprey
#

you could do bin search today for finding intervals but it doesnt really make sense to do due to the small input size

naive stone
# dense osprey ok can you do fft

honestly writing bfs from scratch is so much easier than people think. I would find it easy to explain even to a beginner. I feel like people hear the word dijkstra and get scared, but the overall concept is very simple

#

networkx is overkill

dense osprey
#

since it is an algorithm which you learn as a beginner

compact wasp
#

if bfs isn't a beginner topic then idk what is

#

it's the kind of stuff that anyone could independently come up with

naive stone
#

ok i think you guys are going too far now lol

dense osprey
naive stone
#

you've forgotten what it's like to be a beginner

compact wasp
#

if you ask a beginner how to go to every node in a graph then bfs or dfs is something they'd be able to come up with

naive stone
#

maybe in a theoretical sense. I don't think they'd be able to code it

compact wasp
#

ig

naive stone
#

intuitively yes, flood fill is something anyone can imagine

#

it's not necessarily obvious how to make a computer do it

cyan sleet
#

(and DFS if a stack)

simple bison
#

As someone who's never had formal CS learning, I'm pretty sure I did work out floodfill/dfs myself, maybe bfs. I'm sure they were inefficient and I probably never thought about which one I was using, but I think they were recognisable. Dijkstra and A* I definitely only discovered through reading (because of aoc, actually).

dense osprey
halcyon pulsar
#

What day would you guys expect the part 2 of this problem to be from?

minor cave
naive stone
noble skiff
#

Because before you simply don't think of reframing a grid as a graph

#

I remember a problem where I failed to come up with flood fill from scratch in high school

#

Once you spend some time studying graphs you start reframing other things as graphs

#

At the time though I didn't even know what a graph was

dense osprey
dense osprey
#

idk why but putting these logical stataements in equations feels wrong

#

i always feel like they might cause some problems

#

even thou they dont

simple bison
#

Unless you're in #1180008645384216606, I would say it's generally bad readability. But yeah, works fine.

dense osprey
#

but writing an if statement for this is also weird

#

i usually try to avoid this

sharp crown
#

Could somebody explain the meaning of todays challenge to me? I have different maps with different mappings. I choose the mapping that fits my seed number? But all the submaps within one map are all equal in relevancy?

scarlet wasp
#

The maps are a chain, from seed -> soil -> whatever -> something else -> ... -> location

dense osprey
#

oh

#

ill have to rewrite everything for part 2

lime finch
#

Always 😭

slate berry
slate berry
#

the type of map doesn't matter

#

just keep changing value for every key seed while u go through all ranges

#

minimum value of a key value pair is answer

scarlet wasp
slate berry
#

but for same order it doesn't

quartz badger
#

Hi how do i put the puzzle input in the code?

pine tiger
#

some read from stdin

#

some read fromi a file

#

doesn't really amtter

slate berry
quartz badger
#

Python

slate berry
quartz badger
#

ty

simple raven
#

I ctrl+A, ctrl+C, ctrl+V the input from the website 🤷‍♂️

#

but there is a python module to get the inputs automatically

quartz badger
simple raven
quartz badger
#

Ty

dense osprey
simple raven
#

or that

dense osprey
#

but i think every account has different inputs / not every but there are different inputs

simple raven
#

afaik the inputs are generated for each account separately but who knows

earnest forge
simple raven
#

ah okay

earnest forge
#

Eric has previously stated that some generators take 'several hours' to come up with satisfactory inputs

simple raven
#

wow, then that makes sense

slate berry
naive stone
#

i don't think so

#

i've definitely seen one or two of his mods here before though

simple raven
#

yay! finally done with part1 😄

#

I see the issue with part2 now...

dense osprey
#

ill try once im home again

woven sable
#

part 2 seems super complicated

strange zinc
#

I'm still wrapping my head around it :}

cyan sleet
#

progol tiem

simple raven
#

coding part2 is making my brain melt

sour trout
#

How much python experience is required to be medium at aoc problems?

#

They include a little bit of data structures so you need some experience

scarlet wasp
# sour trout How much python experience is required to be medium at aoc problems?

What "python experience" is can vary a lot. If the bulk of your python experience is from doing code challenges, you don't need too much (whatever that means). But at the same time, you might have been coding for years and still struggle, because you've been solving very different types of problems. Soooo kindof an impossible question I think

simple raven
#

as someone with no formal CS education but having done a fair few easy leetcode problems, I would say you want to be comfortable with medium leetcode problems for AoC + a tiny bit of practical experience writing bigger code than just 1 function that solves a thing (happy to be corrected if people think otherwise)

sinful pewter
#

Should I brush up on my algos to figure out the puzzles? I can't figure out the puzzles like I used to last year. It's getting more and more complicated and unintuitive.

sour trout
#

My current language is Lua, but im learning python aswell so thats why i joined this, also ive been doing a lot of stuff except solving problems and im actually good in Lua but the problem is that i cant solve aoc problems that well 😔

#

I struggle too much

odd wigeon
#

I miss the days where I could solve the day 1 aoc with a one liner in the browser console.

sinful pewter
sour trout
#

people struggled a lot today with python's interpreter speed

#

I dont know why python isnt compiled but is interpreted

odd wigeon
#

python is compiled

simple raven
sinful pewter
sour trout
#

It is?

#

oh then im mistaken

odd wigeon
#

you just don't have to compile it manually before running your script

sour trout
#

I thought it was interpreter i remember once seeing this

simple raven
odd wigeon
#

it compiles to bytecode.

sour trout
#

It is compiled to byte code then it is executed on the py VM

odd wigeon
#

just like java

sour trout
#

Java is starting to not get as popular nowadays

#

people rather use js with a lot of frameworks

odd wigeon
#

Because that's what their frontend is written in

sinful pewter
sour trout
#

Well you can do the same on backend

#

Nodejs & js

odd wigeon
#

which is why people use it

#

why learn javascript, python, java, C, and SQL when you only need to learn javascript?

sour trout
#

foreal

#

but for ios i dont know the situation there but i mostly see swift

odd wigeon
#

you can use react-native on ios

sour trout
#

Yeah

sour trout
sinful pewter
#

I feel JS is messy. Like it is a language for people in a hurry

sour trout
odd wigeon
simple raven
sinful pewter
sour trout
#

console.log(typeof(null)) - > object

simple raven
#

nice

odd wigeon
#

typeof isn't a function, it's a keyword

#

typeof null

sinful pewter
sinful pewter
simple raven
sour trout
#

python is an awesome language

#

thats the only i wanna learn

#

Nothing else needed

sinful pewter
sour trout
#

Is there a lot of theory at CS? mostly math?

sinful pewter
#

We came up with a new metric for defining the movement in a file of a student solving problems

sour trout
#

i never went to college but i wish to

sinful pewter
#

You guys get it... AoC and learning how to solve problems 😄

simple raven
#

yup

#

very topical

sinful pewter
#

Yup

#

I am done with the major analysis. My professor wants cool plots

simple raven
#

I am also working as a teaching assistant and sooo many master's students could really do with learning the basics of programming

sinful pewter
#

Nice, I am applying for my PhD. I have got the initial approval. Waiting for LORs and TOEFL

#

GRE is optional so skipping it

#

This is going off topic

#

Back to Python and that shitty mess JS

simple raven
sinful pewter
#

Thank you

sinful pewter
simple raven
sinful pewter
#

Day 5 part 1

simple raven
# sinful pewter Day 5 part 1

I didn't use anything I would call an algorithm, trickiest bit was translating from source to destination without creating the whole map, but the logic isn't too bad

sinful pewter
#

Got it

#

So kind of like pattern recognition without the regex, right?

simple raven
#

I haven't used regex so far 😅 I think if I say more I will start spoiling, but I can do that if you want

sinful pewter
#

Please, a few hints won't spoil. This one is initmidating as it is.

simple raven
sinful pewter
atomic cairn
#

Now the problem is part 2 lol

dense osprey
#

there werent that many seeds

#

but part 2 makes my solution for part 1 useless

atomic cairn
simple raven
dense osprey
atomic cairn
#

Im clueless on what to do with part 2

simple raven
#

I wrote a solution I'm coding up now in #aoc-solution-hints , it's the latest big block of spoiler if oyu're interested

dense osprey
hazy ermine
#

is there some sort of optimisation for part 2?

dense osprey
#

id be kinda embarassed (because id hate myself)

hazy ermine
#

i bruteforced and got the answer in under 4m30s

#

used Golang tho

simple raven
dense osprey
#

solution isnt supposed to be bruteforce

simple raven
hazy ermine
#

||range query||?

dense osprey
#

thats pretty difficult for day 5

hazy ermine
#

whats the lowest time you all got for part 2?

scarlet wasp
#

My python solution runs in like 3 ms, doing both parts

hazy ermine
#

💀

dense osprey
#

when is usaco december contest

#

?

cyan sleet
#

@hidden musk how is the pain?

hazy ermine
simple raven
terse comet
hazy ermine
#

yes

terse comet
#

wow

hidden musk
simple raven
hidden musk
hazy ermine
#

it wasnt in Python btw (was in Golang)

terse comet
#

even then, that's billions of operations if not trillions

cyan sleet
#

part 1 wasn't too bad with some codegen

#

part 2 is...worse

rapid wolf
#

Yeah, it is very bruteforcable in not-python. 60s in C a friend got

hidden musk
#

I can't figure out how to do the default mapping

cyan sleet
hidden musk
#

without basically solving it in codegen

#

huh. that exists???

cyan sleet
#
( pred1 -> if_true; if_false )
#

and you can chain it

#
( pred1 -> if_true1
; pred2 -> if_true2
; if_false )
hidden musk
#

wack

cyan sleet
#

it's not how would prefer to write it, but it works

#

I'm legit confused about some stuff though

hidden musk
#

oh that's nice

#

same

cyan sleet
#

how is this Arguments are not sufficiently instantiated

blah(R) :- between(1, 99, X), 0 < R, R < X.

:- blah(X), writeln(X).
dense osprey
#

oh solution for part 2 < 3e8

#

i dont know if i really want to avoid a naive solution

dense osprey
rapid wolf
hidden musk
#

huh

cyan sleet
#

yeah that made it do something

rapid wolf
#

oh yeah, you'll get that fancy range answer then

#

I think clpfd will work quite well for this problem

#

but I don't quite have the energy to do a prolog solve rn

cyan sleet
#

I...need to actually express things in terms of ranges first 🥴

woven sable
#

i feel like rust would be rlly. good for today

#

why have the first days been so hard recently 😭

#

ion remember day 5 being this hard

#

chat gpt prevention?

rapid wolf
#

If my vague brain is right, I think prolog can crush this problem effortlessly.

dense osprey
cyan sleet
#

(if one knows prolog)

dense osprey
rapid wolf
#

indeed

dense osprey
#

and i dont think that the chatgpt usage would hurt anyone

safe bough
#

hey

hazy ermine
#

well theres no way to tell if someone on the leaderboard used it

dense osprey
#

you just sabotage yourself imo

hazy ermine
#

yes

minor cave
#

It's allowed but in a disappointed dad way

hazy ermine
#

its pointless to use gpt here lol

safe bough
#

is this the appropriate place to ask for help in day2 part 2?

dense osprey
woven sable
dense osprey
#

i remember it fail9ing when asked to solve problems like these

minor cave
terse comet
woven sable
#

kotlin was pretty nice for today's challenge mostly bc it has nice implementations for ranges

#

like|| .intersect & .subtract||

cyan sleet
#

@rapid wolf
could you explain what I'm being dumb about?

seed(between(1, 10)).
soil(between(L, R)) :- seed(between(LL, RR)), LL #< L, R #< RR.

:- soil(X), writeln(X).
:- halt.

Output: between(_7734,_7960)
woven sable
#

basically j set operations

cyan sleet
#

this makes no sense

noble skiff
#

yeah kotlin is a nice aoc language IMHO

woven sable
#

yeah i've had zero struggles w it so far

#

i j have to finish part 2 when i get home 💀 and hope the solution im thinking of isn't slow

noble skiff
#

yeah. I mean, it's as easy or easier to write than python, and still a lot faster.
not as fast as Rust but you dont' have to deal with borrow checker issues

woven sable
#

also all the predicate functions or wtv they're called

#

my solutions have been so clean

dense osprey
#

how is youtube checking if i have an adblocker legal

terse comet
rapid wolf
hidden musk
#

unfortunately, I'm not very good at prolog

rapid wolf
#

which is definitely not confusing at all. God I hate how prolog immediately forces you into clpfd if you want sane math

cyan sleet
#

oh _<number> are placeholders?

#

variables/whatever

rapid wolf
#

ye

cyan sleet
#

ah

#

so if I added a constraint that would imply a maximum or something it might work?

#

I got used that blah(X) got me some solution X

#

but I guess this doesn't

rapid wolf
#

there are sort of two steps to using clpfd -> you construct your constraints, and get a list of your constrained variables. Then you call label/labeling, which assigns actual values and solves those constraints

#

you can also ask them to minimize/maximize certain variables

#

Yeah, variables which have a constraint on them will not get assigned anything

safe bough
minor cave
wet yoke
#

I must admit, my solution for part 2 today was in no way clever: I just generated all the seeds and brute forced it.
But on the bright side, Rust in release mode got it done in about a minute.

simple raven
#

I am deep in the trenches trying to get part 2 done without bruteforcing and I just realised I backed myself into a corner and have to rewrite half of my logic... fml

noble skiff
hidden musk
#

I'm just about done with part 1 😔

#

I mapped the things and now I just need to find the min of all my query results

#

which is apparently really hard

hazy ermine
simple raven
hazy ermine
#

ah right

lime fulcrum
rapid wolf
hidden musk
#

honestly the language seems really cool

rapid wolf
#

It does, I just always get sad when I have to do anything that it doesn't do amazingly well.

hazy ermine
#

u mean Python? yes imo u can really just convert your logic into code without much translation

hidden musk
#

I think it does today really well

#

I mean, part 1

#

idk about part 2

hazy ermine
#

nvm... i realised youre talking about some esoteric lang lol

rapid wolf
#

I am hoping the builtin datalog of flix.dev will perhaps give me a similar experience while also giving me just plain old FP for when I don't want DFS

lime fulcrum
cyan sleet
#

so apparently the solver easily gets unhappy whenever anything is unbounded pithink

hidden musk
#

not as big of a problem as you might think @lime fulcrum

cyan sleet
hidden musk
#

with functional langs that's the norm really. just takes a different kind of thinking

lime fulcrum
#

yeah well first I have to get a bit better in python

gentle cape
#

Because I can’t just add a print call somewhere

hidden musk
#

depends on the language

gentle cape
#

I’m fighting the urge to switch to lisp

pine ravine
#

this program just ate 24gb

hidden musk
cyan sleet
#

@rapid wolf any hint how to even start to think about modeling the interval logic?

#

I feel like whatever I try I run myself into a corner

pine ravine
#

how many bytes is python using to store them

cyan sleet
#

what is them?

leaden tartan
#

Had to goto bed before I finishe p2 of yesterdays. Is todays brutal?

#

I need to sleep at some point

minor cave
#

It's not pretty for a day 5. Like 25 minutes for part 2 global to fill up

hidden musk
#

kat are you prologueing with us

lime fulcrum
minor cave
leaden tartan
lime fulcrum
#

i mean part one is okay. two is a lot harder

rapid wolf