#AdVENt of Code

1 messages · Page 8 of 1

proper totem
#

could make it handle larger inputs with file reads but I don't want to deal with syscalls

#

anyways beb time probably

tranquil vapor
#

did u test mine on it

#

i wanna know if it works

#

well ill just do it myself soooon

sullen fiber
#

i downloaded it but it was not windows

tranquil vapor
#

ohhh yeah lol

#

linux

#

don't u have wsl

sullen fiber
#

and guh wsl i dont wanna install it agin

#

i deleted cus its so huge

tranquil vapor
#

xd fair

#

i just dual boot

sullen fiber
#

ya i was gonna but faulty ssd

hazy sinew
#

still faster than my original day 5 part 2

real hinge
#

I will nuke discord

#

wth is thi ugly icons

real hinge
#

vscode remote beloved

#

what if we hosted code-server on your vps

#

in different account ofc

proper totem
#

vap I will write a readme for the large repo tomorrow if you have not by then

sullen fiber
#

omg real

hazy sinew
#

halfway

#

just another 50 minutes

proper totem
#

do you care about me sharing the repo with other people yet or should I wait

sullen fiber
#

nah u can share

hazy sinew
#

make it multilang

#

so i can put my kt there

sullen fiber
#

but imma wait to do so til i do day 3

#

nop kotlin virus

hazy sinew
#
        var output = ""
        for (i in 1..1000000000) {
            val winningNumbers = listOf((Math.random()*110 % 99 + 1 ).toInt(), (Math.random()*110 % 99 +1 ).toInt(), (Math.random()*110 % 99 +1 ).toInt(), (Math.random()*110 % 99 +1 ).toInt(), (Math.random()*110 % 99 +1 ).toInt())
            var myNumbers = mutableListOf<Int>()
            repeat(25) {
                myNumbers.add((Math.random()*110 % 99 +1 ).toInt())
            }
            repeat(15) {
                if (Math.random() < 0.25)
                    myNumbers[(Math.random() * 30 % 25).toInt()] = winningNumbers[(Math.random() * 30 % 5).toInt()]
            }
            output += "Game $i: ${winningNumbers.joinToString(" ")} | ${myNumbers.joinToString(" ")}\n"
            if(i % 10000 == 0) "Game $i: ${winningNumbers.joinToString(" ")} | ${myNumbers.joinToString(" ")}\n".println()
            if(i % 1000000000 == 0) File("out.txt").writeText(output)
        }
proper totem
#

alright gn everyone have a good day

hazy sinew
sullen fiber
#

damn generating day 4 is

#

hard

#

to do normal size

#

i might have to do it smartly

#

oo raising my random seed to the 3rd power seems to work good

real hinge
#

I wonder if theres reverse regex

real hinge
#

you give variables that will go into groups

#

and it generates text

tranquil vapor
real hinge
#

oh

#

lmao

real hinge
tranquil vapor
ornate nexus
real hinge
#

@tranquil vapor this will be ur vps soon

tranquil vapor
#

NO

real hinge
#

yopp

tranquil vapor
#

I'M SCARED OF YOU RUNNING CODE SERVER ON MY VPS

real hinge
#

its not in your server

tranquil vapor
#

cause it makes it too easy for you to run your brute force 20gb ram solutions on my vps

real hinge
#

yet

hazy sinew
#

why is my code taking so long

#

is math.random really that inefficient

real hinge
#

I am sane

hazy sinew
#

maybe i should pre generated all possible permutations

tranquil vapor
hazy sinew
#

its been an hour and im at 550k

real hinge
#

imagine needing math.random

hazy sinew
#

60 random numbers every iteration

real hinge
#

while you can just read some random memory adress

sullen fiber
#

if u think ur math.random is making ur generator slow

tranquil vapor
sullen fiber
#

imagine how my sha256 random is slowing mine

tranquil vapor
#

i calculated that it would take many years to finish

tranquil vapor
real hinge
#

my python math solution

hazy sinew
#
        var output = ""
        for (i in 1..1000000000) {
            val winningNumbers = listOf((Math.random()*110 % 99 + 1 ).toInt(), (Math.random()*110 % 99 +1 ).toInt(), (Math.random()*110 % 99 +1 ).toInt(), (Math.random()*110 % 99 +1 ).toInt(), (Math.random()*110 % 99 +1 ).toInt())
            var myNumbers = mutableListOf<Int>()
            repeat(25) {
                myNumbers.add((Math.random()*110 % 99 +1 ).toInt())
            }
            repeat(15) {
                if (Math.random() < 0.25)
                    myNumbers[(Math.random() * 30 % 25).toInt()] = winningNumbers[(Math.random() * 30 % 5).toInt()]
            }
            output += "Game $i: ${winningNumbers.joinToString(" ")} | ${myNumbers.joinToString(" ")}\n"
            if(i % 10000 == 0) "Game $i: ${winningNumbers.joinToString(" ")} | ${myNumbers.joinToString(" ")}\n".println()
            if(i % 1000000000 == 0) File("out.txt").writeText(output)
        }
native pewter
real hinge
#

how could I know I needed to divide it by multiplcation of all prime numbers

#

I just let it calculate 512+ bit numebrs

tranquil vapor
#

i forgot, was that day 11?

sullen fiber
tranquil vapor
#

where you had to calculate the monkey stuff

#

and modulo to keep the number sane

real hinge
sullen fiber
#

who can run a large day 4

real hinge
#

yeah 11

#

I remember using python because I could do eval trolley instead of parsing

tranquil vapor
sullen fiber
#

scratch cards

#

that win otehr scratch cards

tranquil vapor
real hinge
#

just make 1000 games

tranquil vapor
#

it's ruby but it shouldn't be too slow

sullen fiber
#

cards?

