Cut a rectangle

FCC link

A given rectangle is made from m × n squares. If m and n are not both odd, then it is possible to cut a path through the rectangle along the square edges such that the rectangle splits into two connected pieces with the same shape (after rotating one of the pieces by 180°). All such paths for 2 × 2 and 4 × 3 rectangles are shown below.

.g { fill: none; stroke: #ccc } .s, .s2 { fill: #bff; stroke: black; fill-opacity: .4 } .s2 { fill: #fbf } .d { stroke:black; fill:none}

Test

{{test}}

Console output