Solved LeetCode program · 900 of 1,000
#1240 · Tiling a Rectangle with the Fewest Squares
Original English source
Keep a shared best of 99. Keep a shared open of 0. Keep a shared masks holding 27, 54, 1, 2, 4, 8, 16, and 32.
To Find from spot (a whole number) with taken (a whole number). If spot is more than 5, set open to -1, return. The bit is shift 1 left by spot. The overlap is bitwise and of taken and bit. If overlap is 0, set open to spot, return. Find from spot plus 1 with taken.
To Cover from filled (a whole number) with used (a whole number). If used is at least best, return. If filled is 63 and used is less than best, set best to used. If filled is 63, return. Find from 0 with filled.
For every place from 0 to 7.
The square is item place of masks. The bit is shift 1 left by open. The covers is bitwise and of square and bit. The hits is bitwise and of filled and square. If covers is more than 0 and hits is 0, Cover from filled plus square with used plus 1.
Cover from 0 with 0. Show best.
Expected stdout
3