[Community Puzzle] The greatest number

Hi, just wondering what should be the output for the following sequence “-001”

Could be one of the following

  • “-001” - probably not, because of spaces in the beginning
  • “-1” - is the greatest number, though not all digits are used
  • “-100” - is the greatest possible number if all digits are used

It would be nice to have such a test case.

You should output “-100”.

I wrote this puzzle 1 year ago. It was a proposition for clashes. The rules of the puzzle are really bad written. Moderators should have modified it before validating.

Your level allows you to rewrite it. :wink:

I know but i can’t find a way to write it better than it for now. I know the text is bad written, but well, i can’t really do better :smiley: I never said i was good at making puzzles !

In this case I can bet that most of the submitted solutions will fail this test :slight_smile:

My solution prints “-1”. :slight_smile:

  • danBhentschel

Mine too. :wink:

I don’t quite understand this puzzle. Leading zeroes are not permitted, but for the 4th test case it expects “-0…[something]”. The input is -400598.2 , so should the output not be -2.4589? And while it says not to end a number with a decimal, it says nothing of how far to the right a decimal can be. Although from the first test case -2.45889 is correct, it would make more sense for the answer to be -.245889.
I have code that works for half of the test cases, so I really want to finish this problem, but I’m frustrated that I can’t understand how the samples should output. Can someone explain to me more precisely what the rules are to this problem?

The syntax ‘.xxxx’ is incorrect for a number, even though we understand it, behind this way of writing the real number is ‘0.xxxx’ and so this is how you are supposed to output the answer. You should understand that unnecessary leading zeros are not permitted.

That makes more sense, thank you. So then for input -400598.2, would the output be -0.024589? Is -.024589 acceptable?

There is a test “Gérer le zéro une 2ème fois” which is in my opinion wrong. It claims that the greatest number from characters “0 0 0 1 0 0 0 .” is “100000”. The issue is that this solution misses the decimal point. I think the correct result should be “0.000001”.

What about 100000.0 = 100000?

eulersheZahl is right. The real response is 100000.0, but as the rules says, at the output, trailing zero must be removed. So you have to output 100000.

I think I broke it. Whatever I output for the 100000 test fails. The IDE says that it expects to find "Nothing’.

For me it is the same.
Strange.

The trick is not to use all the zeros. Write the number as a decimal with one zero after the decimal point, but then delete the trailing zero because it adds nothing to the answer, and then delete the decimal point because you don’t need it. So the answer for this case is 100000, not 100000.0