YODA
InterviewTime limit1sMemory limit64 MB
Compare two numbers digit by digit from the right and drop the smaller digit at each position, printing YODA for a number left with no digits.
- Level
Easy2 of 10
- Topics
- String, Simulation
- Solved
- No attempts yet
Problem
A long time ago in a galaxy far away, two integers are colliding. When two integers collide, their digits fight position by position. The positions line up at the right end: the ones digit meets the other ones digit, the tens digit meets the other tens digit, and so on.
Of the two digits that meet, the smaller one falls out of the number that contains it. If the digits are equal, nothing happens and both stay. If one number has no digit at that position, treat its digit as 0. A position that does not exist has no digit to lose.
After all positions have been compared, the digits still left in a number move together in their original order and form a new number. The new number is printed as a value, so leading zeros are dropped. For example, if the digits 0 and 0 are left, the value is .
Given two integers, write a program that determines their values after the collision. If every digit of a number has fallen out, print YODA for that number.
Input
The first line contains the first integer . ()
The second line contains the second integer . ()
Output
On the first line, print the value of the first integer after the collision.
On the second line, print the value of the second integer after the collision.
If every digit of a number has fallen out, print YODA on that line.