Chapter 14 - Python Quest
Algorithm Workshop
Trace state, swap safely, and compare selection sort with bubble sort.
XP
0Level 1Stars
0/18quest starsCombo
0clean runsRank
Seed0/160 Python scoreRunning-best algorithms
100 XPSmallest Number Scout
A mountain rescue team compares beacon heights and needs one scout to remember the lowest reading seen during a single walk through the list.
Write smallest_number(numbers) so it returns the smallest value in the nonempty list. Build the scan yourself without using min, sorted, or list.sort.
Sample checks
smallest_number([7,3,9,1,5])returns1Explanation: the remembered smallest value changes from 7 to 3 when 3 is seen, stays 3 at 9, changes to 1, and remains 1 after 5
smallest_number([4])returns4Explanation: the only value 4 becomes the starting champion, and because there are no later values to challenge it, 4 is returned
Hint
Hints are ready when you want one.
Lesson reference
Review: Carry a running best value
Your Python
smallest_number
Loading editor
Judge
Ready
Run your code when it feels ready.
