Beta
Tiling a rectangle with squares
Description:
You have to cover a rectangular area (measuring n x m where n and m are positive integers) with square tiles. You have an unlimited supply of square tiles, but the lengths of the sides are all powers of 2 (1 x 1, 2 x 2, 4 x 4, 8 x 8, etc.). You must use the minimum number of tiles which will exactly cover the area.
For example, given an area measuring 13 x 11:
___________________________
| | 4x4 |_|
| | |_|
| | |_|
| |_______|_|
| 8x8 | 4x4 |_|
| | |_|
| | |_|
|_______________|_______|_|
|2x2|2x2|2x2|2x2|2x2|2x2|_|
|___|___|___|___|___|___|_|
|_|_|_|_|_|_|_|_|_|_|_|_|_|
We can exactly cover the required area with 32 tiles.
Write a function which takes as its inputs the length and width of the rectangular area to be tiled, and returns the minimum number of tiles required to exactly fill the area.
Be aware that some very large areas will be tested.
Fundamentals
Algorithms
Recursion
Performance
Similar Kata:
Stats:
Created | Sep 19, 2022 |
Published | Sep 19, 2022 |
Warriors Trained | 19 |
Total Skips | 5 |
Total Code Submissions | 11 |
Total Times Completed | 7 |
Haskell Completions | 7 |
Total Stars | 3 |
% of votes with a positive feedback rating | 100% of 5 |
Total "Very Satisfied" Votes | 5 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |