Problem source: https://oj.vnoi.info/problem/backtrack_j
We have these two shapes:
#.
##
and
.#
##
Let's call the first shape the L and the second shape the flipped L.
On a 4x4 board, there are 16 cells. Each cell can be either free or occupied. In all the illustrations, #
represents an occupied cell and .
represents a free cell.
Your job is to print all 4x4 boards that can be completely filled using the L shape and the flipped L shape. You are not allowed to rotate or flip the shapes, but you can put them anywhere you want as long as the shape isn't clashing with existing occupied cells. You are allowed to represent the boards in any reasonable format and print them in any order.
Here is an example of a board that can be filled:
.##.
....
.##.
....
We can perform these steps to fill the whole board.
Step 1: Fill an L at the top left corner
###.
##..
.##.
....
Step 2: Fill a flipped L at the top right corner
####
####
.##.
....
Step 3: Fill an L at the bottom left corner
####
####
###.
##..
Step 4: Fill a flipped L at the bottom right corner
####
####
####
####
Here is an example of a board that can't be filled:
#...
....
....
....
No matter how hard you try, it's just impossible to fill the board.
Sample output:
###.
#...
....
....
##.#
#...
....
....
#.##
...#
....
....
.###
...#
....
....
####
##.#
....
....
####
#.##
....
....
#.#.
....
#.#.
....
.##.
....
#.#.
....
#..#
....
#.#.
....
.#.#
....
#.#.
....
###.
##..
#.#.
....
##.#
##..
#.#.
....
##.#
#..#
#.#.
....
#.##
#..#
#.#.
....
#.##
..##
#.#.
....
.###
..##
#.#.
....
####
####
#.#.
....
#.#.
....
.##.
....
.##.
....
.##.
....
#..#
....
.##.
....
.#.#
....
.##.
....
###.
##..
.##.
....
##.#
##..
.##.
....
##.#
#..#
.##.
....
#.##
#..#
.##.
....
#.##
..##
.##.
....
.###
..##
.##.
....
####
####
.##.
....
#.#.
....
#..#
....
.##.
....
#..#
....
#..#
....
#..#
....
.#.#
....
#..#
....
###.
##..
#..#
....
##.#
##..
#..#
....
##.#
#..#
#..#
....
#.##
#..#
#..#
....
#.##
..##
#..#
....
.###
..##
#..#
....
####
####
#..#
....
#.#.
....
.#.#
....
.##.
....
.#.#
....
#..#
....
.#.#
....
.#.#
....
.#.#
....
###.
##..
.#.#
....
##.#
##..
.#.#
....
##.#
#..#
.#.#
....
#.##
#..#
.#.#
....
#.##
..##
.#.#
....
.###
..##
.#.#
....
####
####
.#.#
....
###.
#...
#...
##..
##.#
#...
#...
##..
#.##
...#
#...
##..
.###
...#
#...
##..
####
##.#
#...
##..
####
#.##
#...
##..
###.
#...
..#.
##..
##.#
#...
..#.
##..
###.
.#..
..#.
##..
##.#
.#..
..#.
##..
##.#
...#
..#.
##..
#.##
...#
..#.
##..
####
#.##
..#.
##..
####
.###
..#.
##..
#.#.
....
###.
##..
.##.
....
###.
##..
#..#
....
###.
##..
.#.#
....
###.
##..
###.
##..
###.
##..
##.#
##..
###.
##..
##.#
#..#
###.
##..
#.##
#..#
###.
##..
#.##
..##
###.
##..
.###
..##
###.
##..
####
####
###.
##..
###.
#...
...#
##..
##.#
#...
...#
##..
###.
.#..
...#
##..
##.#
.#..
...#
##..
##.#
...#
...#
##..
#.##
...#
...#
##..
####
#.##
...#
##..
####
.###
...#
##..
#.#.
....
##.#
##..
.##.
....
##.#
##..
#..#
....
##.#
##..
.#.#
....
##.#
##..
###.
##..
##.#
##..
##.#
##..
##.#
##..
##.#
#..#
##.#
##..
#.##
#..#
##.#
##..
#.##
..##
##.#
##..
.###
..##
##.#
##..
####
####
##.#
##..
##.#
#...
#...
#..#
#.##
#...
#...
#..#
#.##
..#.
#...
#..#
.###
..#.
#...
#..#
####
###.
#...
#..#
#.##
...#
#...
#..#
.###
...#
#...
#..#
####
##.#
#...
#..#
###.
#...
...#
#..#
##.#
#...
...#
#..#
###.
.#..
...#
#..#
##.#
.#..
...#
#..#
##.#
...#
...#
#..#
#.##
...#
...#
#..#
####
#.##
...#
#..#
####
.###
...#
#..#
#.#.
....
##.#
#..#
.##.
....
##.#
#..#
#..#
....
##.#
#..#
.#.#
....
##.#
#..#
###.
##..
##.#
#..#
##.#
##..
##.#
#..#
##.#
#..#
##.#
#..#
#.##
#..#
##.#
#..#
#.##
..##
##.#
#..#
.###
..##
##.#
#..#
####
####
##.#
#..#
#.#.
....
#.##
#..#
.##.
....
#.##
#..#
#..#
....
#.##
#..#
.#.#
....
#.##
#..#
###.
##..
#.##
#..#
##.#
##..
#.##
#..#
##.#
#..#
#.##
#..#
#.##
#..#
#.##
#..#
#.##
..##
#.##
#..#
.###
..##
#.##
#..#
####
####
#.##
#..#
##.#
#...
#...
..##
#.##
#...
#...
..##
#.##
..#.
#...
..##
.###
..#.
#...
..##
####
###.
#...
..##
#.##
...#
#...
..##
.###
...#
#...
..##
####
##.#
#...
..##
##.#
#...
.#..
..##
#.##
#...
.#..
..##
#.##
..#.
.#..
..##
.###
..#.
.#..
..##
####
###.
.#..
..##
#.##
...#
.#..
..##
.###
...#
.#..
..##
####
##.#
.#..
..##
###.
#...
...#
..##
##.#
#...
...#
..##
#.##
...#
...#
..##
.###
...#
...#
..##
####
##.#
...#
..##
####
#.##
...#
..##
#.#.
....
#.##
..##
.##.
....
#.##
..##
#..#
....
#.##
..##
.#.#
....
#.##
..##
###.
##..
#.##
..##
##.#
##..
#.##
..##
##.#
#..#
#.##
..##
#.##
#..#
#.##
..##
#.##
..##
#.##
..##
.###
..##
#.##
..##
####
####
#.##
..##
#.#.
....
.###
..##
.##.
....
.###
..##
#..#
....
.###
..##
.#.#
....
.###
..##
###.
##..
.###
..##
##.#
##..
.###
..##
##.#
#..#
.###
..##
#.##
#..#
.###
..##
#.##
..##
.###
..##
.###
..##
.###
..##
####
####
.###
..##
##.#
....
....
####
#.##
....
....
####
####
#.#.
....
####
####
.##.
....
####
####
#..#
....
####
####
.#.#
....
####
##.#
#...
##..
####
#.##
#...
##..
####
#.##
..#.
##..
####
.###
..#.
##..
####
####
###.
##..
####
#.##
...#
##..
####
.###
...#
##..
####
####
##.#
##..
####
###.
#...
#..#
####
##.#
#...
#..#
####
#.##
...#
#..#
####
.###
...#
#..#
####
####
##.#
#..#
####
####
#.##
#..#
####
###.
#...
..##
####
##.#
#...
..##
####
###.
.#..
..##
####
##.#
.#..
..##
####
##.#
...#
..##
####
#.##
...#
..##
####
####
#.##
..##
####
####
.###
..##
####
#.#.
....
####
####
.##.
....
####
####
#..#
....
####
####
.#.#
....
####
####
###.
##..
####
####
##.#
##..
####
####
##.#
#..#
####
####
#.##
#..#
####
####
#.##
..##
####
####
.###
..##
####
####
####
####
####
####
This is code-golf, the shortest code (in bytes) wins.