7 kyu

ISBN Corruption

Description
Loading description...
Strings
Algorithms
Arrays
  • Please sign in or sign up to leave a comment.
  • Voile Avatar

    The kata doesn't rule out the possibility where ? appears before the last digit, and the only digit that can satisfy the checksum is X, which can only appear in the last digit.

    Either this needs to be explicitly ruled out, or it needs to be tested.

    • alexlostorto Avatar

      Hi! There's a generateCode() function which will generate a valid ISBN code. That function can only ever return X as the last digit, so I don't believe it's something that would happen in the tests.

      Also, in the description, it mentions that only the last digit can be X

      Sometimes it is necessary to make the last digit equal to ten; this is done by writing the last digit as X. For example, 156881111X.

      Maybe I'm misunderstanding your issue??

    • Voile Avatar

      What is the expected result for input ?11111111X then?

    • alexlostorto Avatar

      This comment has been hidden.

    • Voile Avatar

      Yes, I'm aware of that, in this case you need to explicitly rule this out in the description (aka state that the answer will always be valid).

    • alexlostorto Avatar

      Ahh ok thanks for your patience in resolving this :)

      I've altered the description to make this more explicit: Write a program that reads in an ISBN code (will always be valid)...

      Issue marked resolved by alexlostorto 15 months ago
  • Voile Avatar

    Returning different typed values is a bad practice (it doesn't fly in strongly-typed languages), and it's entirely a design problem: if we're supposed to return a digit, we should definitely return the digit as a character/string, not only when it is X. This would make it consistent and avoid the potential problem mentioned above.