Since there are 6,227,020,800 possible permutations of 13 numbers, it may be more convenient to use 10,000 randomly chosen permutations instead of all possible permutations. There are ways of calculating the exact P-value without doing all 6,227,020,800 permutations, but these are more difficult to program. Since there are 87,178,291,200 possible permutations of 14 numbers, it may be more convenient to use 10,000 randomly chosen permutations instead of all possible permutations. There are ways of calculating the exact P-value without doing all 87,178,291,200 permutations, but these are more difficult to program. Since the midranks are independent of the order of the data, computer time can be saved by replacing the data by their midranks, permuting the midranks rather than the data, and skipping the ranking steps.
Many computers can manipulate integers faster than floating point numbers.
Thus the midranks can be replaced by twice the midranks and stored in an integer array, since twice a midrank is always an integer. The Kruskal-Wallis score can be replaced by any strictly monotonic function of itself in the permutations, as long as this is done for both the observed and the permuted scores. A reasonable way to start is to put the midranks in an array of 13 or 14 variables, and then repeated randomly shuffle this array. The permuted Wilcoxon score will be the sum of the first m elements of this array. The simulations here should take less than a second on most modern computers, including PCs.