#advent of code 2025

1 messages · Page 9 of 1

robust yacht
#

frisky faint

verbal parrot
#

@cold jackal Heyyy :) DMS

hoary mirage
#

it did work on me

lusty atlas
#

oh i think because

verbal parrot
#

lowkey i would really like ai to analyze all my messages for like a year and then write a 100-pages writeup describig me

#

unronically wd b v cool (would be very cool)

native maple
#

vee it turns out my 10ms solution was actually just wrong because i did a fucky thing with static arrays and pointers

#

but its fine because my new solution is like 15ms-22ms

lusty atlas
#

request your discord data package

#

it contains every message u ever sent

hoary mirage
#

except it wont fit the ai contrext limit

verbal parrot
#

like... every message...?

lusty atlas
#

yes

robust yacht
#

vending machine

#

this machine is vending

verbal parrot
#

thats why i use imessage!

native maple
#

im being contained

#

in this globe

frigid socket
#

might ban faint

#

i think i found a way to solve p2

verbal parrot
#

might unrot faint

#

unrot faint

#

#unrotfaint2026

frigid socket
#

||- put all red/green tiles in an arraylist

  • for every two positions, if the area is positive, get every position in the area
  • if all of them are allowed then count it||
verbal parrot
#

i should solve p2 faster than nino

robust yacht
#

i should solve p2 now

#

oh roie my roie

feral valve
dusky frost
#

polygon in polygon

#

do it

#

use some library if you can't implement the logic behind polygons/intersections

verbal parrot
#

im tryna do it with ray casting i think

dusky frost
robust yacht
#

im just implementing a function i found online

native maple
#

its extremely fast

native maple
#

its actually faster to sort here

#

my solution with 10ms was wrong

#

i did more things and got it down to like 15ms

robust yacht
#

bruhhh

native maple
#

the sort brings it down quite a lot

robust yacht
#

of course example input is correct but not my real input!

#

@native maple will you put my input in and tell me how far off i am

#

waiut

#

wait

native maple
#

yeah sure

#

send whenever

robust yacht
#

i get 4273752100

feral valve
#

also add dependent types it’s so cool

native maple
#

i get 1529011204 for p2

dusky frost
#

Like it doesn't work for U/C shape

native maple
native maple
#

test it

robust yacht
native maple
#

oh

dusky frost
#

I can't now I'll try tomorrow but I think it'll not work

native maple
#

girl if i tell you how far off you are you can just calculate the answer

robust yacht
#

how

native maple
#

if i tell you "you are 2,744,740,896 off" you can just subtract this from your answer lol

feral valve
robust yacht
#

what wrong @native maple

dusky frost
#

0,0
10,0
10,2
4,2
4,8
10,8
10,10
0,10

#

@native maple try this input

robust yacht
dusky frost
#

It should return 45 if I'm not mistaken

robust yacht
#

the example is right

dusky frost
native maple
#

i get 49

dusky frost
robust yacht
#

youre a nerd you sohuld know

native maple
robust yacht
native maple
#

its aoc after all

dusky frost
native maple
robust yacht
#

i should use longs?

dusky frost
#

You can fix it by adding raycast function

feral valve
cloud girderBOT
dusky frost
#

but nice solution @native maple :D

#

I like it

robust yacht
#

wdym @native maple

#

roieee 😭

#

oh

#

maybe i should use floats

feral valve
robust yacht
#

uhh

#

what is in

feral valve
#

treat it like a semicolon;

#

great ref like mutable, disregard the !

robust yacht
#

and what is fst and snd

#

and ref

#

and <>

feral valve
#

first and second of a tuple

feral valve
robust yacht
feral valve
robust yacht
#

cursed

#

ill try implementing

feral valve
feral valve
robust yacht
#

i just got mine off SO

feral valve
#

just notice the offset test point

robust yacht
#

hm

feral valve
#

it’s a hacky fix for integer division

robust yacht
#

is yours using floats

feral valve
#

nop

verbal parrot
#

OMFG U WILL NEVER BELIEVE WHAT I JUST SPENT 20 MINS TRYING TO DEBUG

#
>>> l = [[0]*3]*2
>>> l
[[0, 0, 0], [0, 0, 0]]
>>> l[0][1]=1
>>> l
[[0, 1, 0], [0, 1, 0]]
#

are we serious

verbal parrot
#

i think im getting close to solving it

............
.......XXXXX
.......XXXXX
..XXXXXXXXXX
..XXXXXXXXXX
..XXXXXXXXXX
.........XXX
.........XXX
#

i managed to fill the area inside the shape

#

this is probably gonna be veryyyyyy slow tho

native maple
#

girl 😭

#

im sorry to tell you this

#

flood fill will not work for the real input

verbal parrot
#

yeah

native maple
#

its a grid of like 100_000x100_000

verbal parrot
#

its fine i have a poweful pc

native maple
#

you can maybe do flood fill if you do coordinate compression first

native maple
#

but otherwise its not really viable

#

you can try tho

verbal parrot
#

it did it in like 10 seconds

#

tho its taking forever to print it out lmao

native maple
#

for the real input?

feral valve
#

woaw

#

so fast

verbal parrot
#

i mean i just printed this grid

#

like i didnt solve it i just determined for all the points whether its inside or outside the shape

feral valve
#

such an obnoxiously large number

verbal parrot
#

nevermind it was only p1 text 😭😭😭

#

i forgot i left that print() for p1

#

but thats fine lets just wait for a bit

#

PYTHON 70GB RAM HELP

#

guhhh

robust yacht
feral valve
robust yacht
#

sample is right

#

i get 24

verbal parrot
#

well at least i now know that my implementation of ray cast works fr

robust yacht
#

could this be wrong? i dont think it woul be though

feral valve
#

warp the first != group

robust yacht
#

same result

verbal parrot
#

is it even possible to solve it with ray casting something something or should i just quit trying it

feral valve
#

i did it that way first

native maple
dusky frost
#

^

verbal parrot
#

does it take v long tho

dusky frost
#

no

verbal parrot
#

oh okay great

native maple
robust yacht
#

guhh this makes no sense

feral valve
native maple
#

^^^

verbal parrot
#

thanks

dusky frost
#

raycast is a nice solution for this ig

robust yacht
#

@native maple helppp

native maple
#

i cant really help without being able to run your code

robust yacht
#

@native maple

git clone https://github.com/zt64/advent-of-code.git
./gradlew run

make sure you have jdk 21

pale stirrup
#

zeet using until when ..< exists

robust yacht
#

ill clean up after working code

robust yacht
#

pul latest i just put a thing that should download the jdk

#

curious to see if it works

cloud iron
#

and put it on your path

feral valve
#

nix fixes this

pale stirrup
#

reading also fixes it ykyk

verbal parrot
#

guh how do i do it with ray cast like idk how u can do it without checking every point inside every rectangle which will take forever cuz it's essentilly x*y*100000*n

feral valve
#

i cant read

cloud iron
#

yes

#

apt-get install jdk-21 or smth

#

or pacman -Syu jdk-21 or some shit idk

pale stirrup
#

sorry i use fedora btw

#

dnf

cloud iron
#

dnf if you want

#

i believe in debian supremacy

robust yacht
#

i think rosie died

verbal parrot
#

hm i guess i should just rather check if my points intersect any of the lines using just their coordinates rather than creating a big ass array

#

actually i think rosie said it before

feral valve
#

where do i place input @robust yacht

robust yacht
#

i think ill allow passing input from cli

frigid socket
#

i should push d9

robust yacht
#

ninoh death

gilded quarry
#

no

frigid socket
#

Caitbaiting

feral valve
#

@robust yacht your part 2 main doesn't make much sense

robust yacht
#

how

feral valve
#

if you filter all the red tiles to be inside, they should all be. You need to check a rectangle and if all the green tiles inside are valid

robust yacht
#

oh

verbal parrot
#

i dont get it how im supposed to determine whether a side of a rectangle is inside or outside the shape initially

pale stirrup
#

i have no idea how to do any of this

robust yacht
#

good froggy

pale stirrup
#

p1 5 lines p2 150

robust yacht
#

part 3

pale stirrup
#

yk what i mean

robust yacht
pale stirrup
#

i could actually make p1 3 lines if i sacrifice legibility

verbal parrot
#

lc.g vai5000

prime sphinxBOT
robust yacht
#

my p1 is 7 lines @pale stirrup

#

could be a little shorter though

pale stirrup
#

i reused the function i took for yesterday

#

that generates all possible pairs

robust yacht
#

oh

#

i dont do that

pale stirrup
#

then i just maxOf for the area

robust yacht
#

shortened

robust yacht
#

yop

pale stirrup
#

don't you need to abs though

robust yacht
#

i was initially

#

but no change removing it

pale stirrup
#

interesting

frigid socket
#

zesty zeet

verbal parrot
#

d9p2 will be the reason i kms

pale stirrup
#

maze tomorrow please

#

🤞 🤞 🤞

frigid socket
#

die

#

just because you vibe coded DJ Kistra doesn’t mean we all did ykyk

#

if theres a maze ill have to implement DJ Kistra in some language

verbal parrot
#

DJ Swamp Izzo

pale stirrup
#

djikstra not hard to implement

#

you just need priority queue

robust yacht
#

my cpu is struggling

pale stirrup
#

zeet has a Pentium 4

feral valve
robust yacht
#

hm

#

||checking only the corners might work?||

robust yacht
#

fug

#

c

#

sfdjn

#

even checking just hte perimeter is taking ages

#

I'm gonna run it for a while and see

verbal parrot
# feral valve

so you do have to check every point (or what do you call it) of a rectangle 😭

#

that sounds so fucking long

verbal parrot
#

guh

feral valve
#

@native maple what optimizations did you do for the ||raycasting method||

robust yacht
#

okay its still not down after 30 minutes

#

maybe another 30

feral valve
robust yacht
#

||is checking the perimeter how you did it||

feral valve
robust yacht
#

gu

quartz aurora
#

I'm at 303 bytes currently ||```py
Z=sorted
Y=lambda A,B,C,D:Z((A,C))+Z((B,D))
I=lambda A,B,C,D,E,F,G,H:A<E<B>0<max(G,C)<min(H,D)or C<G<D>0<max(E,A)<min(F,B)
n=m=0
R=Z(zip(P:=[eval(x)for x in open(0)],P[1:]+P))
for A,B in R:
for D in P:y=a,b,c,d=Y(B+D);n=max(n,s:=~(b-a)~(d-c));m=[m,s][m<s>1>any(I(*y+Y(*a+b))for a,b in R)]
print(n,m)