tranquil vapor
#

i will get on my pc in 30 mins or so then I can try

real hinge
#

will try

sullen fiber
#

ok i forgot to not be stupid so let this generate for another 3 minutes

#

oh god its so slow to generate

real hinge
#

make a fast one

#

I have 18% battery left

#

be fast

sullen fiber
#

i did but its just like

#

the same size as the normal one

hazy sinew
#

i restarted it

#

gonna do it the faster way

#

in iterations of 100000

real hinge
#

@sullen fiber I just had a idea

#

just reuse same games

sullen fiber
#

WAHT

#

FAKE

#

FAKE

#

FAKE

real hinge
#

8300 line took 10 seconds

#

wait I will remove unneccesary prints

sullen fiber
#

yea if u reuse same games it would be like instant

real hinge
#

why tho

#

I dont get how release mode is so fast

#

under 1 second

tranquil vapor
#

reusing games shouldn't really matter (as long as you don't cheat and make ur code optimise by caching results lol)

tranquil vapor
real hinge
#

I do not

#

rust

#

I also dnot even use game ids

#

just index trolley

sullen fiber
#

ur right i just prefer that it isnt a possible avenue

#

since im putting it in a repo

hazy sinew
#

reusing games doesnt count

real hinge
#

few thausand line output

#

1 min 16 sec on 83k line

#

hm

tranquil vapor
#

im gonna try ur inputs now

real hinge
#

tbh it looks linear

#

just reuse trol

#

0.055 s on 198 game

hazy sinew
real hinge
#

4

hazy sinew
#

almost done generating

sullen fiber
#

LOL this is particularly large

real hinge
#

send

#

12% charge

sullen fiber
#

my upload so bad

real hinge
#

FAST

hazy sinew
#

how large

sullen fiber
#

115mb

real hinge
#

WHAT

tranquil vapor
#

are u sure u followed the contract

sullen fiber
#

the contract?

hazy sinew
sullen fiber
tranquil vapor
#

the puzzle specifically said nothing will be out of bounds

sullen fiber
#

wdym

tranquil vapor
#

oh wait

real hinge
#

HOW DO I DOWNLOAD THAT

hazy sinew
#

why did u make it so stupid

tranquil vapor
#

im dumb

sullen fiber
#

put it in quotes

hazy sinew
#

why does it have so many winning numbers

tranquil vapor
#

it was my example.txt lol

real hinge
#

okay removing dumb stuff worked

sullen fiber
hazy sinew
#

i made it same format as real but with 1 million lines

tranquil vapor
#

my part1 takes longer than part2 lmao

sullen fiber
#

i think the ratio makes it actually insane

hazy sinew
#

ok done

tranquil vapor
#

cause i made part1 brute force

real hinge
#

how many lines btw @sullen fiber

sullen fiber
#

100k

real hinge
#

okay

sullen fiber
#

but eagely made me realize

#

this probably grows too fast

#

for a normal number

real hinge
#

if it doesnt overflow

#

its fine

hazy sinew
#

how do i upload the file

real hinge
#

vap this is not ending

sullen fiber
#

LMAO IT KEEPS

real hinge
#

aaaaaaaaaaaaaaa

#

not finishing

hazy sinew
#

guys

#

i deleted the file

real hinge
#

its still only using 240mb of ram

sullen fiber
#

i fear it will overflow

real hinge
#

letts hope not

sullen fiber
#

im thinking about the growth function

#

its like

#

a lot

real hinge
#

I fear my pc will ran out of battery before

#

it can die anyime

sullen fiber
hazy sinew
#

i made a git repo to upload it but clone with https not ssh so i had to enter pw so i deleted the repo locally but i alr moved the file there

sullen fiber
sullen fiber
#

ok i know that is defintely normal

tranquil vapor
#

EWW WTF ARE THESE NEW ICONS

#

I JUST NOTICED

sullen fiber
#

im raising the seed to the 5/2 power

tranquil vapor
#

SO DISGUSTING

hazy sinew
#

thats tiny bro

sullen fiber
#

yop

real hinge
#

Laptop died. trolldayruined

#

I got this

hazy sinew
#

my file is cooking something

tranquil vapor
# tranquil vapor 😭

originally my part 2 took like three times as long as here but i just optimised it further

#

cause I was parsing the mappings once for each seed range

hazy sinew
#

game 100k should not be on line 550k

real hinge
#

My code is very optamized

#

(I didnt do anything)

hazy sinew
#

oh im not clearing the output

tranquil vapor
#

i wanna try a further optimisation which is using a set instead of array for storing the ranges (cause currently deleting ranges is O(n))

hazy sinew
#

bruh

#

BRO ITS LIKE 100x FASTER NOW WTF

real hinge
#

Wth did u do

hazy sinew
#

its time for 10 million lines of day 4

#

i had an output variable that i appended each game to, and every 10000 i printed it, but i didnt clear it, so every 10000 i printed the entire file again

tranquil vapor
hazy sinew
#

so it took me 1h to get to 500k

#

now im at 700k after 50 seconds

real hinge
#

Tro

#

I wish I put some prints

hazy sinew
#

ok its gonna take about 11 minutes

real hinge
#

Ven will add print for me

#

Writing code from phone pain

native pewter
real hinge
#

There isnt even arrows in mt keyboard

#

I have to rewrite command everytime

#

This is bad

hazy sinew
#

i didnt have 500k lines i actually had 12.75 million lines

#

lmao

#

its actually 1mil

real hinge
#

Lets go

hazy sinew
#

how many lines is that

real hinge
#

12 minutes on vaps input

hazy sinew
#

have fun with 10 million lines

tranquil vapor
real hinge
#

Why slow

sullen fiber
#

LOL

hazy sinew
real hinge
#

Oh

tranquil vapor
#

it's just O(n) cause I loop from start to end so I can't delete by index

real hinge
#

Solve

sullen fiber
tranquil vapor
#

but I just need to loop from end to start so I can delete by index

hazy sinew
real hinge
hazy sinew
#

yes thats 6.71 million

real hinge
#

Answer is lots of numbers

sullen fiber
#

Oh cool ty

real hinge
#

I didnt know I used int64

#

Oh I used usize

hazy sinew
real hinge
#

I love how people here focus on running code in huge datasets or creating big datasets

native pewter
#

:3

hazy sinew
#

i wonder if anyone will be able to solve it

#

in a reasonable timeframe

real hinge
#

That is at least 1-2 hour of runtime

hazy sinew
#

its exponential

#

12 minutes for 100k lines i think

real hinge
#

We can use vens vps

#

What can go wrong

real hinge
#

For 1 mil it would be something like 1.5 hours I thibk

tranquil vapor
real hinge
#

It should be linear but not completely

#

10 mil would be maybe 20 hours or smthn

sullen fiber
#

Manti what's ur card solution look like

real hinge
#

Gijub

tranquil vapor
#

what card input should i try

#

u sent so many

sullen fiber
#

Latest

real hinge
sullen fiber
#

Others are bork

hazy sinew
#

imagine aoc inputs were also 1GB

real hinge
#

tho its hard

hazy sinew
#

bro github is taking so long for it

tranquil vapor
#

wtf my solution so fast

tranquil vapor
#

is it 4081485 43610187939196406391740660158070498473393984626099324285536447

native pewter
#

tf r u guys cooking

sullen fiber
#

15249 24426334738393

tranquil vapor
#

lol

sullen fiber
#

Not real

#

I just spammed

tranquil vapor
sullen fiber
#

See manti screenshot

tranquil vapor
#

0.94s

hazy sinew
#

i ran git add . a minute ago and it still hasnt finished

sullen fiber
#

He did it and got smth diffenr

hazy sinew
#

it finished

tranquil vapor
#

i think my solution is right

sullen fiber
#

Yea probably

hazy sinew
#

there goes 1GB of my mobile data

real hinge
hazy sinew
tranquil vapor
#

im surprised how fast it is tho

real hinge
#

Not other

sullen fiber
#

WTH

tranquil vapor
sullen fiber
#

Why was the output so small

tranquil vapor
#

send 100mb one

real hinge
#

Is it small

tranquil vapor
#

i will test as well

hazy sinew
tranquil vapor
#

ok

hazy sinew
#

10mil 15% there

real hinge
#

I honestly have no idea if it is correct

#

It might overflowed exploded

tranquil vapor
#

shithub slow

real hinge
#

But there isnt a way to confirm it so

tranquil vapor
#

i dont think rust would overflow

real hinge
tranquil vapor
#

it would panic probably

tranquil vapor
real hinge
hazy sinew
#

how else am i supposed to upload it

real hinge
tranquil vapor
#

MY PC FROZE

#

FROM 1MIL

real hinge
#

But also I doubt uint is enough for all that

real hinge
tranquil vapor
#

is Ruby multi threaded by default or smth

hazy sinew
#

u probably need rust for 1mil or 10mil

tranquil vapor
#

insane

#

how would 1 thread 100% freeze my pc

#

or memory?

#

VJIJIGEDSJIOGJIOSGJIOGJIOEIOJ

real hinge
#

ARE YOU USING GNOME

tranquil vapor
#

thanks oom killer

real hinge
#

@tranquil vapor 100mb

tranquil vapor
#

the way i do day 4 is i just use an array to keep track of how many cards i have

#

thats why it oomed

hazy sinew
#

where can i upload it

real hinge
#

DO 100MB

tranquil vapor
#

doing vaps input now

#

didnt freeze yet

real hinge
#

Actually instead of Vector I could try static lenght arrays

tranquil vapor
#

I SHOULDNT HAVE SPOKEN

real hinge
#

Whateve

tranquil vapor
#

vscode froze again

real hinge
tranquil vapor
real hinge
#

Ruby so bad

tranquil vapor
#

no

#

i think its just cause numbers become masssive

real hinge
#

Mine never froze

tranquil vapor
#

exponential growth

tranquil vapor
real hinge
#

Wrong

#

Its possible

tranquil vapor
#

its cause ur integers are capped to 32bit or smth

#

mine are infinite so it grows so big

#

i think the fix is to discard lower cards

#

not use an array

#

or rather make the array only 5 big

#

cause u only need that much

#

and shift all elements after each iteration

real hinge
#

21 digit

tranquil vapor
#

cause i currently just push to array

#

so if there are 1 million lines it will make 1 million element array

hazy sinew
tranquil vapor
#

ohh

#

u made longer ranges

hazy sinew
#

but the issue is, i made it so that it repeats 15 times a 25% chance to add one of the winning numbers to the scratch card

#

so there is gonna be a lot of winning cards

tranquil vapor
#

isnt this just 10 winning cards

hazy sinew
#

what input is this

tranquil vapor
#

vaps

hazy sinew
#

bro 10 winning numbers is too much i think

real hinge
#

Ven tell output

tranquil vapor
#

NOT YET

hazy sinew
#

thats 512 copies

real hinge
#

Why

tranquil vapor
#

i didnt do yet

real hinge
#

Did it not finish

hazy sinew
real hinge
#

Ruby so slow

hazy sinew
#

10mil coming soon

tranquil vapor
#

i need to change my code

hazy sinew
#

anyone got rust sol and goot specs?

real hinge
tranquil vapor
#

NO

real hinge
#

Run in your vps

#

It has 24 gigs

#

How did I not ran out of memory

tranquil vapor
#

done

tranquil vapor
#

number so large it doesnt fit in a message

hazy sinew
#

LMAO

#

now run 10

tranquil vapor
#

i might

hazy sinew
#

is that p1 or p2

tranquil vapor
#

it was really fast tbh

tranquil vapor
hazy sinew
#

how fast

#

wait maybe it isnt exponential

#

yea its not

#

the max a card can have is 16

#

wait yea it is

#

if every card is 16 its gonna be 16^x where x is the card

tranquil vapor
#

actually nvm my code is wrong

hazy sinew
#

and most of my cards are winning

#

gonna run mine on 1mil

#

Test Part 2: -325994640 (4215 ms)

#

shit

#

.size returns an int

#

id have to redo my solution from scratch

#

part 1 on 1mil is suspiciously similar to part 2 on real input

real hinge
hazy sinew
real hinge
#

Part1 is true

#

Part2 is explosion

#

Why rust doesnt panic

tranquil vapor
#
cardsWon = 0
cardsWonBuf = []

File.foreach(file).with_index do |line, idx|
    idx %= 20

    cardsWonBuf[idx] ||= 1

    left, right = line.split " | "

    winning = parseNums left.split(":")[1]
    owned = parseNums right

    winningCardCount = owned.count { |n| winning.include? n }
    next if winningCardCount == 0

    for i in 1..winningCardCount do
        cardsWonBuf[idx + i] ||= 1
        cardsWonBuf[idx + i] += cardsWonBuf[idx]
    end

    points += 2 ** (winningCardCount - 1)

    cardsWon += cardsWonBuf[idx]
    cardsWonBuf.delete_at idx
end
#

is this not correct

hazy sinew
#

whats ||= 1

tranquil vapor
#

when i change module it changes result xd

#

shouldnt it not matter

#

oh i get the problem

real hinge
#

Problem is Ruby

#

You should use java

tranquil vapor
#

nop

native pewter
real hinge
#

Fast

#

Java very fast

native pewter
#

nop

real hinge
#

I seen duke surfing

native pewter
#

he surfing on a wave from 12 years ago

real hinge
#

Idc

#

Fast

#

I want a battery that doesnt run out

hazy sinew
#

maybe someone will give us the solution

real hinge
#

@tranquil vapor how much energy usage do you get in your laptop

#

As wattages

native pewter
real hinge
#

Went down to 5-6 watt

native pewter
#

plink

real hinge
#

But 400mhz cpu trolldayruined

#

On windows I get like 10-11

native pewter
#

400???

real hinge
native pewter
#

what

real hinge
native pewter
#

guhh

hazy sinew
#

any rustaceans here

#

or solutions that use dynamic numbers

tranquil vapor
#

guh this is confusing

real hinge
#

I think m macs can go all way down to sub 100 mwatt

#

Idk how

real hinge
tranquil vapor
#
cardsWon = 0
cardsWonBuf = []

File.foreach(file).each do |line|
    cardsWonBuf[0] ||= 1

    left, right = line.split " | "

    winning = parseNums left.split(":")[1]
    owned = parseNums right

    winningCardCount = owned.count { |n| winning.include? n }
    next if winningCardCount == 0

    for i in 1..winningCardCount do
        cardsWonBuf[i] ||= 1
        cardsWonBuf[i] += cardsWonBuf[0]
    end

    points += 2 ** (winningCardCount - 1)

    cardsWon += cardsWonBuf.shift
end
#

i thought this should be right

#

but its not

#

i wonder why

real hinge
#

Void

tranquil vapor
#

result is WAYYY too high

real hinge
#

You will powertop

native pewter
#

idk not on laptop rn

real hinge
#

Go

#

Go to your laptop

native pewter
#

later

real hinge
#

Fiine

tranquil vapor
#

oh i see an issue

tranquil vapor
#

im close

#

yayy it works

#

input-100k.txt
4081485
43610187939196406391740660158070498473393984626099236846382392

#

same results as earlier

real hinge
#

How fast

tranquil vapor
#

100k is very fast

#

1m is still running

real hinge
#

Try 100mb

tranquil vapor
#

yop i am

real hinge
#

100mb is 100k too right

tranquil vapor
#

done

real hinge
#

Or was it 1M

real hinge
tranquil vapor
#

INSANE NUMBER

real hinge
#

Show

tranquil vapor
#

soon

#

i need to run again

#

and pipe result into file

real hinge
#

why

#

Baaad

tranquil vapor
#

RESULT SO LARGE I CANT COPY IT

#

i will rewrite this in crystal and see if it makes any difference

real hinge
#

GİVE YOUR ANSWER FIRAT

tranquil vapor
#

here

#

230kb number posttroll

real hinge
#

Why 280kb

#

You got wrong answer

tranquil vapor
#

nop

#

you did

#

do you understand that its exponential growth...

real hinge
#

Your part1 is smaller than mine

real hinge
#

HOW MANY BITS IS THAY

#

yeah definiletly not happening with rust

tranquil vapor
#

i will rewrite in crystal now

#

guh index out of bounds

real hinge
#

Java rewrite when

native pewter
#

@real hinge

real hinge
hazy sinew
#

i wonder how much money aoc costs

real hinge
#

Make your gpu go to sleep

tranquil vapor
#

Unhandled exception: Invalid Int32: "" (ArgumentError)

#

insane

hazy sinew
#

for the average person

real hinge
#

50% brightness etc

#

Just wonder ing how low you can go

hazy sinew
#

the worse you are at it the earlier you wil drop out so youll waste less power, but the better you are the faster your code will be, so its also less power, being average is the worst

#

cuz youll be bruteforcing day 19

tranquil vapor
#

I REWROTE IN CRYSTAL AND DIFFERENT RESULT

#

i will fix my crystal solution

#

oh i know issue

hazy sinew
#

