public static int[] CreatePattern(int lines, int legs) { var result = new int[legs]; var primes = MathExtension.DecomposeInteger(lines); primes.MapTo(result); return(result.OrderByDescending(c => c).ToArray()); }
public static int[] CreateSmartPattern(int lines, IReadOnlyDictionary <int, int> legSelections) { var fistCount = legSelections.Values.First(); if (legSelections.Values.All(c => c == fistCount)) { return(CreatePattern(lines, legSelections.Count)); } var primes = MathExtension.DecomposeInteger(lines); return(primes.AssignTo(legSelections)); }
public static int[] CreateFectaPattern(int lines, int legs) { var result = new int[legs]; var primes = MathExtension.DecomposeInteger(lines); primes.MapTo(result); var fectaResult = result.OrderBy(c => c).ToArray(); var addCount = 0; for (var i = 0; i < fectaResult.Length; i++) { if (fectaResult[i] == 1) { continue; } fectaResult[i] += addCount++; //add 0, 1, 2, 3, ... } return(fectaResult); }