コード例 #1
0
 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);
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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);
             }
         }
     }
 }
コード例 #4
0
        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);
                    }
                }
            }
        }