Solving Programming Puzzles Without Using Your Brain

Solving Programming Puzzles Without Using Your Brain

In this case, I’m going to plot a simple scatter graph to the terminal, using the following code (I apologise for my terrible indentation style):

And we get the following output:

There’s a clear pattern there, but it might be easier to see if we inverted it, plotting those things which don’t loop:

For this kind of thing it’s also worth getting familiar with gnuplot. After that, we get the following function to test:

This last step is pretty straightforward: see if there’s an algorithm already out there that solves your problem. In fact, python provides this algorithm as a function in the standard library, making our last version of the function the following:

I’m not sure if this function is fully correct, but it was accepted as a solution to the puzzle.

Source: doisinkidney.com