These are the backtracking problems every placement candidate should be able to solve, from binary codes to N-Queens and a small sudoku. Write the search with a path and an undo, think about how many answers can exist, then read the input and print. Trace each one on a small input before you check every test.