#AdVENt of Code

1 messages · Page 9 of 1

tranquil vapor
sullen fiber
#

i change this to crystalline?

tranquil vapor
#

no

#

in the server field

sullen fiber
#

ohh

tranquil vapor
#

that contains the crystal compiler and language server stuff....

#

pretty complex

native pewter
sullen fiber
#

ok so

#

i guess imma try to redo day 5

#

im crydtal

tranquil vapor
#

compiling this takes longer than compiling crystal itself lol

#

way longer

#

its still compiling

warped dust
#

vee cannot wait two minutes

tranquil vapor
#

THIS IS A TERRIBLE NAME https://github.com/samueleaton/sentry

GitHub

Build/Runs your crystal application, watches files, and rebuilds/restarts app on file changes - GitHub - samueleaton/sentry: Build/Runs your crystal application, watches files, and rebuilds/restart...

GitHub

Build/Runs your crystal application, watches files, and rebuilds/restarts app on file changes - GitHub - samueleaton/sentry: Build/Runs your crystal application, watches files, and rebuilds/restart...

#

FLOSS devs will stop naming their shit so that it seems like telemetry

tranquil vapor
warped dust
native pewter
#

wdym

#

everyone is

#

thats why theres rust wasm

sullen fiber
#

why isnt this showing me an error

warped dust
#

she's having a reality shock

sullen fiber
#

is this valid

tranquil vapor
#

maybe

#

try

sullen fiber
#

holy shit

tranquil vapor
#

it might split it into chunks of 3 chars

sullen fiber
#

i hovered to see all th oveload

#

it is valid

#

thats crazy

tranquil vapor
#

/run ```cr
print "explosionsssssoooooooo".split 3

sullen fiber
#

nah

split heartBOT
#

Here is your cr(0.36.1) output @tranquil vapor

["explosionsssssoooooooo"]```
sullen fiber
#

i only need intellisense

tranquil vapor
#

qhar

sullen fiber
tranquil vapor
#

wtf does it do then

#

/run ```cr
print "explosio3nsssssoooooooo".split 3

#

does it just cast to string

split heartBOT
#

Here is your cr(0.36.1) output @tranquil vapor

["explosio3nsssssoooooooo"]```
sullen fiber
#

Makes an array by splitting the string on any ASCII whitespace characters (and removing that whitespace).

tranquil vapor
#

???

warped dust
#

ur so fuckin dumb

#

splits three times

tranquil vapor
#

/run ```cr
print "i am going to explode".split 3

native pewter
split heartBOT
#

Here is your cr(0.36.1) output @tranquil vapor

["i", "am", "going to explode"]```
tranquil vapor
#

ohhhh so real

sullen fiber
#

/run cr print "abc def ghi jkl def iek".split 3

tranquil vapor
#

fire

split heartBOT
#

Here is your cr(0.36.1) output @sullen fiber

["abc", "def", "ghi jkl def iek"]```
tranquil vapor
#

wait thats actually fire

sullen fiber
#

oo true

#

/run cr print "abc def ghi jkl def iek".split -3

split heartBOT
#

Here is your cr(0.36.1) output @sullen fiber

["abc def ghi jkl def iek"]```
tranquil vapor
#

/run ```cr
print "real::banana::lover".split "::", 2

split heartBOT
#

Here is your cr(0.36.1) output @tranquil vapor

["real", "banana::lover"]```
tranquil vapor
#

thats so real

sullen fiber
#

who needs DOCS

#

when you have LSP

#

im definitely going to never use the parentheses-less syntax

tranquil vapor
#

we need to write eval func in crystal

tranquil vapor
#

why not

#

its soo based

#

crystal/ruby naming convention is so funny

you suffix your method names with
? to indicate a boolean func
! to indicate a dangerosu action

#

/run ```cr
print " banana".strip!.includes? "ban"

split heartBOT
#

@tranquil vapor I received cr(0.36.1) compile errors

Showing last frame. Use --error-trace for full trace.

In file0.code:1:17

 1 | print " banana".strip!.includes? "ban"
                     ^-----
Error: undefined method 'strip!' for String

Did you mean 'strip'?
/piston/packages/crystal/0.36.1/run: line 4: ./out: No such file or directory
tranquil vapor
#

fake

#

thats actually fake

warped dust
#

! means inplace

tranquil vapor
#

no

#

it means dangerous

#

which often but not always means inplace

warped dust
#

ur mom dangerous

native pewter
#

/run ```cr
print "ven".strip!

tranquil vapor
#

this is the worst part of crystal

sullen fiber
#

wouldnt it mean mutation

split heartBOT
#

@native pewter I received cr(0.36.1) compile errors

Showing last frame. Use --error-trace for full trace.

In file0.code:1:13

 1 | print "ven".strip!
                 ^-----
Error: undefined method 'strip!' for String

Did you mean 'strip'?
/piston/packages/crystal/0.36.1/run: line 4: ./out: No such file or directory
native pewter
#

no!!!!

tranquil vapor
#

i hate when u always have to include lang in ur searches

native pewter
sullen fiber
#

is this a real lsp

tranquil vapor
#

LOL

#

its kinda bad lol

#

wait did u enable intellisense in settings

#

but yeah naming convention is cool

sullen fiber
#

i have these

tranquil vapor
#
arr.sort  # returns new copy
arr.sort! # sorts in place
#

so fire

sullen fiber
#

it looks like it just

#

doesnt know what String.split returns

#

but it DOES

#

?!?!

tranquil vapor
#

