String permutation checker

I havent written any code to test the speed, as I dont know where you are getting your source strings, or how long they would be.

But:

While Xojo doesnt have a string sort, there have been many attempts at ‘fastest sort’ algorithms.

So it seems to me that if you put the strings into a memoryblock, then accessing each digit is just a case of using MemblockA.byte(n) and MemblockB.byte(n)

Each memoryblock can then be treated in almost the same way as an integer array.. it just comes down to how fast you can sort those.

Sadly, while Xojo has a sort method on an actual integer array, there is no similar thing for a memoryblock.

So you would either apply your own sort to the memoryblock,

or waste processing time putting the bytes into a Xojo array

Obviously, but it will be found out when it does. The total number of digits is the same in both numbers, so if some digit does occur more often in the first number than it does in the second one there must be another digit occurring more often in the second number to compensate. Therefore if no digit occurs more often in the second number than it does in the first – which we can check for in the second loop – then there cannot be a digit occurring more often in the the first loop, i.e. all counters are guaranteed to be zero so we don’t need to waste time checking for that.

Michael,
I’m useless in everything but did you try AI on Google which give me solutions in a fraction of a second for your application, even in Xojo :slight_smile: