#advent-of-code

1 messages ยท Page 30 of 1

candid berry
#

so, if the goal is to add 2 binary numbers using only 3 types of gates, you're essentially wiring up a bunch of full adders

#

there's 8 wires that need swapping, and ||3 of them are obviously wrong because the wrong type of gate is directly connected to the output||

#

you can also get pretty far by figuring out ||what the least significant bit with a wrong wire connected to it is||

#

if you set x to ||all 1 bits|| and toggle y between ||all 0s|| and ||all 0s except a 1 as the lsb|| then it's easy to see if addition is working for the N least significant bits

#

also it's helpful to know that ||there aren't any extra gates||

hollow wharf
#

that @jagged widget

jade cedar
#

|| ๐Ÿ˜ญ ||

dapper pawn
ripe meteor
#

this is not on topic for the channel

dapper pawn
#

ok sorry

hollow wharf
#

Hey sup

sacred oriole
#

๐Ÿ˜€

waxen minnow
#

Hi

paper folio
#

@minor cave Is it too late to join the leaderboard for 2024?

lime hill
#

hi

paper folio
#

I'm not able to get the join code with the /aoc join command. I already completed the challenges, and wanted to add my self to the leaderboard for the role pithink

solar tinsel
#

Tf

minor cave
paper folio
#

woot woot got the flair!

hot scarab
#

What does mean socket.AF_INET? I mean AF on front..

#

What is AF?

rapid wolf
#

@hot scarab^

long bear
#

How do I unlock the strings for my discord bot?

#

I need to unlock firewall as well, I use python on desktop

#

My firewall is corrupted

tender swallow
fathom kiln
#

Hello guys

#

Nice to meet you

rancid creek
#

Hullo! Channel is a lot more active in December during the event.

rancid creek
fathom kiln
#

Sorry I'm new to discord I'm learning a little python for programming

rancid creek
fathom kiln
#

Yes

rancid creek
# fathom kiln Yes

Some of them get impossibly hard for new coders, don't let that discourage you, it's ok to google how, or ask questions so that you can keep moving forward. Or just focus on the easier puzzles.

fathom kiln
#

Tank you

solar tinsel
pulsar parrot
#

hi im completely new to this and joind this server to find some help

#

idk if im in the right chat room for this message ether btw

distant igloo
tepid knot
#

how can you make your message appear like this in discord?

hybrid gull
vast schooner
#

Is there a channel for GSoC 2025 contributer in python?

#

Does anyone contribute or interested in contributing to python this year?

lusty rover
lusty rover
distant igloo
#

Google summer of code I presume

uncut cypress
lusty rover
#

<@&831776746206265384>

minor cave
#

!cban 728561488536535102 Not fit for our community

marsh currentBOT
#

:incoming_envelope: :ok_hand: applied ban to @zinc bane permanently.

hardy relic
#

I'm just looking into AOC. Do you do all the workings in your own IDE or on the website

ripe meteor
#

Theres no way of solving the puzzles on the website itself

hardy relic
#

OK just the answer perfect thanks

#

And does the puzzle input always just strings ?

#

Like aoc2024-1

tender swallow
#

yes, it's always ASCII text.

hardy relic
#

Hmmm ok

hardy relic
#

Struggling with this first one haha

#

I guess they ain't easy

normal loom
#

no, some of them require a lot of thought

hardy relic
#

Nice

hardy relic
#

Dam I'm.so close i think lol It's not working though

hardy relic
#

what am i doing wrong here: for AOC2024-1

    answer: int
    ab = input.replace("   ","")
    ac = ",".join([ab[i:i+5] for i in range(0, len(ab), 5)])
    x = ac.rsplit(",")
    l1 = len(x)
    l2 = int(l1 / 2)
    ab1 = 0
    ab2 = 1

    for i in range(l2):

        if int(x[ab1]) > int(x[ab2]):
            higher = int(x[ab1])
            lower = int(x[ab2])
        
        else:
            higher = int(x[ab2])
            lower = int(x[ab1])
        
        z = higher-lower
        answer =+ z
        ab1 += 2
        ab2 += 2

    print(answer)

a = input()
calc(a)
solar tinsel
#

answer =+ z

#

Type of answer is defined but not the default value

hardy relic
#

hhmm

solar tinsel
#

Are you giving the input by pasting it in?

hardy relic
#

yeh im pasting in the massive string as 1 line,

#

this also doesnt work - give the incorrect numner:

    answer = 0
    ab = input.replace("   ","")
    ac = ",".join([ab[i:i+5] for i in range(0, len(ab), 5)])
    x = ac.rsplit(",")
    l1 = len(x)
    l2 = int(l1 / 2)
    ab1 = 0
    ab2 = 1

    for i in range(l2):

        if int(x[ab1]) > int(x[ab2]):
            higher = int(x[ab1])
            lower = int(x[ab2])
        
        else:
            higher = int(x[ab2])
            lower = int(x[ab1])
        
        z = int(higher-lower)
        answer += z
        ab1 += 2
        ab2 += 2

    print(answer)

a = input()
calc(a)
#

its working as far as, i can get the numbers seperated into a list, then i must be messing up somewhere calculation the difference of adding all the differeneces

hardy relic
#

holy shtit, im not doing it lowest to hightest

hardy relic
#

now i realised that my list is not all of the input... why would that be?

    answer = 0
    left = []
    right = []
    
    # Remove new lines
    ab = input.replace("\n", "")
    # Remove the spaces
    ab = ab.replace("   ", "")
    
    ac = ",".join([ab[i:i+5] for i in range(0, len(ab), 5)]) # add a comma between each number is the string
    x = ac.split(",") #create new lsit with each number as seperate
    #list = x.sort() # sorted list

    print("Length of full list:", len(x))
    print("First few elements:", x[:10])
    print("Last few elements:", x[-10:])

    ab1 = 0
    for i in range(len(x)):
        if ab1 % 2 != 0:
            left.append(x[ab1])
        else: 
            right.append(x[ab1])
        ab1 += 1

    print("Left length:", len(left))
    print("Right length:", len(right))

    return left, right

a = input()
calc(a)
hardy relic
#

ok and now in 5 hours i and realise that input has a max limit that im goingbeyond. wow

#

these are the fun mistakes that you will never do again

cyan sleet
ripe meteor
#

Just use a file

#

Pasting a 1000char string into a terminal is insane

hardy relic
#

Yeh I'm guan look into that but I'm sure that will require a total restart on the code ha daym

vestal mural
#

Can anyone here help me with my code? I'm running into a problem where I don't know what to do, It's with lists and inputs and such and I can't seem to get it to work.

marsh currentBOT
hardy relic
tender swallow
mortal bronze
#

!paste

hardy relic
#

@solar tinsel i did it! day 1 complete. after using the file and a few tweaks! onto the next!

solar tinsel
#

Gl hf

hardy relic
#

Oossh number 2 is making me loopy

glacial anvil
#

number 2 for days

sullen adder
#

does advent of code have a non-oauth option?

lusty rover
#

I donโ€™t think so

sullen adder
#

unfortunate, github suspended my account ๐Ÿ˜ฎโ€๐Ÿ’จ

dense gale
#

&aoc link zak799

shut trellisBOT
minor cave
sullen adder
#

thanks

strange zinc
#

Hallo again people ๐Ÿ™‚

clear sundial
#

Hey everyone! Iโ€™m Caleb. Iโ€™ll be doing Advent of Code in Python again this year (and maybe some TypeScript on the side).

As part of my own workflow, I put together a small CLI called "elf" that handles fetching inputs, caching them, submitting answers safely, and checking private leaderboards. Happy to share it in case it helps anyone.

GitHub: https://github.com/cak/elf
PyPI: https://pypi.org/project/elf/

Looking forward to hanging out here, comparing approaches, and seeing how everyone tackles the puzzles this year.

Happy coding and good luck on Day 1!

GitHub

A modern Advent of Code helper that fetches inputs, submits answers, and tracks your progress. - cak/elf

lusty rover
#

I'm super suprised that name wasn't already taken or reserved

visual ridge
#

What name mine?

#

I'm new here.

lusty rover
#

elf on PyPI

visual ridge
#

Oh, I'm new to python (and coming from AutoHotKey v2 after mastering it)

terse comet
#

(that 0.1dev version looks like a project initialized from a template with zero changes though)

lusty rover
#

Yeah

#

Seems like the template company still exists

clear sundial
#

So thanks to Solos for the great package name!

waxen wyvern
#

hiii

#

Can every problem can by solved using python only?

waxen wyvern
#

:D** **

#

How hard is solving the problemas of the lats days?

#

I'm new in python, it's my first time in an advent-of-code, and I'm happy for finding it :)** **

normal loom
#

they do get fairly tricky. Don't worry about whether or not you will be able to complete all of them, just see how far you can get

zinc kindle
#

And also it's rare that a problem on one day is a prerequisite for a different day. Most of the time if you get stuck on e.g. day 7, you can still do days 8, 9 etc.

lyric sigil
#

i will miss being able to do aoc as soon as it releases..

bright spindle
#

But yeah, try your best anyway

#

See how much you can solve

waxen wyvern
#

๐Ÿค ๐Ÿ‘

tender swallow
#

last year I managed to get up to day 20 solving everything
after that I couldn't do the part 2s anymore

bright spindle
#

I completed two previous years, and I don't feel like any problems were super hard. They don't require super advanced or obscure algorithms. Stuff you'll learn in an intro to DSA at most.

#

And most aren't even on that level.

tender swallow
#

a good chunk is just knowing when to apply memoization/caching

bright spindle
#

Yeah

ripe meteor
#

Last year one of them needed you to look at the input

#

With your eyes

normal loom
#

๐ŸŽ„

terse comet
#

but yeah, give it a try and skip or stop if you must
(that post I linked is very old too)

bright spindle
#

Some people in that thread complained about puzzles that take a lot of time, but I feel like it's kinda traditional to have one or two days like that.

bright spindle
#

Some people also don't seem to like it when you get a big advantage from manually looking at or preprocessing the input, which I feel is a little arbitrary.

zinc kindle
#

I don't think there were any last year, but usually there's a day where part1 requires writing an emulator for a toy programming language (where the input is code in that language). part2 then tends to require studying the given code by hand and figuring out the algorithm. This gave me a lot of trouble my first few years.

cyan sleet
runic drift
#

I see there are only 12 puzzles this year, is it just the first 12 days of December?

minor cave
#

Yup

open elbow
#

I've never tried advent of code seems fun

late portal
#

Hi

#

My 2-3 advent of code, never completed it though
I hope to complete it this year ๐Ÿ™‚

worthy horizon
#

I will be boring and do it all in no-std Rust this time

open elbow
#

im gonna do it in python because I don't know any other language ๐Ÿ˜Ž

zinc kindle
#

I plan to do it in Haskell this year, but I reserve the right to retreat to Python if I'm having trouble and redo it in haskell later (probably. I remember one time I spent ages trying to parse an input in Rust, before giving up and just using Python's ast.literal_eval)

limpid grail
#

omg AoC today

limpid grail
#

i will use this as an opportunity to further my knowledge in rust :ferrisCat:

#

maybbe i could try no-std after i do the std solution

#

i will be competing with my friends afterall
||this was just a placeholder challenge to print double the value you read from a file||

#

so excited

remote mauve
#

hello

#

python...

#

I will do it like 6 hours or 16 hours after it releases

open elbow
#

advent of code in an hr 21m

rancid creek
#

Hullooooooo all.

open elbow
#

1 hour remains

rancid creek
open elbow
#

aoc in 15 mintues

#

10 mins now

#

glhf guys

covert arrow
#

glgl

open elbow
#

hehe im the first one to do it here

#

1 MIN

#

Excel????

magic oxide
#

oh god

open elbow
#

๐Ÿ˜ญ

#

yeah imma just stick to python for now lol

lusty rover
covert arrow
#

im gonna speedsolve in python first

open elbow
#

less than a min

#

30 secs

magic oxide
#

welp i guess i get to procrastinate setting up my repo another day

open elbow
#

10 secs

shut trellisBOT
open elbow
#

oh hod

#

oh god

magic oxide
#

how does one parse in microsoft excel

sullen adder
#

i misread the question already...

potent pumice
plush peak
#

oh em gee

#

can someone who needs to freshen up on python attempt this

oak marten
#

im so cooked

lusty rover
#

Hmm
This is not a thing I know how to do well

ivory marsh
#

Part 1 looks straightforwards, so I'm scared for the part 2 twist