#

I don't understand why it works though

robust yacht
#

I need a hint@tnixc

feral valve
#

and ||dont test every point in the rect, you can test points in an N lattice||

verbal parrot
feral valve
# robust yacht not sure what that is

basically to check points inside the rect, you || iterate (i = x_min; i < x_max; < i += 1)but what if you iterate it as (i = x_min; i < x_max; < i += step)||?

robust yacht
#

oh

#

I thought about that but how small can the step be

feral valve
robust yacht
#

oh

#

yea

#

it can't be very large can it

robust yacht
feral valve
quartz aurora
#

I don't do any caching at all, though it is admittedly a bit slow

#

About 1.2s on pypy

feral valve
#

you could also ||only check the validity after checking the area is > current max||

robust yacht
#

ok its not done after an hour time to optimize

native maple
#

i started to then realized thats gonna be a pain in elle lol

robust yacht
#

roinga

#

guh im caching and it still takes ages

feral valve
#

what’s your step size?

robust yacht
#

just 1 idk how large i can make it

#

with 200 i get an incorrect value

#

same with 20

#

im just getting the same value

feral valve
#

How are you stepping it? push

robust yacht
#

@feral valve pushed

#

fsdnjfsdn same exact value 4743369984

#

this is so stupidd ughh

feral valve
# robust yacht <@509618780301950996> pushed

