This challenge consists in finding the greatest number removing y digits from the original number n which has x digits.
y=2 n=5263 x=4, the possible numbers removing y=2 digits are:
[52, 56, 53, 26, 23, 63]
So, the greatest number is
63 which must be the output for this example.
Another logic would be: for each y, search from left to right the digit which right next digit is greater, then remove it, else when no match, remove the last y-digits.
y=3 n=76751432 x=8 to explain:
y=3 76751432 -^------ remove 6 because right next 7 is greater y=2 7751432 ---^--- remove 1 because right next 4 is greater y=1 775432 -----^ the search failed, then remove last y digits result = 77543
Both methods explained above works.. of course, you can use another method too :)
The number n won't have more than 8 digits, and y will always be greater than zero and lower than x.
To avoid strict input format, you can use the values:
y n x the way you prefer: as parameters in function, raw input, or any other valid way. Just don't forget to say how you did that in your answer.
The output should be the result number.
This is code-golf, the shortest answer in bytes wins.
Example Input and Output
Again: you do not need to be too strict :)
4 1789823 7 -> 983 1 54132 5 -> 5432 3 69314 5 -> 94 2 51794 5 -> 794
I changed the input order to reflect the fact that some of you may not need the x value to solve the problem. x is now an optional value.