Project

General

Profile

« Previous | Next » 

Revision f51c164f

Added by Leszek Koltunski about 1 year ago

CU_323 solver: speedups

View differences:

src/main/java/org/distorted/objectlib/tablebases/TablebaseHelpers.java
207 207

  
208 208
  public static int computePermutationNum(int[] permutation)
209 209
    {
210
    int len = permutation.length-1;
210
    int len = permutation.length;
211 211
    int ret = 0;
212 212
    int mul = 3;
213 213

  
214
    for(int i=0; i<len; i++)
214
    for(int i=0; i<len-2; i++)
215 215
      {
216
      ret += swaps(len-1-i,permutation,len+1);
217

  
218
      if( i<len-1 )
219
        {
220
        ret *= mul;
221
        mul++;
222
        }
216
      ret += swaps(len-2-i,permutation,len);
217
      ret *= mul;
218
      mul++;
223 219
      }
224 220

  
221
    ret += swaps(0,permutation,len);
222

  
225 223
    return ret;
226 224
    }
227 225

  

Also available in: Unified diff