Quest 3: The Deepest Fit
- Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
- You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL
Link to participate: https://everybody.codes/
Also, don't wait for me to make these posts, feel free to post yourself :)
10 Comments
vole@lemmy.world · 3 pts · 288d
Scheme/Guile
Guile doesn't seem to come with a bag implementation :(. Not a big deal, a linear scan works about as well.
ragingHungryPanda@piefed.keyboardvagabond.com · 1 pts · 269d
I'm so far behind on these, but it's rare that I see a lanugage I've never heard before. I've heard of scheme. How did you come to using this language for the challenges?
vole@lemmy.world · 2 pts · 268d
I wanted to learn scheme and perhaps work through SICP. Guille seemed like a reasonable scheme to choose because I've also been considering learning Guix. Guix is a package manager similar to Nix, and it uses Guille as its configuration language.
mykl@lemmy.world · 3 pts · 286d
Very simple task for Uiua.
-> 29, 781, 3
hades@programming.dev · 2 pts · 291d
Rust
VegOwOtenks@lemmy.world · 2 pts · 290d
I was scared of a hard combinatorial puzzle day, but this was a breeze.
Quant@programming.dev · 2 pts · 169d
Uiua
I'm currently going through the 2025 Quests to learn Rust, committing great sins along the way.
Decided to take a shot at the third one with Uiua because it looked nice and simple, and it was. This may have been the fastest I've ever finished a complete quest :P
Run with example input
:::spoiler Code
:::
janAkali@lemmy.sdf.org · 2 pts · 291d
Nim
Reading this day's quest I was at first a bit confused what it asks me to calculate. Took me about a minute to realize that most of descriptions are not important and actual calculations for each part are very simple:
part 1 wants sum of each unique crate size
part 2 is same but only 20 smallest
part 3 is max count, because you can always put most crates in one large set and you only need 1 extra set per duplicate crate
Full solution at Codeberg: solution.nim
ragingHungryPanda@piefed.keyboardvagabond.com · 2 pts · 269d
FSharp
I'm a month late, but eh. Compared to everyone else, it looks like my approach of preserving duplicates was unnecessary. I chose to use SortedSets (redundant since I sort the inputs) and cascade to the next best fit. The sorted sets also let me grab the Max/Min values and I thought that it was more in line with the intention than having a list that happens to be sorted.
I also sorted part 1 based on what I thought was the best fit, which was the same solution for part 3.
For part 2 I duplicated part 1's logic but reversed the order to asc instead of desc, but I don't know that that made a difference and excluded it here. The only difference is the "add if count < 20".
lwhjp@piefed.blahaj.zone · 2 pts · 290d
I thought this was going to be the knapsack problem, but no.