Ad
  • Default User Avatar

    Well, generating permutations is not the correct way to go about this task. If the number contains a lot of digits, you will end up generating a huge amount of different permutations, which is what leads to your timeout. Look for a pattern between the input that you're given and the correct return value. There is a method to figuring out the next highest number. Try this kata if you're stuck: Basics 08: Find next higher number with same Bits (1's). It's a very similar premise, but it's made simpler by the fact that you're only dealing with 1's and 0's. If you can spot the pattern there, you may be able to apply that knowledge to this kata.

  • Default User Avatar

    Interesting task, in python I implemented generator that generates next element of permutation for those numbers. Seems to work fine but test cases are timing out after 3/4 test cases for bigger numbers. Any hints for optimazation?