open elbow
#

aghghg I already got it wrong once

sullen adder
#

i did so bad on day 1 but it was fun ;;

open elbow
#

twice

#

i've got the gist of it, i'm stuck on how to get the proper answer tho

#

AHH I SEE

gentle cape
#

Wait aoc day 1 is out?

ivory marsh
#

Yep

lusty rover
#

yes

old badge
#

i really should sleep but this looks easy enough to try

gentle cape
#

Oh shi

old badge
#

it's harder than it looks i assume

gentle cape
#

Time to actually do it then I guess

lusty rover
#

God that was annoying

#

I'm gonna end up tapping out really early this year

open elbow
#

yeah so am i ๐Ÿ˜”

ivory marsh
#

It's always the worst when you get the correct answer from part one, but seem to be doing it completely wrong because the example makes 0 sense

magic oxide
#

doing this in excel isn't that bad actually

lusty rover
#

Oh you're already doing Excel lol

magic oxide
#

yeah i'm not doing python sols if i can help it

#

just roulette lang only

lusty rover
#

oh?

open elbow
#

I'm getting so close to replicating the example

pseudo fulcrum
#

what is advent of code ?

potent jacinth
#

Day 1 is dope. I can't find the document: I'm on phone. But just 6 hours ago I finished making a Python-like document parser in C that advances line by line, so if the document has multiple lines I just need to read the first byte and from there it's easy.

Time to figure out how to access the document on mobile

potent jacinth
lusty rover
#

lol the sponsor I got is my new vendor at work

open elbow
#

ok for some reason it's giving me the correct answer for the test data but not the actual data?

lusty rover
#

Edge cases!

open elbow
#

yeah that's what im tryna figure out

#

wow only 4 ppl so far

#

i'm beginning to give up this is actually pretty difficult

old badge
#

i got part 1 but part 2 is uuuogh

open elbow
#

i'm stuck on part one due to the edge cases

magic oxide
#

there are edge cases on p1?

open elbow
#

or im just stupid

#

goddamn it

#

my code works on the example, but not on the actual data

#

I NEED A HINTTTT

tender swallow
solid escarp
#

Hey, question, doesn't going from 0 to 95(L5)
gives us a point?
like the lock does point to zero since it is circular, right?

loud slate
solid escarp
#

aaah

#

that makes sense

#

me realising my solution was low, now handling the edge case, it is even lower

half swan
#

idk how I'm getting my ass handed to me so hard checked addition shouldn't be this hard ๐Ÿ˜ญ

worthy horizon
#

going back to my fix error roots

naive wharf
#

