los subrangos serian:
01 al 09
10 al 19
20 al 29
30 al 39
40 al 49
50 al 59
60 al 69
70 al 79
80 al 89
90 al 99
Ahora este código me los combina de esta forma
01, 02, 05, 07, 08, 15, 17, 18
01, 02, 05, 07, 08, 15, 17, 45
01, 02, 05, 07, 08, 12, 15, 17
01, 02, 05, 07, 08, 15, 17, 22
01, 02, 05, 07, 08, 15, 17, 23
01, 02, 05, 07, 08, 15, 17, 27
01, 02, 05, 07, 08, 15, 17, 28
01, 02, 05, 07, 08, 15, 17, 33
01, 02, 05, 07, 08, 15, 17, 34
Pero los necesito de esta forma
01 05 10 15 20 25 35 38
07 09 11 16 24 26 70 78
10 19 35 38 45 49 80 88
como verán por cada combinación solo hay dos de cada subrango y haci llenar todas las combinaciones posibles con los números que contiene la variable.
Código
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim combinations As New List(Of List(Of Integer)) Dim length As Integer = 7 Dim skipStart As Integer = 0 Do Until skipStart = (constantValues.Count - length) Dim values As List(Of Integer) = constantValues.GetRange(skipStart, length) Dim count As Integer = 0 Do Until count = (constantValues.Count - length - skipStart) Dim list As List(Of Integer) = values.Concat(constantValues.Skip(skipStart + length + count).Take(1)).ToList list.Sort() combinations.Add(list) ' Debug.WriteLine(String.Join(", ", values.Concat(constantValues.Skip(skipStart + length + count).Take(1)).ToArray)) count += 1 Loop ' count = (constantValues.Count - length) skipStart += 1 Loop ' skipStart = (constantValues.Count - length) combinations.RemoveAll(Function(list As List(Of Integer)) list.First = 0) combinations.ForEach(Sub(combination As List(Of Integer)) ListBox2.Items.Add(String.Join(", ", From value As Integer In combination Select If(value.ToString.Length = 1I, value.ToString.Insert(0I, "0"c), value.ToString))) ' Label11.Text = combinations.Count.ToString() End Sub) ' Button4.Enabled = False End Sub
saludos
Luis