using Combinatorics.Collections;
Console.WriteLine("debut");
int[] numbers = Enumerable.Range(1, 50).ToArray();
var combinations = new Combinations<int>(numbers, combinationSize);
int validCombinationCount = 0;
foreach (var combination in combinations)
if (!HasMoreThanThreeConsecutive(combination.ToArray()))
Console.WriteLine($"Nombre de combinaisons valides (avec au plus 3 nombres consécutifs): {validCombinationCount}");
static bool HasMoreThanThreeConsecutive(int[] combination)
int consecutiveCount = 1;
for (int i = 1; i < combination.Length; i++)
if (combination[i] == combination[i - 1] + 1)
if (consecutiveCount > 3)