[day 1 part 2]||```py
n = 50
zeros = 0
for i in ndata:
for j in range(abs(i)):
if i < 0:
k = -1
else:
k = 1
n += k
n %= 100
if n == 0:
zeros += 1

we don't need efficiency where we're going!||
bright spindle
#

||I had a solution that used modulo that ended up being off from the correct answer by only a little, so I assume I somehow failed to account for some obscure special case.||

pulsar drum
#

||ย i also just did the "stupid" way and looped one by one, brain wasnt braining for figuring out the actual math ||

tender swallow
#

||did the manual simulation to get the star, then figured out the modular stuff at leisure||

mossy basin
#

new spoiler channel

strange hawk
worthy horizon
# worthy horizon

update: I had a single off by one error. Thankfully valgrind exists

craggy cairn
#

Hello everyone

quaint comet
#

I got it right on the first try ๐Ÿ˜„

waxen wyvern
#

First day, first part, and it's already not easy ๐Ÿ˜‚

#

If it's 50, and them goes "R50", it stops in 0, right?

torn sapphire
#

yep

half swan
lime fulcrum
tender swallow
#

?

late portal
#

day 1 puzzle was so fun

#

i was dumb, i was using 0 as start position

vast jetty
#

bro doesnt have the repo public

#

so sad

bright spindle
#

I do think that this year's day 1 is a bit harder than in previous years. Maybe it's because there are fewer days, so each one is a bit more involved.

vast jetty
#

its exactly because of that

vast jetty
late portal
vast jetty
#

in spoilers ig

late portal
#

kk

vast jetty
#

altho really just make a public repo?

late portal
#

can we post it there from other langs than python?

vast jetty
#

ok fine i didnt make a public repo either

#

but its cuz its easier to just commit everything in my workspace which includes inputs and some throwaway files

vast jetty
#

do the repo thing then

late portal
#

kk

torn sapphire
vast jetty
#

ah ok

torn sapphire
#

as long as you're not spoiling people outside the spoiler channels, of course

late portal
#

ill just make a repo

#

my code a bit big

#

i am bad at code golfing

pulsar drum
shy tulip
#

I'm trying it in haskell and have absolutly no idea what i'm doing ๐Ÿ˜…

ripe meteor
#

Average Haskell moment

shy tulip
#

Yeah i'm getting type errors but idk why

#

I had the acc and the input the wrong way round ๐Ÿ˜ฉ

bright spindle
tender swallow
bright spindle
#

Ah

worthy horizon
#

turns out the rust compiler is very fast if you don't make it compile millions of lines of code

#

I got to play with errno and segmentation faults and then add enough rustisms on top of that such that my solution code doesn't have any unsafe

dusk wraith
#

Does someone wants to Group up for Advent of code?

ripe meteor
#

AoC is not a group activity

dusk wraith
#

But it can be to brain storm

worthy horizon
#

I'm just building safe abstractions myself

#

(as the language was intended to be used)

potent zealot
#

part 2 man
checking for double counting while not having any visible way to track my mistakes on the 4k line test cases is rly sth
im doing this in c++ too

viral grotto
#

Am i the only 1 who created 2 func rotate left and right and incremented it by 1๐Ÿ˜ญ

viral grotto
potent zealot
#

not write, i mean the input.txt is 4k lines long

viral grotto
#

Oh kk

pulsar drum
#

but for private repos it shudnt be a problem

white arrow
#

how do i apply for the advent of code and see the challenge?

tender swallow
white arrow
#

i have done that

#

thatโ€™s all iโ€™ve done

tender swallow
white arrow
void forge
#

Completed Day 1

white arrow
#

im kinda confused

#

ive read the puzzle

#

ah ive just seen the document.

solid escarp
solid escarp
#

๐Ÿคฉ

#

This year i will complete my tree for sure

deft terrace
white arrow
#

How do i share my solutions to problems etc?

#

I've signed up

tender swallow
#

have you solved the problem, got the star?

white arrow
#

no i have no clue lol

#

just wondering how i do

tender swallow
#

you take your input, write code according to the problem statement, feed your input into your code, then type the answer into the website. which will tell you if you got it right or not.

white arrow
#

ah is that literally it

#

could i just make my own github repo to share my solutions or is that not allowed?

void siren
white arrow
#

By puzzle text, you mean like the description of the task?

#

And my inputs are like, the one that the document contains

void siren
#

Yes.

white arrow
#

okay got it thank you

minor cave
#

Also, for folks interested in Language Roulette, because there are much fewer days this year I'd like to prioritize languages people are interested in trying. So feel free to post requests here!

white arrow
#

can i get help with my code for the challenge or not?

#

also i need to know how i download this file lol

tender swallow
tender swallow
white arrow
#

from the website

tender swallow
#

yeah, right click on the "get your input" (etc) link and choose Save As

#

alternatively just select all and copy-paste it into a file in your editor

white arrow
#

awesome thank you

#

i also have a question about git

#

if my file structure is

#
aoc-2025
  - Day 1
    - input.txt
  - .gitignore
#

if i put input.txt in .gitignore

#

when i push, will it be ignored even though they're not in the same directory

tender swallow
#

it will be ignored yeah

white arrow
#

awesome

bright spindle
#

Maybe not

tender swallow
#

nope
my gitignore for AoC is just

__pycache__/
*.py[cdo]
input
small*input*
others/
bright spindle
#

Seems like there's special handling for filenames without leading paths

white arrow
#

i just added input.txt to mine

tender swallow
#

also TIL (based)pyright treats module resolution differently based on whether you're in a git repo or not

white arrow
#

also, does the dial always start at 50?

tender swallow
#

yes

white arrow
#

okay cool

wanton plover
#

Today's pt2 stressed me out to no end firAAA i just gave up and decided to do the bruteforce and it annoys me i couldn't figure out a cleaner way it would always be off by like 30

worthy horizon
#

I just did it the very dumb way

bright spindle
shy tulip
#

I'm trying it in a new language and i'm not sure if my logic is wrong i'm just not used to how this works ๐Ÿ˜…

earnest forge
tender swallow
earnest forge
#

Intuitive is the word I'd use

#

Or, depending on mood, naรฏve

bright spindle
#

||I mean, the code for the naive approach is easier to read than even nicely written non-naive solutions. And in this case it doesn't need to be optimized at all.||

earnest forge
#

Also I assume everyone noticed that [not solution related] ||the password method we used is the 'CLICK' method||

white arrow
#

can anyone help me lol im having problems with types

tender swallow
#

I mean that it closely follows whatever real-world object we're trying to represent

#

and in that sense it feels more elegant than a clever shortcut to sidestep the real-world

bright spindle
earnest forge
bright spindle
white arrow
#

i put it in solution hints :)

bright spindle
dusty trout
#

finally

#

the second part was tough

prime vector
#

&aoc link aocleaderboardnamegoeshere

shut trellisBOT
prime vector
#

&aoc link OneidaGui

shut trellisBOT
cyan sleet
bright spindle
#

There's pros and cons.

cyan sleet
#

I just hope we get a good handful of problems to silence the "I kept brute forcing and it kept working" crowd

tender swallow
#

we'll get punishing inputs eventually I'm sure

bright spindle
#

There usually are.

warm berry
#

inb4 ||recursion stones||

tender swallow
#

I really enjoyed that one last year

cyan sleet
#

which one was that?

tender swallow
#

2024 day 11

cyan sleet
#

ooh, dlang

#

I recall that one being fine

#

iirc the main insight was just that things are order independent and that you should handle things in bulk

remote mauve
#

Wohooo

#

just finished day 1

#

btw @minor cave is it 12 stars for @Advent Of Code Completionist role?

bright spindle
remote mauve
earnest forge
#

Yes, previously it's been 50*

cyan sleet
earnest forge
#

And tbf it is called 'completionist'

cyan sleet
#

completionisht

bright spindle
#

I just don't understand the way I'm calculating the counts.

cyan sleet
#

now I'm curious

bright spindle
# cyan sleet now I'm curious
fn evolve(data: &Vec<i128>, max_gen: usize) -> i128 {
    let mut data = data.clone();
    for i in 0..max_gen {
        data[(i + 7) % 9] += data[i % 9];
    }
    data.iter().sum()
}
#

Ah, hmm

#

I guess (i + 7) % 9 represents that which will be 8 on the next day on day i

#

And i % 9 is 0 on day i

#

or something like that

#

I dunno man

earnest forge
bright spindle
#

Speaking of solutions that don't correspond to the natural representation of the problem...

cyan sleet
#

here is the relevant part of my code

  for _ in 0..256 {
    let zeroes = counts[0];
    counts[0] = counts[1];
    counts[1] = counts[2];
    counts[2] = counts[3];
    counts[3] = counts[4];
    counts[4] = counts[5];
    counts[5] = counts[6];
    counts[6] = counts[7] + zeroes;
    counts[7] = counts[8];
    counts[8] = zeroes;
  }
ripe meteor
#

part2 took way longer than i would have liked it to

#

washed gang

cyan sleet
#

you just make use of things being cyclic

bright spindle
worthy horizon
bright spindle
earnest forge
# bright spindle ```rs fn evolve(data: &Vec<i128>, max_gen: usize) -> i128 { let mut data = d...

Oh wait no this is actually really simple you're just doing the whole 'shift everything down' but you're rolling around the array without actually shifting the elements. Your array has 9 places, which i cycles around, and then i+7 is to reset the timer on the current slot, which has effectively been replaced by its children. It's actually a super clever optimisation, but yeah rather inscrutable unless you really think about it

cyan sleet
#

it's clever

bright spindle
#

Yes. I am clever. Or well, past me anyway. Not current me.

earnest forge
worthy horizon
#

slices have .to_vec() I believe

earnest forge
bright spindle
#

I wonder how I came up with this, tbh.

earnest forge
bright spindle
earnest forge
worthy horizon
#

(sorry if I'm being pedantic, I thought you were doing AoC in Rust this year so that might have been relevant informaiton)

bright spindle
bright spindle
worthy horizon
#

to be pedantic, I wasn't being pedantic, rather I was providing unsolicited advice

#

well now I am being pedantic

worthy horizon
#

soul staring smiley ๐Ÿ™‚

earnest forge
bright spindle
earnest forge
#

That seems likely, I can't imagine anyone would think of the circular array thing first lol

cyan sleet
#

I was focusing on learning rust that year

#

(and the solution was so fast that I didn't revisit it to optimize)

open elbow
limpid grail
#

next AoC challenge soon

#

is this how i link my acc for the aoc completionist role too
#aoc-faq message

/aoc join

#

oh its aoc link

mossy basin
#

gonna fall asleep before todays problem

lusty rover
#

SLACKER

open elbow
#

ok this time for today's puzzle I'm going to reread it 10 times

storm rampart
lusty rover
#

oh hey

#

Based

sullen adder
#

yippee day 2

shut trellisBOT
open elbow
#

oh this ones a good one

#

a really easy but slow way to do this would be in o of n squared time

late frigate
#

time for the yearly lurk on the python discord server until AOC

hollow summit
#

95-115 has one invalid ID, 99.

#

what

#

isn't it 99 and 111

open elbow
#

no because the pattern has to be repeated twice and only twice

#

so for 1111 - 2222 it would ofc be 1111 and 2222 or 1919 or 1818 or 1717 or 1616 or 1515 or 1414 and so on

#

this is a tougher one due to the ambiguity of the combos

sullen adder
#

wow part 2 really stumped me @~@

magic oxide
#

clojure is not bad pithink

lusty rover
open elbow
#

ah i see a pattern now

lusty rover
#

It can get pretty terse

#

You probably love that you math guy

#

But I just can't read it

open elbow
#

oh nvm aghghg

#

oh lmao I already found a working case

half swan
#

regex ftw

open elbow
#

aww damn it part 2 actually kinda has me stumped rn

naive wharf
onyx aspen
#

what is advent of code ._.

atomic cairn
ivory vigil
#

That felt easier than d1

limpid grail
#

is someone done with part 1 and part 2

magic oxide
#

there are plenty of people done in the spoiler thread

limpid grail
#

i dont want to spoil it for myself, but id like your input and outputs for this personal leaderboard im hosting for my hostel mates

ivory vigil
limpid grail
#

i mean i can post my input but its kinda pointless without the outputs heh

#

and i need to solve it

#

i like the stories

#

does anybody else enjoy reading the stories

mossy basin
#

nope, you're the only one

limpid grail
#

but its so cute

#

i stopped documenting after day 14 but i did read the rest too

hollow summit
#

stupid elf kid

#

why would you let your elf child go on the shop computer

#

i just had to filter out invalid ids using python

limpid grail
ivory vigil
potent echo
hollow wharf
#

lmao

#

and outputs

limpid grail
half swan
limpid grail
#

well, if you dont trust me thats fine, but i could have shared my own to the public if i wanted to heh

ivory vigil
#

How exactly does input+output get used for a leaderboard?

hollow summit
limpid grail
half swan
ivory vigil
half swan
#

Ah

hollow summit
#

i mean, if you like, you could generate your own inputs and outputs
but that's another problem

ivory vigil
#

Use your own input ๐Ÿ˜›

limpid grail
#

but fine, ill just solve it myself then

#

they'll just have to wait

coarse wagon
limpid grail
#

they have solved it

#

:c

coarse wagon
#

Then ask them

limpid grail
#

im the slow one

limpid grail
#

well, the one who has solved it wouldnt do that tbh

#

cant say the same for the others

#

ill do that ig

#

but i was hoping to find a fren here who would help me maintain the added fairness

ivory vigil
#

๐Ÿ‘€ Why would it matter if you get the solution from one of us vs one of them? And/or what's the rush if it's based on runtimes. Just solve it.

limpid grail
#

theres no rush, id like to offer the lb faster for them is all

#

so they can compare

#

an anonymous person who shall not be named has helped me
thank you!! โค๏ธ

vast jetty
#

2 hours wasted

mortal bronze
#

how you guys solve the part 2 of the day 1

potent echo
acoustic dock
#

Whats the expected complexity for day 2 part 1?

half swan
#

or to solve?

acoustic dock
#

Like the optimal time

tender swallow
#

mine was just O(N) where N = number of ranges x average span of each range
but apparently ||generating the repeats|| can be faster? salt-die did something like that

naive wharf
#

[part 2] can I reasonably ||store all invalid IDs that have been added to the sum?||

tender swallow
naive wharf
#

oh wait I can just make a set and sum at the end

tender swallow
#

||or do you mean if the sum itself will fit in an int/long/etc? Python ints shouldn't be a problem, but I'll say my sum was 11 digits||

tender swallow
naive wharf
magic oxide
#

||i personally feel like eric would've made the inputs not overlap

They've even checked most of the product ID ranges already; they only have a few product ID ranges (your puzzle input) that you'll need to check.

wouldn't make much sense in the lore if they overlapped||

naive wharf
magic oxide
#

joining inputs?

naive wharf
#

I deleted the code tho because I am given 33 ranges and I have cycles to spare

magic oxide
#

interesting

#

mine didn't have overlap, and i think ||a lot of solutions just sum over invalid ids in each range||, so must be rare

naive wharf
sage bobcat
#

do you guys make a repo with your solutions? lemon_thinking

naive wharf
#

Wait people actually solved this by... iterating through all numbers and checking if they repeat?

magic oxide
magic oxide
#

||adding to a set or just summing wouldn't change anything for those tho||

naive wharf
magic oxide
#

||but storing it in a set would be less efficient?||

half swan
#

||hash retrieve sum is worse than sum as you go since you don't have repeats||

sage bobcat
#

where to discuss solutions?

noble flower
#

cracked part 1 but with an O(n^2) solution

mortal bronze
eager dove
#

is there others there also feel the part 2 is really hard ( think I have used almost 1ยฝ hour and cant wrap my head around a solution atm )?
Where part 1 was really easy for me
And no I'm not looking for a solution at lest yet which is why I won't go into the hints chat and spoilers chat

just curious if others also find it hard

pulsar drum
#

i accidentally did part 2 in part 1 :D i misread the instructions

dense osprey
#

cpp returning 100 when computing 1+pow(10, 2) made solving this problem so much slower

#

and it printing 101 when doing cout << 1+pow(10, 2) << endl; made it even worse

dense osprey
#
s = '...' # input
        arr = s.split(',')
        x = 0
        for i in arr:
            a, b = i.split('-')
            x += (int(b)-int(a))
        

        # x = 1949801  
eager dove
eager dove
dense osprey
#

because for me part 2 only required me to change a few lines from part 1

potent zealot
#

i did p1 in the mathy way, i cant see how p2 can be done like this

eager dove
eager dove
#

Wee finally got the part 2 done even that I don't like my solution

potent jacinth
#

Yo folks. I don't understand this.

#

How can those be invalid IDs?

#

Where are 99 and 1010 coming from? ๐Ÿค”

sick musk
#

yeah part 2 made me rewrite whole thing, but i glad that it can be heavy optimized by math knowledge

warm berry
#

invalid IDs by looking for any ID which is made only of some sequence of digits repeated twice

tender swallow
thick bluff
#

it states in the question that it's a range

potent jacinth
#

Oh good Lord.

warm berry
#

Ah thats the part

potent jacinth
#

I understand now.

#

It's more tedious.

#

Thanks guys. I'll go grind the question again.

#

I'm still in doubt: does the sequence have to be repeated exactly twice? For example, would the number 1010610 be an invalid sequence? And should it "occupy" the full number string? What I mean is: should the repeated sequence be exactly half the amount of digits of the whole invalid number? If so, 10106 would be valid (not to be considered), but something like 101101 shall be added.
I believe it's this way, right?

shy tulip
#

For part 1 its exactly twice

#

Like you split it in the middle and left and right are equal

potent jacinth
#

Beautiful.

#

Thanks.

vast jetty
#

asking because for me I just abused itertools did the easy thing

sick musk
vast jetty
#

as you should

#

how long does yall's code take

#

for both parts

#

i just ran mine and its not good

#

lemme time it

tender swallow
#

0.15s for p2

vast jetty
#

30 repetitions should do?

#

holy shit

#

nice

#

im assuming you didnt do lazy stuff

tender swallow
#

my first go at p2 was just ||checking each number in range||, which took ~3s
a while ago I tried ||generating all possible invalid IDs for a given number of digits and checking in the range|| which brought it down

vast jetty
#

INTERESTING

sick musk
#

~0.3-0.4ms for d2p2

vast jetty
#

my core logic is just:

#

which does take a bit time to run

#

well

#

not the function itself

#

but so much looping

#

i have ~5.2 seconds for both parts

#

5.3 more like

#

p1 is like <1 sec apparently

tender swallow
vast jetty
#

p2 is the excessive looping

bright spindle
vast jetty
#

alrighty

#

lol

vast jetty
#

ill throw the whole solution onto spoilers just for tradition's sake (throw them on the subreddit anyway)

potent jacinth
#

Uhm.

#

Is it safe to make the assumption the number of digits of the upper boundary is equal to the amount of digits of the lower one?

#

I don't think it's written anywhere, but I wouldn't know, for now, how to include the problem of different amount of digits in my code.

tender swallow
potent jacinth
#

ARGH

dense osprey
# vast jetty my core logic is just:

||

for(ll i=a; i<=b; i++) {
            string ts = to_string(i);
            ll ls = ts.length(); // length of s
            for(int j=1; j<ls; j++) {
                if(ls%j!=0) continue;
                ll div = 0;
                for(int k=0; k<ls/j; k++) {
                    div += pten(j*k);
                }
                if(i%div==0) {
                    sol2 += i;
                    break;
                }
            }
        }

||

potent jacinth
#

Save me, someone. ๐Ÿ™

dense osprey
#

idk what batched does in py

vast jetty
#

its from itertools

dense osprey
#

oh ill look it up

vast jetty
#
def batched(iterable, n, *, strict=False):
    # batched('ABCDEFG', 2) โ†’ AB CD EF G
    if n < 1:
        raise ValueError('n must be at least one')
    iterator = iter(iterable)
    while batch := tuple(islice(iterator, n)):
        if strict and len(batch) != n:
            raise ValueError('batched(): incomplete batch')
        yield batch
hollow wharf
#

for long long

#

are you by chance competitive programmer

dense osprey
#

havent touched it in a long time

#

but i still use the same template and writing ll doesnt make it less readable than using long long

hollow wharf
#

fair

mossy canyon
#

hey, anyone know if there is a forum where we can create threads for aoc? I want to generate some images in the style of the story following the storyline of the puzzles and compile them in a thread

hollow wharf
#

following the story line of puzzles

#

sounds like a fun idea

hardy relic
#

Haha shit just looked at day2 and got that dunder Mifflin effect or whatever it is

#

Yesterday was ezpz

hardy relic
#

are these designed to be done without any extra modules?

minor cave
#

No, use whatever you need

drifting radish
hardy relic
#

ok sweet as

#

thansk

vast jetty
#

anyway no you just need the answer

#

found this which is amazing

solar jay
drifting radish
vast jetty
hardy relic
vast jetty
#

or smth along that lines

solar jay
vast jetty
#

or tens of thousands

solar jay
#

then I spent like an hour coding because Im not the best at it

hardy relic
#

maybe100

vast jetty
#

no it doesnt

hardy relic
#

oh your right haha

#

lucky i got a pencil sharperner

#

so stab myself with

vast jetty
#

this is my invalid list

hardy relic
#

i really dont know how i would do this, i think regex but ill need to do some research

vast jetty
#

got part 1?

hardy relic
#

i diud day 1 was pretty easy, but no i havent really started day2 yet. Just going over it in my head how i should do it but i dont know how to do the part where your looking for a pattern lol

#

you know, the main part that ya need to do

potent jacinth
#

I'm the stuckest person in this challenge.

#

I can't beat challenge 2 part 1.

#

Got my 170 lines of code (half of which are comments so I can track what I'm doing), but God knows why I get a wrong result.

#

At this point I might generate random numbers for ever until I get the answer right.

warm berry
#

Are you passing with the example input and example answer?

minor cave
#

If you're still stuck after the examples, feel free to make a thread in #aoc-solution-hints and people can help get you un-stuck

potent jacinth
#

The whole building is a mess.

#

Well, very interesting.....

potent jacinth
#

I thought I was in another server.

maiden drum
#

hello

hardy relic
#

my ternimal is running for like a minute just to try get the lists of numbers between the start id and l;ast id lol, i think im doing something wrong

normal loom
#

maybe, the largest gap I get between the start and end ids is in the order of hundreds of thousands, and it shouldn't take that long to iterate through all of them

hardy relic
#

now i have my gigantic lists of numbers, but i dunno how to looks for that pattern

#

yeh its the printing, the itarating takes 1 sec

warm berry
#

Could you instead check each value as you iterate instead of adding them to an ever-growing list? Would also save you from having to re-iterate over that list after it is made

hardy relic
#

yeh, but im still very stuck how to check for that pattern

warm berry
#

Which pattern? Part 1 or 2

hardy relic
#

im having fun tho haha

#

part 1

warm berry
#

So you need a sequence to be repeated twice

hardy relic
#

yeh totally stuck on that

warm berry
#

Is there any symmetry to that

hardy relic
#

ohhh it has to use the entire number. that changes it. i was thinking th pattern could be like 568121285 ( that has repeating "12"s in it ) and i was like HTF can i ever figure that out

vernal coyote
#

helo

#

i just had s doubt can anyone solve it for me

#

like on day 2 puzzle how do i store that input like do i need to give it in a scan function or i can take it as a string with that input ?

vernal coyote
#

oo so i have it as a txt file and then scan character by character to get the number values in a way ?

warm berry
#

The provided values are comma separated start and stop points for a range of numbers

#

11-22 means a range of numbers starting at 11 and ending at 22

#

e. g. 11-22,95-115,998-1012 are three different ranges

#

Generally, saving the full input as a text file and then reading it in is a good way to handle the full inputs. The example inputs are usually short enough to keep as a multiline or single line string

void forge
vernal coyote
#

i see
thank you for the explanation

hardy relic
vernal coyote
#

will give it a try now
since i don't know python completely
imma use c

void forge
#

What determines the total score?

warm berry
void forge
#

ah

#

thanks

echo wave
#

day1 part1 for me so far

warm berry
#

thank you joe_salute

white arrow
#

day 1 made me give up py_strong

bright spindle
white arrow
#

just frustrating lol i couldnt figure out my type problems

bright spindle
#

I often just shelve something when it gets frustrating and do something else, then come back to it later when I feel more motivated.

#

I feel like I often get insights about the problem when I'm not actively working on it.

#

like in the shower or something

ripe meteor
#
โžœ Measure-Command { py .\solve.py }

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 21
Milliseconds      : 524
Ticks             : 215240285
TotalDays         : 0.000249120700231481
TotalHours        : 0.00597889680555556
TotalMinutes      : 0.358733808333333
TotalSeconds      : 21.5240285
TotalMilliseconds : 21524.0285

I do not care AoC a star is a star

ripe meteor
#

a win is a win

#

i've got time

pseudo fulcrum
#

I,m feeling badly, I can't share in advent of code due to I,m beginner ๐Ÿ˜ฉ

#

enjoy my friends

shy tulip
#

You could have a go at day 1 part 1 even as a beginner

hardy relic
#

YEH im a begineer and day1pt was fun!

white arrow
#

can anybody help with day 1 pt 2?

lusty rover
#

Chat whats more important?
Sleep, or AoC?

low condor
ripe meteor
#

dont tell me you stay up for aoc shen

hollow wharf
ripe meteor
#

you have all day

hollow wharf
#

I do stay up

#

Till 1 am

#

For it

#

Atleast thatโ€™s what it took at max to solve all the problems

#

I can stay longer

#

๐Ÿซก

lusty rover
hollow wharf
#

Opens at 11

#

Huh

ripe meteor
#

What timezone is that

hollow wharf
#

You are 1 hr ahead of est

low condor
#

I do actually prioritise sleep - puzzles open 5am for me and no way am I waking up for that

lusty rover
lusty rover
hollow wharf
#

Sorry behind

ripe meteor
#

In the spirit of xmas they should move the opening time to like 10am UTC

hollow wharf
#

To wake up at that

#

Time

ripe meteor
#

Think about it

lusty rover
ripe meteor
#

When you open your gifts you dont do it at 00:01 xmas day

#

You do it when you naturally wake up

#

And i naturally wake up at 10

low condor
#

I kinda wish the opening hours would change every day before

lusty rover
hollow wharf
#

But we are programmers

#

We donโ€™t do normal

low condor
#

But since thereโ€™s no global leaderboard I care less

ripe meteor
lusty rover
#

Yeah but sleep when thereโ€™s no sun

#

Donโ€™t sleep the sun away

hollow wharf
#

I also sleep during the day

#

So that I can keep up

#

Late

ripe meteor
#

Theres no sun when i sleep

#

The gf has black out curtains up

hollow wharf
#

there is no sun

#

Any time of day

#

For me

lusty rover
hollow wharf
#

๐Ÿ˜ญ ๐Ÿ˜ญ ๐Ÿ˜ญ ๐Ÿ˜ญ

ripe meteor
#

But all the time i invested in this one

hollow wharf
#

Gf or AOC

ripe meteor
#

gf lmao you nerds

hollow wharf
#

๐Ÿ˜ญ

#

โ˜ ๏ธ

magic oxide
low condor
#

Stressing oneself out over Advent of Code seems like the opposite effect of what the author wanted

#

And yet I have done that myself on occasion

ripe meteor
#

Idk about that

#

Midnight release + leaderboard= what else could have happened

hollow wharf
#

Lmfao

#

True

ripe meteor
#

You gotta be new to humanity to not see whats going to happen

open elbow
hollow wharf
#

๐Ÿ’€

hollow wharf
#

And you replied

#

great minds think alike

#

๐Ÿ—ฟ

hollow wharf
open elbow
#

almost

#

im at part 2 right now

#

i'm very close

hollow wharf
#

Super quick

open elbow
#

yeah I finally got my part 2 parsing working, it's not working completely for a certain number ๐Ÿ˜”

low condor
#

Debug time ๐Ÿž

open elbow
#

nvm it's missing like 4 values

low condor
#

Who is Uncle Albertโ€™s older brother anyway ๐Ÿค”

open elbow
#

i have no idea ๐Ÿ˜”

low condor
#

I wish your display name was a reference to the British show โ€œOnly Fools and Horsesโ€ - that show has an Uncle Albert

#

But itโ€™s just referring to Einstein isnโ€™t it

open elbow
#

yeah

open elbow
#

YEAHHH

hollow wharf
open elbow
#

I solved this one entirely by myself with some hints

hollow wharf
#

Hell yeah mate

#

๐Ÿ—ฟ

open elbow
#

I used a big brain technique to just turn the lists into sets and union both of them ๐Ÿ˜Ž ( #1445278429372219422 )

open elbow
#

1 min

ivory vigil
#

Tick... tock...

shut trellisBOT
open elbow
#

this one's weird lemme reread it

open elbow
#

oh my god what the HELL is the input ๐Ÿ˜”

ivory vigil
#

That was fun

earnest forge
#

That was cool

ivory vigil
#

Now I need to figure out what I did ๐Ÿ˜†

woven oriole
vast jetty
vast jetty
#

tfw the brute force approach wont work for part 2

open elbow
#

this one was actually pretty easy for part 1

woven oriole
#

i really wanted to know the global rank for this one

vast jetty
#

wdym i gotta write actually good code

vast jetty
woven oriole
#

4, 8

vast jetty
#

this is def not gonna work LMAO

#

good on part 1 tho!

tepid galleon
vast jetty
#

part 2 you gotta write actual logic

#

yeah it wont

#

lol

tepid galleon
#

I gave it a solid 6 minutes

vast jetty
#

LMAO

#

did we all do this

woven oriole
#

i am very glad it doesnt work on p2

#

some value given to day 3

vast jetty
#

i dont feel like writing actual logic rn

#

yeah lmao

#

i was prepared to even gave it half an hour if needed

#

but its not even doing a single line

#

theres prolly a way to make more optimised brute forcing tho

vast jetty
#

gonna be stuck in vim now lmfao

reef harness
#

Just notice this. Can I start from day 1?

woven oriole
#

sure

#

whos stopping

vast jetty
#

sure

#

honestly day 3 is easier tho ๐Ÿ’€

#

at least part 1

tepid cairn
#

it's advent of code already??

#

i didn't even notice ๐Ÿ˜ญ

vast jetty
#

do we think ||recursion|| sounds stupid

#

i think it could work

#

or at least a loop calling a function over and over again

ivory vigil
humble copper
vast jetty
#

no?

#

it seems efficient enough

#

im writing a prototype for example lets see if it works there first

humble copper
#

oh wait for which part

vast jetty
#

well fuck

humble copper
#

yeah

vast jetty
#

omw to debug

vast jetty
#

part 1 was done in like 5 minutes

peak dock
#

100C12 is ~10^15 btw

#

while 100C2 is like 5k

vast jetty
#

pretty quick debug lmfao

#

yeah i think this is gonna work

#

ill tidy up code later lemme just find the answer first

humble copper
#

let me just bust out my botnet

vast jetty
#

it works

obsidian shell
#

part 1 is so easy bro

#

but

#

part 2..

#

fucking hell

#

had to literally spend an hour LMAO

vast jetty
obsidian shell
#

yeh

#

true

vast jetty
vast jetty
#

mightve gotten it done before otherwise

#

lol

obsidian shell
#

lmao

vast jetty
#

what did you do

obsidian shell
#

i was eating tangerines lmao

open elbow
#

damn it part 1's already stumping me because I have no idea what method can actually do this

rancid creek
half swan
open elbow
#

don't know why I'm struggling on something so easy ๐Ÿ˜”

#

I guess this is a new type of challenge (that I haven't done before)

sullen adder
#

...i spent half of an hour assuming the actual input was the same length as the example before i read my input file ๐Ÿคก

rancid creek
sullen adder
#

i'll take it as a sign to stop attempting AoC at midnight

magic oxide
#

dang i forgot about aoc

vast jetty
#

hm

#

fucked up timing i think

#

ok much more believable

#

yeah ok the other one is more shit

#

good to know

mortal bronze
#

Bruh I still can't solve the day 2 part 2 maybe I'll just brute force it

winged trellis
#

i brute forced it, took me about six seconds of runtime ๐Ÿ˜„

bright spindle
#

after making my code work with all the samples

vast jetty
#

i check actual input almost immediately after reading instructions

#

maybe after getting parsing to work

bright spindle
#

In order to grasp the full extent and intention of the puzzle.

#

And identify any potential traps.

winged trellis
#

ask in a spoiler channel

winged trellis
teal field
pulsar drum
#

My part 2 for today
Execution time: 0.003069162368774414 seconds

winged trellis
#

all relavant parts or just the core business logic?

pulsar drum
#

also i use just pythons time, so it might not be super accurate

winged trellis
#

fair, i just time the time for everthing, starting the interpreter included

#

perf_counter is fairly ok

pulsar drum
#

what command to use to time the literal python command? for unix

winged trellis
#

time python main.py

#

uv run day3.py 0.02s user 0.01s system 97% cpu 0.028 total

pulsar drum
#

python3 2.py input.txt 0.01s user 0.01s system 64% cpu 0.040 total

#

TIL: about the time command cool_finger_guns

winged trellis
#

its pretty nice to know about

coarse wagon
#

There's also more dedicated benchmarking tools that do multiple runs similar to timeit

winged trellis
#

i like timeit!

#

is hyperfine a general tool?

pulsar drum
#

i downloaded hyperfine jusdt now, looks cool

coarse wagon
# winged trellis is hyperfine a general tool?

Yeah similar to time it benchmarks CLI commands, but doing multiple runs with support for stuff like warmups, and setup/cleanup steps. (For example if you are benchmarking builds you could add the cache cleanup as a setup command)

winged trellis
#
โฏ hyperfine --warmup 3 'uv run day3.py'
Benchmark 1: uv run day3.py
  Time (mean ยฑ ฯƒ):      26.0 ms ยฑ   1.0 ms    [User: 18.3 ms, System: 7.5 ms]
  Range (min โ€ฆ max):    24.2 ms โ€ฆ  30.5 ms    108 runs
#

running it with uv has an huge improvement over just running the python interpreter normally

tender swallow
#

how come?

winged trellis
coarse wagon
#

Are they using the same python version?

winged trellis
#

yes

warm fiber
#

but really... I have to ask... was the description of the part 1 problem enough to understand the example 818181911112111 -> 92 ?
I had more problems cracking the hidden rules than the actual problem.. (problem is actually trivial)