#AdVENt of Code

1 messages · Page 13 of 1

solemn python
#

But you underestimate how large that is

#

Not to mention having to calculate the actual value of those, bc the formula only deals with the count

real hinge
#

TRUE

#

we should use swift

sullen fiber
#

||binomial coeff|| in uiua is so pain

sullen fiber
#

for my input given that i have a way to iterate through them it reduces my iteration count from 5.5mil to 32k

#

||naive 2^k vs nCr counts||

#

putting this here in case i need it again later cus it was a pain to write
||```

Naive 2^k count

/+ ⁿ:2 ⊐≡/+ =@? ≡⊡ 0 Table

nCr count

Fac ← /×+1⇡
≡⍜°⊟(⊃(-:⊓⧻/+|⋅⧻) ∩°□) Table
≡(÷:⊃(Fac|×∩Fac ⊃(⋅∘|-:)) °⊟)
/+

#

@solemn python I KNOW

#

I KNOW HOW TO ITERATE

#

I KNOW

#

i'll write about it later

solar tide
#

I will delete them today

sullen fiber
tranquil vapor
#

yall are mad overengineeeing for advent of code

#

i respect it

sullen fiber
#

well i cant bruteforce today in uiua

#

so i have to

#

also its fun too true

tranquil vapor
sullen fiber
#

it is

#

but part 2 isnt

tranquil vapor
#

oh real

sullen fiber
#

i had part 2 spoiled for me so i alr know it wont be worth waiting

#

kinda glad i did tho cus i would have been annoyed otherwise

#

like eagely said it feels lazy

tranquil vapor
#

WHY DID U HAVE P2 SPOILED

hazy sinew
#

maybe if u post it to github and put the unlicense the copycat can blame you in case of a lawsuit

sullen fiber
#

simple wont license

hazy sinew
#

i think doing it like a normal person is faster

sullen fiber
#

its not

#

in uiua

#

uiua is NOT fast

#

imagine uiua is python but even python would be faster at a bruteforce

sullen fiber
hazy sinew
sullen fiber
#

it would take 30m for part 1 in uiua

hazy sinew
#

no it wouldnt

#

how long did yesterday take

sullen fiber
#

not long

#

seconds

#

like 10 seconds maybe

hazy sinew
#

today is gonna take seconds as well then ig

sullen fiber
#

so ur saying a solution exists that between naive and what im doing rn?

#

hmm

#

i can think of another way but its basically the same just

hazy sinew
#

its literally ||part 1 with a cache||

sullen fiber
#

||recursive instead of iterative||

#

||a cache??||

hazy sinew
hazy sinew
sullen fiber
#

||ngl if i wasnt doing this at a library i could use perf and find out what was making my impl slow||

#

||but yea that solution where u walk through the 2^k possibilities and check if they match, it is super slow in uiua||

#

wait i thought of an optimization

#

nope slower

#

fuck u uiua

#

wait i thought of another

hazy sinew
#

bro just ||bruteforce it with memoization pls||

sullen fiber
#

explain or die

tranquil vapor
#

|| im about to brute force my fist in your face with memoisation (you will never forget) ||

sullen fiber
#

TRUE

hazy sinew
sullen fiber
#

||count the ?s as k, iterate through 2^k as k-bits, use the bits as a mask to insert # or . into the ?s, count the partitions for each iteration and check if they match and if so increase accumulator||

#

||i dont actually use strings but yea its basically that||

#

also i just realized why it was slow and i made it a lot faster

#

from 30m to 3m

#

still kinda slow

hazy sinew
#

wtf

#

r u doing

sullen fiber
#

i want you dead

#

ur getting insufferable, help or dont talk!

hazy sinew
#

im trying to understand

#

ok thats smart

#

but idk how youd use it for part 2

#

i did ||iterate through each string recursively, check the first char, recursively add the function to total for the rest of the string||

#

||pass in the config and the group sizes, check first of config if its in ".?" then result += count(config without first char, sizes) if its in "#?" then check if there is a . or a ? after the group (substr until groupsize) and if yes add count (config substr until groupsize, group sizes)||

#

that was a terrible explanation

sullen fiber
#

nah it made sense i think

#

its basically the same as mine but recursive rather than iterative

#

i dont know if you can do more than one recursive call in uiua

#

recursion is experimental

tranquil vapor
sullen fiber
#

thats just the uiua frontpage

#

mandelbrot so easy in uiua tho uiua so cracked

#

also you love large matrices displaying as images

#

it can also do this in ur terminal lol

#

click the arrows next to run NOW

#

ok i was wrong @solemn python its so bad for part 2

#

im just gonna typescript today with eagle's idea

solemn python
#

Factorials are crazy

sullen fiber
#

YEA

#

Insane

#

@warped dust I'm going to add Uiua stdlib as a typescript package

hazy sinew
#

why tf is 🚓 🚑 🚒 right to left

tranquil vapor
sullen fiber
#

Easy

steady fog
#

@tranquil vapor learn Hebrew

sullen fiber
#

Is Hebrew rtl

solemn python
#

aaaaaa

#

i hate this math stuff

#

I dont know how any of it works and am just getting numbers with no clue how they relate to each other

steady fog
#

part 1 or 2

#

pArt 1 looks like it could be solved using math

solemn python
#

technically both

solemn python
steady fog
#

oh

#

I'm not sure where to even start

tranquil vapor
#

pt2 is basically just pt1 but fuck ur brute force

solemn python
#

as with like 1/2 the p2s this year

steady fog
#

what should first step of p1 be

solemn python
#

I have math
idk what to do with it
but I have numbers

solemn python
steady fog
#

47 microseconds

#

fast

solemn python
#

especially considering its arbitrary precision arithmetic rather than fixed precision

#

but anyways

steady fog
#

the number is how many possibilities right

tranquil vapor
steady fog
#

I did

solemn python
#

given the length of the springs

#

the 2nd is the amount of possible arrangements for the springs list in general

#

the 3rd is the amount of possible spring lists when replacing the ?s with every possible option

steady fog
#

oh

#

wait

#

guh im having stroke

solemn python
#

ok i give up on the math for now

#

i just can't think of a way to calculate this without at least generating some of the spring list stuff

solemn python
#

should I solve this with ai

#

ok yeah I give up for real this time
there might be a way but I don't know enough about probability or math in general to figure this out

#

if you find it vap pls tell im curious

steady fog
#

why is of highlighted

solemn python
#

b/c its in my search query

steady fog
#

of

tranquil vapor
#

ty the type of fella to google for of row

solemn python
#

so true

solemn python
#

guhhh I hate recursion

#

the answer is NOT 4

sullen fiber
#

I just found a polynomial time algorithm to do this

#

That's crazy

#

O(n^2) rather than O(2^n)

steady fog
#

why am I dumb

#

I wish I could do stuff like that

solemn python
#

IHATERECURSIONIHATERECURSIONIHATERECURSIONIHATERECURSIONIHATERECURSIONIHATERECURSIONIHATERECURSIONIHATERECURSION

#

im trying to do this the smart way but it is so hard to debug or even conceptualize recursion

delicate crane
#

Recursion is never viable for me because I cant get tail call optimization to work in js. (I don't know if it even exists)

sullen fiber
#

TMR I'll try to write the polynomial time algorithm in the morning

#

In rust

#

@solemn python

#

Or maybe tonight if I use my friends laptop

solemn python
#

time to delete my recursive function and try again for the 3rd time

#

ill get it eventually probably

#

ok well I looked at the megathread for a hint or two and now I think I figured it out

#

its actually pretty simple once I actually thought through what the function was supposed to do and added comments to literally every ifelse path

#

NOOOOOOO

#

i made it so far without worrying about the borrow checker and lifetimes

#

and when I go to cache shit I realize I can't add a slice to a map

native pewter
delicate crane
#

Good excuse to finally try bun

native pewter
#

guh fucking wasm has tco

sullen fiber
#

U can make todays recursive with tail calls?

#

That's kinda cracked

warped dust
#

tail calls can always be rewritten as loops

delicate crane
sullen fiber
delicate crane
#

but recursion less lines and less indent than loop

steady fog
#

@delicate crane have you done day 8

delicate crane
#

uh

steady fog
#

guh

#

wait

delicate crane
#

will not wait

steady fog
#

will

#

ok did day 8

delicate crane
#

did you just steal my code

steady fog
#

yes

delicate crane
steady fog
#

evil

delicate crane
steady fog
#

@delicate crane hi

delicate crane
#

unsteal my code

steady fog
#

never

solemn python
steady fog
#

@solemn python hi

#

tyminky

#

@solemn python get ready

#

well i was gonna do gleam

#

but its dum and wont let me do a single file

#

haskell it is

delicate crane
#

I dislike this

teal mountain
#

i kept confusing rows and columns

solemn python
#

p1 is not bad

#

its pretty simple tbh

teal mountain
#

i did now what i should've done from the start, just write one version and transpose

solemn python
#

p2 im just going to throw some code at it and hope it works

teal mountain
#

can confirm this is the correct intuition for p2

steady fog
#

@solemn python how bad is it

#

im not doing tonight

teal mountain
#

p1 took me 25 mins, p2 38

solemn python
teal mountain
#

it's not that bad tbh

solemn python
#

I should make a 2d array lib for rust

#

because the amount of times I have used 2d arrays is crazy

steady fog
solemn python
#

i will

delicate crane
#

where is the reflection in this shit?

##.##.#.#..##
##.##.#.#...#
.#.###......#
.###.##..#..#
##.#.##....##
.#..###.###.#
.#...#...#.##
#.#.##.#...##
#.###.#.##.#.
#.#.#...####.
#.#.#...####.
#.###.#.##.#.
#.#.##.#...##
solemn python
#

rows 10&11

delicate crane
#

ah

steady fog
#

it's reflected

#

funny

sullen fiber
solemn python
#

i am NOT using uiua

#

i am using rust and nothing can stop me from that

solemn python
delicate crane
#
..###..##..
.#.#.....##
#.##..##.#.
#.#..###..#
.#..##.##.#
.#....##..#
#.####.##.#
#.####.##.#
.#....###.#
.#..##.##.#
#.#..###..#
#.##..##.#.
.#.#.....##
..###..##..
..###..##..

where is the reflection in this one?
its not 7.5

#

I swear to fucking god if 14 and 15 counts as a center

steady fog
#

I see it

sullen fiber
#

It's probably 14 and 15

#

It's all I imagine it could be

solemn python
#

all it has to do is hit the edges

#

not have more than 2 lines reflected

delicate crane
#

I way overthought reflections

#

my code that worked is way simpler

#

for p2 solvers, what the actual fuck?

solemn python
#

workin on it

delicate crane
#

ngl p2 is easy edit of p1

solemn python
#

it probably would be if I wasn't so bad at programming

#

I know exactly how to do it, my setup is just horrifying

#

its only vaguely usable

delicate crane
#

||in your function for determining if a specifc center is actually a mirror

  1. keep track of smudgeFound (default to true for part 1)
  2. replace line equivilance checker with oine that will allow smudge only if !smudgeFound
  3. when equivilance checker uses a fuzzy, set smudgeFound to true
  4. only return line is mirror if smudgeFound
    ||
real hinge
#

p1 is easy

#

BUT WHY DOES MY CODE OUTPUT WRONG

delicate crane
# real hinge BUT WHY DOES MY CODE OUTPUT WRONG

||```js
const vert = findReflectionVert(pattern)
if (vert !== -1)
return vert
const horz = findReflectionHorz(pattern)
if (horz === -1) console.error(i) // <--- add this
return horz * 100

for me it was because I wasn't finding all the reflections, so add code to see if you have the same problem
sullen fiber
#

Omg today is very Uiua

#

Can't wait to wake up tomorrow

delicate crane
#

Uiuable

sullen fiber
#

YES

delicate crane
#

dreeam of solution

sullen fiber
#

I already am having those dreams

delicate crane
#

I can't sleep once I see an AOC problem
brain will keep working on solution and I cant sleep until I solve it

sullen fiber
#

I think same kinda

#

I have an idea alr tho

real hinge
#

thank god aoc is on the morning for me

#

otherwise it would've been same

solemn python
#

ok I need to sleep

#

I have 2 finals tomorrow

#

I don't want to have a backlog of p2s wahhgone

delicate crane
#

3ms for p1 + p2
p1: ~1.5ms
p2: ~1.5ms

solemn python
#

OH MY GOD

#

I HATE MYSELF

#

SO MYCH

delicate crane
#

gonna try and see what multithread does to that time because I want to tuck with the js lib I found yesterday

solemn python
#

ZLJDKLSJLKDSJKJKDSJKLSAJDSLAS

#

tip: it helps to read the problem before overcomplicating everything

delicate crane
#

I didn't read too much of p2, please explain your mistake

solemn python
#

I didn't realize all you needed for the answer was the ||smudge'd reflection||, not the rest