||```kt

            if (!checkPoint(start.x, start.y)) {valid = false}
            if (!checkPoint(start.x, end.y)) {valid = false}
            if (!checkPoint(end.x, start.y)) {valid = false}
            if (!checkPoint(end.x, end.y)) {valid = false}
||
robust yacht
#

every, single, time its 4743369984

#

those are the corners but arent i already checking them?

#

okay i get a different nubmer when i do that

feral valve
#

i am confused

robust yacht
feral valve
#

the algorithms between your version and mine are basically the same

robust yacht
#

could the + 1 be causing issues

feral valve
#

you were missing several things
||

  1. check corners
  2. add the edges to containedPoints ahead of time
  3. in your part 2 you need
        val Mx = maxOf(start.x, end.x)
        val mx = minOf(start.x, end.x)
        val My = maxOf(start.y, end.y)
        val my = minOf(start.y, end.y)

since end.x may be < start.x so you end up not checking anything
||

robust yacht
#

i thoguht i am checking corners though

feral valve
#

||The stepping might skip them and also I think this is just way faster if you do the corners||

robust yacht
#

what would those mins and maxes be for

feral valve
#

not bad!

frigid socket
#

i have a solution idea but it will be so imperformant

#

and probably use hundreds of gigabytes of ram

feral valve
#

also i dont like kotlin

robust yacht
#

i somehow messed up the area calculation

frigid socket
#

store every single green tiles coord

robust yacht
#

idk if i should add + 1 to the width and height

feral valve
robust yacht
#

evil

#

EVIL

feral valve
#

?

robust yacht
#

how am i still getting it wrong what

#

ugsdfs

#

i hate aoc so much

#

advent of SUFFERING

feral valve
#

oh try making step smaller

#

it works for my input but idk if it does for yours

robust yacht
#

okay i copied everything and it works

#

i made it twice as fast too

#

i suck at aoc

frigid socket
robust yacht
#

cleaned up @feral valve

#

123 ms

feral valve
feral valve
#

this lowkey feels cursed

terse edge
#

what abt it

pale stirrup
#

this ones gonna be annoying to parse

robust yacht
#

yop

#

im goinng to use regex

#

oh my god minky wont move

verbal parrot
#

i hope today’s is easier fr

robust yacht
#

can regex capture variable number of groups

#

actually im overcomplicating it

pale stirrup
#

i got it parsed

#

no regex

robust yacht
#

cheater

verbal parrot
#

wait why do u need regex for today. isn’t it just

a = file.split(" ")
first = a[0][1:len(a[0])-1]
second = [a[i][1:len(a[i])-1)].split(",")for i in range(1, len(a))]
third = a[-1][1:len(a[-1])-1].split(",")

fr

robust yacht
#

not readable

pale stirrup
#

i do that but more readable

robust yacht
#

wingyy

pale stirrup
#

using removeSurrounding

robust yacht
#

wing be like ribbit

verbal parrot
# robust yacht not readable

made it more readable:

first,second,third=(a:=open("input").strip().readlines())[0][1:len(a[0])-1],[a[i][1:len(a[i])-1)].split(",")for i in range(1,len(a))],a[-1][1:len(a[-1])-1].split(",")

fr

robust yacht
#

i wonder if this is brute forceable

#

idk how you would even do this without randomly guessing the combination

lusty atlas
#

what's so hard?

just split by spaces then pop and shift 1 each

robust yacht
#

snat

#

@pale stirrup do you have any idea

lusty atlas
#

oh god and the joltage is going to come in for part 2

robust yacht
#

yea

#

theres probably some weird logic math way to determine what buttons to press

#

ive got no idea

lusty atlas
#

try brute force

robust yacht
#

idk how theres so many possible combinations

lusty atlas
#

there aren't that many buttons in each row

#

do a smart brute force

#

first try each button once

if that doesn't work, try each button once and then a second any other button

if that doesn't work try the same but 3 buttons

4 buttons

until you get the right result

#

do for each row

#

does that make sense

robust yacht
#

yes but i have a feeling theres gonna be ones where

#

press button a, then button b, then a again

lusty atlas
#

yah that's going to be covered

robust yacht
#

ill try

lusty atlas
#

but yeah surely there's a logic way to do this xD

#

well you can do some basic filtering first for buttons that are guaranteed to be included

#

like if you want light 2 and 3 on, you know that the solution has to include at least one button that toggles 2 and one button that toggles 3

so those are your starting buttons

#

and you can also eliminate buttons that can't be included

if you don't want light 2 on and there is exactly one button that toggles light 2, you know that button can't be included

robust yacht
#

hm

#

veepy

#

filtering it would be easy i think

lusty atlas
#

god this is aids

#
[#..####..] (3,6,8) (1,2,3,4,5,6,7) (5,6) (0,1,3,4) (1,2,3,4,5,7,8) (0,1,3,4,8) (0,1,2,3,4,5,7,8) (0,2,4,5,6,8) (4,8)
#

line 2 of my input

robust yacht
#

filtering kinda helps but not much

lusty atlas
#

very evil

#

can't even filter anything here

robust yacht
#

husk BOMB

lusty atlas
#

maybe calculating the difference of each pair of buttons could help

robust yacht
lusty atlas
#

that seems efficient

#

like if you combine each button and get the difference you basically create a new button with cost 2

robust yacht
#

guh

lusty atlas
#

update challenge

robust yacht
#

guhhh this is too hard to think about

robust yacht
#

what values would you difference

lusty atlas
#

wait im turning on pc

#

I was going to sleep but this is exciting

pale stirrup
#

ill do this tomorrow

robust yacht
#

same i think

#

ill wait until the smart people here solve it

pale stirrup
#

its tough bc you have to consider the future

lusty atlas
robust yacht
#

if ti was only one button press allowed then it could jsut be running through all the possible combinations

pale stirrup
lusty atlas
robust yacht
#

same

#

i have a combinations function

pale stirrup
#

it does not work bc it doesn't consider the future

robust yacht
#

permutations

pale stirrup
#

basically we need a chess bot

robust yacht
#

do

robust yacht
#

a litle

#

apparently p1 can be done with BFS

terse edge
#

are youguyS on p1

#

or p2

pale stirrup
#

1

terse edge
#

i did a bls

#

bfs

#

for p1

#

you will die when you see p2

pale stirrup
#

so im the dummy for trying to logic it

terse edge
terse edge
#

you can bruteforce p1

#

and i think theres only 1 approach that works for p2 and its not bruteforce

pale stirrup
#

how slow is the bruteforce

terse edge
#

for p1?

pale stirrup
#

yeh

terse edge
#

couple ms

#

its the intended solution

pale stirrup
#

oh thats lame

terse edge
#

bruteforce in the sense that you just try all buttons and keep a visited set

#

p2 cant do that

pale stirrup
#

bfs being intended kinda sucks tbh

terse edge
#

why

pale stirrup
#

doesn't feel smart to get it right

#

not satisfying

terse edge
#

yiou will feel smart when you get p2 right

robust yacht
#

otherwise the current lights is invalid

#

for each set of buttons to press

terse edge
#

and that works

robust yacht
#

interesting

terse edge
#

@native maple solve today manually pls

#

p2

lusty atlas
terse edge
#

p2 done

robust yacht
robust yacht
terse edge
#

for p2 dont forget > 0 presses check

lusty atlas
#

okay i did p1 with the worst brute force ever

terse edge
#

@pale stirrup someone logiced it

lusty atlas
#

lets see how long

#

is it even possible to brute force

#

or too complex

#

OKAY 😭

native maple
#

part 2 is NP-hard 😭

#

how the fuck do i solve this in elle

hoary mirage
#

IS IT DJAKSTRA

#

@native maple

hoary mirage
lusty atlas
#

day10

#

but it's impossible to brute force

#

don't try

hoary mirage
terse edge
#

@native maple please solve it by hand

native maple
#

no

lusty atlas
#

solve with an abacus @native maple

hoary mirage
#

I cant believe theo is fast

#

maybe he is llm wrapper

native maple
#

do i just write a simplex for this atp

#

😭

hoary mirage
#

@lusty atlas does this remind you something

prime perchBOT
#
Lights Out: Medium (4x4)

🎉 You win! 🎉
You moved 5 times.
You solved the puzzle in 39.26 seconds.
You earned 25 🪙 Town Tokens for playing!

hoary mirage
#

thankfully I am PRO at this game

#

honestly I have zero idea how to solve this without brute forcing

#

z3 is a option but also kinda cheating idk

fallen lily
#

It looks like I'll have fun over winter break when I have time to do aoc

hoary mirage
#

or matrixes hm

hoary mirage
#

well brute force it is

frigid socket
#

yk what @hoary mirage

#

it’s DJ Kistra time

hoary mirage
#

because I did not write the algorithm blabla

frigid socket
#

is today just brute force

hoary mirage
#

only part1

frigid socket
#

choose lang @hoary mirage

hoary mirage
#

python

quartz aurora
#

I did brute force on p1 and scipy on p2

native maple
#

i need to write my own simplex algorithm in elle

#

❤️

hoary mirage
#

ROSIE HELP ME

native maple
#

idk how to do it either

#

i'm still doing it

frigid socket
#

i'll brute the force

#

which lang though

hoary mirage
#

python

frigid socket
#

using NodeJs today @hoary mirage

#

today will not be Elle day

#

i'll do d1 in Elle

#

and move swift somewhere else

hoary mirage
#

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

#

took 55s

frigid socket
#

okay maybe i need a compiled language today

hoary mirage
#

time to brute force part 2

#

@lusty atlas watch and learn noob

#

@terse edge how big is p2 answer

quartz aurora
hoary mirage
#

hmm

#

bfable

frigid socket
#

@hoary mirage ill do go and tay for 11/12

#

Elle and something else for d1 and 3

#

love?

#

it gets more difficult the languages get simpler

hoary mirage
#

nino machoist

#

if ur true programmer do today in sql

frigid socket
#

die

#

i actually did d3 2024 in sql

hoary mirage
#

rude

#

running solution

#

time to play some videogames

frigid socket
#

@hoary mirage i wrote parser

hoary mirage
#

incredible

#
e["light_diagram"] = [bool(int(i)) for i in m[0][1:-1].replace(".", "0").replace("#", "1")]
e["joltage"] = [int(i) for i in m[-1][1:-1].split(",")]
e["buttons"] = [[int(e) for e in i[1:-1].split(",")] for i in m[1:-1]]

#

my parser

frigid socket
#

you start with all lights off right

#

and have to turn on to match state

#

./run

const balls = [false, true, false]
const gaming = [false, true, false]
const gambling = [false, false, false]

console.log(balls == gaming, balls == gambling, balls === gaming, balls === gambling);
cedar troutBOT
#

Here is your js(18.15.0) output @frigid socket

false false false false
frigid socket
#

./run

function compareArray(a1, a2) {
    if (a1.length !== a2.length) return false;
    for (let i = 0; i < a1.length; i++) {
        if (a1[i] !== a2[i]) return false;
    }
    return true;
}
const balls = [false, true, false]
const gaming = [false, true, false]
const gambling = [false, false, false]

console.log(compareArray(balls, gaming), compareArray(balls, gambling));
cedar troutBOT
#

Here is your js(18.15.0) output @frigid socket

true false
quartz aurora
native maple
#

the solutions to each equation aren't that big, they're like a few hundred at most

#

is this really not brute force able hold on

native maple
frigid socket
#

oh true

#

ykyk

hoary mirage
frigid socket
#

// @ts-pmo

hoary mirage
#

you can press buttons max sum of joltages

#

and mininimum single max joltage amount

#

for number like
{44,80,42,84,83,194,55,64,32,33}

#

n^250 ish which is impossible ig

frigid socket
#

@hoary mirage

function perm(
    xs: any[],
    len: number
): any[][] /* based on https://stackoverflow.com/a/43260158 */ {
    const ret: any[][] = [];

    if (len === 0) return [[]]; // base case: one empty permutation of length 0

    for (let i = 0; i < xs.length; i++) {
        const rest = perm(xs.slice(0, i).concat(xs.slice(i + 1)), len - 1);
        for (let j = 0; j < rest.length; j++) {
            ret.push([xs[i]].concat(rest[j]));
        }
    }

    return ret;
}

function getCombinationsFor(length: number, quantity: number) {
    const set = [];
    let i = 0;
    while (i < length) {
        set.push(i);
        i++;
    }
    return perm(set, quantity);
}
#

i love stack overflow

#

i vibe coded len

#

it's not puzzle logic ykyk so i can vibe code it

#

and i was spending half an hour on this

hoary mirage
#

well whatever I will go math route

#

a is 3 b is 5 and blabla

#

I could do matrix calculation but they also have to be integers not floats

#

so sympy gaming

frigid socket
#

i'll scrap my solution

#

doesn't work well

hoary mirage
#

EQUATIONS ARE CORRECT

#

WHY IS IT NOT SOLVING

#

I HATE SYMPY SO MUCH

#

trime to try pulp

#

@frigid socket vibecoding

#

That's the right answer! You are one gold star closer to decorating the North Pole.

You have completed Day 10! You can [Share] this victory or [Return to Your Advent Calendar].

#

well I dont feel proud

#

pulp did everything

#

whatevber

frigid socket
#

i didn’t

native maple
#

and i'm doing it in elle lol

robust yacht
#

what even is z3

#

ive seen it mentioned but no idea what it is

hoary mirage
#

looks yummy

hoary mirage
robust yacht
#

evil

native maple
#

microsoft linear programming solver

verbal parrot
robust yacht
#

roinga

lusty atlas
#

just generate each equation and put into chatgpt @hoary mirage

#

it won't be fast and it won't be correct but it will still give you an answer

hoary mirage
#

it would be so funny

robust yacht
#

do

hoary mirage
#

solving via wolfram api

#

too bad I already solved

native maple
#

technically i can use z3 in elle if i call the executable blobcatcozy

#

i'm not doing that though my solution is coming together

#

i think i will be solve this in under 500ms today

hoary mirage
silk smelt
#

my z3 solution runs for over 2 minutes :p

feral valve
#

p1 easy now time to learn about simplex

quartz aurora
#

Shrimplex, you mean

lusty atlas
#

not so shrimplex now

native maple
#

TODAY SUCKS SO BAD

quartz aurora
#

A python program

quartz aurora
native maple
#

FINALLY

dusky frost
#

nice

#

||i used scipy for now but i want to do it without lib later, just have a lot of school||

native maple
#

i did it in elle with no libs, just did ||branch-and-bound with the simplex algorithm||

#

it is absolutely horrendous

#

and quite slow

#

but this is genuinely the most difficult aoc problem i think ive ever solved

dusky frost
#

agree

verbal parrot
#

for like a day there were two python processes on my os that were consuming a total of 100gb of ram 😭

feral valve
#

yeah i dont think i can do this on my own in ocaml with nothing lol

native maple
hoary mirage
feral valve
#

integer linear programming is actually cool

#

cant wait to take this course

native maple
#

certainly nowhere near enough to do today sanely

verbal parrot
#

im just doing brute force for d10p1 and it works fine with the puzzle input until it hits line 131 or so. is it just taking too long to count or is my algorithm broken

#

like what is the biggest presses u can encounter in puzzle input

#

nvm it found it

#

yyeah my solution is fucking SLOW

#

python3 10.py 418.67s user 1.73s system 99% cpu 7:02.45 total
for just one line fr

#

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

#

only took me uh 430s on m4

feral valve
#

This one is cooking me

verbal parrot
feral valve
#

p2

verbal parrot
#

requires a minimum of 10 button presses
i guess im not brute forcing it 😭

lusty atlas
#

@hoary mirage i have an idea

use one thread for each line

#

part 2 multi threaded brute force

#

if u have threadripper u can probably do it

hoary mirage
#

sadly he didnt have

lusty atlas
#

find someone who has a threadripper

hoary mirage
#

even then I think might not be possible

lusty atlas
#

well

#

my pc brute forced line 1

#

but line1 easy

#

then my pc got stuck on line2 and i only waited like 3 minutes

#

maybe if u wait an hour it can finish

hoary mirage
#

thread troll

lusty atlas
#

just need threadripper

native maple
robust yacht
#

@native maple roieeee

#

hiii

robust yacht
#

@native maple teach me step by step how to solve p1

#

HOW DID MANTIKA GET IT

#

guhh

feral valve
#

@native maple

#

😭

native maple
#

how did you do it

feral valve
#

i just ported some guys solution from rust into ocaml

#

i dont think i was figuring this out lol

robust yacht
#

roie ignoring me..

#

crying

feral valve
#

but i aint doing all that

verbal parrot
robust yacht
#

die faint die

verbal parrot
#

you WILL brute force it

robust yacht
#

guh gang

native maple
#

p1 is so brute forceable

#

p2 is not ever in hell

#

@feral valve

robust yacht
native maple
#

almost 300 lines of absolutely dreadful elle code

robust yacht
#

i only understand brute forcing in a 1d way

#

try x, incremenet, try again

#

not this

feral valve
verbal parrot
robust yacht
#

thats only assuming one button press though?

verbal parrot
#

nop

feral valve
#

Iterate subsets is only 2^n - 1

robust yacht
#

how

feral valve
robust yacht
#

\i cant read that

#

anyways

#

ill try something

verbal parrot
# robust yacht how

what i did was sum like this
||```py
ranges = [range(length)]
while needed != buttons:
for j in itertools.product(*ranges):
// logic here

ranges.append(range(length))
feral valve
#

@native maple upload your solution

native maple
#

it is a complete mess

feral valve
#

i need to bring this down from 8 minutes from to sub 1 second

robust yacht
#

love

native maple
#

blehhhhh

robust yacht
#

roieee

#

hi

native maple
#

hii

feral valve
#

already got a 2.2x speedup blobcatcozy

native maple
#

runs in 2s but i do some.. questionable things

#

idk of a better way than to clone here

#

genuinely about to make all of this shit global!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

#

i dont wanna pass like 6 variables to every function

#

this sucks ass

feral valve
#

that sounds fun!!

robust yacht
#

god

#

im like

#

failing to do even basic loops im so dumb

lusty atlas
native maple
robust yacht
lusty atlas
#

why not

native maple
#

maybe i will

lusty atlas
#

structs are basically free abstractions

feral valve
#

me when I refactor a function with 8 parameters

robust yacht
#

WHY AM I STRUGGLING WITH LOOPS

#

ADNJFSD

#

vbring me death

lusty atlas
#

add kwargs to elle @native maple

#

or just named args

robust yacht
#

soon

native maple
robust yacht
#

[[0, 1], [0, 2], [3], [2], [2, 3], [1, 3]]

#

ughhh

#

ok its running now

#

do i need a cache

verbal parrot
#

cache for what...?

robust yacht
#

ok i ran out of memory

#

great

#

thats what

hoary mirage
#

even if you try to brute force you shouldnt run out of memory

#

unless ur storing every single possibility in a array

native maple
#

@feral valve i added negative indices for this lol

verbal parrot
robust yacht
#

idk

verbal parrot
#

i swear it wasnt even 100mb for me

native maple
#

because without that it became very fucking annoying

robust yacht
#

hm

#

i have an idea why

hoary mirage
robust yacht
#

calculating all the permutations is using up all the memory

hoary mirage
#

DONT BRUTE FORCE

robust yacht
#

die

#

mantika death

hoary mirage
#

Python doesnt do that

robust yacht
#

mantika actually restarted

#

i could write the worst inefficient code ever imaginable and mantika would blame the language

hoary mirage
#

I would not blame the language if it wasnt kotlin

robust yacht
#

you are dum

hoary mirage
#

@native maple look even rosie prefers elle to kotlin

#

She doesnt want kotlin worst language

robust yacht
#

elle syntax husk

#

ai managed to fix the memory leak

#

my permutations function was bad

hoary mirage
#

Everyone vibecoding on todays problem

robust yacht
#

yop

#

Heap's algorithm generates all possible permutations of n objects. It was first proposed by B. R. Heap in 1963. The algorithm minimizes movement: it generates each permutation from the previous one by interchanging a single pair of elements; the other n−2 elements are not disturbed. In a 1977 review of permutation-generating algorithms, Rober...

