It's almost December which means it's almost time for Advent of Code 2019. Advent of code is an annual computer programming competition created and ruyn by Eric Wastl. It's been running since 2015. I've written about it before, mostly from a teacher's point of view (Solve A to Solve B, Data structures and Hidden Complexity, Tools can shape how we think and a few others). Basically, Eric releases one poblem a day at midnight from Dec 1 through Dec 25.
What can I do to discourage my students from using the "break" statement?
That was more or less the gist of the comment and it elicited some good responses. This time the conversation was on Facebook but I've seen this one and participated in it many times before. I never liked the question when presented as a "how can I stop them" one. I equally dislike when the offered advice is basically "never use break no matter what" or something similar.
Today's Advent of Code problem was a variant on the Josephus problem.
I recalled that there was a formula to figure out the sole survivor but I decide to run a simulation rather than looking it up. I also decided to write it up in C++, well, really C with cout instead of printf.
Part 1 was the traditional problem. Part 2 was a variant where at each iteration, you remove the elf opposite the elf being processed (see the problem description for details).