Editorial for COCI '15 Contest 4 #1 Yoda


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

In 30\% of test cases, the numbers N and M were composed of three digits, so the task could be solved by determining all the digits, comparing them and creating new numbers. The task could also be solved by observing the numbers as strings. Here we will observe the numbers as numbers.

The solution is a combination of the algorithm for determining the digits of a number and the algorithm for creating a number. Since we don't want to think about the number of digits, we can assume that there are at most 10 of them, but we can also use a conditional loop. There was one trick in the task. The solution that outputs YODA in the case when the new value of the number is equal to zero is not a good solution because there are cases when the number is zero, and YODA shouldn't be output (e.g. when the zeroes appear in the same position of digits in the number). Let us notice that the given word will be output only when the new number hasn't been modified in the program.


Comments

There are no comments at the moment.