This Python code will create a list of binary values, a portion of logic puzzle solver I am working on.
As part of my logic puzzle solver, I needed an ability to generate a list of 1's and 0's that corresponded to every possible solution. With the list, I am able to remove any entry that is impossible following the hints in the puzzle. This greatly reduces the number of possible solutions.
The original code used a series of if statements and for loops. Using a list comprehension, I was able to optimize the code dramatically. From about fifteen lines to one. This was fun practice for me.
A live example can be found at: http://repl.it/I78