I just now solved that problem by reusing my code from bigger number challenge with some changes.
Going over it again and reading that you are using brute force, leads me to wonder if you mean you’re checking every combination of numbers?
for all I know you’re already doing things in the way I’m about to mention, but just in case it helps…
it might help to think of it like this,
as close to the one’s place as possible you need to replace a digit with a digit that’s not only smaller, but is also closer to the one’s place.
for a number, say
num = 70632182348246
// 6 has no smaller number before it, neither does 4 or 2.
//this leaves 8 as the first digit with a smaller digit that can replace it
// so we can boil this down to just working with 8246
// and leave the beginning 7063218234 part for later
//now you just have to figure out how to rearrange 8246 before stitching the result back onto the end of 7063218234
hope that helps simplify things a bit.