[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.

4 Likes

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.

1 Like

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.

2 Likes

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.

I have written a program that allows according to the requested characteristics to answer the subject, my outputs work, but since several solutions are possible for each puzzle, it is notified that I did not succeed while if. Can you put values with unique answers, thank you.

I can post my solution here, but for example, in ā€˜the final testā€™, you expect the answer 67537905, but 67379052 works as well.

The statement asks you to ā€œoutput the largest number possibleā€ so when you have more than one candidate just pick the largest one. 67537905 > 67379052

The validators are insufficient.
The case of 2 missing but non-consecutive digits is missing

Just to say, the testcase ā€œ2 digitsā€ is still validated with a ā€œone digit removedā€ solution.
All testcases and 80% of the validators, actually ^^

What do you mean? I donā€™t quite understand.

If i use an algorithm testing the entire number, or all versions of the number minus one digit, i validate all testcases, including the ā€œ2 digitsā€ test (3rd test).

EDIT : in testcase 3, the number is 10???. Then, i can solve it with one digit solution because if i remove the ā€œ1ā€ (first digit), then i convert it to number, the ā€œ0ā€ (second digit) will be removed. Might happen to others, i donā€™t know.

Iā€™m unable to visualise the issue fully yetā€¦ I mean, what is the situation for that to be an issue? Or in other words,
(a) what cases require the removal of 2 digits,
(b) a one-digit solution would fail such cases,
(c) while no existing tests/validators are able to fail such a solution?

In the comments on the contribution, somebody suggested to add a test with number = 1000000001332 and D = 3, because their code would wrongly output 1332 as the answer. I donā€™t know whether that falls into the scope of the issue you are thinking about.

It is not an issue, just a comment

I am also having issues with the remove 2 validator. When you said any two numbers can be removed, do you mean that the two numbers can be removed from anywhere in a number like 12345 so that the number can be 234 or 135?