I have a list of List<int>
(List<List<int>>
). The list consists of gaming bets of startnumbers in races.
Lets say i choose three options in the first race, then one option in the remaining 6 races. This adds up to three combinations of bets.
A List<List<int>>
of three unique rows(bets) would look like this:
[0] 1 [0] 2 [0] 3
[1] 1 [1] 1 [1] 1
[2] 1 [2] 1 [2] 1
[3] 1 [3] 1 [3] 1
[4] 1 [4] 1 [4] 1
[5] 1 [5] 1 [5] 1
[6] 1 [6] 1 [6] 1
When i submit the bet, i want to group the single bets into smaller grouped bets (maybe a List<List<string>>
?) that mathematically represent the list above, so according to the above example:
[0] "1,2,3"
[1] "1"
[2] "1"
[3] "1"
[4] "1"
[5] "1"
[6] "1"
I have found similar solutions related to the topic Cartesian-product. But none seems applicaple to this problem. Any ideas?
I found this Reverse Cartesian Product , which describes my problem, but i cant really translate this answer into c# from java.
EDIT: Just to clarify on the questions in the comments, each bet always consist of 7 races, so if i chose bet #1 in race 2-7 and then bet on the #1,#2,#3 in the first race. My function creates three rows of List with a .Count == 7. I was just trying to illustrate the contents of the list. One would in c# initiate a new list this way:
List<List<int>> list = new List<List<int>> { new List<int> { 1, 1, 1, 1, 1, 1, 1 }, new List<int> { 2, 1, 1, 1, 1, 1, 1 }, new List<int> { 3, 1, 1, 1, 1, 1, 1 } };
> ?
– Andrew Nov 06 '19 at 13:36>` doesn't need to be rectangular
– Cid Nov 06 '19 at 13:38>` is **jagged** (though not an array in this case, you might want to look up "jagged array" to understand the gist).
– Flater Nov 06 '19 at 13:44