#AdVENt of Code
1 messages · Page 9 of 1
i change this to crystalline?
ohh

compiling this takes longer than compiling crystal itself lol
way longer
its still compiling

vee cannot wait two minutes
THIS IS A TERRIBLE NAME https://github.com/samueleaton/sentry
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
yop
vee not everyone is a webdev
why isnt this showing me an error
she's having a reality shock
is this valid
holy shit
it might split it into chunks of 3 chars
/run ```cr
print "explosionsssssoooooooo".split 3
nah
Here is your cr(0.36.1) output @tranquil vapor
["explosionsssssoooooooo"]```
i only need intellisense
qhar

wtf does it do then
/run ```cr
print "explosio3nsssssoooooooo".split 3
does it just cast to string
Here is your cr(0.36.1) output @tranquil vapor
["explosio3nsssssoooooooo"]```
Makes an array by splitting the string on any ASCII whitespace characters (and removing that whitespace).
???
/run ```cr
print "i am going to explode".split 3
Here is your cr(0.36.1) output @tranquil vapor
["i", "am", "going to explode"]```
ohhhh so real
/run cr print "abc def ghi jkl def iek".split 3
fire
Here is your cr(0.36.1) output @sullen fiber
["abc", "def", "ghi jkl def iek"]```
wait thats actually fire
mb i saw too late!
Here is your cr(0.36.1) output @sullen fiber
["abc def ghi jkl def iek"]```
/run ```cr
print "real::banana::lover".split "::", 2
Here is your cr(0.36.1) output @tranquil vapor
["real", "banana::lover"]```
thats so real
who needs DOCS
when you have LSP
im definitely going to never use the parentheses-less syntax
we need to write eval func in crystal
bluepilled...
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"
@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
! means inplace
ur mom dangerous
/run ```cr
print "ven".strip!
this is the worst part of crystal
wouldnt it mean mutation
@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
no!!!!
i hate when u always have to include lang in ur searches
is this a real lsp
LOL
its kinda bad lol
wait did u enable intellisense in settings
but yeah naming convention is cool
i have these
/run ```cr
Array(Int64).new.unsafe_fetch 10
@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] ???
FIRE
why does it have that method lmaoo
whats the point of unsafe array methods
crystal is strange cause it has like everything you could ever ask for and still didnt become famous
it has so much shit
yerah,
fire language
so many features and almost c speed too
ok now how run crystl
crystal banana.cr
LSP so bad that it's faster to run the compiler to see if there are errors than use the IDE

this istrue
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
WRONG CHAT GIRLIE
when u gonna shards
@tranquil vapor hi
hiii
Crystal so funny
@tranquil vapor my day 5 solution uses so much ram
systemd oom killer kills it
is day 5 the one with the cards
nop
on the normal input? or large input
okay
issue
soon
did u write that
i don even get whats going on
Makes sense, it's just math which is easy to oneline
Unless you did it the boring way
i did it the boring way because theres nothing stopping you from doing it
kinda dum
like at least yesterdays brute force took a few minutes
you love
I did too at first but then I did the smart way to deal with the Large Input™
0ms
nuh uh
i think hyperfine
might