hoary mirage
#

YOU CAN ONLY DO PART 1 WITH THAT

feral valve
#

yeah I'm doing this now

robust yacht
#

my p1 is running

#

i wonder how long it will take

#

at least a week

#

@feral valve how long did yours take

feral valve
robust yacht
#

yop

hoary mirage
#

My p1 was FAST

feral valve
#

all combinations for p1 is like sub 10ms

robust yacht
#

i think if i use a cache itll help

hoary mirage
#

But it was also in python not kotlin

robust yacht
#

didnt you say like 8 minutes or something

#

python SLOW

feral valve
verbal parrot
hoary mirage
robust yacht
#

what would i even cache

feral valve
hoary mirage
#

ZT YOU DONT NEED CACHING

robust yacht
#

then what do i do

hoary mirage
#

Just solve

robust yacht
#

HOW

#

im not a math professor

verbal parrot
#

what wd u even cache gng 😭

hoary mirage
robust yacht
#

I AM

hoary mirage
#

I did no caching and blah

robust yacht
#

mantika insane

verbal parrot
hoary mirage
robust yacht
#

||

  1. I loop over each machine
  2. I lazily generate all permutations of the machines buttons
  3. I loop through each permutation set to find the min value, trying the buttons and if it is corrrect
  4. after permutations loop done, i get min value and return it to the sum
    ||
#

whats repeat=u

hoary mirage
#

how many buttons it will choose

feral valve
#

5,333x speedup

hoary mirage
#

4 second on part1

native maple
feral valve
#

me when I vibecode guassian elimination

robust yacht
#

is product not hte same as permutations

hoary mirage
#

combination order doesnt matter just combinations

robust yacht
#

guhh

#

@hoary mirage what is the type of i

#

hate dynamic typing

hoary mirage
#

array of array of int

robust yacht
#

im confused

#

wouldnt it be array of array of array of int?
sequences to try, containing the buttons, containing the ints

hoary mirage
#

itertools.product returns iterator

verbal parrot
#

wait wrong chat

#

okay whatever

hoary mirage
#

it runs with new combination every iteration

robust yacht
#

oh

#

okay

hoary mirage
#

if youı tried to store all it would eat all your memory

robust yacht
#

trying to use product keeps messing up my existing loop

hoary mirage
#

fix

robust yacht
#

this is literally so annoying

hoary mirage
#

zt you dont have to solve

#

it will prob get harder tomorrow

robust yacht
#

if i use repeat = 1, i get the wrong answer
if i use repeat = 3, i get an answer thats probably wrong

hoary mirage
#

I might give up tomorrow too

robust yacht
#

idk what repeat is supposed to be

hoary mirage
#

like I do

#

1 repeat all the way to idk forever

#

until it hits something

#

when u do repeat 2, it gets all possible presses of 2 buttons

#

but doesnt include 1 or 3

hoary mirage
#

he brute forcing

feral valve
#

from the first example, we have this vec you want to find which is Ab=x, then you perform guassian elimination, so you get the pivot variables, then you get bounds on the pivots, and then you search

#

such good vibecoded explanation

robust yacht
#

fsidnjfsdn

#

HOW IS IT GETTING 87 INSTEAD OF 7 NOW

hoary mirage
#

do u break at first occurance

robust yacht
#

yes

#

i think so

#

finally

#

takes 2.31 second

#

about 2 seconds now

#

about 1.8 seconds now

native maple
#

@feral valve it turns out i was trying so hard to optimize p2 but p1 was taking all my time

#

p2 only takes 80ms lmao

#

p1 is the one that takes several seconds

feral valve
#

cool

native maple
#

because i do a very naive thing

