Code Kata (programming challenges, "interview questions", etc.)
Wow, I haven’t done one of these for a few months. Let’s see how this goes!
If I’m going to use Elixir, I might as well make use of its pattern matching!
I’m doing some work in Elixir now, so I figure I’d take a shot at this week’s question with Elixir.
Simple, no-frills solution to this week’s question.
There’s a really simple one-liner for arrays, but what about using this with generators? (i.e., the iterator pattern where a length is not known until reaching the end of the iteration)
How can I write a piece of code that can be written quickly and trivially understood? I think it’s mostly good variable names in this case. (And I handle infinite pie!)
What’s faster: a typical JavaScript implementation of .toString() and some basic string manipulation or clever bit shifting? (TL;DR: It’s bit shifting, but it’s uglier code.)
In this case, writing tests to prove the solution was far more interesting than the solution itself.
The simple case wasn’t hard, but the low-memory iterator pattern was a fun, self-imposed challenge.
I decided to tinker with ChatGPT while working on an answer to this week’s question. While each implementation was passable and useful as a starting point, it became almost immediately clear that ChatGPT’s contextual understanding of its own output is fairly limited. Iterating with ChatGPT on its own technical output…
The tests were harder than the implementation 🥴
This one was fun to think about the minimal amount of processing needed to produce the result. In this case, the question is carefully worded to allow naive processing that’s really fast.
Nice little brain teaser involving number base conversion 😄
Nice, bite-sized algorithm question.
Well, I spent quite a bit more time on this tonight than I’d originally anticipated. It’s not pretty, but it does work and has a little bit of viable game theory.
This was a fun, light interview question this week.
This one was tricky to stay mindful of the number of iterations.
I do enjoy getting Cassidy’s newsletter late Sunday/early Monday and trying my hand at the “interview [questions] of the week.”