delicate crane
#

why would you keep bad data in your (very good) summary of all the patterns

#

I absolutely love how the outputs to the problems wouldnt help at all in most cases because how they are joined together

solemn python
#

aaaaaaaaaaaaaaaaaaa

#

works on example too

delicate crane
#

Do you have auto testing for that?

#

Wrong time for that question sorry

solemn python
#

if it can figure out how to fetch the example yeah I can just add --input example and it will run on example input and even comare it to the solution

real hinge
#

is part2 terrilble again

solemn python
#

it manages to get p1 example solution but not p2 for some reason

delicate crane
solemn python
delicate crane
#

No clue

solemn python
#

ah I see my flaw

#

well I need to sleep so ill fix it tmrw

delicate crane
#

How do people do that

#

Sleep with unsolved code problems

real hinge
#

herp

#

guy it answers correctly on example

#

but not on real input

delicate crane
#

@real hinge did you read my advice last time you asked?

real hinge
#

lememe look

real hinge
#

hm

#

I need to some debugging

#

because I do in different way gu

delicate crane
#

You are telling me you don't in any part of your code, loop over each pattern and check for vertical/horizontal mirrors

real hinge
#

terrible

real hinge
#

then rotate the input

#

and use same function

delicate crane
#

||question literally says to check vertical first and ignore horizontal for stuff that had vertical||

real hinge
#

question can explode

#

I am getting too low anyway

#

oh I found the problem

#

this has 2 mirrors

#

but first one is invalid

#

so it eplodes

delicate crane
#

Explod

real hinge
#

at least tell me if its high or low

delicate crane
#

What order of magnitude is your answer?

#

It should be xx,xxx

real hinge
#

okay completed first one

#

it turns out I neeeded to trim the group trolldayruined

#

it was treating empty line as a gorup

tranquil vapor
#

i fucking hate rows and columns in coding

#

cause if u use 2d array you need to arr[y][x]

tranquil vapor
hazy sinew
#

i had to do it using lists (ugly) instead of grid because it for some reason was returning an answer lower by like 300 but correct for example and i couldnt figure out why

#

||

    private fun findMirror(grid: List<String>, smudges: Int = 0) = (1 until grid.size).firstOrNull { grid.take(it).asReversed().zip(grid.drop(it)) { a, b -> a.zip(b).count { (a, b) -> a != b } }.sum() == smudges } ?: 0

    private fun transpose(grid: List<String>) = List(grid.first().length) { i -> grid.joinToString("") { it[i].toString() } }

    override fun solvePart1(input: File) = input.sdnl().sumOf { findMirror(it.lines()) * 100 + findMirror(transpose(it.lines())) }

    override fun solvePart2(input: File) = input.sdnl().sumOf { findMirror(it.lines(), 1) * 100 + findMirror(transpose(it.lines()), 1) }

||

this would be a lot longer with grid, which is the opposite of what im trying to achieve with it

solemn python
#

Which is a nice motivator

solemn python
hazy sinew
real hinge
native pewter
#

i have midterms

steady fog
#

hope you fail heart_red

native pewter
#

doesnt matter if i fail cause its just bonus points trolley
either way, not very nice zt

#

das y ur in da hole

steady fog
#

NO

sullen fiber
#

Part 1 was so Uiuable

#

oh part 2 is chill

#

it looked scary

sullen fiber
#

i dont like that this is arguably more concise than my uiua

delicate crane
sullen fiber
#

||or just transpose the array, by swapping x and y||

#

@solemn python are u still curious about the polynomial time alg for yesterday

real hinge
#

do you count vertical lines on part2

#

or only horizontal

sullen fiber
#

u mean like how u did in part 1

real hinge
#

so variable changing applies vertically too

sullen fiber
#

variable changing 😨

real hinge
#

whateve it is

#

okay nice

sullen fiber
#

FIRE