/run ```cr
Array(Int64).new.unsafe_fetch 10

split heartBOT
#

@tranquil vapor I only received cr(0.36.1) error output

Invalid memory access (signal 11) at address 0x50
[0x557638b392f6] *Exception::CallStack::print_backtrace:(Int32 | Nil) +118
[0x557638b2cbac] __crystal_sigfault_handler +316
[0x7fbe5fe70730] ???
[0x557638b95336] *Pointer(Int64) +6
[0x557638b9531a] *Array(Int64) +10
[0x557638b1ec50] __crystal_main +1120
[0x557638b96396] *Crystal::main_user_code<Int32, Pointer(Pointer(UInt8))>:Nil +6
[0x557638b9620c] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +44
[0x557638b2a0b6] main +6
[0x7fbe5fa4109b] __libc_start_main +235
[0x557638b1e72a] _start +42
[0x0] ???
tranquil vapor
#

FIRE

#

why does it have that method lmaoo

#

whats the point of unsafe array methods

native pewter
#

yooo libc integration?

#

they needa pump more money into crystal

sullen fiber
#

it has no listed return types for split

#

but it knows

tranquil vapor
#

crystal is strange cause it has like everything you could ever ask for and still didnt become famous

#

it has so much shit

native pewter
#

yerah,

tranquil vapor
#

fire language

native pewter
#

so many features and almost c speed too

warped dust
#

crystal is very new

#

and still alpha

sullen fiber
#

ok now how run crystl

tranquil vapor
#

crystal banana.cr

sullen fiber
#

real

#

FIRE

#

ok fire

tranquil vapor
#

LSP so bad that it's faster to run the compiler to see if there are errors than use the IDE

sullen fiber
#

this istrue

tranquil vapor
#

for some reason compile takes like a second but error reporting is fucking instant

#

is it cause the slow part is llvm and it first does type checking then llvm

#

i think llvm might be the slow part cause rust is also fucking slow to compile

warped dust
#

the slowest part is linking actually

#

bitch like nop

tranquil vapor
#

WRONG CHAT GIRLIE

native pewter
steady fog
#

@tranquil vapor hi

tranquil vapor
#

hiii

steady fog
#

Crystal so funny

#

@tranquil vapor my day 5 solution uses so much ram

#

systemd oom killer kills it

tranquil vapor
#

is day 5 the one with the cards

steady fog
#

nop

tranquil vapor
steady fog
#

large

#

I'm making massive arrays

tranquil vapor
#

send me

#

i will test

steady fog
#

okay

tranquil vapor
#

where is it

#

send fasdter

native pewter
steady fog
#

guhhh i cant drag files from vscode into discord

#

@tranquil vapor fixx

tranquil vapor
#

soon

steady fog
#

WHO

tranquil vapor
#

WHAT IS THAT

#

TERRIBLE NAMING

steady fog
#

do you like it

#

i put soo much work

tranquil vapor
#

did u write that

native pewter
tranquil vapor
#

SEND INPUT

#

not code

#

😭

solar tide
#

my day 6 solution is a oneliner

#

sorry meant 6

steady fog
#

this is you @tranquil vapor

solemn python
#

Unless you did it the boring way

steady fog
#

i have sooo many of these 555 timers

native pewter
#

kinda dum

#

like at least yesterdays brute force took a few minutes

tranquil vapor
solemn python
tranquil vapor
steady fog
tranquil vapor
#

how do i check how much ram it uses

#

it finishes too fast

steady fog
#

i think hyperfine

#

might

tranquil vapor
steady fog
solemn python
tranquil vapor
#

fedora

#

give biggerrrrr input @steady fog

#

generate 100mb input

steady fog
#

howw

tranquil vapor
#

or large input

steady fog
#

yop

tranquil vapor
#

ohh thats why its fast

#

sorry for spoilers then

steady fog
#

@tranquil vapor did you use crystal conccurrencyu

tranquil vapor
#

i thought it was larger input

tranquil vapor
#

synchronous

#

its just algorithm i came up with

#

do u brute force just do the entire range

#

i tried that and it took like 10 minutes and my result was wrong anyway

steady fog
#

i dont know how i would brute force

tranquil vapor
#

brute force would just be manually testing every single seed number in the ranges

#

xd

#

i did that first it was sooo slow

native pewter
#

how did nice make it worse lmfao

tranquil vapor
#

wtf is nice

native pewter
#

WHAT

tranquil vapor
#

what now

native pewter
#

how do u not know nice...

tranquil vapor
#

why does nice make it seem slower

native pewter
#

i have no idea.

tranquil vapor
steady fog
#

@tranquil vapor i will make nice implementatiion in rust and call it lice

native pewter
#

just doing nice lowers its priority i think?

tranquil vapor
#

nuh uh

steady fog
#

man vencord

#

@tranquil vapor

native pewter
#

defaults to 10

#

did i do it wrong

tranquil vapor
#

VENCORD IS INAPPROPRIATE

sullen fiber
#

iirc

native pewter
#

yes.

#

we had CFS and niceness in uni exercise recently :3

#

(and then they changed scheduler)

sullen fiber
#

if it adds 20 to the niceness doesnt that mean lower priority

native pewter
#

it goes -20 to 19

sullen fiber
#

oh i was reading the args wrong

#

i thought -n means put the number wher n is

#

and that nice -20 means add 20

native pewter
#

honestly idek because nothing i did seemed to make it faster

solemn python
#

@sullen fiber you love

sullen fiber
#

HOW DID U

#

did u integer sqrt

solemn python
#

wdym

#

I do the quadratic yes

sullen fiber
#

my number is 2 off

#

in my solution

solemn python
#

off by how much

sullen fiber
#

well in my ts solution

#

TWO

#

TWO

#

the number TWO

#

2

solemn python
#

do you want the reason

native pewter
#

ur kinda silly

sullen fiber
#

YES

#

wait

#

wait

#

wait

#

wait

solemn python
#

waiting

sullen fiber
#

no yes i do

#

i thought of a possible reason but it didnt make sense

solemn python
#
  1. Your plugged in distance should actually be distance + 1
  2. Floor the higher solution and ceil the lower one before subtracting
  3. Add one to the final result
#

thats the method that works for me after cheating by looking at reddit

sullen fiber
#

are u not using like bigints

solemn python
#

I am

sullen fiber
#

what do u mean "ceil" and "floor"

solemn python
solemn python
sullen fiber
#

how do u round an integer

solemn python
#

the equation is continuous

#

the solutions aren't integers

#

ok well to be specific

#

I am using Irrational BigInts

#

from some library I found

sullen fiber
#

oh ur using bigfloats

solemn python
#

kinda

#

but basically

sullen fiber
#

i see

#

thats fire

solemn python
#

what lang are you using

sullen fiber
#

ts

solemn python
#

ah

sullen fiber
#

i was thinking

solemn python
#

well just check the rounding on your bigint math, it probably defaults to floor or something

sullen fiber
#

maybe i can calculate sqrt(x) mod 1

#

of a bigint x

#

im using newton's method for approximating sqrt(x) i'd probably have to like

#

reimpl it to somehow retain that information

#

meh too much brainage i dont wanna think about modifying newton's method to retain sqrt(x) mod 1

#

u know

#

i could probably implement bigfloats

#

but brain fried

proper totem
#

too much coding of advents for the vap

native pewter
#

uiua fried their neurons

#

its programmed to work in matrix mode only now

solemn python
#

ok making p1 large-input-able was ez, just had to replace my let acc = 1usize; with a let acc = BigUInt::from(1u8);

#

the actual race #s arent big enough to justify replacing all my floats with arbitrary-precision stuff

steady fog
#

@solemn python

native pewter
#

arent you like torturing yourself with rust

#

also you dont need to feel bad SCpetpetcat
as long as you learned something you finished aoc!

#

ill probably give up too some time bc im not that smart xd

daring marlinBOT
# solar tide https://github.com/taskylizard/adventofcode/blob/trunk/2023/6/day.cr#

**day.cr: **

input = File.read("./input.txt").strip.lines

def part1(input : Array(String))
  time, distance = input.map(&.split[1..])
  time.zip(distance).product { |time, distance| (0_i64..time.to_i).count { |i| i * (time.to_i - i) > distance.to_i } }
end

def part2(input : Array(String))
  time, distance = input.map(&.split[1..].join)
  puts (0_i64..time.to_i64).count { |i| i * (time.to_i64 - i) > distance.to_i64 }
end

puts part1(input)
puts part2(input)

tranquil vapor
#

CRYSTAL YUSS

#

COUNT LMAO

#

you did the stupidest possible brute force I love it

#

i at least binary search only the beginning and end of the winning numbers and then add them together O.O

#

checking every single number is funny

native pewter
#

theres no penalty so its intended clueless

tranquil vapor
#

i would totally make smth similar but i use many different languages so it's pointless

native pewter
#

wth so much effort

solemn python
#

In my opinion, your AoC setup is half the event :)
If you rotate languages then of course that has its own merits, but if you don't, you better make it count

native pewter
#

i mean i get wantin to make proper projects but i wouldnt say aocs goal is to finish as fast as possible

#

its just gamified like that

solemn python
#

In my opinion I agree

warped dust
#

anyone making an elaborate setup to finish it faster is a loser

solemn python
#

Just in terms of making fun projects that aren't just 25 files in a row

solar tide
solar tide
steady fog
#

@tranquil vapor lol it finally finished

#

my brute force took 21 minutes

#

works though

solemn python
#

for what

steady fog
#

day 5 p2

solemn python
#

p2 normal input?

steady fog
#

wdym

native pewter
#

they really out here misspelling advertisements

solemn python
steady fog
#

crystal

native pewter
steady fog
solemn python
#

mine was 13m

#

im better than you (joking)

steady fog
#

i could make it go faster by using threads

#

but then i need to find a way to set a max amount

native pewter
#

cheater

steady fog
#

nuh uh

native pewter
#

damn the adrenaline goes crazy tho if you actually plan to do it fast

#

im so drunk shiggy

warped dust
#

this is literally a fucking physics problem

#

for day 6

#

what

native pewter
#

my guy

#

im 20 :3

solemn python
#

but sure

#

anyways d7 time

warped dust
#

why are you all brute forcing then

steady fog
#

lets go

#

this looks fun

solemn python
steady fog
#

less than a second to write you mean?

warped dust
#

but its lame

steady fog
#

easy to understand

warped dust
#

@sullen fiber tell me u did the maths

#

i believe in you

solemn python
#

I did the maths after initially solving it w/ brute force

steady fog
#

im doing today in rust

proper totem
#

vap did the maths

warped dust
#

🙏

proper totem
#

they solved it in desmos iirc

warped dust
#

my goat

steady fog
#

oh god it gives me pointers

#

the split_at

warped dust
#

they're references

steady fog
#

same thing

warped dust
#

what do you expect

steady fog
#

you

warped dust
#

every string method works on them like normal

solemn python
#

hm this one doesn't look too bad but im sure p2 is hell

steady fog
#

help

#

rust is screaming errors at me

proper totem
#

guh so much info to parse

#

hard for LLM and hard for human

#

probably doesn't help that I've never played poker

steady fog
#

error[E0277]: the size for values of type str cannot be known at compilation time

#

what

#

die

#

i regret this already

warped dust
#

rewriting my website in crystal

steady fog
#

rust is evil

#

hatred

warped dust
#

holy shit ruby on rails is actually fast

#

how

steady fog
#

nuh uh

#

rininininini

warped dust
#

nvm it isnt

steady fog
#

kill rini kill

warped dust
#

ruby so lsow

steady fog
#

@warped dust

solemn python
#

Full house, where three cards have the same label, and the remaining two cards share a different label: 23332
does this mean the 2 remaining cards have to be the same label or is 33321 a full house

steady fog
#

death

#

i kill rini

solemn python
#

oh wait im dumb

#

nvm

delicate crane
#

super sick and cant think right now even if I tried

skipping aoc today

real hinge
#

I FELL ASLEEP

#

OH MY GOD

steady fog
#

@real hinge how

#

im doing rust today this is awful

real hinge
#

It is

steady fog
#

java is better

real hinge
#

Guh I have to have breakfast and go to school in 30 mind

steady fog
#

thread 'main' panicked at ./day-07-rust.rs1044:
called Result::unwrap() on an Err value: ParseIntError { kind: InvalidDigit }
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

#

shut the fuck

real hinge
#

ohgod

#

stupid poker

sullen fiber
#

i just woek up fgrom tha nap

real hinge
#

I dont know how to play that game

sullen fiber
#

i did it in desmos first

#

then in uiua after submitting

#

felt dirty...

#

this looks fire

teal mountain
#

today was ok

sullen fiber
#

im do in uiua

native pewter
#

what the fuck it doesnt build anymore

#

WHAT THE FUCK I JUST DID 2015

#

im gonna kms

#

this is so rarded

solemn python
native pewter
#

fuck me.

solemn python
#

oh wait im an idiot

native pewter
#

2015 day 7```crystal
require "log"

