How? De Bruijn Sequences.
This is a script that will produce a de Bruijn sequence as an ABC music file.
python de_bruijn_seq.py <k> <key> <notes>
Example: generate an exercise containing all 3-mers that can be formed from a pentatonic scale.
python de_bruijn_seq.py 3 C C D E G A c
Then, eg, paste the result into the ABC Convert-A-Matic.