homework for prof. hopcroft's mathcs class