im adding the cards to an array so i cant do it

#

without rewriting

#

cuz .size returns an int

tranquil vapor
tranquil vapor
#

INSANEE

native pewter
#

your single digits dont have an extra space

hazy sinew
#

oh no so relevant

native pewter
#

it 100% is

#

mine doesnt work because i expect them to be there

#

i dont string split

hazy sinew
#

i dont even look at the numbers

#

i look at the indices

#

you could replace all of it with :

hazy sinew
native pewter
#

eat my nuts

hazy sinew
#

sure

tranquil vapor
#

it expects these files

solve "example.txt"
puts
solve "input.txt"
puts
solve "input-100k.txt"
puts
solve "input-1m.txt"
#

source code:

require "big"

def parseNums(line)
  line.strip.split(/\s+/).map { |n| n.strip.to_i }
end

def solve(file)
  startTime = Time.utc

  points = 0

  cardsWon = BigInt.new(0)
  cardsWonBuf = StaticArray(BigInt, 20).new(BigInt.new(1))

  File.each_line(file) do |line|
    left, right = line.split " | "

    winning = parseNums left.split(":")[1]
    owned = parseNums right

    winningCardCount = owned.count { |n| winning.includes? n }
    if winningCardCount == 0
      cardsWon += cardsWonBuf[0]
      cardsWonBuf[0] = BigInt.new(1)
      cardsWonBuf.rotate!(1)
      next
    end

    (1..winningCardCount).each do |i|
      cardsWonBuf[i] += cardsWonBuf[0]
    end

    points += 2 ** (winningCardCount - 1)

    cardsWon += cardsWonBuf[0]
    cardsWonBuf[0] = BigInt.new(1)
    cardsWonBuf.rotate!(1)
  end

  puts file, points, cardsWon, "took #{(Time.utc - startTime).total_milliseconds}ms"
end

solve "example.txt"
puts
solve "input.txt"
puts
solve "input-100k.txt"
puts
solve "input-1m.txt"
hazy sinew
#

in the same dir?

#

can the files be empty

tranquil vapor
#

yes

#

actually i added timing sec

#

this one has timing

#

idk if its correct for the 100k and 1m ones

#

cause idk their solutions

hazy sinew
tranquil vapor
#

chmod +x solution

hazy sinew
#

oh wait

#

right

#

i thought switching to root would do tha ttoo

#

ill let it run ig

#

wait it runs 100k first

#

i named the 10mil one 100k

tranquil vapor
#

10mil will take sooo long

#

1mil took like 15seconds

hazy sinew
#

the number is QUITE big

tranquil vapor
#

do u think u can even fit it in ur ram

#

xd

#

the 1m one was already 230kb

tranquil vapor
native pewter
#

horrible

tranquil vapor
#

also my solution has hardcoded buffer length of 20 so if you have more than 20 wins per game it wont work (can just increase buffer size to fix that)

hazy sinew
#

its max 16

#

10mil the console dies

tranquil vapor
#

LOL YEAH

#

pipe to a file

#

did it finish

hazy sinew
#

10mil no

#

lemme put it in file

#

takes about a minute to run the 1mil

#

10mil still running

tranquil vapor
#

i could optimise it further probably

real hinge
#

Ven

tranquil vapor
#

by not rotating the array and instead writing it like a tape and using modulo to wrap back around

real hinge
#

VEN EXPLODE

hazy sinew
#

you should maybe do that

#

so i can run 10m

real hinge
#

And convert to logic gate

hazy sinew
#

store it using a char* directly

real hinge
#

I just had a idea

#

How hard would it be to make multiplaction with strings

hazy sinew
#

you have to translate pen and paper multiplication into code

real hinge
#

Yop

tranquil vapor
hazy sinew
#

still running 10mil btw

tranquil vapor
#

lmaoo

tranquil vapor
# tranquil vapor it doesnt work for some reason and idk why
i = 0
File.each_line(file) do |line|
  idx = i % 20

  left, right = line.split " | "

  winning = parseNums left.split(":")[1]
  owned = parseNums right

  winningCardCount = owned.count { |n| winning.includes? n }
  if winningCardCount == 0
    cardsWon += cardsWonBuf[idx]
    cardsWonBuf[idx] = BigInt.new(1)
    next
  end

  (1..winningCardCount).each do |c|
    cardsWonBuf[(idx + c) % 20] += cardsWonBuf[idx]
  end

  points += 2 ** (winningCardCount - 1)

  cardsWon += cardsWonBuf[idx]
  cardsWonBuf[idx] = BigInt.new(1)

  i += 1
end
#

ohh

#

yep

#

i posted code and immediately realised my mistake

#

THAT MADE IT SLOWER???

#

modulo slower than array rotate

#

yeah i tried to optimise it further and it's still slower than array rotate

#

funny

#

ig it makes sense cause array rotate is just a memcpy

#

and modulo is expensive

#

but i wouldnt expect modulo to be slower than memcpy...

#

holy shit i made it faster by not using regex to parse lines

#

lol day 6 seems like yet another puzzle where brute force wont work

#

you yet again have a range and need to calculate the subrange that matches a condition

#

xd

hazy sinew
#

10mil finished running

real hinge
#

@tranquil vapor I know how to make it faster

#

Make one to run with cuda

tranquil vapor
#

IT TOOK SO LONG LMAO

real hinge
#

Use gpuuuu

tranquil vapor
real hinge
#

@tranquil vapor

hazy sinew
hazy sinew
hazy sinew
#

not on huge inputs obv

#

on huge inputs u use the quadratic formula

tranquil vapor
#

I'm still confused modulo was slower tho

#

did the compiler realise what I was doing and optimise the rotating to smth different?

hazy sinew
#

what lang is that

tranquil vapor
#

crystal

