I don't quite follow how you track which array to read from next (yet), but godamn it's fast.
The following times yours, Limbic~Region's and mine. The data is 1 .. $N (minus anything with a 9 to stop it being a single contiguous sequence), randomly distributed across 4 arrays. The only tweaks I've made are to accumulate the results into an array rather than printing them out.
c:\test>588553-buk -N=100000 1 trial of Four arrays and a total of 100000 (1.756s total) Found 6561 runs c:\test>588553-lr -N=100000 1 trial of Four arrays and a total of 100000 (1.164s total) Found 6561 runs c:\test>588553-tye -N=100000 1 trial of Four arrays and a total of 100000 (507.209ms total) Found 6561 runs
By way of comparison, I also tested one of the 'sort them all together' solutions (grinder's, with apologies to the other contributors!) against yours, though I had to drop $N to stop it from blowing the memory:
c:\test>588553-gdr -N=10000 1 trial of Four arrays and a total of 10000 (4.491s total) Found 729 runs c:\test>588553-tye -N=10000 1 trial of Four arrays and a total of 10000 (55.570ms total) Found 729 runs
In reply to Re^2: Searching parallel arrays. (just merge)
by BrowserUk
in thread Searching parallel arrays.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |