The number the sorter reads
Statement
The sorter in a logistics warehouse reads the three-digit number written on a box and decides where to send the box. This sorter does not read the number from left to right. It reads the number backward, starting from the last digit, and takes it as one number.
For example, suppose a box has 734 written on it. The sorter reads the last digit 4 first, then the middle digit 3, then the first digit 7 last.
| Reading order | 1 | 2 | 3 |
|---|---|---|---|
| Digit read | 4 | 3 | 7 |
So the sorter takes 734 as 437.
Two boxes now sit in front of the sorter. The warehouse worker wants to send out first whichever box the sorter read as the larger number. Given the numbers written on the two boxes, write a program that prints the larger of the two numbers the sorter read.
For example, suppose the numbers written on the two boxes are 734 and 893 in order. The sorter then reads the two numbers as in the table below.
| Box | 1 | 2 |
|---|---|---|
| Number written | 734 | 893 |
| Number the sorter read | 437 | 398 |
The two numbers the sorter read are 437 and 398. 437 is larger, so the answer in this case is 437. Looking only at the written numbers, 893 is larger than 734, but the order of the values the sorter read comes out the other way around.
There are also cases where the order of the written numbers and the order of the read numbers stay the same. Suppose the numbers written on the two boxes are 954 and 359 in order.
| Box | 1 | 2 |
|---|---|---|
| Number written | 954 | 359 |
| Number the sorter read | 459 | 953 |
Here the two numbers the sorter read are 459 and 953, so the answer is 953. The written numbers must not be weighed against each other. What you weigh are the two numbers read backward.
The two boxes may also have the same number written on them. The two numbers the sorter read are then the same, so that value is printed as it is. Also, a number holds no 0, so there is no need to think about a backward reading that starts with 0.
Input and Output Examples
Example 1
Input
734 893
Output
437
Example 2
Input
954 359
Output
953
Example 3
Input
111 111
Output
111
Input
First, the first line gives the numbers written on the two boxes in order, separated by one space. Both numbers are three-digit natural numbers, so they take values between 100 and 999. Also, every digit is between 1 and 9, so no 0 appears in a number. The two boxes may have the same number written on them.
Output
Print the larger of the two numbers the sorter read, on one line. Do not attach a space after the value, and finish with one line break.
Requirements
- Read the input from standard input and write the result to standard output
- Read the number backward, starting from the last digit
- If the two numbers are the same, the two numbers the sorter read are the same as well, so print that value as it is
- Print one value only, on one line
- You must write a program that reads from standard input and writes to standard output
- Trailing spaces at the end of a line and blank lines at the end of the output are ignored when grading
- The languages you can use are Python and JavaScript
- The memory limit is 256MB. The browser does not measure it, it only states it
- The time limit is set by measuring the setter's reference solution on the same runtime
- On this problem you submit code, not a prompt. That code runs in the browser on this device, and all that goes to the server is a fingerprint of the output and the time it took. Whether it is correct is decided by the server. The run time is a number each device reports, so the code and the device details are posted next to it on the leaderboard.
- The output has to match the expected value down to the character. A space inside a line counts the same as any other character.
- There are 15 cases, and 3 of them show the input together with the expected output. The rest are used only when you submit and are not shown on this page.
- You have to pass all 15 cases to solve this.
Examples
3 public cases. Judging also uses hidden cases. You have to pass all 15 cases to solve this.
734 893
437
111 111
111
954 359
953
Solution
Your code runs on this device. Only the fingerprint of the output and the elapsed time go to the server. The server decides whether it is correct.
Submitting requires you to log in. Running against the public cases works without one.
You can test with 3 public cases. Submitting runs the hidden cases too.
People who solved this problem
The time shown is the time spent solving. Input reading time is outside the solver's control, so it is excluded. And since each device reports this value itself, we record which device measured it.
Log in and you can see the code once you solve this problem.