#advent of code 2025

1 messages · Page 2 of 1

terse edge
#

noo i had the solution for p2 immediately but forgot to check ||if it was 2 or more parts||

#

instead of realizing that i went on to ||"at least 2 equal parts but they dont have to be all equal"||

#

my utils came in very handy but sadly im stupid

pale stirrup
#

got a solution but it's not really fast

#

2.5 second p2

fallen lily
pale stirrup
#

no

#

||list of ranges||

terse edge
#

its easy

terse edge
#

buT

#

I have op cpu

#

so idk urs might be better

pale stirrup
#

its probably not

terse edge
#

what is iT

pale stirrup
#

||```kt
part2 {
var x = 0L
ranges.forEach { range ->
for (id in range) {
val idStr = id.toString()
val len = idStr.length

        for (i in 1..<idStr.length) {
            if (len % i != 0) continue
            val pattern = idStr.take(i)
            if (pattern.repeat(len / i) == idStr) {
                x += id
                break
            }
        }
    }
}
x

}

#

||bruteforce basically||

terse edge
pale stirrup
#

one of those is a util

#

also spoiler

terse edge
#

my utils are foss so theyre not utIlhs

#

anyone could have used my util for it 😄

pale stirrup
#

switched to your solution and it jumped to 13s

rugged kiln
#

I wonder if you can do aoc in typst, given its turing complete

pale stirrup
#

yesterday's was done in just typescript types

quartz aurora
#

Oops looks like I made an assumption that really isn't guaranteed to hold

#

But works on my input so whatever

native maple
#

ok time to solve d2 in elle

native maple
#

my solution is soooo cursed mao

#

i got both parts in like 25 mins but it was kinda slow so i redid the slow parts without string operations

#

@terse edge isnt it beautiful

#

what do we think

#

100ms on real input for both parts

terse edge
native maple
native maple
native maple
terse edge
#

kotlin is so awesome i just wish it wasnt built for the jvm

terse edge
#

but as you can see there are a lot of parens

frigid socket
#

what does that mean

terse edge
terse edge
#

just ignore that

frigid socket
#

ok

#

today i will do Kotlin

#

i liked kts

native maple
terse edge
#

im using kotlin i dont give a shit about speed

native maple
#

i guess actually the slice part was the slow part not the digit counter

native maple
#

the string op sol took like 5s this sol takes 100ms

#

big difference

terse edge
#

idk how long mine takes

#

well its 400ms

#

but on a 6ghz cpu

terse edge
native maple
#

well there are some parts that make it slow for sure

terse edge
#

only thing i understand is why the for loop is there

frigid socket
#

@terse edge is this good

terse edge
#

dont usg vscode

native maple
#

use zed

terse edge
#

for kotlin u have to use intellij

#

@native maple all microsoft products are made for people too lazy to configure shit

frigid socket
#

bloatware @terse edge

terse edge
frigid socket
#

Cursor

terse edge
#

but its the only thing that has a good kotlin lsp

frigid socket
#

IntelliSlop

native maple
# terse edge i dont understand any of this

||
is_twice checks for ABAB, so 44 -> true, 123123 -> true, 4343 -> true, 431 -> false

  1. count the digits
  2. if digit count is odd they cant possibly be the same
  3. build p = 10^(d / 2)
  4. split the number into x / p and x % p

this is the same theoretically as turning it into a string and splitting it in the middle and then checking whether the left and right match

is_repeat checks for whether a number is made up of k-digit blocks repeated 2 times or more

  1. count the digits
  2. try every k such that k * 2 <= d && d % k == 0
  3. for every valid k, build p = 10^k
  4. start from the right and check that every block going from right to left is the same as this block
  5. if all blocks match, it is a "repeated" number, otherwise try another k
    ||
terse edge
native maple
#

well i was close it took me like 30 mins ish

#

maybe a little more

terse edge
#

also there is a lb for the ppl that used to be an global lb more or less

native maple
#

oh that is a good point

#

i doubt it

terse edge
#

well it was open to everyone (now its full i didnt get in) in the aoc discord

native maple
#

oh that wasnt a question

terse edge
#

but jonathan, kroppeb, nimka, etc are there

terse edge
native maple
#

is neil doing it this year?

#

i didnt see any videos

terse edge
#

neil wu?

native maple
#

thistlewistle

terse edge
#

ok

#

oh

#

idk

#

idrc im not gonna watch content abt it

native maple
#

yea me neither

frigid socket
#

i kinda love kotlin

#

i should get into it more yk

#

i am too JSpilled

terse edge
frigid socket
#

vban @terse edge

#

wait now i cannot figure out a solution

#

@terse edge what if ||i divided the ID by length then length-- and divide and again and again until i inevitably get x identical sections||

#

okay i just misunderstood

#

i just have to check if it repeats twice 😭

terse edge
#

if so theres ||string.chunked(n)||

#

for p2

frigid socket
#

@vague knoll my initial p1 solve was a p2 solve 😭

vague knoll
#

lol

frigid socket
#

@vague knoll i will keep doing p1 and p2 in a single function to piss off @fallen lily

native maple
#

i also do that

frigid socket
#

okay so satan is just insane

vague knoll
#

it seems like ai is not good at writing assembly

#

so i guess it's a pretty good option if you want a job

#

(I was curious how well chatgpt would do with the same challenge)

native maple
#

i did it

#

isnt it beautiful @terse edge

#

i think i can post without spoiler because i dont think this can help anybody ever

verbal parrot
#

wait im so dumb i missed this part about p1:

you can find the invalid IDs by looking for any ID which is made only of some sequence of digits repeated twice.

#

this makes things so much easier isob

frigid socket
#

i accidentally did a part 2 solve while doing part 1

#

😭

terse edge
#

no its noT

frigid socket
terse edge
verbal parrot
cloud iron
#

dam it

verbal parrot
#

d2 is so much easier

cloud iron
#

not seen yet, but d2p1 is nice

verbal parrot
#

spinning the wheel for tomorrow

#

THANK GOD

#

wait oh my god all schools in my town are temporarily closed for the next few weeks which means… i will be free in the morning and can do aoc in the first hour (if i come up with the solution quick enough ofc)!!!!

feral valve
#

today was so easy what

native maple
#

now do it in the typescript type system

lusty atlas
#

today is funny

#

are you all just brute forcing it

cloud iron
#

yep so that's the issue

native maple
feral valve
#

oh this would be way faster working with numbers yeah

native maple
#

and very fast

verbal parrot
feral valve
#

fixed

#

yeah the github link is better

#

i'm really starting to like OCaml

#

my solution is really slow though

cloud iron
#

omg that part 2

#

i swear some people will use regex

verbal parrot
cloud iron
#

and i curse those people

feral valve
#

well actually cppo is the cursed preprocessor

verbal parrot
#

i’ve been tryna set up makefile for my aoc solutions repo so i don’t need to remember whatever compile command is for each day but it didn’t work so i switched to justfile and… it didn’t work either

feral valve
#

nix

#

could fix this

verbal parrot
#

bbbut windows users won’t be able to use it!

#

okay tbf they wouldn’t be able to use makefiles either

cloud iron
#

so this is my p1
i think i have to use a brand new strategy for p2

native maple
#

why did you jsdoc everything

vestal owl
#

NOOOOOOOOOOOOOOOOOOOOOOOO

verbal parrot
#

i love reading code in pages

vestal owl
#

i just realized danmakufu uses 32 bit floats only

#

fuck

cloud iron
cloud iron
verbal parrot
#

i’m crine bro there are more comments than code isob

feral valve
cloud iron
#

it's fine, but adding the jsdoc takes nearly no time and makes it better

#

the diff isn't big, but enough to make tab suggestions better

#

reupload in spoilers cause yeah

feral valve
#

i've never seen that many vscode extensions holy hell

native maple
vestal owl
#

please censor t*pescript

#

anyways i cant figure out why even my obligatory assembly rewrite doesnt work

#

i've been staring at this for half an hour

cloud iron
native maple
#

the humble tsc..

lusty atlas
#

my solution is way slower

#

my 0.37s solution

#

oh and this

native maple
#

not sure if log10 is faster than a loop

lusty atlas
#

yes it is

#

i just tried

#

way faster

#

switching to / 10 loop took 0.1s longer

#

maybe it's just crystal being slower

native maple
#

its like 60ms slower using log10 in elle

#

wait

#

yeah about 60ms slower

#

oh no it is slightly faster just the conditions have changed since this morning

#

i now also have minecraft open

#

its like 10ms faster

#

awesome

vestal owl
#

oh my fucking god

#

cbt just under 1kb

native maple
#

garbage collected?

lusty atlas
#

i ran your elle solution

lusty atlas
native maple
lusty atlas
#

amd

native maple
#

also could just be things running in the background

#

performance is like very subjective

native maple
# lusty atlas amd

it could also be that qbe doesnt do vectorization so arm just happens to be slightly faster when neither are vectorized

#

i replaced the digit count with this

lusty atlas
#

py??

native maple
#

oh no thats just a second benchmark lol

lusty atlas
#

xD

native maple
#

i stole the makefile from my aoc 2024 when i compared the times

vestal owl
#

@native maple i can send my asm solution if you wanna benchmark

native maple
#

sure

vestal owl
#

you'll need fasm to compile

lusty atlas
#

tokenlagger...

vestal owl
lusty atlas
#

scary

#

oh you're the turkish femboy manti friend

native maple
#

i cant run fasm on macos

#

ill test on linux in a sec

vestal owl
#

imagine i somehow fitted an entire token stealer into 1kb

vestal owl
#

also fell for the macos meme

vestal owl
#

it's not even just twitter i just have that kinda aura i guess

native maple
#

youll have to git pull && make install-std install-runtime in the main repo tho because log10f and floorf werent in the stdlib

vestal owl
#

that's what im doing

native maple
#

you mean like this?

#

its really slow idk why

hoary mirage
#

hi @native maple

native maple
#

no way manti in 🅱️encord

hoary mirage
#

QWRONG

#

correct

lusty atlas
#

tried adding cache but it just made it way slower lmao

native maple
#

YEAH

native maple
lusty atlas
#

i mean you only cash the digit count

#

i cached everything

#

ig making a massive hashmap is slower than just doing the math

#

i wonder if a massive array would be faster

hoary mirage
#

oh you edited rosies code

lusty atlas
#

no

#

mine is 0.3s for part2

hoary mirage
#

test mine

#
p1,p2 = 0,0
import itertools
u = {0}
with open('input.txt') as f:
    for r in f.read().strip().split(","):
        s, sl, e, el = (v for i in r.split("-") for v in (int(i), len(i)))

        for k in itertools.product("1234567890", repeat=int(len(str(e))/2)):
            if k[0] == "0":
                continue
            n = int("".join(k) * 2)
            if n >= s and n <= e:
                p1+=n

        for l in range(1,int(el/2) + 1):
            for k in itertools.product("1234567890", repeat=int(l)):
                if k[0] == "0":
                    continue
                for f in range(max(sl,2),el + 1):
                    n = int("".join(k) * (f//l))
                    if n >= s and n <= e and n not in u:
                        p2+=n
                        u.add(n)

print(p1,p2)
#

you have 9800x3d

native maple
hoary mirage
#

yes

#

he saying 0.3 so it looks fast

native maple
#

mine is 80ms in elle for both parts

#

its not bad but can be faster

hoary mirage
#

I think I can combine p1 and p2

#

but it gets wrong result

lusty atlas
hoary mirage
#

USE PYPY

#

NOBODY USES PYTHON3

native maple
#

USE PYPY

lusty atlas
#

don't have pypy

fallen lily
hoary mirage
#

INSTALL

fallen lily
#

So bad

hoary mirage
#

lc.gemini how 2 install pypy explain to @lusty atlas

prime sphinxBOT
# hoary mirage lc.gemini how 2 install pypy explain to <@343383572805058560>

-# <:i:1263593669215256597> labsCore will be shutting down <t:1767265200:R> • Learn more

how 2 install pypy explain to <@34338357280505856…

There are a few ways to install PyPy, a fast, alternative implementation of Python. The easiest method depends on your operating system.


💻 Recommended Installation Methods

The quickest and most common methods are using a package manager like Homebrew (macOS), or Conda (cross-platform), or simply downloading the pre-built binaries.

1. Using Homebrew (macOS)

If you're on macOS and have Homebrew installed, this is the simplest way:

  • Open your terminal.
  • Run the following command to install the latest Python 3 version of PyPy:
    brew install pypy3
    

2. Using Conda (Cross-Platform)

If you use the Conda package manager (like with Anaconda or Miniconda), you can install PyPy into a new environment:

  • Open your terminal/Anaconda Prompt.
  • Create and activate a new environment with PyPy (e.g., using Python 3.9):
    conda create -c conda-forge -n my_pypy_env pypy python=3.9
    conda activate my_pypy_env
    

3. Using Linux Package Manager (Ubuntu/Debian)

Some Linux distributions offer PyPy through their package repositories. For Ubuntu/Debian, you can use the PyPy PPA:

  • Add the PyPy PPA:
    sudo add-apt-repository ppa:pypy/ppa
    sudo apt update
    
  • Install PyPy 3:
    sudo apt install pypy3
    

📦 Direct Download (Manual Installation)

For Windows, or if you prefer a direct download for other systems, follow these steps:

  1. Download the Binary: Go to the official PyPy Download Page. Download the latest PyPy3 version for your specific operating system and architecture (e.g., Linux x86_64, Windows 64-bit).
  2. Extract the Files: Unzip or untar the downloaded file (e.g., pypy3-vX.Y.Z-OS.zip or .tar.bz2) to a simple, convenient location on your machine (e.g., C:\pypy on Windows, or ~/pypy on Linux/macOS).
  3. Run PyPy: PyPy is ready to run right after extraction. Navigate to the extracted folder (specifically the bin subdirectory on Linux/macOS) and run the executable.
    • Linux/macOS Example:
      cd /path/to/extracted/pypy-folder
      ./bin/pypy3
      
    • Windows Example:
      \path\to\extracted\pypy-folder\pypy3.exe
      

Optional: Add to PATH

To run the pypy3 command from any directory, you should add the directory containing the pypy3 executable (usually the bin folder) to your system's PATH environment variable.


✅ Verifying the Installation

After installing, you can check that PyPy is working correctly by running the interpreter and checking its version:

pypy3 --version

You should see output indicating the PyPy version and the CPython version it is compatible with (e.g., PyPy 7.3.11 with GCC 11.2.0, based on Python 3.10.13).


Would you like to know how to install the pip package manager for your new PyPy installation so you can install third-party libraries?

lusty atlas
#

no

#

wtf does this do

#

insanity

#

tbh this might just be crystal skill issue

lusty atlas
hoary mirage
# lusty atlas here :)
p1,p2 = 0,0
import itertools
u = set()
with open('input.txt') as f:
    for r in f.read().strip().split(","):
        s, sl, e, el = (v for i in r.split("-") for v in (int(i), len(i)))
        for l in range(1,int(el/2) + 1):
            for k in itertools.product("1234567890", repeat=int(l)):
                if k[0] == "0":
                    continue
                for f in range(max(sl,2),el + 1):
                    n = int("".join(k) * (f//l))
                    if n >= s and n <= e:
                        if l == f/2:
                            p1+=n
                        if n not in u:
                            p2+=n
                        u.add(n)

print(p1,p2)

#

optimized

#

try now

hoary mirage
#

and checks if its in range

lusty atlas
lusty atlas
hoary mirage
#

@native maple beaten

lusty atlas
#

asked chatgpt to translate my code to go and it runs very fast

#

so yes it's crystal skill issue

#

nvm it translated wrong

#

let's ask claude

#

claude got it

#

optimised rust version is 100ms

#

go takes 150ms

hoary mirage
#

python faster

#

rust bad language

lusty atlas
#

my solution is insanely dumb brute force blobcatcozy

#

it checks every single number in range

#

i wonder why crystal is so much slower than rust though, they both use llvm backend and crystal gc shouldn't matter

verbal parrot
hoary mirage
verbal parrot
#

oh

lusty atlas
#

i made my solution 70ms faster by adding i64 suffix to every number

#

turns out otherwise it does a lot of implicit conversion

#

dumb that it's not smart enough to automatically do this at compile time

verbal parrot
#

what’s ur algorithm

native maple
#
sed -e 's/,/lEx\n/g;s/-/ /g;s/^$/lEx/' test.txt | dc -e '[ddd10%s110/s2Z1-l1r:Cl2d0!=C]sC[Number: ]s"0sK[s>s<0scl"nl<n[ to ]nl>ps>[l<dlCxl<Zd2/sBsL0sI[1+]silBs(lB1+s)[0s{l(s}1sJ[l{l(+;Cs%l{;Cs&0l%l&=ilJ*sJl{1+s{l{l}>:]s:l:xlJlI+sIl(1+s(l(l)>;]s;lB2*lL=;[1sIl<lK+sK]s=lI0!==lclI+scl<1+s<l<1-l>>,]s,l,x[K=]nlKpsK]sE[?xlXx]sXlXx'
``` @lusty atlas
lusty atlas
#

