Selects a way in set given the current validity of its ways.
set
int select(int set, List<bool> valid);