#AdVENt of Code

1 messages · Page 7 of 1

steady fog
#

@sullen fiber help

#

ok maybe i can like

sullen fiber
#

WTH

steady fog
#

parse mapping, process mapping, then go to the next

sullen fiber
#

oh yea int32 isnt enough

steady fog
#

i think crystal should do garbage collection?

delicate crane
#

mental illness

steady fog
#

@sullen fiber ok so part of it might be

#

cause im initializing the array

#

of like 481096765 elements

sullen fiber
#

how

#

what part are u on

steady fog
#

lots of memory

#

11111

#

same one

sullen fiber
#

how are u even doin gthat

#

on part 1

steady fog
#

struct Guh
getter dst_start : Int64
getter src_start : Int64
getter length : Int64

getter dst_range : Array(Int64)
getter src_range : Array(Int64)

def initialize(@dst_start, @src_start, @length)
@dst_range = (dst_start...(dst_start + length)).to_a
@src_range = (src_start...(src_start + length)).to_a
end
end

#

dst_range is an array

#

of every singkle number

sullen fiber
#

WHAT

#

WHAT IS WRONG WITH YOU

steady fog
#

idk

sullen fiber
#

WHAT IS WRONG WITH YOU

#

WHAT IS WRONHG WITH YOU

steady fog
#

it used like 40 gb

sullen fiber
#

WHAT IW SOWHT ANG

#

AWTHJ GFHN

#

WATOFGNWAOHTN

#

AWOTNHFOHWTAFNTHOWNAFGHO

#

TNWAOHNAWTOH

steady fog
#

until systemd killed it

sullen fiber
#

TWAOWTHAN

#

THNAWONTWAHTOFG

steady fog
sullen fiber
#

NOWHNATAOHEWNTG

#

OHNAWEG

#

TOHOEWATHG

#

OH

#

OAEWHTGOHE

#

OEWHTNGA

#

WEOHT

#

AOWENHAO

#

WEHTOAHGN

#

WEOHTAOGEWHOAEWHTGOEWATHG

steady fog
sullen fiber
#

end

steady fog
#

i wonder if the Range class is better

#

@sullen fiber find method on Range that lets me get value at index in the range

#

only other idea i got is doing some math

sullen fiber
#

bro literally just range.start + index

#

you will explod

steady fog
#

oh

#

so

solemn python
#

soon

delicate crane
#

in 25 seconds

steady fog
#

range.dst_range.valueOf(index)

#

I need to replace that with math

solemn python
#

chaos shall be upon us

sullen fiber
#

ur insane zt

solemn python
#

3

#

2

steady fog
#

nop

solemn python
#

1

steady fog
#

happy new year

sullen fiber
#

LOVE THIS PROBLEM

solemn python
#

this input tiny af

sullen fiber
#

yea i think the bulk is math

#

algebra sweep

real hinge
#

Todays problem seems fine after yesterdays incident

steady fog
#

the input is so tiny

real hinge
#

Zt will calculate output himself

steady fog
#

okay

harsh marsh
#

I was in the restroom when it started

#

lmfao

#

this was such a

real hinge
#

I AM WAITING FOR BUS

harsh marsh
#

different experience from day 5

#

one single quadratic

sullen fiber
#

fr

real hinge
steady fog
#

how would you get the numbers from the string as seperate numbers

#

since theyre spaced by varying spaces

#

cant do a split(" ")

harsh marsh
#

does your stdlib split not account for that

steady fog
#

idk

sullen fiber
#

in uiua its just ⊜□≠@\n.

real hinge
#

Split : take second

#

Trim

#

Split again

teal mountain
#

refreshingly easy

#

wow today is the first problem that doesn't make me wanna kill myself

harsh marsh
#

and they say middle school algebra is useless

teal mountain
#

part 2 is totally fine, no bullshit

steady fog
#

i wasnt doing quadratics in middle school

#

??

sullen fiber
#

why would i write code to do this

teal mountain
#

i don't even know what math shit y'all are talking about i threw a for loop at it and it worked 👍

teal mountain
sullen fiber
#

no like to solve the problem

delicate crane
#

I did it, just waiting on the solution

harsh marsh
#

i wrote it in python but wish I just used a calculator instead lmao

proper totem
#

my flatmate was talking to me about rust when the problem started and he wouldn't stop and i couldn't read the puzzle text cri

#

would have gotten it done so much faster

teal mountain
#

did i get extremely lucky with my puzzle input or something

proper totem
#

I just did mine with a for loop too

delicate crane
teal mountain
#

ah

#

yeah

delicate crane
#

I got it now

#

I just rewrote to use a for loop

teal mountain
teal mountain
#

"SHUT THE FUCK UP IT STARTED"

proper totem
#

he won't even do advent of code because he thinks it's too competitive

#

like ;w; sure it's nice to get on the leaderboard but it's also just fun to see how fast I can go? i don't care about the leaderboard ;w;

#

i feel like most people don't do it for the leaderboard

solemn python
#

how is the example solved correctly but not the actual input

real hinge
#

Yeah

solemn python
#

whar

real hinge
#

Tbh in this question you dont even need to parse input

#

Just hardcode kekw

sullen fiber
#

mfw i put the answer to the example and not my inpuit

#

