This one will work for group sizes > 5, which the old one would not.
Turns out I don't need a contains function because the elem function exists and does the same thing. Also got rid of the need for that transpose in day 6.