hazy sinew
#

rip leaderboard i guess

sullen fiber
#

thats what i did lol weird

hazy sinew
#

i mean it did work but not with my custom grid for some reason

#

i rewrote it with lists

#

and it magically started working

sullen fiber
#

ohh

#

true

hazy sinew
#

i was getting like 300 and change below correct answer

sullen fiber
#

rip grid impl

#

kotlin looks so hot

hazy sinew
sullen fiber
#

what

#

also it has non jvm targets right

hazy sinew
#

yes

sullen fiber
#

so fire

hazy sinew
#

js and umm uhh

sullen fiber
#

native i hope

hazy sinew
#

ive never met anyone that uses it

hazy sinew
sullen fiber
#

fire

hazy sinew
#

u can run kotlin in console

#

but its extremely slow

sullen fiber
#

wdym

hazy sinew
#

its super slow in console

sullen fiber
#

wdym in console

hazy sinew
#

with graalvm on jvm it competes with c

hazy sinew
sullen fiber
#

like a REPL?

hazy sinew
#

and itll open up one of those input thingies

sullen fiber
#

ah true

#

that'd make sense that a compiled language has a slow repl

hazy sinew
#

whats a repl

sullen fiber
#

read-eval-print-loop

#

aka those input thingies

hazy sinew
#

ok

#

just say input thingy its more understandable

sullen fiber
#

not

hazy sinew
#

did u know theres a function

inline fun Boolean.not() = !this
sullen fiber
#

😭

#

atleast its inline

hazy sinew
#

also theres 2 types of kotlin users

list.filter { it.isNotEmpty() }

and

list.filterNot { it.isEmpty() }
#
list.filter { it.isEmpty().not() }
sullen fiber
#

list.filter { !it.isEmpty() } better

hazy sinew
#

its been 14 days without pathfinding

#

im excited

native pewter
hazy sinew
#

why is kotlin repl so stupid

#

if u have a syntax error it just says ... and halts

native pewter
#

kotlin seems like a stupid language to repl

steady fog
#

list.filter(String::isNotEmpty) assuming it's a list of strings

sullen fiber
#

anyone else notice that it seems like it ends on day 14

#

like how its visually laid out

#

i wonder if the layout will change drastically tmr or if it just will extend

sullen fiber
#

is fire

steady fog
sullen fiber
#

minmax ur stackframes

hazy sinew
tranquil vapor
#

{} better

steady fog
#

nop

sullen fiber
tranquil vapor
#

zt loves func references in crystal

steady fog
#

yop

tranquil vapor
#

