[Community Puzzle] Largest Number

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @MattDESTROYER,validated by @FredericLocquet,@RRRoumy and @j01.
If you have any issues, feel free to ping them.

The example inside the statement gives an impression that line 2 is a blank line, not a number. May be it is an illusion but I guess it can be improved.

1 Like

A problem with this puzzle is that test case that requires to remove two digits are only tested with the validator.
So all the IDE test can be passed with a solution that remove no or one digit.


Revised. Thank you for your comment.

1 Like

Added “Remove 1 digit validator” and “Remove 2 digits” testcase. Probably still too few test cases which require the removal of 2 digits to reach the answer. Please feel free to add some more.

1 Like

My code solved all test cases but failed at every validator test.

I calculated all possbile numbers (number % d) and if the result is 0 i added them to a array at the end I output the max value from the array.

You have not implemented the “removing between 0 and 2 digits from the input” part?

I have done this.
I check these numbers:

num = (number,int(str(number)[:-1]),int(str(number)[1:]),int(str(number)[1:-1]),int(str(number)[:-2]),int(str(number)[2:]))

This only removes digits from beginning or the end. You need to consider cases where removed digits are anywhere.
For example, for number 72659 your code never tries to remove 6.


If you are writing in py, if number is 12345
then num is (12345, 1234, 2345, 234, 123, 345)
You missed checking 145, 135, 235, 1245…and many other possibilities.

1 Like

Oh ok. I misunderstood the instructions.
Of course, it would be good if the test cases could be adapted to cover this.
In the test cases, the numbers are only cut off at the beginning or end.