def one(input : String) : Int32 | Nil
wires = Hash(String, String).new

input.split("\n").each do |line|
    spl = line.split(" -> ")
    wires[spl[1]] = spl[0]
end

calcOp(wires, Hash(String, Int32).new, "a")

end

def calcOp(wires : Hash(String, String), known : Hash(String, Int32), op : String) : Int32
if known.has_key?(op)
return known[op]
end

if /\d+/.match(op)
    return op.to_i32
end

if wires.has_key?(op)
    spl = wires[op].split(" ")
    if spl.size == 1
        known[op] = calcOp(wires, known, spl[0])
    elsif spl.size == 2
        known[op] = ~calcOp(wires, known, spl[1])
    elsif spl.size == 3
        if spl[1] == "AND"
            known[op] = calcOp(wires, known, spl[0]) & calcOp(wires, known, spl[2])
        elsif spl[1] == "OR"
            known[op] = calcOp(wires, known, spl[0]) | calcOp(wires, known, spl[2])
        elsif spl[1] == "LSHIFT"
            known[op] = calcOp(wires, known, spl[0]) << calcOp(wires, known, spl[2])
        elsif spl[1] == "RSHIFT"
            known[op] = calcOp(wires, known, spl[0]) >> calcOp(wires, known, spl[2])
        end
    end
    return known[op]