/run ```cr
puts ["zt", "banana"].map &.upcase

split heartBOT
#

Here is your cr(0.36.1) output @tranquil vapor

["ZT", "BANANA"]
tranquil vapor
#

very good

hazy sinew
#

/run

println("Hello World!")
split heartBOT
#

@hazy sinew I received kotlin(1.8.20) compile errors

file0.code.kt:1:1: error: expecting a top level declaration
println("Hello World!")
^
file0.code.kt:1:8: error: expecting a top level declaration
println("Hello World!")
       ^
file0.code.kt:1:9: error: expecting a top level declaration
println("Hello World!")
        ^
file0.code.kt:1:10: error: expecting a top level declaration
println("Hello World!")
         ^
file0.code.kt:1:22: error: expecting a top level declaration
println("Hello World!")
                     ^
file0.code.kt:1:23: error: expecting a top level declaration
println("Hello World!")
                      ^
Error: Unable to access jarfile code.jar
hazy sinew
#

/run

fun main() =
println("Hello World!")
split heartBOT
#

Here is your kotlin(1.8.20) output @hazy sinew

Hello World!
hazy sinew
#

omg it works

#

/run

fun main() = "me when".map { it.toInt() }.reduce(Int::xor).let { it * it }.toString(16)
split heartBOT
#

@hazy sinew I only received kotlin(1.8.20) error output

Error: Invalid or corrupt jarfile code.jar
hazy sinew
#

/run

fun main() = println("me when".map { it.toInt() }.reduce(Int::xor).let { it * it }.toString(16))
split heartBOT
#

@hazy sinew I only received kotlin(1.8.20) error output

Error: Unable to access jarfile code.jar
hazy sinew
#

/run

fun main() =
println("me when".map { it.toInt() }.reduce(Int::xor).let { it * it }.toString(16))
split heartBOT
#

@hazy sinew I only received kotlin(1.8.20) error output

Error: Unable to access jarfile code.jar
hazy sinew
#

stupid bot

steady fog
#

agreed

native pewter
tranquil vapor
hazy sinew
#

im trying to understand berlekamp-massey

#

wtf is he cooking

#

ok i get it

#

its not useful

real hinge
#

les goo

#

I finished day 12 part 2 too

#

ig its good

#

god now I feel relaxed

#

full gold

tranquil vapor
#

wont feel relax after dinosaur attack

real hinge
#

where will I get dinosour attack

tranquil vapor
#

🦖

#

🦕

real hinge
tranquil vapor
real hinge
#

🦖

sullen fiber
#

wow timescript is super cursed

#

@warped dust look

#

[number, ...number[]] is meh but D & {} is crazy..

warped dust
#

D & {} is just non nullable

sullen fiber
#

so

#

if u just do D, and u do new Tensor([5, 5], x => x)

#

instead of inferring from the first D, and using it for the second D

#

it cries that they arent equal

tranquil vapor
#

wtf is timescript

#

malwware

warped dust
#

TimScript

sullen fiber
#

so ig D & {} is like a "derived" type, so it actually uses the first D then

warped dust
#

fucked

sullen fiber
#

idk how it works really im just assuming cus thats how i fixed it

tranquil vapor
#

is that typescript

#

or

sullen fiber
#

yea

#

typo

real hinge
#

why is it so limited

#

its not even close to 1mb

tranquil vapor
#

LOVE

#

@real hinge

fallocate -l 1G mantika.explosion
git add mantika.explosion
git commit -m "add big explosion"
git push
real hinge
#

explode

tranquil vapor
#

run anyway

real hinge
#

vscode cloud changes

#

when I finish aoc I just store changes in cloud

#

and pull in my main computer

hazy sinew
#

so actually its not a big explosion

sullen fiber
#

@warped dust CHALLENGE

real hinge
sullen fiber
#

wait i should stop treating this thread as general chat

real hinge
#

devilbro repo alone takes more than 1gb

#

pretty sure

hazy sinew
#

yea but ur uploading 1 file

real hinge
#

for 1 file yeah possible

hazy sinew
#

obviously the linux kernel github is more than 1 gb

real hinge
#

@tranquil vapor cloning to oracle

tranquil vapor
#

NO

#

NOT ON VPS

real hinge
#

too late

hazy sinew
real hinge
#

vens vps is more useful now

tranquil vapor
#

NO

#

DONT DO THAT

#

delete

real hinge
#

never

#

time to host them

tranquil vapor
#

YES

#

WHY SHITPOOP.VENDICATED.DEV

#

why did u take the server down

real hinge
#

CADDY INSANE

#

I think it got ratelimited

#

not related my to my config issues just restart triggered it

#

I should have reloaded h

high lintel
#

gat damn

real hinge
#

I am so skilled

native pewter
#

not the shitpoop :sob

exotic meadow
#

Haven’t done a single day

#

ripsies

proper totem
#

i was keeping up then the mental health exploded before i could finish day 12

#

maybe i will catch up over the weekend

native pewter
#

been too busy after the pipes ChillBar_dizzy

tranquil vapor
#

i kinda have no motivation to do it rn

warped dust
#

gave up after day 4

steady fog
#

@warped dust return

sullen fiber
#

It's been a fun morning ritual walking to the library after waking up

#

I think imma keep doing them after waking up when I get home

#

A lot more enjoyable than doing at midnight

solemn python
#

just finished d13p2

#

only minor change to my program from last night which is nice

#

basically I was just ||not checking if a smudge for 2 specific lines matching would actually expand into a valid reflection||

#

so instead of ||returning from the iterator instantly I just stored if the current reflection in the picture was smudged and then find the one valid smudged reflection at the end after checking everything||

#

ok finished d12p2

#

holy shit ||dynamic programming|| is crazy
how is it so fast wtf

#

I was not expecting that

#

and my code is very bad too

steady fog
#

@solemn python

solemn python
#

@steady fog youre slacking on your ping duties

#

dang it

steady fog
#

@solemn python it's time

#

get ready

solemn python
#

ready for what? it to release? it already did

sullen fiber
#

Lolol

solemn python
#

wow this p1 is easy

#

im scared for p2

#

very very scared

steady fog
#

is this the last day of aoc?

delicate crane
#

there are 25 innit?

steady fog
#

why does it just stop

solemn python
#

no, see how 15 is going downwards

steady fog
#

no

sullen fiber
#

LOL

solemn python
#

I think we go back down the islands

sullen fiber
#

YHIS IS WHY

#

OMH

steady fog
#

NO MORE

sullen fiber
#

That's awesome

#

Love

steady fog
#

i need lang but ive tried everything i could think of

#

nothing esoteric

delicate crane
#

ruby?

steady fog
#

i did crystal does that count as the same

solemn python
#

have you done elixir

delicate crane
#

I guess

steady fog
delicate crane
#

nim?

solemn python
#

do it

steady fog
sullen fiber
#

This is like

delicate crane
#

raw wasm

sullen fiber
#

6 chars in Uiua

steady fog
sullen fiber
#

I might do this in my phone rn

steady fog
#

insane

solemn python
#

@steady fog@steady fog

sullen fiber
#

Today is crazy Uiuable

solemn python
#

you love disassembled rust wasm

steady fog
#

@sullen fiber forbidden from using usuaia

sullen fiber
hazy sinew
real hinge
#

today looks cancer

real hinge
#

part 2 is real bad

steady fog
#

@real hinge hi

real hinge
#

hi

hazy sinew
#

i solved it exactly when everyone else did

#

#100 is 17:15

teal mountain
#

wasted like 5 mins on part 1 wondering why my shit wasn't working bc i hard coded ||10 - i for the load lol||

hazy sinew
#

this was basically 1 trillion elephants exactly

#

for part 1 i just ||made a function that rolls rocks to the north and that was faster than everyone but 7 people ig||

solemn python
#

p1 done

hazy sinew
#

for part 2 ||made the function go in all directions made a cache and iterated through the cycles, checked the cache and if a state is repeated calculate that for 1 billion and get the remaining cycles, then just break and iterate through the remaining cycles manually||

teal mountain
#

same

sullen fiber
#

Damn my part 1 is NOT compatible

#

It would have been if I did the lazy way 😭

solemn python
#

I love a billion iterations

teal mountain
#

a trillion elephants

hazy sinew
real hinge
#

okay part1 done

#

now I have to school elved

sullen fiber
#

||Split columns into groups by #, number them, count O them mul by number||

teal mountain
#

for part 1 || i iterated column wise with a hashmap with indices of cube rocks, incrementing the highest index on round rocks||

real hinge
#

I did part1 in one try

#

I am suprized h

steady fog
#

suprized

hazy sinew
#

i just used kotlin for it ||```kotlin
grid.withIndex().sumOf { (i, row) ->
row.count { it == 'O' } * (grid.size - i)
}

