Sounds like homework. I'll give you a hint. When you want to keep track of things you've seen, a hash is usually what you want.
You'll have a lot better luck getting help if you actually give it a go and post what you've got.
-Lee
"To be civilized is to deny one's nature."