end

return 0

end

def two(input : String) : Int32 | Nil
wires = Hash(String, String).new

input.split("\n").each do |line|
    spl = line.split(" -> ")
    wires[spl[1]] = spl[0]
end

a = calcOp(wires, Hash(String, Int32).new, "a")

known = Hash(String, Int32).new
known["b"] = a

calcOp(wires, known, "a")

end

solemn python
#

why do I keep doing this

native pewter
#

dont drink and code kids

harsh marsh
#

LOL

#

wait did I do 2015 day 7

steady fog
#

lina moment

sullen fiber
#

LMAO

#

LAMO

harsh marsh
#

ballmer peak experiment failed

sullen fiber
#

guh ok back time to code for real

proper totem
#

works on example but not real

#

bleh

teal mountain
#

do you want my big input + answer @proper totem

#

for debugging

proper totem
#

that could be neat

teal mountain
harsh marsh
#

the example was really weak this time

#

i submitted like 3 times wrong before getting it

#

all passed the example

teal mountain
#

part 1 ||251136060||, part 2 ||249400220||

teal mountain
real hinge
#

You dont need to spoil

#

H

teal mountain
#

i had one wrong submission on p2, but i realised that there was so many conditions that the example wasn't touching

teal mountain
native pewter
#

time for bed.

sullen fiber
#

true tur

#

true true

teal mountain
#

@harsh marsh what the fuck 34 second delta

#

damn

#

oh wait that was yesterdays

#

oops

sullen fiber
#

lole

teal mountain
#

i actually got the p2 logic like 98% fully correct on my first write

#

but i spent like 2 mins debugging smth stupid

#

my approach was basically to ||have a frequency table of hands, and add J's frequency to the most frequent hand, but i wasn't accounting for 5x J's||

harsh marsh
#

I would have gotten like a 30 second delta but i forgot about some really dumb standard library behavior

#

||the 5Js|| gave me an exception the first time I ran so I caught that

proper totem
#

dkfjndkfjnkjnKjnKjndksjnvkDJNKJNVKDJFNKDFJVDKFJVDFVKJN

#

||my answer was wrong because I wrote a new sorting function for the different strengths with joker but forgot to use it instead of my original one||

#

nvm that was apparently just one of many issue frog_dancin

#

blehhh

#

I don't know what I changed but it works now

sullen fiber
#

i love uiua updating and then failing at the last second after 10m of fetching an dcompiling

proper totem
#

my brain's smartness knows no bounds

sullen fiber
#

huge

solemn python
#

aaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAa my example is correct but not actual input

#

and my code is absolute hell to debug

#

ok found my issue

#

success

#

my code is shit but it works so don't judge me

solar tide
#

where is your code

solemn python
#

well I haven't pushed it yet

#

i will in a sec

solar tide
#

my code is ok

sullen fiber
#

uiua compiled omg

#

🙌

solar tide
#

had to write a frequency and a sort function though

#

did today in Typescript

#

actually I was thinking, maybe I'll rewrite this in civet or coffee

solemn python
#

so many lines of code wahhgone

#

@sullen fiber when large input

sullen fiber
#

soon tm

#

i have to do part 1 and 2 in uiua first

solemn python
#

or should I make one trolley

#

ill do that

#

seems easy enough

sullen fiber
#

are u gonna pr it or just make for fun

solar tide
#

alright I'll scrap my current code and do today in jq

#

fuck it we ball

solemn python
#

ill make a large input and you can choose to add it or not idc

#

I just want to test my code

sullen fiber
#

real

#

i wont cus i want the generators in the repo

#

i wonder what a large input looks like

solemn python
#

hm

#

well probably just a crap ton of ranomized cards + inflate the bids some fun number of digits for comedic bignum effect

#

I guess I won't do it myself then

#

I should sleep

#

if I had more time I would pr it in ts

hazy sinew
#

worst day of my life

#

wtf

solemn python
#

how so

sullen fiber
#

what happend