hazy sinew
#

if a language uses the end keyword its shit

tranquil vapor
#

it uses llvm

hazy sinew
#

also that code looks inefficient idk why

tranquil vapor
#

how

hazy sinew
#

idk it just does

native pewter
hazy sinew
#

should i do it in c

#

day 4

#

find some bigint lib

#

idk if i should use gmp or just manipulate memory manually

#

allocate myself 10mb

tranquil vapor
#

crystal uses gmp

hazy sinew
#

and just write the bytes manually

#

cuz gmp might have some bloatplate

tranquil vapor
#

adapting my solution in C should be really easy

#

I might do it for the memes

real hinge
#

Advent of code teached me to not use arrays

#

Or at least use as less as possible

#

I am iterator guy now

#

@real hinge

hazy sinew
#

i HAVE to win

#

wait ik how to do day 6 without ranges

#

i do time.last { beats the record } - time.first { beats the record }

native pewter
real hinge
#

Void why did u become vtuber linus

native pewter
#

i will help you learn english by being a grammar nzi

real hinge
#

Thank

native pewter
real hinge
#

Horror

native pewter
#

also being evil fits me no?

hazy sinew
native pewter
#

i dont think itd work

#

or am i missing smth

steady fog
hazy sinew
#

red red red

#

if it was a chess board from white side, b1 has one

#

dont see any more

real hinge
#

@steady fog do day 8

steady fog
#

okay

hazy sinew
#

I know what day 7 and 8 is gonna be

----- Day 7: Dimensions?! -----
You wake up to the sound of excited elves, it turns out you've slept for 2 million years and the interdimensional rocket transfer boost coordination system is corrupted.

The technician elf gives you the log and asks you to read it to him, stating that he doesn't speak SHA-256.

For example:

635185f0ef78066ee1acccfa386335e720ece408a80100ab9c8f1333d2dc0b48
64a204364f1a86492e406034439b9d0048314bff4d3306ceadcdfcf1617fd09d
ca91534dfcb701210e325d5d979089ffe37edc0697b2f4185c1d94c3fc94c059
6f0434072cbcb8df770089c0f0b79c33ae4de9668ba93faaee3e5c7727f2b953
0e2b85b1126bcfaede2ce21827ed4156707a82c010aed6a4c94cc2917b7b118e
7200dd6e94d329cb285325558ecafd8a7ed17f7e5c3386fe644a1e1e97b14fc7
03ef27a056cc014a0b35d3d94ea95f8de4b8ebe99c11970a6a01a21fd112e71b
40ba3c9b227797ba491cecd01e531133fc00bc8ea91fdd8f40ba7450cf6520d7
b5d69a31bfe7aaba76f51c40c551f75736f51c8663ea301d680b3c5872e4ca0b
c554ec7fd7c15968ba4538331595e1ee3f0b5051aa370755656a2dc25277db94

You translate to the elf: "Press the big red button"

He tries, but nothing happens, you receive another log (Your puzzle input), and the elf asks you to translate.

What is the decoded instruction?

Answer: [ ] Submit

----- Part Two -----

Only nonsense comes out, the elf looks at the instructions in confusion: It turns out, it's actually SHA-512, each 2 lines being 1 string.

What is the new decoded instruction?

Answer: [ ] Submit

----- Day 8: Boat -----

You are in a boat. How many letters does the word boat have?

Answer: [ ] Submit

----- Part Two -----

Include the period

Answer: [ ] Submit

tranquil vapor
#

qhar

steady fog
#

venny

solemn python
#

whats the right answer

#

because I definitely got a number

#

is it right? who knows

#

(thats part 2)

#

Luckily rust had a very convenient arbitrary-precision quadratic library

daring marlinBOT
hazy sinew
#

cool bot

solemn python
#

That's not even a fun thing to solve, you just have to loop a few million times
Maybe later

#

Have to go to school now

real hinge
solemn python
#

What's a dynamic number

real hinge
#

Bit

#

Whenever it overflows it will go 32 - > 64

#

Or 512 - 1024

hazy sinew
solemn python
#

I don't really have a use for that so never

daring marlinBOT
hazy sinew
solemn python
hazy sinew
#

the output has 1 million digits

solemn python
#

So

hazy sinew
#

does a regular bignum have infinite precision

solemn python
#

That's why it's called arbitrary precision I thought

real hinge
hazy sinew
#

rust has that?

tranquil vapor
#

day 6 is easy but || im getting overflow even on u128 lmao ||

tranquil vapor
#

normal input

hazy sinew
#

wtf r u doing

#

it works with i64 for me

real hinge
#

Whar

#

Wth

tranquil vapor
#

wait what

solemn python
tranquil vapor
real hinge
#

I will soon look

solemn python
#

For example

#

In computer science, arbitrary-precision arithmetic, also called bignum arithmetic, multiple-precision arithmetic, or sometimes infinite-precision arithmetic, indicates that calculations are performed on numbers whose digits of precision are limited only by the available memory of the host system. This contrasts with the faster fixed-precision arithmetic found in most arithmetic logic unit (ALU) hardware, which typically offers between 8 and 64 bits of precision.

tranquil vapor
#

ohhh

real hinge
#

looove

#

then bigint doesnt have any bit limits

solemn python
#

Yes

real hinge
#

ITS NOT SUPPOSED TO BE THAT BIG

solemn python
#

Only limited by how many digits your memory can store

tranquil vapor
real hinge
solemn python
#

Yeah

real hinge
#

love

#

I will soon try

tranquil vapor
#

apparently numberLiteral..i64 makes an i32 range

#

dumb

real hinge
tranquil vapor
#

i used brute force with binary search sorrykirino

real hinge
tranquil vapor
#

send

#

i want to see how long brute force takes with binary search

real hinge
#