steady fog
#

mantika cant spell

teal mountain
#

i'm so pissed i did part1 in basically 1 try but i hard coded some shit for the sample

steady fog
#

i have an interesting idea i wanna try

#

just need to figure out how to do it in elixir

sullen fiber
hazy sinew
#

huh

teal mountain
hazy sinew
#

lmao

sullen fiber
#

Lol rip zain

hazy sinew
#

why

#

do u not have grid.size

hazy sinew
#

wtf

#

why does that work

#

wait i thought only rocks that touched the north row directly or via other rocks should count, but i forgot to implement that and it ended up being right

steady fog
#

does elixir have a way to shorten this

#

Enum.map(fn m -> m |> String.split("") end)

#

surely theres something

#

dont feel like scouring documentation right now

sullen fiber
#

Just after they shift

hazy sinew
#

yea i get it now

sullen fiber
#

Ok gravity is a lot shorter in Uiua than my stupid group thinf

steady fog
#

ok elixir has some cool concepts

#

i kinda like this

#

@hazy sinew we need to port to kotlin

hazy sinew
hazy sinew
steady fog
#

pipe operator

solemn python
#

dang it, no bruteforcing for me :(

hazy sinew
real hinge
solemn python
sullen fiber
#

Omg today is real

steady fog
#

today is fake

#

my idea very nearly works blobcatcozy

#

wait

#

god

#

fuck

#

that wont work

#

guh

real hinge
#

I didnt look at part2 yet

steady fog
#

i was thinkling i could sort the values

#

but

#

that would also move the #

#

idk how to get around that

rustic orchid
#

maybe next year I will be able to actually do aoc

real hinge
#

Dynamic programming will get us through part 2 alhamdulillah

#

At some point it probably repeats

hazy sinew
#

1 billion actually isnt that long

#

should take about 1h40 to bruteforce in kotlin with an inefficient function

steady fog
#

guh i thought i was onto something

#

i was gonna transpose, then sort the values

#

it wouldve been so simple

sullen fiber
#

Idk how to do part 2 in a fast way

#

But I can do it in a funny way

#

Probably intended ig

real hinge
#

My guess would be try to find a point where it repeats

#

If it exists

#

Then modulo it with 1000000

#

Do the rest

solemn python
#

might just let it run for the memes

#

oh wait nvm

#

im running it on the example lol

#

hah

#

but I might let the example run for the memes :)

steady fog
#

tymonky

sullen fiber
#

Real

#

Did part 2 by hand I'm lazy I'll do it in code tmr

#

Sleep time

solemn python
steady fog
#

@solemn python how did you do part 1

solemn python
steady fog
#

@solemn python@solemn python@solemn python tell

hazy sinew
steady fog
#

how

hazy sinew
# steady fog how

My AoC repository: https://github.com/hyper-neutrino/advent-of-code
Join my Discord! https://discord.gg/j9uunTRRJm

0:00 Part 1
4:50 Part 2

Want to improve your mastery or learn a new language? Try Codecrafters, a platform where you learn by building your own project! I've always believed that learning by doing is the best way to learn to code ...

▶ Play video
steady fog
#

already?

#

fast

solemn python
#

AoC is so hard to debug and I hate it

steady fog
#

true

#

oh

#

i see how hyperneutrino did it

#

thats smart

solemn python
#

hm I think I have a better idea for my dumb direction logic

#

||what if instead of having separate logic for each direction, I just flip the board, run the north code, then flip it back||

hazy sinew
#

sorting is overcomplicated

steady fog
#

how

hazy sinew
#

or maybe not sorting but bro is talking about diagonally flipping a matrix and then inverting the columns bro just make 4 for loops and a switch case and change the row or column that ur changing

#

its better to start writing than to think about how to do it simpler

#

you should only think when your bruteforce doesnt work

steady fog
#

except i dont know the lang

hazy sinew
hazy sinew
steady fog
#

i guess

real hinge
#

see you guys in a year

steady fog
#

NO ONE SANE USES UIAIAWE

real hinge
#

memoization will kick in after a hour

#

and it will complete in seconds

#

0.002% now

sullen fiber
#

I'm sane tho

real hinge
#

wrong

sullen fiber
#

I'm super sane

hazy sinew
real hinge
#

@steady fog 0.003%

real hinge
hazy sinew
#

cause today doesnt even take that long

real hinge
#

I believe that it will repeat after some time

hazy sinew
#

2h max

steady fog
#

mantika mastery

real hinge
#

instead of just putting rocks to top

hazy sinew
real hinge
#

I move them one by one

sullen fiber
#

Manti I promise it should be much sooner

hazy sinew
sullen fiber
#

HUH

real hinge
hazy sinew
#

i didnt print for mine i just calculated the output

sullen fiber
#

For me it was 98

real hinge
#

oh my rotate function is broken

#

I should'nt have copied it

hazy sinew
#

maybe 7 is example

real hinge
#

GUHH LESSON STARTING

#

I will do later

sullen fiber
#

Example is two I think

#

Oh 7 was the length tho

hazy sinew
#

huh

#

yea

#

start is 3

#

first repeat at 10

sullen fiber
#

Ya

#

True

solemn python
#

||guh my rotations appear to work but my answer is wrong||

#

oh wait im an idiot as always

solemn python
#

I can't figure out how to best cache this

steady fog
#

tmpfs in ram formatted as zfs

solemn python
#

not what I meant

steady fog
#

too late

solemn python
#

nice one, solution

#

it really does take time to kick it in

#

