I’m working on importing a dataset that looks like:
Quantity
100-500
Processes
litho, plain
Grammage
80, 120
These come in on a single record. The issue is that the above represents 8 different potential prices, one for each combination of each of the variable options, so from this one record we make 8 pricing records:
- 100, litho, 80
- 100, litho, 120
- 100, plain, 80
- 100, plain, 120
- 500, litho, 80
- 500, litho, 120
- 500, plain, 80
- 500, plain, 120
But in reality there are a lot more variables and options, such that this one record results in over 1000 pricing records.
So my question is one of elegant code; is there any typical pattern that this represents and how could it best be modelled in C#?
http://blog.noldorin.com/2010/05/combinatorics-in-csharp/
He was some working examples for a GetCombinations() extension for a list. It probably won’t solve your problem as is, but it should give you a good starting point on how to deal with combinations. This can be a difficult problem.