Write a program that prints all the ways to place kings on a board so that no king threatens another king. Remember that a king threatens all the surrounding cells, either horizontally, vertically, or diagonally.
For instance, these are some ways to place 3 kings on a board:
Input consists of two natural numbers and .
Print all the ways to place
kings on a
board so that no king threatens another king. Mark the kings with a
‘K’, and the empty cells with a dot. Print a line with ten
hyphens after every board.
You can print the solutions to this exercise in any order.
The test cases of this problem do not require a very clever algorithm.
Input
2 1
Output
K. .. ---------- .K .. ---------- .. K. ---------- .. .K ----------
Input
3 4
Output
K.K ... K.K ----------
Input
3 5
Output
Input
3 3
Output
K.K ... K.. ---------- K.K ... .K. ---------- K.K ... ..K ---------- K.. ..K K.. ---------- K.. ... K.K ---------- .K. ... K.K ---------- ..K K.. ..K ---------- ..K ... K.K ----------