anyways who cares, my solution is bad but works, I should sleep

real hinge
#

I wonder if I can optamize this

hazy sinew
#

how do rolling rocks and non rolling rocks make sense

#

if none of the rocks are attached and you tilt the plane all the rocks are gonna fall

#

you need the square rocks to be attached to the ground

#

but then it doesnt matter if theyre square

#

and it makes more sense for the rolling rocks to be square because if they get stuck on a square theyre just gonna roll to the side and continue if theyre round

native pewter
hazy sinew
#

maybe were tilting it exactly north and not part of a degree to the side

real hinge
#

my vscode suddently turned into turkish

#

why did it do that

native pewter
#

noooo

hazy sinew
#

cuz its vscode

real hinge
#

good editor

native pewter
#

my dad used to use emacs apparently

real hinge
#

you use emacs

#

horror

#

no way

native pewter
sullen fiber
#

Or Cinder blocks

hazy sinew
#

actually now that i think about it maybe all the stones are big

#

cuz i dont imagine ur gonna be tilting small rocks

#

and applying pressure

tranquil vapor
#

i was wondering why my puzzle input resulted in 0

hazy sinew
#

lmao i had that

tranquil vapor
#

brute force so slow

steady fog
#

@tranquil vapor elixir is funny

#

you will love

hazy sinew
#
fun timeskip(cycleLength: Int, startOffset: Int, totalCycles: Int) = (totalCycles - startOffset) % cycleLength
#

now i dont have to remember the formula anymore

tranquil vapor
steady fog
#

ventika so smart

tranquil vapor
#

today was easy

#

my solution takes ~10s

#

@real hinge

#

i wonder how much faster it would be if it didnt use ruby

steady fog
#

hop on crystal

tranquil vapor
steady fog
#

ven do you know elixir

tranquil vapor
#

nop

steady fog
#

guh

#

i need help

real hinge
tranquil vapor
#

two

real hinge
#

very slow eitherway blobcatcozy

#

mine takes 4

#

4.83

tranquil vapor
# tranquil vapor and tbh u can probably optimise these but im lazy

my solution:
|| rotate map in a loop and put the resulting array into a map with the loop index. after every rotation check if the array is already in the map. if yes, we have a cycle, so use index from map to calculate how many rotations until a cycle happens and break the loop

now subtract the amount of rotations done with the loop from 1000000000 and take modulo with the amount of rotations until cycle to get how many rotations are left to do, then do those rotations
||

hazy sinew
tranquil vapor
#

cause ruby so slow

tranquil vapor
#

yes

#

it has to do like 50 rotations

#

ruby slow

steady fog
#

fix

hazy sinew
#

it takes 71ms in kotlin with exactly the same method

real hinge
#

I was gonna optamize mine furthger

tranquil vapor
#

CRYSTAL SO FAST

real hinge
#

but uhhhh ureaxjsal

steady fog
#

ruby so bad

steady fog
real hinge
#

is crystal and ruby same

steady fog
#

furthger

#

mantika cant spell

tranquil vapor
#

literally same code but ruby

#

crazy how much of a difference it makes

steady fog
#

love

hazy sinew
# tranquil vapor

you probably did something that is really inefficient like read the input again every iteration

tranquil vapor
#

no

hazy sinew
#

and didnt notice

tranquil vapor
#

its the same code bro

hazy sinew
#

it shouldnt take 15s

#

ruby isnt 218 times slower than kotlin

tranquil vapor
#

i dont think ruby has jit

#

ruby might not be much slower in every day apps that do IO and stuff

#

but this is pure CPU work

#

where compiled languages are a shit ton faster

hazy sinew
#

not even starting the gradle daemon takes 15s

#

theres no way its this slow

steady fog
#

venny

tranquil vapor
# hazy sinew you probably did something that is really inefficient like read the input again ...
❯ diff solution.cr solution.rb -w
0a1,2
> require "set"
> 
87c89
<   map = File.read_lines(file).map &.chars
---
>     map = File.readlines(file, :chomp => true).map &:chars
94c96
<   map = File.read_lines(file).map &.chars
---
>     map = File.readlines(file, :chomp => true).map &:chars
96c98
<   prev_maps = {} of Array(Array(Char)) => Int32
---
>     prev_maps = {}
103c105
<     dump = map.map &.dup
---
>         dump = map.map &:dup
hazy sinew
#

i dont speak weirdly formatted ruby

tranquil vapor
#

its the diff output

#

to show that they're almost the same

hazy sinew
#

wait are ruby and crystal the same thing

steady fog
#

no

tranquil vapor
#

crystal is just ruby with types

tranquil vapor
# hazy sinew i dont speak weirdly formatted ruby

||

--- solution.rb 2023-12-14 17:54:13.123423262 +0100
+++ solution.cr 2023-12-14 17:53:11.742596153 +0100
@@ -1,5 +1,3 @@
-require "set"
-
 def tilt_north(map)
     (0...map.first.size).each do |j|
         loop do
@@ -86,23 +84,23 @@
 end
 
 def solve1(file)
-    map = File.readlines(file, :chomp => true).map &:chars
+  map = File.read_lines(file).map &.chars
     tilt_north map
 
     puts calculate_load map
 end
 
 def solve2(file)
-    map = File.readlines(file, :chomp => true).map &:chars
+  map = File.read_lines(file).map &.chars
 
-    prev_maps = {}
+  prev_maps = {} of Array(Array(Char)) => Int32
     rotations_done = 0
     cycle_happens_after = 0
 
     1000000000.times do |i|
         rotate map
 
-        dump = map.map &:dup
+    dump = map.map &.dup
         if prev_maps.has_key? dump
             rotations_done = i + 1
             cycle_happens_after = i - prev_maps[dump]

