🦆 Everybody.Codes 2025 Quest 2 Solutions 🦆
Quest 2: From Complex to Clarity
- 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/
It's gradually coming back to me. The Haskell Complex type doesn't work particularly nicely as an integer, plus the definition of division is more like "scale", so I just went with my own type.
Then I forgot which of
divandquotI should use, and kept getting nearly the right answer :/That sounds amazingly infuriating! and hard to debug. I totally feel you there.
FSharp
(my first submission failed, so I may not be as detailed here)
I laugh at how long this took me. At first I got stuck due to checked arithmetic. In FSharp you open the
Checkedmodule and you get the overloaded operators for primitives, whereas CSharp ischecked {a + b}. I also mistakenly useddistincton part 3 when I didn't need it.I did appreciate the
choosefunctions of functional programming, which returns all of theSomevalues of a sequence of options. The PSeq library let me use 70% of the cpu on the calculations :)For quest 2, I decided to implement my own Complex type and operators, because I expected parts 2 and 3 to have something unconventional, but alas it's just a regular Mandelbrot fractal.
Nim again, Nim forever:
Full solution at Codeberg: solution.nim
Rust
I struggled for a long time because I had nearly the correct results. I had to switch
divwithquot.This puzzle was fun. If you have a visualization, it's even cooler. (It's a fractal)
::: spoiler Haskell Code
:::
My girlfriend is learning python, we are taking on the challenges together, today I may upload her solution:
::: spoiler python
:::
The commented out print statements produce an ascii map of the set, which can be cool to view at the right font size.
I was stuck for a while on part 2. I thought I was running into precision errors, so I re-implemented everything using exact integers, then I re-implemented it in python, but it turns out that I just had an off-by-1 error. It just so happened that my off-by-1 algorithm gave the correct solution to the sample input. Part 3 takes a while to compute.
Scheme/Guile
Sadly Uiua doesn't handle the large numbers here well, so here's a Dart solution instead.