Cut a rectangle: Difference between revisions

Content deleted Content added
Updated D entry
m minor grammatical changes
Line 1: Line 1:
{{draft task}}
{{draft task}}
Given a rectangle made of ''m'' × ''n'' squares, if ''m'' and ''n'' are not both odd, it's 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 them by 180°). All such paths for 2 × 2 and 4 × 3 rectangles are shown below.
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.


[[file:rect-cut.svg]]
[[file:rect-cut.svg]]


Write a program to calculate the number of different ways to cut an ''m'' × ''n'' rectangle. Optionally, show each of the cuts.
Write a program that calculates the number of different ways to cut an ''m'' × ''n'' rectangle. Optionally, show each of the cuts.


Possibly related task: [[Maze generation]] for depth-first search.
Possibly related task: [[Maze generation]] for depth-first search.