Algorithm for condensing/consolidating number combinations

Posted by user1404383 on Stack Overflow See other posts from Stack Overflow or by user1404383
Published on 2012-06-05T04:29:05Z Indexed on 2012/06/05 10:40 UTC
Read the original article Hit count: 220

Filed under:
|

Using a horse race betting scenario, say I have a number of separate bets for predicting the first 4 finishers of the race (superfecta).

The bets are as follows...

1/2/3/4  
1/2/3/5  
1/2/4/3  
1/2/4/5  
1/2/5/3  
1/2/5/4 

What I want to do is combine or condense these separate combinations as much as possible. For the bets above, they can be all condensed into 1 line...

1/2/3,4,5/3,4,5

What would algorithm look like for this?

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about combinations