Here’s an idea for exercise that’s based on a interesting fractal structure: The dragon curve
I’ll provide a short explanation based on the Wikipedia article.
The curve can be constructed in various ways. One method involves taking a long strip of paper, repeatedly folding it in half, and then unfolding the paper while creating 90-degree angles with each fold. This is how the curve was originally formed. Another, more mathematical approach, starts with a line segment, which is repeatedly replaced by two segments forming right angles, with alternations between 45° rotations to the right and to the left. The “fold” approach is simpler to explain, so that’s what will be mentioned in the instructions.
The task is to determine how many squares the final curve contains, given a number of folds.
At this point, I’m not entirely sure how to solve the problem, but based on the Wikipedia article, this exercise may serve as a practice for:
I’m not worried about that. There’s no math involved here. You can use math if you want, but i’m not even sure if it’ll help. It’s mostly an algorithmic oriented exercise, that requires people to think how they can approach it.
The “count the number of squares” is just my idea. There’s probably nothing on the Wikipedia page about it. I’ll try to device a solution when i have some time.
Edit: For the record, i have drawn this curve when i was 15 years old in Qbasic using zero math.
I just checked all the problems from AoC 2024, and there’s nothing similar there. I would be very surprised if I came up with an exercise even remotely close to an AoC problem from any year. Their exercises are quite involved in terms of logic and design, so it’s also unlikely that they just went to the Wikipedia page, copied the idea, and asked for something simple — which is exactly what I did.
That said, it does have the feel of an AoC problem. I’ve already coded the first part based on the folding process from the Wikipedia article, which was very easy. Now, I need to find a way to count the number of squares, and I already have a process in mind.
Staff: please feel free to move the relevant posts about this exercise to a new topic.
When I’m evaluating exercises for myself, my main starting point is to write the code and then judge how easy/hard/elegant/interesting/etc the solutions can get. I then tend to backfill everything else based on that. Without the code, I feel like it’s really hard for me to evaluate how “good” at exercises is on the educational metrics.
So I’d love to see a solution (ideally in a high-level language - e.g. JS, Python, Ruby, C#, your QBasic one, etc) in order to get a feel for what this would look like.