||

#

this is the only difference between the files

hazy sinew
#

so its python typescript

#

but on llvm

tranquil vapor
#

its nothing like python

#

theyre very different

hazy sinew
#

it has no semicolons and no braces so its python

tranquil vapor
#

those are very minor similarities

hazy sinew
#

i dont care

tranquil vapor
#

that's like saying javascript is c++ cause they both have classes and {}

hazy sinew
#

no because c++ has semicolons and types and js doesnt

#

i see def, no semicolons, no types, prev_maps = {} which is python syntax

#

its python

#

stop coping

#

also theres no variable declaration keyword

tranquil vapor
#

the difference is that crystal is actually good

#

while python stinks

#

anyway

#

im surprised ruby is this slow

#

ofc its gonna be slower than llvm, but 62 times? O.O

hazy sinew
#

nah not even python2 takes 15 seconds

tranquil vapor
#

when it comes to performance, Ruby tends to be slower than Python

steady fog
#

elixir captures are funny

hazy sinew
#

i thought ruby was llvm?

neon ore
#

ruby is interpreted

steady fog
#

Enum.count(&(&1 == "O"))

#

& is capture

#

like an anonymous function

real hinge
steady fog
#

&1 is first param

#

its pretty neat i think

tranquil vapor
tranquil vapor
real hinge
#

python bette

tranquil vapor
#

ruby is interpreted without jit

#

crystal has comparable performance to rust / c++

steady fog
#

crystal de crystal de

#

ven what lang should my extensible modular de be in

#

go, v, crystal

tranquil vapor
#

i enabled ruby jit and it's still 14s

steady fog
#

it must be scriptable

#

so users can add their own scripts

tranquil vapor
#

crystal

steady fog
#

can i hot load scripts into the same runtime

tranquil vapor
#

write ur own scripting engine

#

or use lua/ruby

steady fog
#

lua husk

tranquil vapor
steady fog
#

i am teh anti lua

tranquil vapor
#

linux users love lua for their configurations

steady fog
#

nop

#

awm sets bad practice

proper totem
#

lua kinda cozy

steady fog
#

badbadbad

proper totem
#

not super cozy but a tiny bit cozy

steady fog
#

@proper totem hi

proper totem
#

i wrote my first programming language in lua blobcatcozystars

#

hewo @steady fog @steady fog @steady fog

steady fog
#

hewwo

tranquil vapor
#

crystal is nicer than lua imo

#

kinda similar in a way

#

but nicer

steady fog
#

yop

proper totem
#

i want to try crystal it seems neat

#

will do once motivation comes back from negatives

#

I've done ruby for work but it was Bad ruby in a project that I just needed to patch enough to get barely working so I don't think it's a good gauge of how writing it feels

tranquil vapor
#

crystal would be so amazing if its language server was better

#

but its terrible pensive_cat

#

the fate of most lesser used languages

#

ruined by bad LSP

steady fog
#

fix

#

rewrite in ruby

tranquil vapor
#

but its really not it

proper totem
#

ruined by bad lsp or strangely bigoted leadership (or both [hello nim])

steady fog
#

nim makes me scream

proper totem
#

i did aoc in nim one year

#

i think 2021

real hinge
#

can you run ruby code with crystal

steady fog
#

momtika

tranquil vapor
#

theyre a bit different in some things

#
[1, 2].map &:to_s  # ruby
[1, 2].map &.to_s  # crystal

arr = []           # ruby
arr = [] of String # crystal
#

crystal requires you to specify type of arrays, maps, sets, etc

native pewter
#

bit weird that those annotations are required, could probably infer

#

esp on returns, you already know the type silly

tranquil vapor
#

ig they wanted to be explicit about arrays

native pewter
#

i mean i dont hate it

#

just feels off

steady fog
#

why does this comparison fail

#

Enum.count(~c"###", &(&1 === ~c"#"))

#

returns 0

#

???

#

unhusk

tranquil vapor
#

insane code

native pewter
#

mentally ale

tranquil vapor
#

zeet did u solve part 1 yet

steady fog
#

no

tranquil vapor
#

you will never solve

steady fog
#

wrong

native pewter
#

just gonna plagiarize vens

tranquil vapor
#

terror

#

my solution today was pretty good

#

pretty clean i think

real hinge
#

@tranquil vapor how is yours so fast

#

mine takes 0.98s minimum

#

do you check arrays in all directions

#

maybe its because I rotate the array and check again with same function all the time

tranquil vapor
#

wdym check

#

whats ur check

tranquil vapor
#

tbh my code isnt even vastly optimised

#

i could optimise it better

real hinge
#

rotate and do same thing

#

ig this horribly written function takes most of the cpu time

#

checking normally would be way faster but I dont wanna do that

steady fog
#

@real hinge figure out why mine doesn't detect O correctly

steady fog
#

how

real hinge
#

I put virus in your computr

steady fog
#

whyyy

real hinge
#

money

tranquil vapor
#

you create new array every time

#

that's probably why

real hinge
#

yop

tranquil vapor
#

i don't ever create new elements

#

i just change elements by index

daring marlinBOT
real hinge
real hinge
#

I do kinda same too

#

just rotating creates new array

steady fog
#

what adds those errors in the line @real hinge

solemn python
#

That's just rustc

real hinge
#

whats the difference

tranquil vapor
real hinge
#

isnt rust analyzer just language server

tranquil vapor
#

do you mean you physically rotate the array by 90°

real hinge
solemn python
#

Rustc gives the error
Rust analyzer puts it in your editor

real hinge
#

yes

solemn python