INSANE

lusty atlas
#

@native maple i have an even more optimised digit count function than the log10

lusty atlas
native maple
#

ok this reminds me of my solution in 2024 for a day

hoary mirage
#

same

#

i dont remember which day

lusty atlas
#

getting faster

native maple
#

yeah lmaooooo

#

day 7 2024

hoary mirage
#

USE MILLISECONDS

lusty atlas
#

i prefer nicer to read number

hoary mirage
#

why do yall use log

#

you can like get length before parsing it to int

native maple
#

hell yeah lmao

#

i did the bad one, then log10, then switched to this before committing because it was fastest

hoary mirage
#

djakstra day will bea early this year

#

so little prblems

native maple
#

the whole point is to not turn it into a string at all

hoary mirage
native maple
#

oh well strings in elle are null terminated so its actually much slower to get the length of a string than to turn it into a number and use log10

hoary mirage
#

elle soo bad

native maple
#

sized strings soon

#

when i need sized strings i just use char[] anyway

vestal owl
#

that's why after seeing part 2 i was like "fuck ts in out"

vestal owl
vestal owl
lusty atlas
#

WAIT it was fast all along i just had to enable optimisation @hoary mirage

#

bro

#

crystal doesn't optimise by default

hoary mirage
#

HOW

#

GUHHH DONT MAKE ME OPTIMIZE MINE MORE