What distro btw
fedora
its literally instant
give biggerrrrr input @steady fog
generate 100mb input
howw
yop
@tranquil vapor did you use crystal conccurrencyu
i thought it was larger input
no
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
i dont know how i would brute force
brute force would just be manually testing every single seed number in the ranges
xd
i did that first it was sooo slow
how did nice make it worse lmfao
wtf is nice
WHAT
what now
how do u not know nice...
why does nice make it seem slower
i have no idea.
nice seems slightly slower
go look at man page
just doing nice lowers its priority i think?
nuh uh
VENCORD IS INAPPROPRIATE
i think the lower the number the higher the priority
iirc
yes.
we had CFS and niceness in uni exercise recently :3
(and then they changed scheduler)
if it adds 20 to the niceness doesnt that mean lower priority
it goes -20 to 19
oh i was reading the args wrong
i thought -n means put the number wher n is
and that nice -20 means add 20
honestly idek because nothing i did seemed to make it faster
@sullen fiber you love
off by how much
do you want the reason
ur kinda silly
waiting
- Your plugged in distance should actually be distance + 1
- Floor the higher solution and ceil the lower one before subtracting
- Add one to the final result
thats the method that works for me after cheating by looking at reddit
are u not using like bigints
I am
what do u mean "ceil" and "floor"
ceil: round up
floor: round down
how do u round an integer
the equation is continuous
the solutions aren't integers
ok well to be specific
I am using Irrational BigInts
from some library I found
oh ur using bigfloats
what lang are you using
ts
ah
i was thinking
well just check the rounding on your bigint math, it probably defaults to floor or something
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
too much coding of advents for the vap
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
@solemn python
arent you like torturing yourself with rust
also you dont need to feel bad 
as long as you learned something you finished aoc!
ill probably give up too some time bc im not that smart xd
**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)
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
theres no penalty so its intended 
ur aoc runner seems cool
i would totally make smth similar but i use many different languages so it's pointless
wth so much effort
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
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
in my opinion ur insane
In my opinion I agree
No not in terms of speed
anyone making an elaborate setup to finish it faster is a loser
Just in terms of making fun projects that aren't just 25 files in a row
So true
thanks, it's also published on npm
it has templates support so you can do this
@tranquil vapor lol it finally finished
my brute force took 21 minutes
works though
for what
day 5 p2
p2 normal input?
wdym
they really out here misspelling advertisements
what lang
crystal
so slow,
nuh uh
i could make it go faster by using threads
but then i need to find a way to set a max amount
cheater
nuh uh
youre like 14
the most basic physics problem ever
but sure
anyways d7 time
why are you all brute forcing then
because it takes less than a second to do and its the easy copy paste solution
less than a second to write you mean?
but its lame
easy to understand
I did the maths after initially solving it w/ brute force
vap did the maths
🙏
they solved it in desmos iirc
my goat
they're references
same thing
what do you expect
you
every string method works on them like normal
hm this one doesn't look too bad but im sure p2 is hell
guh so much info to parse
hard for LLM and hard for human
probably doesn't help that I've never played poker
error[E0277]: the size for values of type str cannot be known at compilation time
what
die
i regret this already
rewriting my website in crystal
nvm it isnt
kill rini kill
ruby so lsow
@tranquil vapor loves https://github.com/soveran/toro
@warped dust
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
super sick and cant think right now even if I tried
skipping aoc today
It is
java is better
Guh I have to have breakfast and go to school in 30 mind
thread 'main' panicked at ./day-07-rust.rs
44:
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
https://github.com/CodeF53/AdventOfCode/blob/main/src/2023/07.ts
heres how far I got before realizing brain no worky
i just woek up fgrom tha nap
I dont know how to play that game
yes i did but
i did it in desmos first
then in uiua after submitting
felt dirty...
this looks fire
today was ok
im do in uiua
what the fuck it doesnt build anymore
WHAT THE FUCK I JUST DID 2015
im gonna kms
this is so rarded
angy
fuck me.
oh wait im an idiot
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
why do I keep doing this
@sullen fiber sobbing rn
dont drink and code kids
lina moment
ballmer peak experiment failed
guh ok back time to code for real
that could be neat
the example was really weak this time
i submitted like 3 times wrong before getting it
all passed the example
part 1 ||251136060||, part 2 ||249400220||
agreed
i had one wrong submission on p2, but i realised that there was so many conditions that the example wasn't touching
i know, i do just in case because some people don't even want a ballpark
time for bed.
@harsh marsh what the fuck 34 second delta
damn
oh wait that was yesterdays
oops
lole
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||
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
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 
blehhh
I don't know what I changed but it works now
i love uiua updating and then failing at the last second after 10m of fetching an dcompiling
okay so this did actually solve it i just ran with my input but looked at aeth's answer instead and thought i had it wrong because of that
my brain's smartness knows no bounds
huge
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
where is your code
my code is ok
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
are u gonna pr it or just make for fun
ill make a large input and you can choose to add it or not idc
I just want to test my code
real
i wont cus i want the generators in the repo
i wonder what a large input looks like
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
how so
what happend
i was COOKING in part 2
eagely playing ranked aoc
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)||
i at least wanna win on some private leaderboards
im #3 here
@solemn python tyminky
@steady fog zeeter
Well take pride in knowing you are definitely winning MB
Not that it's much of a competition
I'm like the only one who does days directly after release
Competitive advent of code participator (derogatory)
ok for the next 30 minutes im gonna be deleting code and seeing if anything changes
@solemn python what lang are you doing

