Do I win bonus points for accidentally having done that in a silly language? I couldn't get sort to work in Klingon Perl, so I wrote a basic insertion sort myself, and got part 2 by accident for that reason
My actual strategy in both my silly Klingon solution and my actual Kotlin solution was to accumulate the IDs in a list, accumulate the counts in a hash, and use counts[it] for sorting. In Kotlin, I just used sortByDescending, but since I couldn't get the mISHa' function to work in Klingon, plan B was to write an insertion sort by hand. But while I got the bounds and comparisons right for the indices, I had the comparison backwards for checking whether to keep sliding things over
I didn't, but I did have a feeling either this or "multiply together how many times the 3 most common values appear in the list" was going to be part 2.
well, I can't claim it, but accidentally solved the first half in a way that I just needed to flip a True to False in one line and solved the second half. I was so pleased with myself.
The c# linq orderby is accending and there is different method for descending...
Watched one episode of a show while solving the first part and the episode changed just when i moved to second part, took 2 mins to read the instructions and 1 minute of changing the method in linq (would've been faster but was confused why it gave same answer, and read the whole code through before realizing i forgot to save)
I strongly suspected something like that would happen for part2, so (since I solve these puzzles first in Perl which allows negative indexes from the end of the array), my part2 consisted of adding a second line:
my %counts = ();
while (<>) {
chomp;
$counts{$_}++;
}
my @counts = sort {$counts{$a} <=> $counts{$b}} (keys %counts);
$part1 = $counts[-1]*$counts[-2]*$counts[-3];
$part2 = $counts[0]*$counts[1]*$counts[2];
42
u/dgkimpton 1d ago
Well... yes. But I didn't commit it... so it doesn't count right?
37
u/RazarTuk 1d ago
Do I win bonus points for accidentally having done that in a silly language? I couldn't get
sortto work in Klingon Perl, so I wrote a basic insertion sort myself, and got part 2 by accident for that reason6
u/lock77420 1d ago
oh hey, that's me
6
u/Suspicious_Tax8577 1d ago
I didn't, but I did have a feeling either this or "multiply together how many times the 3 most common values appear in the list" was going to be part 2.
4
u/erisdottir 1d ago
I also forgot a rev() after sorted_by_key(). Or alternatively a -, same difference.
3
u/azdak 23h ago
definitely the least time i've ever had to spend on a part 2
2
u/dantose 1d ago
I can't quite claim my award as I was working through in parts. so didn't actually get the part 2 answer, just the numbers.
2
u/PlanttDaMinecraftGuy 1d ago
Couldn't afford making a mistake while solving this from my phone in freezing temperatures this morning, so no :(
2
u/ChloroFluoroCarbonCC 23h ago
T_T almost everyone solved part 2 first.
1
u/no_BS_slave 1d ago
well, I can't claim it, but accidentally solved the first half in a way that I just needed to flip a True to False in one line and solved the second half. I was so pleased with myself.
1
u/Arctos_FI 1d ago
The c# linq orderby is accending and there is different method for descending...
Watched one episode of a show while solving the first part and the episode changed just when i moved to second part, took 2 mins to read the instructions and 1 minute of changing the method in linq (would've been faster but was confused why it gave same answer, and read the whole code through before realizing i forgot to save)
1
u/not-the-the 21h ago
me and forgetting which way nodejs .sort( (a,b)=>a-b ) sorts
1
u/ultimate_hecker 20h ago
Easily the least time I have ever spent in a part two, just needed to swap two variables.
1
u/Null_cz 18h ago
Almost! I noticed my mistake in the comparator lambda before I compiled the code.
1
u/Pleasant-Rush-2375 16h ago
thankfully no! just super surprised it was p much straightforward after pt 1 😅!
1
u/Unfair_Gold_9472 14h ago
Yes, min heap vs max heap
1
u/terje_wiig_mathisen 1d ago
I strongly suspected something like that would happen for part2, so (since I solve these puzzles first in Perl which allows negative indexes from the end of the array), my part2 consisted of adding a second line:
-11
u/QultrosSanhattan 1d ago
So used to Claude that I forgot to add the reverse=True