Codington
0 of 6 problems solved • 0%

Exercise prompt

Fold the Map

A while loop checks a condition before every pass. Change the value being checked so the loop eventually stops.

Example

A countdown removes two seconds at a time.

seconds = 5 while seconds > 0: print(seconds) seconds -= 2 # 5 # 3 # 1

The values checked are 5, 3, 1, and -1. The check fails at -1, so that value is never printed. A false starting condition skips the body entirely.

Your task

Write a while loop in folded_width(width, limit). While the map is wider than the limit, halve its width using integer division (//). Return the final width. Both arguments are positive integers. A width of 18 with a limit of 5 shrinks to 9, then 4.