Ad
  • Custom User Avatar

    For the error message ValueError: invalid literal for int() with base 10, I tried Python's

    try: except ValueError: pass

    which worked.

    However, I am no stuck with:
    Input: 't"expEXXk67748NaX2D825897348000089'
    Output says my output:
    't"epEXXk100' should equal 't"epEXXk100'

    I really could do with some help on this one. Any help welcome.

  • Custom User Avatar

    On running sample tests the output says that my code returns [('a',)] should be ['a']. Running my code from windows powershell using both python 2.7 and 3.6 I get out put of ['a'] for an input string of 'a'. Same thing if I run my code using spyder and python 3.6.

    Also I believe somehow you can print what the input was for the test condition that produced the failed output but I cannot see how to do this.

    Help would be most welcome. Thanks.

  • Custom User Avatar

    OK thanks I did not realise that. Not sure how I can print the input. I have not seen how to do this. In the meantime I have been logged out so it seems I have lost the chance to complete the kata.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Hello Giacomo,

    Thanks for replying.

    I recognise that the instruction states "the next bigger number formed by the same digits" as opposed to "the next bigger number compared to the test input". Even so the next bigger number formed by the same digits as 9876543102 is I believe 9876543120. It uses the same digits as the input and is the next biggest number using those digits. In other words there is a possible combination of the given digits that gives a bigger number which is the next biggest - the number I output is next biggest compared to the input. The "should equal -1" given back as output implies that, using the words in the instructions "no bigger number can be composed using those digits". Besides, in order to make sense of "next" biggest is it not a requirement that "next to what" is known.

    Again why does output give: '21' (in single quotation marks) should equal 21 mean?

  • Custom User Avatar

    On attempt (after run sample tests was successful) I received the following test results:
    9876543102 should equal -1

    My answer was 9876543120 which on reading and checking is greater than the input n of 9876543102 and as far as I can tell the next greatest. Basically the input case is all digits in descending order except the last 2 so swap the last two - or am I wrong ? Please help.

    With different code on run sample tests I receive the following test results:
    '21' should equal 21

    What am I missing please. I have carefully read the instructions, attempted putting in:
    if type(n) == str:
    return int(n)

    which does not help.