fn min_lights(i32 lights, i32[][] buttons, i32[] target) {
    start := (0..lights).map(fn() 0).collect();
    queue := Deque::new<i32[]>();
    queue.push_back(start);

    visited := $map($(start, 0));

    while _, state := queue.pop_front() {
        presses := visited[state];
        if state == target { return presses; }

        for button in buttons {
            new_state := state.clone();
            for i in button {
                new_state[i] ^= 1;
            }

            if !visited.contains_key(new_state) {
                visited[new_state] = presses + 1;
                queue.push_back(new_state);
            }
        }
    }

    return i32::max();
}
feral valve
robust yacht
feral valve
#

i can see how that'd be pretty bad

feral valve
native maple
#

i can uhhhh

#

use a bitmask?

feral valve
native maple
#

it will definitely be faster

robust yacht
native maple
#

cloning a u64 is way faster than cloning a i32[]

#

it does a deep clone

robust yacht
#

using an IntArray instead of List<Int> saved me like 200 ms

#

funny

feral valve
#

oh i see what you mean now

frigid socket
#

i will get home and try doing today

#

my P1 solution i think is broken

robust yacht
#

most of my performance loss is during the product calculation

feral valve
#

I'm also brute forcing without a bitmask and copying a new array every time but it takes like 8ms

robust yacht
#

wdym bitmask

feral valve
#

to press, do lights = lights xor button

robust yacht
#

oo

feral valve
#

where button is represented as 001001 for the indexes

#

4.4ms no bitmasking

#

Using a bitmask is 1.2 ms slower???

#

maybe it's because i'm going from chars to bool array to int

#

yeah bitmasking is just not faster even if i parse it as int

robust yacht
#

oh

frigid socket
#

oh you know you know @robust yacht

#

iiwii ykyk

robust yacht
#

what about parsing them as bytes@feral valve

#

and instead of using array, store as single byte

feral valve
#

I doubt bytes would be significantly faster than ints

frigid socket
#

SkibidiZt

feral valve
#

i have no idea why this is so fast

robust yacht
#

nino death

frigid socket
#

@robust yacht help

#

or @fallen lily

#

did you do aoc

fallen lily
#

i do it slowly

#

dont have time to do it every day

frigid socket
#

actualyl my solution does work

#

my solution is also very slow

#

its dying on machine three

native maple
#

@feral valve how fast was yours again?

#

for both parts?

frigid socket
#

@native maple could a machine require >1k button presses

native maple
#

for fucks sake

feral valve
#

but i’m on m3

native maple
#

i dont think that will save me

#

must optimize more..

feral valve
#

i’m also not reading in the file

native maple
#

i think i can cut some time in parsing the input

native maple
feral valve
native maple
#

that has like almost no impact

#

lol

feral valve
#

lol yeah

#

but still you could save a few microseconds

robust yacht
#

steamy sadan

#

okay xoring is just slightly faster

#

maybe like 50-100ms for me

robust yacht
#

@native maple how do i make brute force faster

robust yacht
#

dont know what that is

#

oh

#

i made it 228 ms now

#

by changing my product function

feral valve
robust yacht
#

p2 cant be brute forced right

native maple
feral valve
native maple
#

if i dont i get an incorrect answer lol

feral valve
native maple
#

ehhh its fast enough

robust yacht
#

faster.

native maple
#

if i wanted to not use floats id have to entirely rethink my solution

frigid socket
#

@native maple hiiii

feral valve
robust yacht
#

@native maple hiii

frigid socket
#

rosie ignoring me

#

gonna kms a bit yk

native maple
#

hold on ill put on github in a sec

robust yacht
#

fold function so funy

#

||```kt
buttons.fold(0) { acc, c -> acc xor c } == lights

|| this is all i need now
#

my p1 is only 6 lines

lusty atlas
#

HOW

native maple
#

my p1 is like rather long

robust yacht
frigid socket
#

why husk

robust yacht
#

@lusty atlas rate
||

override fun part1(): Any {
    return machines.sumOf { (lights, schematics) ->
        generateSequence(1, Int::inc).first { repeat ->
            schematics.product(repeat).any { buttons ->
                buttons.fold(0, Int::xor) == lights
            }
        }
    }
}

||

#

ninuh fears

#

oh thats vee

feral valve
#

is generateSequence a builtin 😭

robust yacht
#

yop

lusty atlas
#

im too busy to do p2

#

insane

feral valve
#

oh yeah you could use a generator function pretty easily actually

robust yacht
#

p2 scary

#

@feral valve can p2 be brute forced like how im doing in p1

#

i think most my time comes from generating the products

feral valve
#

every 1 billion years, take a step forward. Once you have walked around the earth remove a single drop of water from the oceans. Once the oceans are empty put a sheet of paper down then refill the oceans. Once the stack of paper reaches the sun you will still not have searched more than 1e-99 of the search space

robust yacht
#

i see

#

i can wait that long

native maple
feral valve
lusty atlas
native maple
#

@feral valve i think its finally time

feral valve
native maple
#

to push my solution lol

feral valve
native maple
#

i used multiple files in this one

#

oh wait

#

i need to push elle too

#

how am i 2nd on the vencord leaderboard 😭

#

ive literally been doing it several hours late every day except 1

native maple
feral valve
#

this takes 10 years to compile every time

native maple
#

??? it shouldnt

#

did you compile elle in release

feral valve
#

oh yes

#

@native maple

native maple
#

uhhh

feral valve
#

oh

native maple
#

what..