Do you mean five percent of 530? Or five percent of the ‘diff_goal’, the desired difference between the two lists? After all, the sum of the two lists combined will remain unchanged. That’s why I used a ‘diff_goal’ slider.
The initial sum of ‘List A’ is 511.74518 and ‘List B’ is 499.74605 for a total of 1011.49123. So if you want one of them to be 530, the other must be 481.49123, which is a ‘diff_goal’ of 48.50877.
Five percent of 530 is 26.5 (more half of the ‘diff_goal’!)
Five percent of 48.50877 is ~2.43, which sounds like a more reasonable tolerance value, eh?
So… I removed the unnecessary Sort but it had little effect. 18 seconds instead of 19 seconds, but remember, it is testing 500 values of ‘Seed’, each with 20 variations of Random Reduce, so 10,000 tests in all (556 tests/second) .
I added a ‘tolerance’ slider with default of 0.01 (1%) that is multiplied by the ‘diff_goal’. Then added a check to terminate the loop when ‘variance’ becomes less than that value. For smaller values of ‘diff_goal’, the loop now finishes in a fraction of a second! It was way more precise than you needed.
However, for large values of ‘diff_goal’ (like 48.5), it still takes ~18 seconds to test 10,000 variations and fails to meet the 1% tolerance goal. If you change ‘tolerance’ to 0.05 (5%) then it finishes in ~6 seconds - three times faster. Just be aware that the larger your ‘diff_goal’ (and the smaller the ‘tolerance’), the harder it becomes to find a solution.
Treelog_2020Mar3a.gh (59.2 KB)
NOTE: If you set the ‘diff_goal’ to zero to search for equal length lists (your original goal), the A/B component after FastLoopEnd will fail because of divide by zero. That can be ignored.