You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
TrustPilotChallenge/WhiteRabbit/PrecomputedPermutationsGene...

33 lines
1.2 KiB

8 years ago
namespace WhiteRabbit
{
using System.Collections.Generic;
using System.Linq;
internal static class PrecomputedPermutationsGenerator
8 years ago
{
8 years ago
private static PermutationsGenerator.Permutation[][] Permutations { get; } = new[]
{
PermutationsGenerator.HamiltonianPermutations(0).ToArray(),
PermutationsGenerator.HamiltonianPermutations(1).ToArray(),
PermutationsGenerator.HamiltonianPermutations(2).ToArray(),
PermutationsGenerator.HamiltonianPermutations(3).ToArray(),
PermutationsGenerator.HamiltonianPermutations(4).ToArray(),
PermutationsGenerator.HamiltonianPermutations(5).ToArray(),
PermutationsGenerator.HamiltonianPermutations(6).ToArray(),
PermutationsGenerator.HamiltonianPermutations(7).ToArray(),
PermutationsGenerator.HamiltonianPermutations(8).ToArray(),
PermutationsGenerator.HamiltonianPermutations(9).ToArray(),
};
8 years ago
public static IEnumerable<PermutationsGenerator.Permutation> HamiltonianPermutations(int n)
{
8 years ago
if (n > 9)
8 years ago
{
8 years ago
return PermutationsGenerator.HamiltonianPermutations(n);
8 years ago
}
8 years ago
return Permutations[n];
8 years ago
}
}
}