desmos bleh

teal mountain
solemn python
#

i'm so confused

#

why am I wrong

#

IM AN IDIOT
CRISIS AVERTED

sullen fiber
teal mountain
#

wee wah

#

(ue, ue, ue)

steady fog
#

uiaiai so bad

solemn python
#

honestly part 2 is easier than part 1

#

the only thing that gave me trouble was parsing lol

steady fog
#

i got 88k milimeters

#

i think something is wrong

solemn python
#

for what

steady fog
#

par 1

solemn python
#

what

#

yeah mildly

proper totem
#

my answer was 74k for p1

solemn python
#

where did you get 88k

proper totem
#

remember you're not calculating distance for these

solemn python
#

or do you mean 88k solutions

steady fog
#

galunguh

solemn python
#

my answer for p1 is 449,820 lol

steady fog
#

how do i tie in quadratics to this

hazy sinew
#

did any of yall also use ||dfs || for part 1 and then cry in p2

solemn python
#

what is that

sullen fiber
#

||depth first search (bruteforce)||

solemn python
#

||oh yeah I just checked every button pressing time value possible and incremented a number lol||

#

||that worked for both p1 and p2||

proper totem
#

it's not brute forcing it's just applied mathematics trolley

solemn python
#

|| part 2 benchmark Average timing: 84.909324ms ± 38.073447ms ||

sullen fiber
#

time to make a large input trolley

solemn python
#

||part 1: Average timing: 1.112µs ± 2.031491ms||

steady fog
#

oh

#

i got infinity now

hazy sinew
#

i made an actual ||dfs function that adds 1 to time and speed and calls itself twice per iteration||

#

||in p2 i had to rewrite it to just filter 0..maxtime||

solemn python
#

I like your funny words magic man

hazy sinew
#

|| ``` override fun solvePart1(input: File): Any {
val (time, dist) = input.rl().map { it.split().drop(1).map { it.toInt() } }
return time.map { (0..it).filter { t -> (it - t) * t > dist[time.indexOf(it)] }.size }.product()
}

override fun solvePart2(input: File): Any {
    val (time, dist) = input.rl().map { it.extractNumbers().toLong() }
    return (0L..time).filter { (time - it) * it > dist }.size
}```||
steady fog
#

i love kotler

hazy sinew
#

why is it so unformatted

#

this is the first day ive done where ||if you wrote part 1 properly, part 2 requires you to delete code and run again||

#

i should probably stop looking at early day problems and coming up with the most mentally insane and complicated solution

solemn python
#

||yeah part 2 is so easy, if he was going for yesterday's "no more brute forcing" then he completely failed because computers are actually pretty fast||

hazy sinew
#

well he didnt fail

#

i got ||out of memory error on my dfs that solved part 1||

solemn python
#

||well any sane person shouldn't be using lists in the first place, basic loops are so much better||

steady fog
#

||hi||

solemn python
#

||just increment a number, no need to calculate size||

solemn python
hazy sinew
#

||```
fun dfs(time: Int, speed: Int, totalTime: Int): List<Int> {
if (time >= totalTime) return listOf(time, speed, totaltime)
return dfs(time+1, speed+1, totalTime) + listOf(time, speed, totaltime)
}

steady fog
hazy sinew
#

smth like this

#

extremely ugly and inefficient

hazy sinew
solemn python
#

yeah because your "increment" is a list that you count

hazy sinew
#

||

(0L..time).filter { (time - it) * it > distance }.size

||

#

for part 1 its the same but product and ||all the times||

#

kids, remember, whenever you decide to do a ||dfs that increments by 1 and only checks if the number has exceeded the bounds and do nothing else, it shouldnt be a dfs, it should be a range.filter||

#

also today is solveable with 12 clicks on a calculator

steady fog
#

nuh uh

hazy sinew
hazy sinew
# steady fog nuh uh

guy on reddit says ||Not really lol, the algebra is literally

!time, divided by 2, squared, minus distance, floor, times two, plus one!<

That's it. Six total steps to the answer - three of which are doing a calculation against a single digit, the fourth is one button, and the other two are using the inputs. If you have the input and output as pre-registered values, T and D, you can press 12 total strokes on a standard scientific calculator to get the answer.

!T/2=^(2)-D_x2+1!<||

steady fog
#

i got part 2 now

hazy sinew
sullen fiber
native pewter
hazy sinew
#

then you did it wrong

steady fog
#

square root?

real hinge
#

physics have failen me

steady fog
#

wh

real hinge
#

why does it not move while accelearting

#

anyway eas

steady fog
#

mantika cant spell

hazy sinew
#

acceleartion

#

close enough ig

hazy sinew
sullen fiber
steady fog
#

oops

#

forgor to spoiler

steady fog
#

||```js
const fs = require("node:fs");

try {
const file = fs.readFileSync("./input/day-06.txt").toString().split("\n");

console.log(Part 1: ${part1(file)} ways to win);
console.log(Part 2: ${part2(file)} ways to win);
} catch (err) {
console.error(err);
}

function part1(lines) {
const [times, distances] = lines.map((line) =>
line.split(/\s+/).slice(1).map(Number)
);

return possibilities(times, distances);
}

function part2(lines) {
const [times, distances] = lines.map((line) => [
Number(line.substring(10).split(" ").join("")),
]);

return possibilities(times, distances);
}

function possibilities(times, distances) {
return times.reduce((acc, time, i) => {
const recordDistance = distances[i];
let waysToWin = 0;

for (let heldTime = 0; heldTime <= time; heldTime++) {
  const distanceTravelled = heldTime * (time - heldTime);

  if (distanceTravelled > recordDistance) waysToWin++;
}

return waysToWin * acc;

}, 1);
}```
||

real hinge
#

it would be more harder if it accelearted while moving tho

steady fog
#

uhhh

#

idk

real hinge
#

I felt like my phycics lessons gave me something for a second

#

then realized

hazy sinew
steady fog
#

phycics

hazy sinew
#

theres prob a formula

sullen fiber
#

i was hoping it accelerated

real hinge
#

1/at^2

steady fog
#

mantushka

hazy sinew
# real hinge yes

instead of ||(maxtime - time) * speed you do (maxtime - time) * (it/2 * (it+1)) i think||

real hinge
#

yes

sullen fiber
#

i think u can do this on a calculator

hazy sinew
sullen fiber
#

the formula u gave was wrong

#

i have the correct one its how i solved

hazy sinew
#

what is it

#

apparently its just pq formula

sullen fiber
steady fog
#

square root

hazy sinew
sullen fiber
#

the bottom is notice that its wrong tho

hazy sinew
#

idk thats not my formula

sullen fiber
#

T=30 D=200 is one of the examples

hazy sinew
#

i did ||

(0L..time).filter { (time - it) * it > distance }.size

||

sullen fiber
#

ya ik i was just letting u know its not that one

hazy sinew
#

u can probably also just do a manual binary search

#

find the first number where it works and the last where it works

sullen fiber
#

yall ready for large input

real hinge
#

I thought my part 2 would take few mins

#

it took milliseconds

#

looove

#

non release is 1.56 seconds husk

sullen fiber
#

the hardest part of this large input is the damn formatting guh

steady fog
#

vap help me

#

im still on day 5

#

||```crystal
struct Guh
getter dst_start : Int64
getter src_start : Int64
getter length : Int64

getter dst_range : Array(Int64)
getter src_range : Array(Int64)

def initialize(@dst_start, @src_start, @length)
@dst_range = (dst_start...(dst_start + length)).to_a
@src_range = (src_start...(src_start + length)).to_a
end
end

def process_map(mapping, value) : Int64
mapping.each do |range|
if index = range.src_range.index(value) # check that value is in the src_range, and fetch the index it occurs at
return range.dst_range[index] # get the value at the same index in dst_range
end
end

return value
end

#

i just dont know how to rearrange it

#

im blanking

steady fog
#

yop

delicate crane
#

I always end up naming at least 3 variables some variation of fuck while writing my solutions

#

and then have to clean up after

sullen fiber
#

do

real hinge
#

part 1 or part2

sullen fiber
#

both

steady fog
#

part 3

sullen fiber
#

ill get the answers i have to write the solver

steady fog
#

how would part 2 work

#

that number is

#

incomprehensible

delicate crane
steady fog
#

float2048

sullen fiber
#

floats will not be enough

steady fog
#

@sullen fiber check ping

sullen fiber
#

wait zt im codin

steady fog
#

die

sullen fiber
#

yop

steady fog
#

get struck by lightning

solemn python
#

I decided to make my part 2 answer better
now it solves in 13.776µs with the power of MATH

#

quadratics are fun

sullen fiber
solemn python
#

is that going to fit in an f64 wtf

real hinge
sullen fiber
#

nop

steady fog
#

@real hinge

real hinge
#

I was supposed to billions

#

@steady fog

solemn python
#

sorry im not finding a decent arbitrary-precision number lib rn

proper totem
sullen fiber
#

not even close

solemn python
#

wait actually do I even need floats

proper totem
#

yea no thanks ;w;

real hinge
#

okay found

#

answer is 0

solemn python
#

but yeah im not doing bigints, you can cope

#

I need to sleep

proper totem
#

to make today's non brute forceable you only need to add like three races of the normal size anyways

real hinge
#

if outcome count is 0

#

part1 becomes 0

proper totem
#

just adding two makes my brute force take over 30 minutes (estimated based on runtimes from other tests)

steady fog
#

oh

#

wtf

#

i solved day 5 part 1 in less than a second

#

how did others get like minute long times

proper totem
#

depends how you implemented it

real hinge
steady fog
#

i made mine go lazily

proper totem
#

oh just part one

delicate crane
steady fog
#

yes

proper totem
#

yeah part one isn't hard

real hinge
#

i256?

sullen fiber
#

yea thats the right answer

delicate crane
real hinge
#

WHY AM I GETING 0

sullen fiber
#

part 2 will be fun

proper totem
#

vap unsane

sullen fiber
#

so sane

delicate crane
real hinge
#

what is the outcome count for 7509 9731106

sullen fiber
#

part 2 i need to make sure im doing the math without rounding errors

real hinge
#

nvm

sullen fiber
#

4178

delicate crane
#

WSL is taking 4 gb of ram

hazy sinew
real hinge
#

I somehow broke my part1 code while writing part2

delicate crane
hazy sinew
#

someone try it

sullen fiber
#

wdym

hazy sinew
#

run it

sullen fiber
#

part1 or two

hazy sinew
#

both

sullen fiber
#

i dont have 2 yet

hazy sinew
#

it should work for both

sullen fiber
#

part 1 is 1489058314105824

hazy sinew
#

are there any 0s

sullen fiber
#

if there were it would have zerod the whole accumulator i think

#

u just need one in there thats

#

time^2 / 4

#

or more

hazy sinew
#

o yea

real hinge
#

VAP

#

YOUR CODE IS BROKEN

#

IT WORKS IN REGULAR INPUT

#

IT GIVES 0 IN YOURS

sullen fiber
#

whats regular input

real hinge
#

aoc input

sullen fiber
#

mine works on regular input too what now

#

one of us is broken

delicate crane
hazy sinew
#

@real hinge run my input

sullen fiber
#

that was for eagely's input

real hinge
#

wait

delicate crane
real hinge
#

1742517216

#

why mines are so small

#

oh wait

#

its i32

delicate crane
hazy sinew
#

p2?

real hinge
#

1489058314105824 this is on i128

#

I would try part 2

#

but I hardcoded values

#

because was too lazy to parse

#

imma do parsing

sullen fiber
#

your part 2 requires more than float64 for me

delicate crane
#

"please do not spam"

sullen fiber
#

manti are u doing math on int

real hinge
stiff raptorBOT
sullen fiber
#

you're probably getting rounding errors

real hinge
#

why would part2 require float tho

#

isnt it integer

sullen fiber
#

if ur doing stuff like sqrt

#

div2

real hinge
#

huh

#

nop

sullen fiber
#

oh ok

#

also if ur doing i128

#

on hte large input

#

maybe overflow?

steady fog
#

guh

#

how am i even gonna do part 2

#

day 5

#

@sullen fiber@sullen fiber

sullen fiber
#

true

#

how will you

steady fog
#

