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