#551 · Modules and random · Beginner · 30 XP · about 4 min
A builder wants to cover a rectangular floor with square tiles, all the same size, without cutting a single tile. The floor measures width by length centimeters, both whole numbers. The largest tile that fits exactly has a side equal to the greatest common divisor of the two measurements, which math.gcd works out.
Write tile_plan(width, length) that returns a tuple (side, count): the side of the largest such tile, and how many of those tiles cover the floor.
tile_plan(360, 240) # returns (120, 6) tile_plan(7, 5) # returns (1, 35) tile_plan(100, 100) # returns (100, 1)
A 120 cm tile fits 3 times along 360 cm and 2 times along 240 cm, so the floor takes 3 * 2 = 6 tiles.
Both measurements are at least 1.
First solves only, ranked by stars and then time.