4 kyu

Next polydivisible number in any base

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

    Very fun Kata! Could not find much information online about polydivisible numbers so had to think up an efficient algorithm carefully.

  • Blind4Basics Avatar

    Hi,

    in python's random tests, the user is getting invalid string numbers from time to time:

    b=16 n='098': 'A2' should equal '9A'
            ^
    

    (this situation doesn't happen in JS, for example)

  • Avanta Avatar

    This comment has been hidden.

    • JohanWiltink Avatar

      There are fixed tests for that. In light of your below question, it would probably take quite some ( testing and generating ) time to generate those values specifically, or it would require hardcoding.

      I like random tests that are completely, fully random, and there is no specific random generator for overly big numbers ( that'd be the way to ensure it ), though there is a decent chance at least some will be generated, especially for smaller bases.

      It might be nice to have, but I just did not specifically include it, and I'm not adding it now.

      Suggestion marked resolved by JohanWiltink 4 years ago
    • Avanta Avatar

      I understand. The only thing is, my solution uses a heursitic that only holds when b <= 10, so technically I have an incorrect solution. I didn't have to tune this number as it wasn't tested for b > 10.

    • JohanWiltink Avatar

      Precalculating maximum polydivisible numbers for bases from 2 to 62 inclusive would make it possible to write a random generator that generates a base and a number larger than the largest possible polydivisible number in that base.

      I'm not precalculating that stuff myself, and I don't know how to then do the tests in Python. But it would be a useful start to get those tests in. Can I interest you in that?

    • Avanta Avatar

      Sorry, I probably wouldn't be too interested, although I could edit the Python translation if someone else makes a reference test case for a difference language.

      It's not really much of an issue, which is why I only marked as a suggestion. If you're happy with the test cases currently, then I can just approve the kata if you'd like.

    • Avanta Avatar

      I'll just approve at 4kyu then if you're happy with that?

    • JohanWiltink Avatar

      I'm happy with that. :]

  • Avanta Avatar

    This comment has been hidden.

  • mauro-1 Avatar