A boutique vault has three mechanical combination dials. Each dial currently shows a positive integer, printed with no leading zeros, using at most four digits. To compute today's override code, a technician mentally pads every dial's number with leading zeros until all three are exactly four digits long, then looks at the four digit positions one at a time (thousands, hundreds, tens, units) and keeps the smallest of the three digits shown in that position. Reading the four kept digits left to right in the usual base-10 way gives the override code (which may itself have fewer than four digits, or may simply be 0). Given the three dial readings, find the override code.
A single line with three integers d1 d2 d3 separated by spaces.
Print a single integer: the override code.
1 <= d1, d2, d3 <= 9999Example 1
Input
1 10 1000
Expected
0
Explanation
Padded to four digits: 0001, 0010, 1000. Taking the minimum digit at each position gives 0,0,0,0 (thousands: min(0,0,1)=0; hundreds: min(0,0,0)=0; tens: min(0,1,0)=0; units: min(1,0,0)=0), so the override code is 0.
Example 2
Input
987 879 798
Expected
777
Explanation
Padded to four digits: 0987, 0879, 0798. Minimum per position: thousands min(0,0,0)=0, hundreds min(9,8,7)=7, tens min(8,7,9)=7, units min(7,9,8)=7, giving digits 0,7,7,7, which as an integer with no leading zero is 777.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →