Dobble/SpotIt is a card game, where people have to spot same symbol on pair of cards in shortest time, indicate it and move to next pair. Each card has multiple symbols (8 in normal version), but exactly one is common between each pair of cards.
Write a program, which given set of symbols (single ascii characters) and number of symbols on single card will produce output listing cards with symbols for each card. There are obviously many equivalent combinations, your program just has to write any of combinations which produces largest amount of cards for given input.
It is a code-golf, so shorter the code, better.
It would be also great if computation will finish before heat death of universe for most complicated case.
Two arguments to function/stdin (your choice)
First of them being collection of symbols, something like 'ABCDE" or ['A','B','C','D','E'] - your choice of format, be it string, set, list, stream, or whatever is idiomatic for language of choice. Characters will be given from set of [A-Za-z0-9], no duplicates (so maximum size of input symbol set is 62). They won't be neccesarily ordered in (so you can get "yX4i9A" as well for 6-symbol case).
Second argument is integer, indicating amount of symbols on single card. It will be <= than size of symbol set.
Print multiple lines separated by newlines, each one of them containing symbols for single card.
ABC 2 >>>> AB BC AC
ABCDEFG 3 >>>> ABC BDE CEF BFG AEG CDG ADF
ABCDE 4 >>>> ABCD
- Number of cards produced cannot be larger than amount of distinct symbols and in many combinations it will be considerably smaller
- You might want to read up Some math background if you need help with math side of the problem
This is my first code golf challenge, so please forgive possible issues with formatting/style - I'll try to correct errors if you point them in comments.
Edit: There is a very nice youtube video explaining the math behind the Dobble setup here: