You can get some interesting information with the use of MultiSets in haskell
This example is finding combinations of sequences with a given hand in mahjong. A more indepth explanation can be found here
runFilter $ MS.fromList
[ Suits Character One, Suits Character One, Suits Character One, Suits Character One
, Suits Character Two
, Suits Character Three
, Suits Character Four
, Suits Character Five
, Suits Character Six
, Suits Character Seven
, Suits Character Eight
, Suits Character Nine, Suits Character Nine, Suits Character Nine
]
returns this really obscure MultiSet (Maybe Run).
fromOccurList
[(Nothing,4)
,(Just (Suits Character One ,Suits Character Two ,Suits Character Three),4)
,(Just (Suits Character Two ,Suits Character Three,Suits Character Four) ,1)
,(Just (Suits Character Three,Suits Character Four ,Suits Character Five) ,1)
,(Just (Suits Character Four ,Suits Character Five ,Suits Character Six) ,1)
,(Just (Suits Character Five ,Suits Character Six ,Suits Character Seven),1)
,(Just (Suits Character Six ,Suits Character Seven,Suits Character Eight),1)
,(Just (Suits Character Seven,Suits Character Eight,Suits Character Nine) ,1)
]
The amount of information that can be inferred is quite amazing with this simple check.
- Anything that didn't work returned Nothing
- If there was multiple of a specific tile and had a successful run then it'll have multiple of the number
- As shown with the first found run