hazy sinew
#

i was COOKING in part 2

sullen fiber
#

eagely playing ranked aoc

hazy sinew
#

instead of just doing ||cards.replace("J", "23456789TQKA")|| i tried to ||do some + or - depending on the amount of js and the amount of other uniuqe characters and get it that way (horrible idea)||

hazy sinew
#

im #3 here

steady fog
#

@solemn python tyminky

solemn python
#

@steady fog zeeter

solemn python
#

Not that it's much of a competition

#

I'm like the only one who does days directly after release

hazy sinew
#

moulberry one doesnt count

#

im moving up in the kotlin one hopefully ill get top 10

solemn python
#

Competitive advent of code participator (derogatory)

hazy sinew
#

ok for the next 30 minutes im gonna be deleting code and seeing if anything changes

steady fog
#

@solemn python what lang are you doing

solemn python
teal mountain
#

but eyy you finally got it, gj

steady fog
solemn python
#

I love rust as a language and this is my first AoC so I'm not doing anything crazy

#

Just sticking to what I know for now

hazy sinew
#

wouldve gotten me like #200

#

excited for tomorrow tho because its gonna be super easy

steady fog
#

i keep forgetting to push my code

proper totem
steady fog
#

@proper totem vscode plugin that reminds me in a way I notice

proper totem
#

that doesn't change anything

steady fog
#

tyminky are you using regex to identify the type of hand

#

or some other method

hazy sinew
steady fog
#

I'm using rust too

proper totem
#

having a J will never get you a full house because it could get you a four of kind instead which is higher

hazy sinew
#

what about 23J32

solemn python
proper totem
#

ah I mispoke because i misremembered the logic

#

but yes it would still work

proper totem
#

||just sort by most cards add j to first in array||

#

and you'll get a full house but it wouldn't change it because it doesn't matter which card you have three or two of

hazy sinew
#

heres my refactored approach that i ended up using (not the orginal one)
||

 private fun valueOf(s: String): Int {
        val hand = s.map { if (it == 'J') "23456789TQKA" else it.toString() }.joinToString("")
        val uniques = s.replace("J", "").distinct().count()
        val counts = hand.groupingBy { it }.eachCount()

        val score = when {
            counts.any { it.value == 5 } -> 6
            counts.any { it.value == 4 } -> 5
            uniques == 2 && counts.any { it.value == 3 } -> 4
            counts.any { it.value == 3 } -> 3
            uniques == 3 && counts.any { it.value == 2 } -> 2
            uniques == 4 -> 1
            else -> 0
        }

        return score
    }
```||
proper totem
#

fancy

#

have idea to make mine more performant with that

solemn python
#

Yeah my solution was needlessly overcomplicated, fun

#

But who cares, it works

hazy sinew
#

if i realized that i can just ||replace all Js with 23456789TQKA|| then i wouldve had part 2 in like 22 minutes

proper totem
#

nvm wouldn't make it more performant probably since I'd need to add more logic for it

hazy sinew
#

also how did u guys compare by strength

solemn python
#

Wdym?

proper totem
#

||const strengths = "23456789TJQKA" compare indexof card and sort`||

hazy sinew
#

bruh

solemn python
#

Yeah

#

That

hazy sinew
#

||

    fun compareHands(hand1: String, hand2: String): Pair<String, String> {
        val cardsHand1 = hand1.map { charToCardRank(it) }
        val cardsHand2 = hand2.map { charToCardRank(it) }

        for (i in 0 until 5) {
            if (cardsHand1[i] != cardsHand2[i]) {
                return if (cardsHand1[i] > cardsHand2[i])
                    Pair(hand1, hand2)
                else
                    Pair(hand2, hand1)
            }
        }

        return Pair(hand1, hand2)
    }

    fun charToCardRank(ch: Char): CardRank {
        return when (ch) {
            'A' -> CardRank.ACE
            'K' -> CardRank.KING
            'Q' -> CardRank.QUEEN
            'T' -> CardRank.TEN
            '9' -> CardRank.NINE
            '8' -> CardRank.EIGHT
            '7' -> CardRank.SEVEN
            '6' -> CardRank.SIX
            '5' -> CardRank.FIVE
            '4' -> CardRank.FOUR
            '3' -> CardRank.THREE
            '2' -> CardRank.TWO
            'J' -> CardRank.JOKER
            else -> throw IllegalArgumentException("Invalid card character: $ch")
        }
    }
    enum class CardRank(val displayName: String, val value: Int) {
        ACE("Ace", 14),
        KING("King", 13),
        QUEEN("Queen", 12),
        TEN("10", 10),
        NINE("9", 9),
        EIGHT("8", 8),
        SEVEN("7", 7),
        SIX("6", 6),
        FIVE("5", 5),
        FOUR("4", 4),
        THREE("3", 3),
        TWO("2", 2),
        JOKER("Joker", 1);
    }
```||

this is where i spent most of part 1
proper totem
steady fog
#

I need to make another enumm

solemn python
#

I love enums but that's not the way to use them husk

steady fog
#

hand > hand2

#

then

hazy sinew
#

wtf bro Exception in thread "main" java.lang.IllegalArgumentException: Comparison method violates its general contract!

#

i didnt sign no contract

sullen fiber
#

violates its general contract

#

that ius crazy

hazy sinew
#

i think its cuz i did ||"23456789TQKA".indexOf(hand) and not .indexOf(card)||

teal mountain
hazy sinew
#

so ur telling me i couldve done this instead of making an enum class, a converter and a comparison with a for loop?
||```kotlin
fun compareHands(hand1: String, hand2: String): Pair<String, String> {
val cardOrder = "J23456789TQKA"

    return hand1.zip(hand2)
        .find { it.first != it.second }
        ?.let { if (cardOrder.indexOf(it.first) < cardOrder.indexOf(it.second)) Pair(hand1, hand2) else Pair(hand2, hand1) }
        ?: Pair(hand1, hand2)
}
teal mountain
#

😨

sullen fiber
#

oh damn i didnt actually see my input til now

#

rip whatever edge case im hitting

hazy sinew
#

i was staring at my input for an hour trying to figure out whats wrong, manually comparing everything to find the edge case and then ended up just ||replacing J with 23456789TQKA||

teal mountain
#

||```ts
const HANDS = [
'A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2'
];

const getType = (card: Card): number => {
const freq: Record<string, number> = {};
for (const hand of card.hand) {
freq[hand] ??= 0;
freq[hand]++;
}

const k = Object.keys(freq);
const v = Object.values(freq);
let num = k.length;

if (num === 2 && v.includes(1)) return num;
if (num === 2 && v.includes(2)) num += 0.5;
if (num === 3 && !v.includes(3)) num += 0.5;

return num;
};

const compare = (a: Card, b: Card): number => {
const aType = getType(a);
const bType = getType(b);

if (aType < bType) return 1;
if (aType > bType) return -1;

for (let i = 0; i < 5; i++) {
const aRank = HANDS.indexOf(a.hand[i]);
const bRank = HANDS.indexOf(b.hand[i]);
if (aRank < bRank) return 1;
if (aRank > bRank) return -1;
}

return 0;
};

sullen fiber
#

oh is ee the issue

#

im sorting hands like garbage

teal mountain
#

ah yeah

#

just try not doing that

#

lmk if that works

sullen fiber
#

TRUE

#

TRUE

#

ok still some problem.

hazy sinew
#

its so nice seeing all of these be gray

sullen fiber
hazy sinew
#

so what was the edge case

sullen fiber
#

i still have edge cases

#

i just misread the text

#

||i was sorting hands like "KTJJT" -> "JJTTK" to do the strength comparisons||

teal mountain
#

today's text didn't have too much bullshit which i'm glad for. it was a lot to read in general tbh

sullen fiber
#

||but i was supposed to be comparing strength in the order it was dealt||

#

really unsure what the edge cases are tho

hazy sinew
#

its all gonna be correct

#

except 1 single mismatch

#

because all the cards are different

#

so one of them might not be handled correctly but only that specific scenario

sullen fiber
#

yea i just have no way of telling which is being handled wrong

teal mountain
#

yeah the sample for today sucked, i posted my big input + answer somewhere above if u need it

sullen fiber
#

the issue is more finding which card im handling wrong

#

err which hand

hazy sinew
#

have fun

sullen fiber
#

true

hazy sinew
#

u can send me ur input and ill give u the correct list back

#

so u can find the edge case

sullen fiber
#

ya that would help actually

hazy sinew
#

dm

sullen fiber
#

holy shit

#

who made shiki work in files

#

that is based

solar tide
sullen fiber
#

apparently ive been doing it right the whole time

#

and im summing wrong

#

but i get the example right

#

so HWO

#

HOW

hazy sinew
#

me when vap sorts the list correctly, sorts the bids correctly but doesnt know elementary school math

#

we should create a better example input

sullen fiber
#

LMAO

#

@warped dust help

#

i spent 2 hours

#

on part 1 today

#

because i didnt know the difference between indices and ordinals

#

guys rate my part 1

hazy sinew
#
2345A 2
2345J 5
J345A 3
32T3K 7
T55J5 17
KK677 11
KTJJT 23
QQQJA 19
JJJJJ 29
JAAAA 37
AAAAJ 43
AAAAA 53
2AAAA 13
2JJJJ 41
JJJJ2 31

can yall run this and make sure part 2 is sorted ascending

#

and the answer is 3667

#

i forgot about the fact that 2 prime numbers can have the same lcm

sullen fiber
#

true u need coprimes

real hinge
#

No one will understand that anyway

sullen fiber
#

because what if u read it and it spoils

#

😦

#

actually

#

you need prime coprimes

#

set of primes that is setwise coprime

teal mountain
#

nerd

sullen fiber
#

china

#

remainder theory

hazy sinew
sullen fiber
#

true

hazy sinew
#

i did this

sullen fiber
#

oh my god wait

#

oh ok no that didnt happen to me

#

thats crazy

hazy sinew
sullen fiber
#

everything is a one liner

hazy sinew
#

wtf is this guys i did 2022 in november 2023 and im first

sullen fiber
#

well its kinda obvious look at the stars

hazy sinew
#

how did nobody here complete 2022

sullen fiber
#

probably motivation death

#

personally i had lots of other things going on in life

real hinge
#

I just got bored after like day 13-14

#

problems were getting very hard and because ı was not enjoying I told myself why continue

sullen fiber
#

yea i had funner things to do but this year i dont really so

#

woohoo

hazy sinew
#

i personally enjoyed every day

#

especially the ones that took me more than 10 hours

sullen fiber
#

real matrix

#

ok did part 2

sullen fiber
hazy sinew
sullen fiber
#

SHUT UP

tranquil vapor
hazy sinew
#

i helped like 30 people with my example input

#

maybe i should start making one every day if the one provided is shit

real hinge
#

how does that work

#

do we only check first different letter

#

???

#

@hazy sinew tell

hazy sinew
#

32222 beats 2AAAA

real hinge
#

okay

real hinge
#

That's not the right answer; your answer is too high. If you're stuck, make sure you're using the full input data; there are also some general tips on the about page, or you can ask for hints on the subreddit. Please wait one minute before trying again. [Return to Day 7]

#

WHY PART 2 IS WRONG

native pewter
#

@rotund moth

hazy sinew
#

day 6 part 2 should have been

As the race is about to start, you realize the piece of paper with race times and record distances you got earlier actually just has very bad kerning. There's really only one race - ignore the spaces between the numbers on each line.
You realize that your boat would move much faster if you also manually pushed it.
To manually push your boat, you need to let go of the button for 5 milliseconds, and then give it a good shove. Pushing your boat will double its speed for the first 50 milliseconds.

How many ways can you beat the record in this one much longer race, while also being able to push the boat?
native pewter
#

stop dreaming

real hinge
#

IGNORE DAY6

#

DAY7 BAD

real hinge
hazy sinew
#

what

real hinge
#

supposed to get 6839

hazy sinew
#

print the list and compare

real hinge
#

doing

tranquil vapor
real hinge
#

I submitted wrong answer once because of that

tranquil vapor
#

it's cause you didn't end ur print with a newline

#

your terminal auto inserted a newline

real hinge
#

bad

tranquil vapor
#

to indicate that it inserted it it adds a %

#

you can disable the %, I did

real hinge
#

I just converted print to println!

#

should work gi

tranquil vapor
#

yop

hazy sinew
#

hear me out

tranquil vapor
#

eagely has gone fully insane from advent of code

hazy sinew
#

HEAR ME OUT

tranquil vapor
hazy sinew
#

mantikas favorite langugae is probably whatever windows uses

real hinge
#

nıp

tranquil vapor
#

her favourite language is python

#

and java

real hinge
#

ve

#

I am getting wrong answer

#

help

hazy sinew
tranquil vapor
#

fix

hazy sinew
real hinge
#

JAVA IS LOOOOVELY

real hinge
hazy sinew
#

send

real hinge
#

2345A 1
J345A 2
2345J 3
32T3K 5
KK677 7
T3Q33 11
Q2KJJ 13
T3T3J 17
Q2Q2Q 19
2AAAA 23
T55J5 29
QQQJA 31
KTJJT 34
JJJJJ 37
JJJJ2 41
JAAAA 43
2JJJJ 53
AAAAJ 59
AAAAA 61

hazy sinew
#

dont replace the most common number with j

#

cuz then ur gonna end up failing when sorting

#

joker is only here to pretend to be another number, not actually be another number

real hinge
#

I am sorting with original chars

#

also I replace after sorting

hazy sinew
#

then dont replace

real hinge
#

yes

#

theres 2 arrays

#

one is replaced

#

other one is regular

hazy sinew
#

print the non replaced sorted one

real hinge
#

wait

#

somethings off

#

oaky here

#

I see the problem I think

hazy sinew
#

send ur logic for 4 of a kind

real hinge
#

I just need to figure out how to fix it

hazy sinew
#

send ur entire eval function

real hinge
#

weait my code is unreadable

#

I will try fix it myelf

hazy sinew
#

ok

real hinge
#

also this is my logic

hazy sinew
#

send the thing that actually checks what a hand is

real hinge
#

thank god

#

the problem was

#

I was first calculating character counts, and putting them into some vector

#

then I was removing "J" element and add its count to element at 0

#

problem is if J has the highest count, I was making J 2x of it and removing it

#

then any J would disappear and therefore boom

hazy sinew
#

wait cant u u just do part2Score(hand) = part1Score(hand.replace("J", "")) + hand.count("J")

#

someone try this im too lazy

real hinge
#

probably not

#

because J changes strength

hazy sinew
#

not with ur logic

#

only later

#
private fun valueOf(hand: String): Int {
        val uniques = hand.replace("23456789TQKA", "").distinct().count()
        val counts = hand.groupingBy { it }.eachCount()
        val score = when {
            counts.any { it.value == 5 } -> 6
            counts.any { it.value == 4 } -> 5
            uniques == 2 && counts.any { it.value == 3 } -> 4
            counts.any { it.value == 3 } -> 3
            uniques == 3 && counts.any { it.value == 2 } -> 2
            uniques == 4 -> 1
            else -> 0
        }
        return score
    }
#

p2score = valueOf(hand.replace("J", "")

  • if (valueOf(hand) != 6) hand.count("J") else 6
#

tho i did basically the same thing except p2score = valueOf(hand.replace("J", "23456789TQKA")) and then removed that string again for the uniques

real hinge
#

@tranquil vapor dont do todays aoc

tranquil vapor
real hinge
#

todays was a bit husk

tranquil vapor
#

OH MY GOD SO MUCH TEXT

#

32T3K 765
T55J5 684
KK677 28
KTJJT 220
QQQJA 483

real hinge
#

|| ```
1:parse inputs
2: count all characters, then order them by length of each character; if character count is same order them by strength
3:loop over game modes and convert character count to game type
4: sort the results by game type, if game type is same loop over characters and order by strength
5: calculate the output

tranquil vapor
#

okay this doesnt seem too hard

real hinge
#

NO

#

IT DOESNT SEEM LIKE

#

BUT dread

tranquil vapor
#

very easy

#

i just finished

real hinge
#

answer

tranquil vapor
#

wait this is actually easy

#

yop

real hinge
#

NO DIE

#

I wasted at least 1 hour on this

tranquil vapor
#

nooob

real hinge
#

I will kill you

tranquil vapor
#

i finished part 1

real hinge
#

I am probably

tranquil vapor
#

jk i didnt

#

but it shouldnt be too hard tbh

#

i will code now

#

i wonder what the best way to store data is

#

maybe class

real hinge
#

You made me lose fatih on myself

tranquil vapor
#

very useful docs

real hinge
#

class Person
end

tranquil vapor
#
class Hand
  getter :cards, :bid, :rank

  def initialize(cards : String, bid : Int32)
    @cards = cards
    @bid = bid
  end

  def self.from(line : String)
    cards, bid = line.split " "
    self.new(cards, bid.to_i)
  end
end
#

cursed syntax

#

INSANE

#

/run ```cr
puts "explode".succ

split heartBOT
#

Here is your cr(0.36.1) output @tranquil vapor

explodf
harsh marsh
#

s u c c

hazy sinew
tranquil vapor
#

do u ever write code, run it, and it immediately works

#

wow part 2 is easy as fuck with my approach

#

i love my solution so much

#

its clean

tranquil vapor
# tranquil vapor its clean
def solve(file)
  hands = File.read_lines(file).map do |line|
    Hand.from line
  end

  puts file, hands.sort!.map_with_index { |h, i| h.bid * (i + 1) }.sum
end
#

i just implemented comparison operator in my class

#

@real hinge today is very easy and cozy

#

wdym

native pewter
#

hop on 2015 day 7

tranquil vapor
#

now i will use inheritence for part 2

real hinge
tranquil vapor
#

part 2 done

#

so easy

#

with oop

#

easy imo

#

mmmm

#

@real hinge did u finish day 7

#

check my solution

SO CLEAN

#

one of the rare times OOP is op

#

cause i just swapped out the card list and rank calculate func via inheritence

real hinge
tranquil vapor
#

it really is easy

#

i cleaned up further

#

now its really readable

#

WAIT I FORGOT TO SUBMIT MY ANSWER LOL

#

oh not right actually

#

maybe i forgot smth

#

i think i know why

#

yep

#

small flaws where i might || count jokers twice ||

native pewter
#

🤡

tranquil vapor
#

GHONNA BE LESS CLEAN

#

ITS OVER

native pewter
#

guys,

sullen fiber
#

This app retheme is kinda goated

tranquil vapor
#

WHY DOES THIS RETURN RETURN FROM PARENT

harsh marsh
#

because its just in a block not a function

tranquil vapor
#

how do u return from block...

harsh marsh
#

you don't they're blocks

tranquil vapor
#

RETURN VALUE

real hinge
tranquil vapor
#

nop

real hinge
#

yop

#

its readable

tranquil vapor
#

first i need to finish mine

real hinge
#

I DONT CARE

#

READ

native pewter
#

matrix

#

thingiemabob

tranquil vapor
#

GUHH I HAVE TO WAIT 5 MINUTES

#

u will send me ur input and part 2 solution @real hinge

#

do

tranquil vapor
#

GUH

real hinge
tranquil vapor
real hinge
#

I went insane with part 2 too

tranquil vapor
#

nop im close

real hinge
#

okay

tranquil vapor
#

SOLVED

#

easy

#

previously it was so pretty
now its SOO ULGY

#

fix commit

real hinge
tranquil vapor
#

because 5 minutes wait posttroll

#

anyway now i will check ur solution

real hinge
#

okay

#

do

tranquil vapor
#

well i take it back it wasn't that easy, but once i realised my mistake of || counting jokers multiple times || it was easy to fix

#

/run ```cr
puts "u love this method"
print "399Q9".chars.tally, "\n"
print "399Q9".chars.tally.values.sort! { |a, b| b <=> a }

