Find Smallest of Three
Sometimes you have multiple options and you need to pick the smallest one—like finding the lowest price while shopping or the shortest route to a destination. In Find Smallest of Three, your job is to compare three different numbers and identify which one is the minimum.
You’ll need to look at all three values and decide which one stands as the smallest. This involves a simple comparison logic where you check each number against the others to find the one that is less than or equal to everyone else.
Imagine you have the numbers 10, 5, and 8. You would compare them and see that 5 is the smallest of the group. Your program should be able to look at any three numbers and pick out the one that stays at the bottom of the list.
Example Input & Output
-1 is the smallest value.
2 is the smallest among the three values.
All values are equal, so the smallest is 7.
Algorithm Flow

Solution Approach
Identifying the minimum among three values requires a series of comparisons. We can approach this by checking one number against the others, or by assuming one is the smallest and updating our assumption as we go along.
In this logic, we initialize min_val with the first number, a. Then we sequentially compare it with b and c. If either b or c is smaller than our current minimum, we update min_val to hold that new value. This sequential comparison ensures we find the true minimum among all three candidates by the time the algorithm finishes.
Best Answers
program find_smallest_of_three
dictionary
a, b, c, smallest: integer
algorithm
input(a, b, c)
smallest <- a
if b < smallest then
smallest <- b
endif
if c < smallest then
smallest <- c
endif
output(smallest)
endprogramComments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