Rust
but eyy you finally got it, gj
guh
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
i had a solution implemented for part 2 in about 30 seconds too except it was wrong and i shouldve just went with the simpler one (||replacing every J with 23456789TQKA||)
wouldve gotten me like #200
excited for tomorrow tho because its gonna be super easy
i keep forgetting to push my code
||you could just add the number of J to the count of the card that was most common in hand||
@proper totem vscode plugin that reminds me in a way I notice
What about like full houses
that doesn't change anything
||i didnt calculate the most common cards in the hand, i just did hand.groupingBy { it }.eachCount { it.value == the number im checking rn }||
I'm using rust too
having a J will never get you a full house because it could get you a four of kind instead which is higher
what about 23J32
||I convert the hand into a vec of card repetitions (KK111 = 3,2 62881 = 2,1,1,1)||
Then match exact formats
||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
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
}
```||
if i realized that i can just ||replace all Js with 23456789TQKA|| then i wouldve had part 2 in like 22 minutes
nvm wouldn't make it more performant probably since I'd need to add more logic for it
also how did u guys compare by strength
Wdym?
||const strengths = "23456789TJQKA" compare indexof card and sort`||
bruh
||
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

I need to make another enumm
I love enums but that's not the way to use them 
if you wanna be extra fancy you can implement Comparable
hand > hand2
then
wtf bro Exception in thread "main" java.lang.IllegalArgumentException: Comparison method violates its general contract!
i didnt sign no contract
i think its cuz i did ||"23456789TQKA".indexOf(hand) and not .indexOf(card)||
holy pattern matching 😩
i just had an array of strings and compared indices
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)
}
😨
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||
||```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;
};
its so nice seeing all of these be gray
wait u were actually right
so what was the edge case
i still have edge cases
i just misread the text
||i was sorting hands like "KTJJT" -> "JJTTK" to do the strength comparisons||
today's text didn't have too much bullshit which i'm glad for. it was a lot to read in general tbh
||but i was supposed to be comparing strength in the order it was dealt||
really unsure what the edge cases are tho
have fun
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
yea i just have no way of telling which is being handled wrong
yeah the sample for today sucked, i posted my big input + answer somewhere above if u need it
have fun
true
u can send me ur input and ill give u the correct list back
so u can find the edge case
ya that would help actually
dm
yeah it was straightforward but long as fuck
apparently ive been doing it right the whole time
and im summing wrong
but i get the example right
so HWO
HOW
me when vap sorts the list correctly, sorts the bids correctly but doesnt know elementary school math
we should create a better example input
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
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
true u need coprimes
because what if u read it and it spoils
😦
actually
you need prime coprimes
set of primes that is setwise coprime
nerd
im instead just gonna hope nobody encounters this issue
true
everything is a one liner
wtf is this guys i did 2022 in november 2023 and im first
well its kinda obvious look at the stars
how did nobody here complete 2022
I just got bored after like day 13-14
problems were getting very hard and because ı was not enjoying I told myself why continue
yea
that doesnt reassure me, your code cant even do index * bid
SHUT UP
MATH IS EVEN LAMER
i helped like 30 people with my example input
maybe i should start making one every day if the one provided is shit
how does that work
do we only check first different letter
???
@hazy sinew tell
okay
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
@rotund moth
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?
stop dreaming
bad
what
supposed to get 6839
print the list and compare
doing
%
i dont even know why that exists
I submitted wrong answer once because of that
it's cause you didn't end ur print with a newline
your terminal auto inserted a newline
bad
yop
hear me out
eagely has gone fully insane from advent of code
mantika's favourite language
mantikas favorite langugae is probably whatever windows uses
nıp
mentally ill
fix
send list from my input
JAVA IS LOOOOVELY
it looks so different
send
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
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
print the non replaced sorted one
this shows non reoplaced ones
wait
somethings off
oaky here
I see the problem I think
send ur logic for 4 of a kind
I just need to figure out how to fix it
send ur entire eval function
ok
also this is my logic
send the thing that actually checks what a hand is
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
wait cant u u just do part2Score(hand) = part1Score(hand.replace("J", "")) + hand.count("J")
someone try this im too lazy
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
@tranquil vapor dont do todays aoc
too late
|| ```
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
answer
nooob
I will kill you
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
You made me lose fatih on myself
very useful docs
class Person
end
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
Here is your cr(0.36.1) output @tranquil vapor
explodf
s u c c
booilerplate
gnome 45 ❤️
cursed by vscode
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
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
no :(
hop on 2015 day 7
ı had pain
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
I did
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 ||
🤡
guys,
Recorded live on twitch, GET IN
https://twitch.tv/ThePrimeagen
Link to article: https://asvln.com/rants/pathetic.html
MY MAIN YT CHANNEL: Has well edited engineering videos
https://youtube.com/ThePrimeagen
Discord
https://discord.gg/ThePrimeagen
Have something for me to read or react to?: https://www.reddit.com/r/ThePrimeagenReact/
Kines...
WHY DOES THIS RETURN RETURN FROM PARENT
because its just in a block not a function
how do u return from block...
you don't they're blocks
RETURN VALUE
https://github.com/mantikafasi/advent-of-code-2023/blob/master/day07/src/main.rs @tranquil vapor read my solution
nop
first i need to finish mine
GUHH I HAVE TO WAIT 5 MINUTES
u will send me ur input and part 2 solution @real hinge
do
okay
249748283
248029057
GUH
did u not complete part 2
no lmao xd
I went insane with part 2 too
nop im close
okay
you werent this happy 6 minutes ago
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 }
Here is your cr(0.36.1) output @tranquil vapor
u love this method
{'3' => 1, '9' => 3, 'Q' => 1}
[3, 1, 1]```
@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
promise = async do
9 + 10
end
puts await promise # 21
doubt
dont you need to implement threads in compiler level
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
Mine is soooo much smaller
malware
Under trans
people should write in uiua instead of obfuscating
this is so unreadable fr
new malware bundles the uiua compiler and uiua source programs
TRUE
Soon I will start writing Uiua byte code
you should do aoc in ijvm bytecode
What is ijvm
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...
websocket language
2019
intcode was fun
its probably easier than writing actual uiua
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
can u do 🎄🎄x in bytecode
RISE
ur subconciously convincing me to use uiua
😁
solve @sullen fiber https://adventofcode.com/2024/day/8
there exists a shard for this for the latter
Hear me out: do part 1 in a normal language and part 2 in whitespace, all in one file
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
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
uiua mobile keyboard
vim on termux (do not
my condolances
)
@solemn python
@solemn python @solemn python @solemn python @solemn python @solemn python @solemn python @solemn python
wdym
Like a node graph
oh
I have zero idea how I am gonna do this
last year tried brute force and ended up with billions of searches
i am using java today
good









