private void ExchangeColumns(int tableLength, String key, ResultAccumulator accumulator) { int[] exchanges = GetExchanges(key); for (int i = 0; i < tableLength; i++) { int row = i / exchanges.Length; int currentOffset = i % exchanges.Length; int destinationIndex = row * exchanges.Length + exchanges[currentOffset]; accumulator.Accumulate(i, destinationIndex); } }
private void railwaize(int length, int fenceSize, ResultAccumulator accumulator) { int period = 2 * fenceSize - 2; for (int step = 0; step <= period / 2; step++) { for (int j = step; j < length; j++) { if (j % period == step || j % period == period - step) { accumulator.Accumulate(j); } } } }