||```crystal
file_content = File.read("./input/day-05.txt").lines

seeds = file_content[0].lchop("seeds: ").split(" ").map { |seed| seed.to_i64 }

seed_to_soil_index = file_content.index("seed-to-soil map:").not_nil!
soil_to_fertilizer_index = file_content.index("soil-to-fertilizer map:").not_nil!
fertilizer_to_water_index = file_content.index("fertilizer-to-water map:").not_nil!
water_to_light_index = file_content.index("water-to-light map:").not_nil!
light_to_temperature_index = file_content.index("light-to-temperature map:").not_nil!
temperature_to_humidity_index = file_content.index("temperature-to-humidity map:").not_nil!
humidity_to_location_index = file_content.index("humidity-to-location map:").not_nil!

struct Guh
getter dst_start : Int64
getter src_start : Int64
getter length : Int64

def initialize(@dst_start, @src_start, @length)
end
end

def process_map(mapping, value) : Int64
mapping.each do |range|
index = value - range.src_start
if index >= 0 && index < range.length
return range.dst_start + (value - range.src_start)
end
end

return value
end

def process_seeds(text, start_index, end_index = nil, values : Array(Int64) = [] of Int64)
values.map do |value|
mapping = if end_index
text[start_index + 1..end_index - 2]
else
text[start_index + 1...]
end

mapping = mapping.map { |line|
  dst_start, src_start, len = line.split(" ")
  Guh.new(dst_start.to_i64, src_start.to_i64, len.to_i64)
}

process_map(mapping, value)

end
end

m = process_seeds(file_content, seed_to_soil_index, soil_to_fertilizer_index, seeds)
m = process_seeds(file_content, soil_to_fertilizer_index, fertilizer_to_water_index, m)
m = process_seeds(file_content, fertilizer_to_water_index, water_to_light_index, m)
m = process_seeds(file_content, water_to_light_index, light_to_temperature_index, m)
m = process_seeds(file_content, light_to_temperature_index, temperature_to_humidity_index, m)
m = process_seeds(file_content, temperature_to_humidity_index, humidity_to_location_index, m)
m = process_seeds(file_content, humidity_to_location_index, nil, m)

puts "Part 1: #{m.min}"

#

part 1 works

sullen fiber
#

bruteforce time

steady fog
#

nop

#

i was thinking just

#

modifying seeds array

#

flattening the ranges into it

real hinge
#

I cant parse

#

for part2

steady fog
#

but thats way too much memory

real hinge
#

it overflows i128 💀 💀 💀

#

lets try u128

sullen fiber
#

the answer to part1 is 11645 bits

real hinge
#

HOW CAN I PARSE THIS

steady fog
#

p2_seeds = seeds.in_slices_of(2).flat_map { |(start, len)| (start...(len - 1)).to_a }

#

guhhh i explode soon

sullen fiber
#

the part2 distance is 22909 bits

steady fog
#

its at 15 gb of memory usage

real hinge
#

okay I think this is unrealistic with static typed langauge

#

I was gonna try u64x64 but weird stuff

steady fog
#

maybe if it can stay low enough i can do it

#

itll just be really inefficient

real hinge
steady fog
#

its just holding at 15 gb

real hinge
#

you are trying part2

#

with arrays

#

its impossible dont even try

steady fog
#

ill buy more ram

#

i have 2 free slots

real hinge
#

IT WONT BE ENOUGH

steady fog
#

wrong

real hinge
#

YOU NEED PETABYTES OF RAM

steady fog
#

i can do it

#

guh make this as a gpu shader @real hinge that runs in parallel

sullen fiber
#

wait i know a programming language that can do this easy

real hinge
#

someone made dthat

#

part 2 in cuda

steady fog
#

@sullen fiber help me

#

NOW

sullen fiber
#

one sec ill get the part 2 answer in 2 seconds

steady fog
#

part 1 worked causes seeds array was small

#

maybe i could make this parallel?

#

process 1 range on one thread, another on another thread?

real hinge
#

why did discord change thread icon to this

#

why did they do that

steady fog
#

read

#

im gonna let my program run over night

#

its at 15 gb of memory

sullen fiber
#

ok here is part 2

#

now just to figure out how to avoid rounding errors

#

in js

delicate crane
#

what datatype did you use?

sullen fiber
#

bigint

#

im anticipating that there will be an issue when trying to square root a bigint

#

and then doing more math on that

#

will accumulate a rounding error

#

wait

#

smh i have idea

proper totem
#

i will simply not bother with mega large inputs trolley

sullen fiber
#

its so fun

#

wait can u send ur day 2 generator btw

#

or what day was it i frogor

proper totem
#

it was 2 yeah

sullen fiber
#

ur on the repo if u wanted to just add it

proper totem
#

i will adapt it to match what you have in there

sullen fiber
#

whats funny is im reading crystal's square root implementation actually

#

oo okok

proper totem
#

it is funny my input generator takes longer to run than my solution for that day

sullen fiber
#

i hope its not too confusing

proper totem
#

nop i took a quick look a bit ago and it didn't seem too bad

sullen fiber
#

real fire

proper totem
#

nvm horror code worst ever

#

blocked and reported

sullen fiber
#

WHERE DID I VAR

proper totem
#

where u copied from stack overflow

#

(the array shuffle)

sullen fiber
#

oh no i copied that from my curve25519 thing

#

its like that for performance reasons

steady fog
#

I'm trying to think of what I need to change to do part 2

proper totem
#

o i c

sullen fiber
#

cus let/const in intensive loops will make gc cry

steady fog
#

Im gonna have to drop that m array aren't i

proper totem
#

understandable

sullen fiber
#

guh i need to publish ec25519 npm package

#

soon tm

#

this is the key

steady fog
#

so I think what I should do is instead of doing all the seeds together I should do them separately, update the min value

#

and I can use parallelism to make that much faster

#

by doing seeds on different threads

#

or one range for a thread

sullen fiber
#

true

#

you wil

steady fog
#

yop

#

tomorrow

sullen fiber
#

rwae;

steady fog
sullen fiber
#

Because of a bug in the day 6 puzzle that made it unsolvable for some users until about two hours after unlock, day 6 is worth no points.

#

fire

#

wait im looking at the wrong year

#

LOL

proper totem
#

unfortunately: no tsconfig

steady fog
#

fix

sullen fiber
#

true

#

do u wanna add it

proper totem
#

also do you care about pull requests or can I just commit and push

sullen fiber
#

here i'll make a smol tsconfig

#

u can just push

proper totem
#

smol works too

#

two different kinds of slightly lazy

#

me: make someone else do work that I could have done
you: do the bare minimum but in the end better

sullen fiber
#

ok tsconfig pushed

#

true true

real hinge
#

z

sullen fiber
#

im big lazy

steady fog
real hinge
#

@rain bloom do aocccc

#

today is sooooo easy

real hinge
steady fog
#

@real hinge I left my AOC running

#

it will be done when I wake up

real hinge
#

I TOLD YOU

#

ITS IMPOSSIBLE

steady fog
#

wrong

real hinge
#

THERES AT LEAST 100 MILLION ENTRIES THERE

sullen fiber
#

are u running it in release mode

steady fog
#

I have enough ram

real hinge
#

and in some cases people ahve 1 billion

#

you shouldnt use array

steady fog
#

never

real hinge
#

HOW ARE YOU GONNA STORE 1 BILLION INT64S

somber smelt
#

i was gonna do aoc this year but man

steady fog
#

wait

#

what if I use swap space

#

that'll be funny

real hinge
#

okay so you need 8 billion bytes

somber smelt
#

day 3 killed my motivation and i heard day 4, 5, and 6 were just as ugh

steady fog
#

I have enough storage too

sullen fiber
#

6 is not ugh i dont think

real hinge
#

7.4506 GB

steady fog
#

mantika I have a network swap device on your computer

real hinge
#

you need that much memory

steady fog
#

I have that

real hinge
#

wait is 7.4 7,4 or 7400 gb

#

wait I think 8 gigabytes

steady fog
#

you are so bad

real hinge
#

well not you need to convert 5 times

#

consdiering you have 5 arrays

steady fog
#

I made mine do it in levels

real hinge
#

if you have 5 40gb

#

also dynamic arrays overallocate

real hinge
steady fog
#

there should only be two arrays at a time

#

@real hinge

real hinge
#

wrong

#

gordon was just determined

steady fog
#

could you do it

real hinge
#

yes

steady fog
#

save rusher

real hinge
#

I will

#

guh teacher was explaining how to make prime number findng algorithm since last 20 minutes

#

soooooooooooooo boring

real hinge
#

WHY WOULD I

#

I am doing weird aoc problems then theres prime number finding algorithm

real hinge
real hinge
#

you dont even need

native pewter
real hinge
#

at worst you can just loop from 0..number and check if its divisible by any number

real hinge
native pewter
#

me? no

#

its 8am bestie

steady fog
#

@delicate crane hi

real hinge
#

good morning

delicate crane
sullen fiber
#

one day you will need to generate a 4096bit prime number truist

real hinge
#

yop

#

idk how more efficent you could do it

#

you need to check if its divisible by any prime numebrs

#

but finding those is the problem

sullen fiber
#

using a sieve

real hinge
#

sieve?

#

like ex nihilo

#

holy sht minecraft referaence

#

okay so

#

isnt sieve basically the same

#

you remove prime numbers

sullen fiber
real hinge
#

2,3,5

sullen fiber
#

sieve is like

steady fog
#

project ozone

sullen fiber
#

u remove all multiples of an integer

real hinge
sullen fiber
#

and do this for all possible factors

steady fog
#

@real hinge guh we need to play modded Minecraft

real hinge
#

and those integers are prime numbersss

sullen fiber
#

ya

steady fog
#

@real hinge give me biggest prime number

sullen fiber
#

and then return all the ones that werent filtered out the primes

real hinge
#

I think if you are trying to see if single number is prime checking all is the easiest

#

but for multiple in range sieve is lovely yop

real hinge
sullen fiber
#

there are better probabilistic tests for chekcing if a single number is prime

#

deterministically checking is super hard yea

steady fog
#

@real hinge modded Minecraft when

real hinge
#

2022

sullen fiber
#

but there are algorithms for checking if a massive number is prime with like easy 99.99999% certainty

hazy sinew
#

for either part

sullen fiber
#

miller-rabin prime test

#

my love

hazy sinew
#

eagely prime test

sullen fiber
#

TRUE

hazy sinew
#

just check if its odd

#

50% certainty

sullen fiber
#

TRUE

hazy sinew
#

either prime or not

sullen fiber
#

WRONG

real hinge
#

THIS IS WEIRD

#

WHAT IS THAT

real hinge
steady fog
real hinge
#

thing is the more numbers are getting bigger the less prime numbers there are

#

I think

sullen fiber
#

thats like

real hinge
#

not sure

sullen fiber
#

bleh

real hinge
#

its probably like hta

sullen fiber
#

notation

#

nevermind im not writing it out

real hinge
sullen fiber
#

that symbol next to p means the number being prime

#

pr means probability

#

the operator on the left of P is NOT

#

MRk is the number passing the miller rabin test after k iterations

real hinge
#

oh

#

I didnt got t

sullen fiber
#

and conditional probabilities make me wanna kill myself

hazy sinew
#

this is the fastest prime checker in existence

hazy sinew
sullen fiber
#

we must stop notating

native pewter
#

:3

sullen fiber
#

NOT A PRIME NUMBER

native pewter
#

wdym

sullen fiber
#

FAKE

#

1 not prime sowwy

native pewter
#

oh rly

sullen fiber
#

ya primes start at 2

native pewter
#

guh

sullen fiber
#

owned

real hinge
#

how many ms

#

53982894593057

#

check this

sullen fiber
#

not REAL

steady fog
#

mk-mantika leaked documents

warped dust
#
enum Maybe {
    Definitely,
    Perchance,
    InnocentUntilProvenGuilty,
}
#

return this

steady fog
#

rini will be crucified

sullen fiber
#

peorchance

#

guys my part 2

#

is 2 off

hazy sinew
sullen fiber
#

wait no

#

its 2 off

#

😭

hazy sinew
hazy sinew
sullen fiber
#

no thats my input

warped dust
#

i actually forgot aoc already started today

#

its joever

hazy sinew
sullen fiber
real hinge
#

0.052

hazy sinew
sullen fiber
#

are u asking me to put zeros in there

real hinge
#

222334565193649

sullen fiber
#

or are u asking if its possible for there to be a zero

real hinge
#

if this simple loop is only using 0.272 seconds itsfine imo

hazy sinew
hazy sinew
sullen fiber
#

nah

hazy sinew
#

how did u gen it

sullen fiber
#

my "Distance is too close to max distance" check

hazy sinew
sullen fiber
#

nah thats cheating

real hinge
#

RUST DOESNT HAVE MORE THAN 128 BIT

sullen fiber
#

it has bytes

hazy sinew
sullen fiber
#

decode it into a [u8]

#

do math on the [u8]

sullen fiber
#

wdym

hazy sinew
#

do i have to use biginteger

#

to compute it

#

is there any number above Long.MAX_VALUE

sullen fiber
#

what is 5?

hazy sinew
#

the large input for 5

sullen fiber
#

ohh

hazy sinew
#

is that correct

sullen fiber
#

no they're all uint32s

hazy sinew
#

nice

#

why is the answer so low

sullen fiber
#

uh random

#

its like 440k

hazy sinew
#

and why tf does part 2 take less time than p1

hazy sinew
#

is my answer wrong

sullen fiber
#

wait i might be smoking let me check

real hinge
#

I found bigint library

hazy sinew
#

im not even merging the ranges in p2

real hinge
#

BUT HOW DO I PUT THE THING

sullen fiber
#

ur part1 is right

real hinge
#

cant even parse

hazy sinew
#

its just faster

sullen fiber
#

i think ur part2 is wrong

hazy sinew
#

is there some edge case that isnt there in my input

#

cuz its all LongRange

sullen fiber
#

uh i can reverse the mappings and tell you the seed that corresponds to the answer

#

if that helps

hazy sinew
#

ok ill put it through p1

real hinge
#

okay we are gaming

#

and its not priem

#

easy

hazy sinew
#

why doesnt it return when finding a match

real hinge
#

because it would finish in 2 microseconds

hazy sinew
#

ok so

real hinge
#

its at 19 million

hazy sinew
#

why is there no infinite precision bigint

sullen fiber
real hinge
real hinge
#

static typing

#

but I wish it had 256 and 512 bit numbers

sullen fiber
#

u can have bigint with static typing

#

its just dynamic allocation

#

like a vec

hazy sinew
#

ocr this

sullen fiber
#

NO

hazy sinew
#

441394

#

so my p2 is wrong

#

lol

sullen fiber
#

F

hazy sinew
#

i mean it solves aoc input so im not debugging it

sullen fiber
#

oh true true

hazy sinew
real hinge
real hinge
#

And I escaped

#

No longer on pc

sullen fiber
#

i mean not really people have made libraries for it already

#

its just not in stdlib

hazy sinew
#

you just gotta reinvent math

real hinge
#

Hmm

#

Nice

hazy sinew
#

represent it as a string or smth

sullen fiber
#

nah you would just represent it as bytes

#

and do math on the bytes

real hinge
#

Technically for addition you can put it in half

#

And add to 2 different numbees

sullen fiber
#

you could do it as a string tho it would just be horror

real hinge
#

And same for loooimg probably

sullen fiber
#

it was horror indeed

hazy sinew
#

java.math.biginteger stores it as an array

sullen fiber
#

java based

hazy sinew
#

so its actually quite limited

sullen fiber
#

how so

hazy sinew
#

cuz you can store way more numbers as a string

#

and storing millions of digits in an array is gonna oom

sullen fiber
#

do they store each digit?

#

im sure they store like chunks of bytes

#

instead of doing it in base10

hazy sinew
#

stores it in base 65536

sullen fiber
#

yea surely thats much better than trying to do math on base 10 digits that take up way too m uch space for each digit

hazy sinew
#

least sig bit first

sullen fiber
#

little endian moment

#

LE = liquid emeralds

#

actually

hazy sinew
#

so 5000000000 is represented as 1 on index 1 and
705032704 on index 0

proper totem
#

vap
storing the large input for day02 in a string may not be an amazing idea unless I shrink the large input a considerable amount

sullen fiber
#

its like 82mb right

proper totem
#

there are a lot of allocations

#

yeah

sullen fiber
#

thats not so bad

proper totem
#

hm well

#

I will see how long it takes to run

#

it's going on a minute or two already

hazy sinew
sullen fiber
#

she made a generator

#

shes trying to put it in the repo

hazy sinew
#

ok

sullen fiber
#

but DAYUM

proper totem
#

here go

hazy sinew
#

77mb???

proper totem
#

yop

#

1 mil games

#

my final solution for the day got this performance

sullen fiber
#

FIRE

hazy sinew
#

ran instantly for me

#

is it correct

proper totem
#

no

#

474402212 214379527

#

er

#

looked at wrong number

#

i have small brain sometimes

hazy sinew
proper totem
#

it is

hazy sinew
#

3.1ms

#

lmao

#

asm moment

sullen fiber
#

92ms

#

thats just the margin of error

hazy sinew
#

it says user 86,4

sullen fiber
#

still blazingly fast 🚀 🚀 🚀 🚀

hazy sinew
#

lemme run it 10 times

sullen fiber
#

get hyperfine

#

trust

proper totem
#

someone more familiar with x86 could probably find some magic opcodes to make it even faster but I'm probably pushing it close to the limit

#

(at least I hope I am)

sullen fiber
#

they will use the xmm simd parallel instructions

proper totem
#

horror

#

SIMD is neat but also difficult for me to wrap my head around sometimes

steady fog
#

@proper totem solve AOC using an attiny85 and 7 segment displays

sullen fiber
#

can u push ur code i wanna add the ability for generators to be streamed to files

proper totem
#

okis

sullen fiber
hazy sinew
#

why does it say 20s

steady fog
#

goodnight friends

proper totem
#

it does work for the example and normal inputs so i do know it works

#

large just explods

sullen fiber
#

NINI ZT

hazy sinew
proper totem
#

sleep goods

hazy sinew
#

it takes 3s

sullen fiber
#

large so tiny

sullen fiber
#

oh cus gradle overhead

hazy sinew
#

does it have to start a daemon itself

sullen fiber
#

its measuring the time of the whole command

#

like 30 times

#

but u prob just one the time of ur part 2logic

#

so hyperfine prob lame for this

hazy sinew
#

i guess i have to install kotlin in cli

proper totem
#

guh it cloned with https

#

pushed now

sullen fiber
#

HTTPS

proper totem
#

http git so bad ssh better

hazy sinew
#

i leaked my ssid

proper totem
#

my initial generator was a lot larger since I guh I forgot to stage changes from index too

hazy sinew
#

all my dependencies are in gradle

#

hyperfine so bad

proper totem
#

@sullen fiber you'll need to add the imports for 02 to index but otherwise stuff should work ish

#

I promise I'm not this bad usually my brain must just be very tired

sullen fiber
#

what nah this is good

hazy sinew
#

we should make a large input for 2022 day 24

sullen fiber
#

how did u redo the round before

hazy sinew
#

like 1mil x 1mil grid

proper totem
#

just round--; continue which would just get new random numbers

sullen fiber
#

oh true

proper totem
#

since I was using Math.random

hazy sinew
#

or is almost every line false because theres so many chances for it to be false

proper totem
#

auto imports are bad

#

I need to get jetbrains to stop auto importing process

sullen fiber
#

lol yea wth

#

oh wow thats tiny

hazy sinew
#

is ur input gen only ts

sullen fiber
#

ya

hazy sinew
#

should i generate a day 3

#

eh too much work

sullen fiber
#

u can

#

i rly wanan generate day 4

hazy sinew
#

ill do day 4

#

but in kt

proper totem
#

okay slight issue

#

change the default large input game count to 100k instead of a mil

#

I must have gotten numbers mixed up because 1 mil generates a 774mb file

sullen fiber
#

OH LMAO

#

that makes so much sense

proper totem
#

time to see how long this one takes to run

sullen fiber
#

for me 100k total games only generates 78mb file

proper totem
#

that makes more sense

#

that's close to how big the file I uploaded here was

#

most sane executable

sullen fiber
#

OHH

#

ur saying

#

u sent a 100k gamefile

#

originally

proper totem
#

yeah

sullen fiber
#

oh okok true true

sullen fiber
#

ok imma add round redos

#

and commit

proper totem
hazy sinew
#

code done

#

gonna take a few mins

sullen fiber
#

oh god this happens a lot

proper totem
#

i must generate an 8gb input file

sullen fiber
#

FEAR

hazy sinew
#

i made it pretty likely that there will be matching numbers, and didnt check for duplicate numbers

#

pretty likely so that there is a u64 overflow

#

i made it append to the output every 1 million games

#

and run for 100 million iterations

#

1 billion actually

#

but it takes like 5 minutes for 1mil iterations

#

cuz it has to compute 60 random numbers for each game

#

Game 70000: [67, 21, 31, 22, 38] | [1, 17, 22, 43, 38, 32, 39, 70, 61, 64, 18, 3, 31, 30, 94, 30, 11, 21, 85, 42, 23, 4, 60, 28, 31]

hazy sinew
#

wait why are there braces

#

fuck

#

Game 10000: 80 59 22 68 9 | 71 10 51 29 59 2 27 86 2 52 59 17 46 50 69 3 79 59 25 92 62 99 17 92 84

#

there can also be duplicate winning numbers

#

but that shouldnt matter anyways

sullen fiber
#

@proper totem can u

#

run ur code on the 02/input_large.txt from the repo

#

i wanna know if my uiua code is still right

#

it was right before but just in case

hazy sinew
#

it will be 99gb after its done running

proper totem
#

yop just a minute

sullen fiber
hazy sinew
#

167 hours

#

more actually

#

like 10 days

#

ill stop at a few million

proper totem
#

mmmmm

#

my asm solution segfaults which probably means we have a formatting issue of some kind

sullen fiber
#

GRRRR

#

does ur asm expect final newline

proper totem
#

oh maybe

#

let me edit

sullen fiber
#

i hope

proper totem
#

still segfaults with trailing newline

sullen fiber
#

TEWRGADFHJ

proper totem
#

I will inspect

#

perhaps add an fprint or two

sullen fiber
#

ty

hazy sinew
#

12 minutes later im at 250k

#

1 bil is gonna take 1.5 months

#

at this pace

sullen fiber
#

what are u goidng'

proper totem
#

I love debug prints in assembly

sullen fiber
#

are u doing the day 4 things

#

with a billion cards?

sullen fiber
hazy sinew
#

shit wait

sullen fiber
#

thank u for ur efforts katlyn

hazy sinew
#

im overwriting the output file every 1mil

#

whatever im gonna stop after 1m anyways

sullen fiber
#

INSANE

proper totem
#

okay it works

#

there were two newlines at the end of the file apparently

#

which mega exploded the assembly

#

general formatting does work though so no issues

#

here is the answers I get for large input @sullen fiber

sullen fiber
#

oh YAY

#

YAY AYAY AY AY

#

TY

hazy sinew
#

1/3RD DONE

sullen fiber
#

@hazy sinew @proper totem how many cards does yalls input got on day4

proper totem
#

192

sullen fiber
#

i see okok

hazy sinew
#

197 i think

proper totem
#

pro tip: trying to link an 8 GB executable may cause your computer to struggle with memory usage

#

another pro tip: gcc will just die if you try to link an 8GB executable

#

I will try half the inputs

sullen fiber
#

LOL

proper totem
#

most games I will bother trying right now is 2.5 million or roughly 1.9GB of games