Ad
  • Custom User Avatar

    I used permutations and got it to pass if you only compute all the permutations for the part of the number that needs changing.

    You seem to create permutations for the entire number, for a number made up of 1234567890 I believe there are 9 billion of them. If you only use permutations on the part of the number that you are interested in, there are only 6. If you also sort them, you can exit once the permutation is lower than the original part of the number you cut out.

    But you should really listend to the author of the kata above, there are much better ways than using permutations. I used it to iterate from a rough/working/inefficient solution to a better solution. Hope this helps.

    Also, look for edge cases and cases where you can just swap 2 numbers to get the solution so you are not entering permuations at all.

  • Custom User Avatar

    Not a chance that might work (much less with a loop, not even a list comprehension); I would ask myself how to deal with it if you were a human.