The Biggest Square Patio

Python for AIMedium+10 XP+10

The Biggest Square Patio

You have a pile of square tiles and want to lay the biggest full square patio you can, like 3 tiles by 3 tiles. Some tiles may be left over.

Write square_patio(tiles) that returns a list of two whole numbers:

  1. the side of the biggest full square (in tiles)
  2. how many tiles are left over

Use from math import sqrt, floor so both names work without a prefix. tiles is a whole number, 0 or bigger.

(A 3-by-3 square uses 9 tiles, leaving 1. A 4-by-4 square would need 16.)

Examples

tiles = 10
returns [3, 1]
tiles = 16
returns [4, 0]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run