@tranquil vapor

#

I couldnt try part 2 because overflow again trolldayruined

tranquil vapor
daring marlinBOT
tranquil vapor
#

SO BIG

#

MY ASS IS NOT BINARY SEARCHING THAT

real hinge
#

nop noppp

#

its small

tranquil vapor
#

THAT NUMBER IS SO BIG IT DOESNT EVEN FIT IN A MESSAGE#

real hinge
tranquil vapor
#

now how do u do this with math

#

im pretty sure theres a formula to calculate this

real hinge
#

so uhh

#

idk

#

but theres fast way to do this probably

#

getting limit from start

#

and end

#

any number between will work probably

tranquil vapor
#

|| i use binary search to find the smallest and highest number that wins, then just everything between those wins ||

real hinge
#

looove

tranquil vapor
#

my rank is so low cause i always do it pretty late

#

i wish it didnt use submit time as a metric

real hinge
#

So I can say I did it later instead of I wasted 1 hour on solution

#

Well its usually combination of both

#

But whatever

tranquil vapor
#

you know what would make it way better

#

mm actually

#

i was gonna say make it start counting the moment you load the exercise for the first time

#

so it measures how long you took instead of just time since american midnight

#

but then u could cheat :I

#

cheaters ruining evrything

solemn python
#

But it's a quadratic

#

The first root is lower bound of success, and the second is the upper

#

Or maybe that's reversed idk, abs it

tranquil vapor
#
x * (n - x) > y

where y is the record, and n is the time

#

solve for x

real hinge
solemn python
#

Yep

tranquil vapor
solemn python
#

quadratic

#

Set that equal to the record distance

#

And set = 0

tranquil vapor
#

riiight omg its a quadratic formula

#
x² - nx + y < 0
solemn python
#

( -n +- sqrt(n^2 - 4y) ) / 2

#

I think

#

What lang are you doing

tranquil vapor
#

i did crystal

solemn python
#

Ah

#

Libraries are fun

daring marlinBOT
#

**mod.rs: **Line 57

// Arbitrary precision solution:
daring marlinBOT
tranquil vapor
#

unreadable

#

rust is so unreadable

tranquil vapor
#

i dont know the quadratic formula

solemn python
#

I don't either, I used Wolfram alpha lol

#

If I ever need it I just programmed my ti84 to do the quadratic formula for me

tranquil vapor
#

yeah

#

i learned the pq formula for school but i forgot it again cause its useless

#

like if i need it i just use a calculator or look it up real quick xd

solemn python
#

(-b +- sqrt(b^2 - 4ac))/2a

#

👍

tranquil vapor
#

i was gonna say what if we added webhooks for everyones repo here but then i realised that'll let anyone at everyone

#

i wish discord would let u configure allowed mentions for a webhook

#

instead of putting that "responsibility" to the webhook executor

solemn python
#

You could run a proxy or something but that might be too much effort

tranquil vapor
#

i already do actually xd

#

could just add additional settings

#

but rn it doesn't hide the webhook urls so it'd be worthless

#

obv you could just use the original webhook

real hinge
solemn python
#

math is very scary

hazy sinew
#

i wrote a generic bfs function that doesnt even take a collection as a parameter but still finds the shortest path from start to end within that collection, including step costs

tranquil vapor
#

im too lazy to do it efficiently so i literally allocate a massive array and binary search on that trolley

hazy sinew
#

so if its not a grid

#

but smth else

#

idk what that would be tho

#
fun <T> bfs(
        start: T,
        getNext: (T) -> Collection<T>,
        isEnd: (T) -> Boolean,
        getStepCost: (T) -> Int = { 1 }
    ): Pair<List<T>, Int>? {
        if (isEnd(start)) return Pair(listOf(start), 0)

        val visited = mutableSetOf<T>()
        val queue: Deque<Pair<T, Pair<List<T>, Int>>> = LinkedList()

        queue.offer(Pair(start, Pair(listOf(start), 0)))
        visited.add(start)

        while (queue.isNotEmpty()) {
            val (current, pathWithCost) = queue.poll()
            val (path, cost) = pathWithCost

            if (isEnd(current)) return Pair(path, cost)

            for (next in getNext(current)) {
                if (next !in visited) {
                    visited.add(next)
                    queue.offer(Pair(next, Pair(path + next, cost + getStepCost(next))))
                }
            }
        }

        return null
    }
#

man i love kotlin function parameters so much

#

allows me to do stupid shit like this

real hinge
#

guh tomorrow will be horrible

native pewter
#

huh?

steady fog
#

*guh?

real hinge
native pewter
#

meh?

#

get good!

#

(i still havent done today and yestedays pt2)

real hinge
#

today is easy

tranquil vapor
#

yeah today was really easy

#

especially if u brute force instead of using brain

#

like i did

real hinge
tranquil vapor
#

yesterday was fun

real hinge
#

and logic

#

anyway we will see tomorrow

tranquil vapor
#

DIDN'T LIKE LOGIC

hazy sinew
# real hinge guh tomorrow will be horrible

tomorrow will be

----- Day 7: Dimensions?! -----
You wake up to the sound of excited elves, it turns out you've slept for 2 million years and the interdimensional rocket transfer boost coordination system is corrupted.

The technician elf gives you the log and asks you to read it to him, stating that he doesn't speak SHA-256.

For example:

