SRM 700, D2, 250-Pointer (Xylophone)
James S. Plank
Sun Oct 23 14:43:39 EDT 2016
Try this one without any hints. If you get stuck or frustrated, come back here, and there
are hints if you scroll down.
Each key on the Xylophone maps to one of seven notes. You don't care what the notes
are. You just want to know which distinct notes are played. So, take each key played,
and calculate its value mod 7. That value will be different for each note (For example,
if you play an A, and then a B, they first key mod 7 will not equal the second key mod 7.
However, if you play two A's, even on different keys, then their values mod 7 will be
So what you want to do is count the number of distinct values there are when you take
each key mod 7. There are two straightforward ways to do this:
- Have a vector whose size is seven. Set a vector's entry to one, whenever the key
mod 7 equals the entry's index. Then sum the vector's entries.
- Have a set of integers, and insert each (key mod 7) into the set. Since you cannot
insert duplicates into sets, at the end, the size of the set will be your answer.