If there's no other constraints and assuming the goal is to minimise the number of rooms, surely it's just a case of getting as many triples as possible plus one single or double depending on how many people are left over?
Triples = FLOOR(people/3)
Remainder = MOD(people, 3)
Doubles = IF(Remainder=2, 1, 0)
Singles = IF(Remainder=1, 1, 0)