The context of assignment was simple: There were 3 stools with a stack of cheeses on it. Sometimes, these cheeses would have to be moved one by one (and without placing larger cheese on top of a smaller one) to another stool for maintenance (or for whatever reason... There has to be one for us to have an assignment). The 3 stool problem was quite simple and explained in details. But then, we were introduced the real problem, where we had 4 stools instead of 3. Even though, having an extra stool makes the cheese movement problem a lot simpler, it didn't make our assignment any easier.
Our goal was to create a TOAH model (Tower of Ann Hoi, the name of the puzzle) that would support already existing code for playing this game on a GUI controller. We would then have to write the code for a console controller, keeping in mind that our model has to work with both, and finally, we would have to make another module that would solve a 4-stool TOAH puzzle in the most efficient way.
Even though, everyone told me that the last part of the assignment is the most challenging part, I felt somewhat overwhelmed in the very beginning. The reason for that was my inability to comprehend some parts of the docstring and the GUI-controller code that was already written. I didn't know what data-structures to use and what methods to write. For example, the docstring for TOAH model class contained a list of methods, and many of those simply had to return a corresponding internal value, which made me confused about whether I just need to create a variable or was it an actual method. (It turned out to be a method, as I later understood).
After the initial attempt, I put of the assignment for more than 2 weeks, after which I could come back and finally finish the first part in one day. I felt a significant boost of inspiration when I was able to play the game manually after hours fixing mistakes and looking for solutions.
Then the "hard" part of the assignment came: creating an algorithm to move cheeses with 4 stools. In fact, the actual algorithm was already given to us, but it had a twist.
While there was a set and definite way to move 3 cheeses, the 4 cheese case required us to move some amount of cheeses to an intermediate stool, then move the rest with our definite 3-stool strategy, and then move the rest of the cheeses. The twist is in the "some amount". We weren't given a definite formula for "some", and while it existed, we were still strongly advised to use a recursive algorithm to find "some" (otherwise, you would have to convince the markers in your understanding of the formula you found on google).
Eventually, I managed to find the best solution, but I still don't know whether I wrote the best algorithm for that. I used a formula given in the handout that gave us the number of moves with a given "some". Since I didn't know a straight way to go, I just used an exhaustive search, trying every possible "some" (this number was always smaller than the amount of cheeses that we had to move), and then used the one that resulted in the least amount of moves. (it was possible to use a constant for every case, but it would provide sub-optimal performance).
The last part of the assignment was definitely challenging, but in a different way from the first part. Instead of looking for how to write code, I had to discuss possible ways to minimize the number of moves with other students (I even tried taking a derivative of a recursive function to find a minimum... It wasn't a good idea with my current math knowledge...). But eventually, it worked, and seeing how the puzzle is solved by itself for any number of cheeses is something that makes completing CS assignments more satisfactory than for any other course.