#

YOU WILL DIE

lusty atlas
hoary mirage
vestal owl
native maple
#

nothing special

quartz aurora
#

Null terminated strings suck, what else is new

vestal owl
#

it's just a bad idea cuz a lot of string ops require you to know the length

#

and also you gotta remember to add 1 to your allocations etc

native maple
#

string ops are in the stdlib you dont need to write it by hand

vestal owl
#

also dynamic linking ew

lusty atlas
#

is this not best optimisation @native maple

hoary mirage
#

rust moment

#

worst language

native maple
native maple
#

weird

vestal owl
vestal owl
#

anyways hello world in 78 bytes

lusty atlas
vestal owl
#

i remember at 89 bytes being like "there is no way i can optimize this further"

lusty atlas
#

benchmark it

#

well your asm solution for today i mean

brazen salmon
#

@lusty atlas hop off ruby

hoary mirage
#

@lusty atlas

p1,p2 = 0,0
u = set()
with open('input.txt') as f:
    for r in f.read().strip().split(","):
        s, sl, e, el = (v for i in r.split("-") for v in (int(i), len(i)))
        for l in range(1,int(el/2) + 1):
            for k in range(10**(l-1),10**l):
                for f in range(max(sl,2),el + 1):
                    n = int(str(k) * (f//l))
                    if n >= s and n <= e:
                        if l == f/2:
                            p1+=n
                        if n not in u:
                            p2+=n
                        u.add(n)
print(p1,p2)

#

try

lusty atlas
hoary mirage
#

NOOB

lusty atlas
#

impressive

#

i concede blobcatcozy

hoary mirage
#

good

lusty atlas
#

my brute force too naive i can't win

lusty atlas
#

and compare

hoary mirage
#

neverr

lusty atlas
#

the difference between pypy and python3 is funny

#

why don't they make pypy the official python version

hoary mirage
#

probably compatibility blahblahgblahg

lusty atlas
#

or yk cpython could just add jit

hoary mirage
#

I have another idea for optimization

#

lets see

lusty atlas
#

lmao i translated my solution to ruby and it still hasn't finished after 1 minute

#

slowest language award

vestal owl
#

uhhhhhhh

#

i'll have to write my own timer fuuuuuuuuck

hoary mirage
vestal owl
#

despite what you might believe

hoary mirage
#

those who believe

vestal owl
#

it's like 95-ish microseconds

#

60 msec on example

#

is that fast

hoary mirage
#
import math


p1,p2 = 0,0
u = set()
with open('input.txt') as f:
    for r in f.read().strip().split(","):
        s, sl, e, el = (v for i in r.split("-") for v in (int(i), len(i)))
        for l in range(1,int(el/2) + 1):
            for k in range(10**(l-1),10**l):
                for f in range(max(sl,2),el + 1):
                    d = int(math.log10(k)) + 1
                    n = k * (10**(d * (f//l)) - 1) // (10**d - 1)
                    if n >= s and n <= e:
                        if l == f/2:
                            p1+=n
                        if n not in u:
                            p2+=n
                        u.add(n)
print(p1,p2)

#

@lusty atlas try

lusty atlas
#

lets see

#

got damn

#

impressive

hoary mirage
#

love

#

I think this is max

#

at least w python

lusty atlas
#

didn't change much only few ms but still

#

the fact that you managed to squeeze out 2 extra ms

hoary mirage
lusty atlas
#

write the same solutuion in rust or c

hoary mirage
#

I would diee

lusty atlas
#

try crystal then it's very easy

vestal owl
#

CLOCK_MONOTONIC_COARSE is so imprecise 😭😭😭

lusty atlas
#

i'll ask claude to port your code to crystal

hoary mirage
#

yop do

vestal owl
#

i guess my best bet is CLOCK_MONOTONIC still

vestal owl
lusty atlas
#

here's the crystal code

p1, p2 = 0_i64, 0_i64
u = Set(Int64).new
File.read("input.txt").strip.split(",").each do |r|
  parts = r.split("-")
  s, sl, e, el = parts.flat_map { |i| [i.to_i64, i.size] }
  (1..(el//2)).each do |l|
    (10_i64**(l - 1)...10_i64**l).each do |k|
      (Math.max(sl, 2)..el).each do |f|
        d = Math.log10(k).to_i + 1
        n = k * (10_i64**(d * (f//l)) - 1) // (10_i64**d - 1)
        if n >= s && n <= e
          if l == f/2
            p1 += n
          end
          if !u.includes?(n)
            p2 += n
          end
          u.add(n)
        end
      end
    end
  end
end
puts "#{p1} #{p2}"
#

surprising that claude got it, crystal is very niche and most ai are terrible at it

hoary mirage
#
n = k * (10**(d * (f//l)) - 1) // (10**d - 1)
``` this line is crazy ngl
#

I didnt write this part

#
Example: Say k = 123 (3 digits) and you want to repeat it 4 times to get 123123123123:

d = 3 (digits in k)
f//l = 4 (repetitions needed)
Formula: 123 * (10^(3*4) - 1) / (10^3 - 1)
= 123 * (10^12 - 1) / 999
= 123 * 999999999999 / 999
= 123 * 1001001001
= 123123123123
lusty atlas
#

did you vibecode

hoary mirage
#

nop

#

only that line

lusty atlas
vestal owl
#

lmao

hoary mirage
#

the one he generated

lusty atlas
#

yeah lmao i asked him because he said he didn't write that part

#

who tf wrote it then

vestal owl
#

baby gronk

fallen lily
lusty atlas
vestal owl
#

wasnt there another guy here that wrote in assembly

fallen lily
vestal owl
#

@vague knoll hows it going

vestal owl
vague knoll
#

I am so traumatised i haven't started day 2 yet

hoary mirage
vestal owl
#

dw i mogged the competition anyway

lusty atlas
#

vscode has extension

#

it's alright just slow

#

kind of like rust analyser

#

crystal lsp is twice as slow as rust lsp

hoary mirage
#

vlang trauma

vague knoll
#

amazing

vestal owl
lusty atlas
#

nah v lsp is much worse lmao

hoary mirage
#

it didnt even work

lusty atlas
#

did V get better lsp yet i should revisit V

fallen lily
vestal owl
vague knoll
#

rust analyser is weird let me see errors without saving blobcatcozy

hoary mirage
lusty atlas
#

bro it still doesn't have lsp

#

V is very cool but no LSP is dealbreaker ngl

vestal owl
fallen lily
#

not really i think

hoary mirage
#

yes

vague knoll
#

i've never even heard of V

#

Vlang

lusty atlas
fallen lily
#

never met this v person

vague knoll
#

vlang should make a linter called vlang-tidy

cloud iron
#

i hate the p2, bruteforced it with regex, not happy of myself, because backtracking in regex is a sin, because not finite automata, but fuck it, it was too annoying, i was starting to do smth that was generating functions and shit

lusty atlas
#

V is funny because the way it compiles is that it translates V code to C code then compiles that code

vague knoll
#

and lsp server called vlangd

cloud iron
#

tbh it's literally made to be bruteforced with regex

vestal owl
cloud iron
#

both p1 and p2 can be solved with the simplest regex ever

lusty atlas
vague knoll
#

ah yes

vestal owl
#

UB-maxxing

vague knoll
#

because c has a lot of compilers

vestal owl
vestal owl
fallen lily
#

i love when i need one package but also download all of rust

#

undefined behaviour

vestal owl
#

undefined vendicated

fallen lily
#

hop on better timezone

lusty atlas
#

WAIT WTF

#

v analyer goood

vague knoll
#

why does vlang connect to discord

lusty atlas
#

it has everything @hoary mirage

#

time to start using v

#

even has formatting

hoary mirage
#

I will honestly stick to python this year ig

lusty atlas
#

V is rust + go fusion

#

combines best of rust with best of go

#

i wonder if V still memory leaks

vague knoll
#

perfect lang

vestal owl
vague knoll
#

i like go and i like everything about rust apart from writing it

lusty atlas
vestal owl
#

@lusty atlas look into it expressions you'll like it

#

wait is v actually usable

#

insane

#

whatever it actually exists unlike jai 🙄

lusty atlas
#

yeah it seems very usable so far the lsp is responsive and good

vestal owl
#

incredbile

lusty atlas
#

bros made vlutter

vestal owl
#

god is dead

vestal owl
fallen lily
#

kinda shocked kotlin has do while

#

didnt think it would

fallen lily
#

solved p1 first try, p2 can't be that hard clueless

#

very cursed kotlin

fallen lily
vestal owl
#

0/10

#

rewrite in assembly

fallen lily
vague knoll
#

no

#

I'm refactoring typescript for relaxation

cloud iron
fallen lily
cloud iron
#

Even p2 run fast enough with regex bruteforce

#

But it's sadge

#

p1 can be done with smart algorithm to only find valid ids

fallen lily
#

REGEX

#

INSANE

#

got p2 first try

#

tbh d2 easier than d1

cloud iron
#

Dam

#

The regex is easier

#

If you're gonna bruteforce it anyway

fallen lily
#

if i wanted to write regex i would use javascript or c++

cloud iron
#

Well

#

I didn't want to do regex

fallen lily
#

when i want to write regex for fun i do vencord dev blobcatcozy

cloud iron
#

But doing p2 while only finding valid ids and not bruteforcing is so pain i gave up

#

I'll do it another day

fallen lily
#

whats the non-bruteforce way

cloud iron
#

Gimme a sec

cloud iron
#

My solution there

#

Basically it rely on the fact the invalid numbers are numbernumber

#

So if you can find the range of number, you just iter on it

cloud iron
#

Yes

fallen lily
#

we basically did the same things

cloud iron
#

Nope

#

It will only find invalid one

fallen lily
#

this is too confusing for my brain

cloud iron
# fallen lily we basically did the same things

Similar but not the same
Yours iter on all numbers in the range ans determine if they are valid
Mine determine the range of half numbers in the range then only iter on those which are the half of the invalid numbers

cloud iron
#

But you did implement an optimization

#

Yours is like bruteforced but better

fallen lily
cloud iron
#

Mine will scale in O(invalid(n)) since it doesn't matter how big the range is, i never iter on the range directly, but on the number of invalid
yours is O(n) because you iterate on all numbers in the range to filter them

fallen lily
#

i get that part

#

i think i will just watch a youtube video later to find out how the non-bruteforce method works

cloud iron
#

Basically yours is linear with the total of numbers covered by the ranges
Mine is linear with the total number of invalid

fallen lily
#

yes

#

i understand that part

fallen lily
#

nah, ill prob understand it after watching a video

cloud iron
#

Basically here's the example of how it'd work
||
So basically for 3 and 20
3 give 1 as half-bound directly compute from power of 10 cause odd
20 give 2 and 0 so 2 - 1 because 2 > 0 so 1
So the half-bounds range is {1, 1}
So when i iter on half-bounds, it generate 1 1 so 11
And indeed 11 is the only number between 3 and 20

If we take 12 and 45 by example
12 give 1 and 2 so 1 + 1 because 2 > 1 so 2
45 give 4 and 5 so 4 because 4 < 5
So half-bounds range is {2, 4}
So the numbers are 22, 33, 44
||

frigid socket
#

@fallen lily wdym math

#

?

fallen lily
cloud iron
#

The you need to compute divisors

#

There's a way

frigid socket
#

look at my solution

cloud iron
#

Basically 1212 is 101 * 12

fallen lily
fallen lily
#

you can use long

frigid socket
#

gu

fallen lily
#

if aoc ever needed numbers > 2 ^63 - 1

#

it would be insane

cloud iron
fallen lily
#

because so many langs have that as the limit where numbers are sane

cloud iron
#

They should have at max uint256_t

#

Dam you might have nerd sniped me

#

I want to do it the pure math way now

frigid socket
#

does long have kotlin range stuff

frigid socket
spring lionBOT
# frigid socket vai

Yes, Kotlin supports ranges for Long values. You can create a LongRange using the .. operator, and also use functions like downTo and step to define progressions. These are handled by LongRange and LongProgression types.

-# Response generated by gemini-2.5-flash. AI may be incorrect or misleading.

cloud iron
#

Basically the pure math way is like this

fallen lily
#

Uses all that

fallen lily
cloud iron
lusty atlas
#

i told zooter to join

frigid socket
#

Bilboofan

fallen lily
#

vai what is the equlivient of LongRange from kotlin in rust

spring lionBOT
# fallen lily vai what is the equlivient of LongRange from kotlin in rust

In Rust, the equivalent of Kotlin's LongRange (which represents an inclusive range of Long values) is typically achieved using the inclusive range syntax start..=end with the i64 integer type.

Here's how they compare:

  • Kotlin: val myRange: LongRange = 1L..100L
  • Rust: let my_range = 1i64..=100i64;

In Rust, i64 is the signed 64-bit integer type, similar to Kotlin's Long. The ..= operator creates an inclusive range, meaning both the start and end values are included in the range. These ranges can often be iterated over.

-# Response generated by gemini-2.5-flash. AI may be incorrect or misleading.

fallen lily
#

dumb ai

#

i asked for the type, not the syntax

fallen lily
spring lionBOT
lusty atlas
#

why not just tias

fallen lily
lusty atlas
#

try it and see

fallen lily
#

what does tias mean

#

oh

ivory knot
fallen lily
#

guhhh

#

does rust not have assignment expressions

#

vai does rust have assignment expressions

spring lionBOT
# fallen lily vai does rust have assignment expressions

Rust does not have assignment expressions in the way many other languages do. In Rust, variable assignment using the = operator is a statement, which means it does not return a value.

While Rust is an expression-oriented language where most constructs evaluate to a value, assignment specifically returns the unit type () (an empty tuple), and thus cannot be used for chaining assignments or within contexts expecting a meaningful return value. This design choice helps prevent common bugs where = might be accidentally used instead of == for comparison.

-# Response generated by gemini-2.5-flash. AI may be incorrect or misleading.

fallen lily
#

evil

#

guhhhh

#

you cant flatten ranges in rust

#

dum

#

vai what is the equivalent of std::iota from c++ in rust

spring lionBOT
# fallen lily vai what is the equivalent of std::iota from c++ in rust

In Rust, the equivalent of std::iota from C++ can be achieved using range iterators. You can create a sequence of numbers and then collect them into a vector or other collection.

For example, to fill a Vec with numbers from 0 up to (but not including) 10, you can use:

let my_vec: Vec<i32> = (0..10).collect();
// my_vec will be [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

If you want an inclusive range (0 to 10, including 10), you would use:

let my_vec: Vec<i32> = (0..=10).collect();
// my_vec will be [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

These range syntax (a..b for exclusive end, a..=b for inclusive end) create an iterator that yields sequential numbers, which can then be used with methods like collect() to form a collection.

-# Response generated by gemini-2.5-flash. AI may be incorrect or misleading.

fallen lily
#

collect is so weird

terse edge
#

but it looks good

fallen lily
#

Doing it that way is faster anyway

#

Did I get ghost pinged @vestal owl

#

EVIL

#

@vestal owl youuuuu

vestal owl
#

what should i do day 3 with

fallen lily
vestal owl
#

excel?

vestal owl
fallen lily
#

Typescript types

vestal owl
#

maybe scrath again hehe

fallen lily
#

C++ templates

#

C++ consteval

terse edge
#

@native maple ||I tried dp before realizing dp is too slow and its just a greedy solve||

verbal parrot
#

why is today so easy

#

okay nevermind i thought p2 was easier

fallen lily
#

I peaked last year on day 3

terse edge
#

i did dp fIrst

#

it worked for example

#

but too slow for real

pale stirrup
#

ran into some small issues on p2 but my thought process was correct out the gate

#

integer overflow on a long

terse edge
#

actuAlly I dont parse the input as numbers

#

i parse as list long

pale stirrup
#

idk how all i know is that using a ulong fixed it

#

how fast is your solution

fallen lily
#

Thanks reddit, would have gone insane tomorrow if I didn't see this

fallen lily
pale stirrup
#

kotlin does first maximum

verbal parrot
#

my p2 is prolly inefficient asf but it works

pale stirrup
#

i count under 100ms as a win

verbal parrot
#

FUCK NO

#

it was so close to c# why c isob

fallen lily
verbal parrot
# fallen lily What's so bad about c

not bad but it will definitely be harder to do aoc in c rather than like python. at least for me. it doesn’t have lists or like literally anything else

#

and i don’t want to nor do i know how to manage memory in c

fallen lily
#

Just malloc and don't worry about free

#

You know malloc, calloc, realloc, right

verbal parrot
#

yeah

fallen lily
#

That's enough

#

You can use xxd to embed your input as a header file so you don't worry about file system

verbal parrot
#

it sounds straightforward is it not

pale stirrup
#

i think he means if you just don't know how

fallen lily
#

You just get a char array

#

You don't have to worry about reading it

fallen lily
#

@verbal parrot if you have a compiler that supports c23, you can use #embed

#

gcc 15 should have it

#

Clang 19 has it as well

verbal parrot
fallen lily
verbal parrot
#

most likely yes

fallen lily
#

Check with -version

#

If not, find a way to use an up to date toolchain

#

( or just use xxd)

verbal parrot
verbal parrot
fallen lily
#

Hop do people use their phones in the bathroom

verbal parrot
fallen lily
#

idk

#

I never use it in the bathroom

#

It's just weird

verbal parrot
#

i hate how bathroom in english can refer to both shitting and showering

#

i meant the first when i said im in bathroom

pale stirrup
#

it doesn't

#

what

verbal parrot
#

oh?

#

but your toilet is located in your bathroom and so does your shower right?

pale stirrup
#

yeah

fallen lily
#

If you say you're in the bathroom that could mean anything from cleaning yourself up to number one or number two or showering or anything. It just means you're in the room

#

If you say you're using the bathroom then that means you're doing number one or number two

verbal parrot
#

ohh

fallen lily
#

That's how I view it at least

verbal parrot
#

here we just say “i’m in toilet” but i think in english toilet is like 🚽

verbal parrot
verbal parrot
verbal parrot
fallen lily
#

faint so smart

verbal parrot
hoary mirage
#

whats todays problem

vestal owl
#

that was easy

#

@hoary mirage you will love this

hoary mirage
#

nop

#

hate

vestal owl
#

i think i know how to solve p2 too

#

even p1 took like 10 seeconds 😭

#

i hate how slow scratch is

hoary mirage
#

your answer is too high

#

hell nah

#

oh nvm I copy pasted işnput 2 times

#

🥀

#

p2 is little tricky hm

vestal owl
#

actually it's pretty easy

vestal owl
vague knoll
#

epic

#

scratch is the best language

quartz aurora
#

Today's turned out pretty nice, 145 bytes ||```py
n=[0,0]
for L in open(0):
for M in 2,12:i=-1;n[M>6]+=int(''.join(L[i:=max(range(i+1,len(L)-M+k),key=lambda i:L[i])]for k in range(M)))
print(n)

vague knoll
#

basically kotlin with only java class library

#

(I will probably try this, also maybe trying to build kotlin with a makefile)

hoary mirage
#

WHYS IT CORRECT ON EXAMPLE

vague knoll
#

i'm doing today in go

#

I need a break from asm

vestal owl
vestal owl
#

thats why i did scratch

hoary mirage
#

broooo kys

vestal owl
#

lmaooooooo

#

switch to rust already

vague knoll
#

I will only write orthodox C++/kotlin or Crust

hoary mirage
hoary mirage
#

hmm

#

idk aoc is wrong

#

my code is perfect

#

@native maple ROSIE

#

HHELP ME

native maple
#

hold on i haven't done it yet

#

i'll see if i can do it before i have to go

vestal owl
native maple
#

i saw something about dp from eagely

frigid socket
#

gonna do day three

#

mantika vibe codes

hoary mirage
#

i think its correct

#

however

frigid socket
#

spoiler

hoary mirage
#

YOU CANT EVEN UNDERSTAND THE CODE ANYWAY

#

MY VARIALBE NAMES ARE HORRIBLE

#

whatever change in tactics

#

this code only works on example

#

so useless

#

nvm

frigid socket
#

@hoary mirage mantikabubu

hoary mirage
#

WHAT NONO

#

I AM ANGRY RN

verbal parrot
#

@frigid socket how u ain’t done d1p2 yet

vestal owl
#

i see the problem

frigid socket
vestal owl
#

read the spoiler text i sent in the other discord

verbal parrot
vestal owl
#

@hoary mirage

frigid socket
vague knoll
#

tay

verbal parrot
frigid socket
verbal parrot
vague knoll
#

regex is neever needed for anything

#

it improves quality of life

verbal parrot
#

sure but in this case it’s literally either the first char is L and everything else is the number or the first char is R and everything else is the number

frigid socket
#

i am learning GoLang while doing d3 @vague knoll

verbal parrot
#

@frigid socket are u picking languages randomly or are these the ones u chose by yourself

frigid socket
verbal parrot
#

rust when??

frigid socket
#

never

#

or maybe some day

vague knoll
#

rust when ?? hello guys ??? anyone using rust ??? nobody ???

verbal parrot
#

what languages are u planning to do

verbal parrot
vestal owl
#

(right after brainfuck)

frigid socket
#

how is this ERROR

vestal owl
#

anyways i wanna use lolcode next

frigid socket
vestal owl
vague knoll
#

go 😭

hoary mirage
#

go sooooo good

vague knoll
#

unless swift also uses the pen island operator

frigid socket
#

it can be a WARNING

#

not an ERROR

vague knoll
#

so true...

#

but you can just do _ = varname to ignore

frigid socket
#

god i need to get used to redwood tree operator

vestal owl
vestal owl
vague knoll
vestal owl
#

this has to be one of the worst language design decisions ever

vague knoll
#

generally by the time you're running the code you've actually used the variable so i don't find it too annoying

vague knoll
#

does go just not do any warnings in the compiler? and leaves that up to linting tools?

#

the problem with warnings being emitted as a side effect of compilation is you need to edit the code again to see them blobcatcozy

#

but maybe there shouldn't be any unused errors? just leave that up to go vet or whatever?

vestal owl
verbal parrot
#

“error: you didn’t use return value from a function call” cuz i don’t need it????

#

why does it need to be an error

vestal owl
vague knoll
vestal owl
#

unused variables is just fucking stupid

vague knoll
#

I've got annoyed with [[maybe_unused]] spam in C++

#

**I mean [[nodiscard]] spam

#

so nodiscard should probably be the default

#

¯_(ツ)_/¯

#

though realistically you don't need to spam it on getters like I've seen people doing

#

(just prefix your getters with get, oh I forget C++ devs are insane)

frigid socket
#

does GoLang not have map

#

insane

verbal parrot
#

idk both unused variable and unused return sounds dumb to me

vague knoll
#

it does have hashmaps

#

but it doesn't have Array.map

frigid socket
#

[].map()

verbal parrot
#

vai golang map

spring lionBOT
# verbal parrot vai golang map

In Go, a map is a built-in data structure that stores elements as unordered key-value pairs, similar to hash tables or dictionaries in other languages. Each key within a map is unique and maps to a specific value.

Declaration and Initialization

You can declare a map using the map[KeyType]ValueType syntax.

  • Declaration only:

    var myMap map[string]int
    

    A newly declared map without initialization will be nil and cannot have elements added to it until it's initialized.

  • Initialization with make(): The make function allocates and initializes a map, making it ready for use.

    myMap = make(map[string]int)
    // Or declare and initialize in one line
    anotherMap := make(map[string]string)
    
  • Initialization with a literal:

    scores := map[string]int{"Alice": 90, "Bob": 85}
    

Working with Maps

  • Adding or Updating elements: Use the map[key] = value syntax.

    myMap["key1"] = 10
    scores["Alice"] = 95 // Updates Alice's score
    

-# Response generated by gemini-2.5-flash. AI may be incorrect or misleading.

verbal parrot
#

not this dumb fuck

vague knoll
#

there are libraries you can use for that

#

iirc method chaning doesn't work very well in go due to automatic semicolon insertion

#

hello
.method()
will become
hello;
.method()

frigid socket
vague knoll
#

though ig you can do
hello.
method
and that's fine

#

lodash style 😭

#

thankks to asi you can do this

hoary mirage
native maple
#

ran for my bus, missed it, went to a shop, collapsed due to running too fast for too long

#

now i'm on the next bus i can do aoc

vague knoll
#

you're missing the riveting jolt calculation

frigid socket
#

@vague knoll

#

i'm actually liking golang

vague knoll
#

golang is cool

frigid socket
native maple
vague knoll
frigid socket
native maple
#

golang? to lang is not a verb smh

frigid socket
#

@hoary mirage That's the right answer! You are one gold star closer to decorating the North Pole. [Continue to Part Two]

vestal owl
frigid socket
#

NixOs tag you can't be talking

hoary mirage
#

DID YOUR BLOOD SUGAR DROP

vestal owl
vestal owl
#

fittest

#

english is hard

verbal parrot
vestal owl
#

laptop?

verbal parrot
#

i can’t even use my phone in a bus how do u use a laptop

frigid socket
#

just collapsed and still thinking about aoc

#

😭

verbal parrot
#

no it’s not there isn’t a single empty space in buses most of the time

vestal owl
#

simply wake up at 7 am

#

take the least traveled path

verbal parrot
#

NO

#

i’m so glad taxi here so cheap like from my home to school it’s only $1.67

verbal parrot
#

nino are you tapped in??

frigid socket
#

did you do p2 @verbal parrot

verbal parrot
frigid socket
#

yeah

verbal parrot
#

yeah

frigid socket
#

love

#

i am refactoring my p1 solution to support p2

verbal parrot
#

shouldn’t be that hard

#

lowkey why is d1p2 the hardest yet

frigid socket
#

true

native maple
#

fuck

#

whatever

hoary mirage
terse edge
#

WHO PINGED ME

native maple
#

i pinged you

#

my code had a || and it broke the spoiler

native maple
#

sorry

#

ill just post on github

verbal parrot
terse edge
#

its 30 cents for us and 22 cents for kids

#

in kazakhstan

frigid socket
terse edge
#

altho its rural village

frigid socket
#

eagely is twelve

terse edge
native maple
#

@terse edge i did this for p1
||```rs
fn solve(string[] lines) {
total := 0;

for line in lines {
    if line.is_empty() or line.len() < 2 {
        continue;
    }

    max_prefix := line[0];
    best := 0;

    for j := 1; j < line.len(); j += 1 {
        cand := (max_prefix - '0') * 10 + (line[j] - '0');

        if cand > best { best = cand; }

        if line[j] > max_prefix {
            max_prefix = line[j];
        }
    }

    total += best;
}

return total;

}

but i wrote a generic fn after that ||handles both 2 and 12||
terse edge
verbal parrot
#

when i was in moscow i had to pay like $8 for a 10-15min ride

terse edge
#

not muhosransk

native maple
terse edge
#

this is optimized solution

#

original sol had for loop instead of recursion

#

and its generic for both parts

native maple
#

thats so short wtf

terse edge
#

@native maple im not gay but i will be gaY for 3blue1bRown

#

Im gonna buy his merch

terse edge
#

will I gain aura if i wear this in a university

vestal owl
#

only if you wear the 6 7 shirt

terse edge
#

67 dId not help me understand math

#

3b1b dId

vestal owl
#

skill issue

hoary mirage
#

@native maple I SOLVED IT

#

ON PHONE

verbal parrot
#

stop sending it without spoilers 😡😡😡😡😡😡😡😡😡😡

frigid socket
#

SPOILER

hoary mirage
frigid socket
#

did you do p2 @hoary mirage

hoary mirage
#

Brooo not like yall can understand my code

hoary mirage
native maple
#

@hoary mirage more readable than my solution from yesterday

hoary mirage
#

You still need to look at it for some time

vestal owl
frigid socket
#

for the life of me i cannot figure out p2

#

@hoary mirage you should take a look

#

it works for p1

native maple
hoary mirage
frigid socket
#

||

package main

import (
    "fmt"
    "os"
    "strconv"
    "strings"

    "github.com/samber/lo"
)

func check(e error) {
    if e != nil {
        panic(e)
    }
}

func getTotalJoltage(pack []int, digits int) int {
    lockedIndex := 0
    working := ""
    for i := 0; i < digits; i++ {
        highestValue := 0
        upperLimit := 0
        if i == digits - 1 {
            upperLimit = 0
        } else {
            upperLimit = 1
        }
        lowerLimit := 0
        if i == 0 {
            lowerLimit = 0
        } else {
            lowerLimit = 1
        }

        println("We are at", i + 1, "looking from", lockedIndex + lowerLimit, "to", len(pack) - upperLimit)

        for ii, battery := range pack[lockedIndex + lowerLimit:len(pack) - upperLimit] {
            if battery > highestValue {
                highestValue = battery
                lockedIndex = ii
            }
        }
        working += fmt.Sprint(highestValue)
    }

    finalValue, err := strconv.Atoi(working)
    check(err)

    return finalValue
}

func solve(path string) (int, int) {
    data, error := os.ReadFile(path)
    check(error)
    input := string(data)
    batteryPacks := lo.Map(strings.Split(input, "\n"), func(item string, _ int) []int {
        return []int(lo.Map(strings.Split(item, ""), func(vlt string, _ int) int {
            value, error := strconv.Atoi(vlt)
            check(error)
            return value
        }))
    })

    joltages1 := []int{}
    joltages2 := []int{}
    for _, pack := range batteryPacks {
        joltages1 = append(joltages1, getTotalJoltage(pack, 2))
        joltages2 = append(joltages2, getTotalJoltage(pack, 12))
    }

    part1Sum := 0
    for _, jolt  := range joltages1 {
        part1Sum += jolt
    }
    part2Sum := 0
    for _, jolt  := range joltages2 {
        part2Sum += jolt
    }

    return part1Sum, part2Sum
}

func main() {
    exampleSolve1, exampleSolve2 := solve("example.txt")
    realSolve1, realSolve2 := solve("input.txt")
    fmt.Printf("EX1: %d, EX2: %d, R1: %d, R2: %d\n", exampleSolve1, exampleSolve2, realSolve1, realSolve2)
}

||

hoary mirage
#

DONT USE 12 FOR LOOPS