split heartBOT
#

Here is your cr(0.36.1) output @tranquil vapor

u love this method
{'3' => 1, '9' => 3, 'Q' => 1}
[3, 1, 1]```
tranquil vapor
#

@real hinge we need to add proper threading and async await syntax to crystal

#

tbh u can probably easily implement async await with a library

tranquil vapor
real hinge
#

dont you need to implement threads in compiler level

tranquil vapor
#

crystal already has coroutines

#

u can just use those to implement async await

#

for real threading yes you'd likely need to edit compiler or make a C library

tranquil vapor
#

malware

sullen fiber
#

Under trans

real hinge
#

this is so unreadable fr

teal mountain
#

new malware bundles the uiua compiler and uiua source programs

sullen fiber
#

TRUE

real hinge
#

true

#

imagine randomly seeing uiua compiler in your pc

sullen fiber
#

Soon I will start writing Uiua byte code

teal mountain
#

you should do aoc in ijvm bytecode

sullen fiber
#

What is ijvm

teal mountain
#

a subset of the jvm ISA that works exclusively on integers

#

you get a stack and you get integer ops

#

IJVM is an instruction set architecture created by Andrew Tanenbaum for his MIC-1 architecture. It is used to teach assembly basics in his book Structured Computer Organization.
IJVM is mostly a subset of the JVM assembly language that is used in the Java platform. This instruction set is so simple that it's difficult to write complex programs i...

sullen fiber
#

FIRE

#

SOON

teal mountain
#

wait

#

can you guys google "ijvm instruction set" and show me the first 3 results

harsh marsh
#

I did one or two AoC days in whitespace

#

now THIS is malware

teal mountain
harsh marsh
#

to be fair i cheated by using an assembler

harsh marsh
#

intcode was fun

hazy sinew
sullen fiber
#

It's probably about the same

#

Worse cus some of the utilities u get in Uiua don't exist in the byte code cus they're inlined

#

I will miss fork

hazy sinew
#

can u do 🎄🎄x in bytecode

sullen fiber
#

CHRISTMAS TREE

#

Yes that's a primitive I think

hazy sinew
#

RISE

sullen fiber
#

RISE

#

FALL

#

The bytecode isn't even real bytecode so hell

#

It's like a tree

hazy sinew
#

ur subconciously convincing me to use uiua

sullen fiber
#

😁

tranquil vapor
solar tide
solemn python
harsh marsh
#

ooh that's a good idea

#

...maybe the other way around though

#

it'd have to be a language that doesn't care about whitespace very much like C

sullen fiber
#

I'm gonna have to do the next week late since I'm in Florida

#

I'mma have to like walk to a library to do them

warped dust
#

uiua mobile keyboard

sullen fiber
#

Can this be real

#

Do u think I can Uiua mobile

#

But the input file pain

warped dust
#

vim on termux (do not

sullen fiber
solemn python
steady fog
#

@solemn python

#

@solemn python @solemn python @solemn python @solemn python @solemn python @solemn python @solemn python

solemn python
#

yop

sullen fiber
#

Real

#

@native pewter this one you will do in asm

real hinge
#

OH MY GOD

#

@steady fog PATHFINDING JUMPSCARE

sullen fiber
#

You love

#

Can someone graph their input

#

And send in spoiler for me

real hinge
#

last year I straight ignored the pathfinding day

real hinge
sullen fiber
#

Like a node graph

real hinge
#

oh

steady fog
#

i like path finding

#

its fun

real hinge
#

I have zero idea how I am gonna do this

#

last year tried brute force and ended up with billions of searches

steady fog
#

i am using java today

real hinge
#

good

steady fog
#

guh i installed gnome @real hinge

#

it makes me cry