635185f0ef78066ee1acccfa386335e720ece408a80100ab9c8f1333d2dc0b48
64a204364f1a86492e406034439b9d0048314bff4d3306ceadcdfcf1617fd09d
ca91534dfcb701210e325d5d979089ffe37edc0697b2f4185c1d94c3fc94c059
6f0434072cbcb8df770089c0f0b79c33ae4de9668ba93faaee3e5c7727f2b953
0e2b85b1126bcfaede2ce21827ed4156707a82c010aed6a4c94cc2917b7b118e
7200dd6e94d329cb285325558ecafd8a7ed17f7e5c3386fe644a1e1e97b14fc7
03ef27a056cc014a0b35d3d94ea95f8de4b8ebe99c11970a6a01a21fd112e71b
40ba3c9b227797ba491cecd01e531133fc00bc8ea91fdd8f40ba7450cf6520d7
b5d69a31bfe7aaba76f51c40c551f75736f51c8663ea301d680b3c5872e4ca0b
c554ec7fd7c15968ba4538331595e1ee3f0b5051aa370755656a2dc25277db94

You translate to the elf: "Press the big red button"

He tries, but nothing happens, you receive another log (Your puzzle input), and the elf asks you to translate.

What is the decoded instruction?

Answer: [ ] Submit

----- Part Two -----

Only nonsense comes out, the elf looks at the instructions in confusion: It turns out, it's actually SHA-512, each 2 lines being 1 string.

What is the new decoded instruction?

Answer: [ ] Submit

real hinge
#

true

steady fog
#

@real hinge hi

real hinge
#

hi

solemn python
real hinge
solemn python
hazy sinew
#

i watched so many hyper neutrino videos i think i can just switch to python and not have any issues now

#

proud of my brother in kotlin

#

tho im pretty sure he uses something else to solve it initially

native pewter
#

@tranquil vapor howd you get crystal tooltips to work

#

i installed crystalline and set the path

tranquil vapor
#

turn them on in extension settings LOL

native pewter
#

doesnt work

tranquil vapor
#

oh

#

skill issues

native pewter
#

just says working and then doesnt

#

are you using this

#

guh this is so shit

#

why do i have to have vsc open in the project dir

#

these people

native pewter
#

REEEEE

tranquil vapor
real hinge
#

stay calm void

native pewter
#

im so calm wdym

real hinge
#

doesnt REEEE indicate anger

native pewter
real hinge
#

part2part2part2part2

native pewter
#

wdym

#

that was

#

crystal is good language me thinks

#

just needs more money

tranquil vapor
#

i love crystal

#

i wish Crystal was more popular

#

instead we have go and rust

#

honestly im surprised crystal didn't pop off, cause rails is so popular

#

missed opportunity

real hinge
tranquil vapor
#

they should have made crystal on rails be a drop in replacement for ruby on rails

real hinge
#

for go part

#

not rust

#

also isnt crystal dynamic language

sullen fiber
tranquil vapor
#

yes

sullen fiber
#

this is right

real hinge
#

baaaaaaaad

native pewter
#

is rails action views like a wasm thing or

sullen fiber
#

my typescript code gets it 2 off 🥲

solemn python
#

I had to cheat a bit and look on Reddit for the correct floor/ceil arrangement and the such

sullen fiber
#

i got the real answer with wolfram mathematica

solemn python
#

But that was also after I ran that so I guess I got lucky

sullen fiber
#

btw u can check in the repo i put output_large.txt files for the answers

solemn python
#

What repo

sullen fiber
native pewter
#

oh yeah since i saw you guys talking
do i need like a bigint for day 6 normal or do can i use i64

sullen fiber
#

i64

native pewter
#

ty :3

sullen fiber
#

yaya

#

we were just having fun with making/solving larger inputs

solemn python
#

I doubt he will make anyone use bigger than 64 bits, that would be interesting but also I doubt it

tranquil vapor
#

anyway if u use crystal replacing int type is super easy

#

bigint has same api as normal int

solemn python
#

Because yes.

sullen fiber
#

TRUEE

proper totem
tranquil vapor
#

2022 day 11

#

the dumb way was impossible

#

numbers so large u oom

sullen fiber
#

oo 2022 day11 looks cool

#

OO i knowp how to do day 11

#

thisis epic

#

imma do it in uiua

#

oh god ui update jumpscare

sullen fiber
#

sike

#

i didnt realize there was addition

#

so sad

native pewter
#

what the fuck today is so easy

native pewter
sullen fiber
#

will i hop on crystal

native pewter
sullen fiber
#

yea today is crazy compared the the last 5 days

native pewter
#

dont quite understand how they work but i just type random stuff and it works

sullen fiber
#

intresting

native pewter
#

okay 6 days 6 languages

#

what next, ruby?

tranquil vapor
#

crystal is just ruby but compiled

sullen fiber
#

whats the crystal lsp again

tranquil vapor
#

theyre basically the same language lol

tranquil vapor
sullen fiber
#

ty

native pewter
sullen fiber
#

guh crystal for windows fake

native pewter
#

hop on linux already

tranquil vapor
tranquil vapor
native pewter
#

wdym

sullen fiber
#

maybe i can install wsl onto my external drive

native pewter
#

isnt that basically what you ha

sullen fiber
#

yea its alpha but also crystalline nop windwos buisl

native pewter
tranquil vapor
#

(kinda)

native pewter
#

doesnt feel like it...

tranquil vapor
#

wait julia looks similar to crystal too

tranquil vapor
#

julia looks like less cool crystal

native pewter
#

ish?

#

id love to use crystal for normal projects if comptime wasnt so bad

#

though julia has horrible jit times on first runs

tranquil vapor
#

why tf are u running these via actions lmao

tranquil vapor
#

no worse than rust

native pewter
tranquil vapor
#

i havent tried it on large projects

native pewter
#

like the stuff were making is kinda small

#

--release on large projects seems insane

#

i tried to install crystalline earlier and accidentally didnt select bin, thought "eh it cant be that bad can it" and stopped after like a minute

tranquil vapor
#

building crystal from source now

#

lets see how long it takes

#

anyway u can configure crystal to use more threads for compiling i think

#

done?