Arnold Rosenbloom
arnold@cs.toronto.edu
http://www.cs.toronto.edu/~arnold

Problem Solving

Why is this important

I Understand

I Understand

I Understand

Common mistakes

Problems

  1. Learning a new programming language
  2. How many 0s are at the end of 999! (Num0s.java Num0s.pl)
  3. Find the last non-zero digit in 999!
  4. Locker Room problem

    A locker room has lockers numbered 0,1,2,...,1023. All lockers are initially closed.

    The first person walks in and flips every locker The 2nd person flips every other locker (starting at 0) The 3rd person flips every third locker (starting at 0) . . . The 1023 person flips every 1023 locker (starting at 0) At the end, which lockers are open and which are closed?

    Level 3 solution, Level 4 solution (no explanation given). Note the flaw at 0 in both cases.

  5. Card swapping problem: 25 people in a circle, a deck of 50 cards with numbers 1,1,2,2,...,25,25 on them. Each person gets 2 randomly selected cards. At each step, each person looks at their two cards and passes a smallest card left.

    Prove that eventually some person will be holding two cards with the same number on them.

  6. Write function compress(s) which returns the run length encoding of alphabetic String s. Example: compress("")="", compress("a")="1a", compress("aaaa")="4a", compress("aaaabbca")="4a2b1c1a" Many solutions
  7. The Jumble Problem: Word X is a jumble of word Y if the letters in X can be rearranged to give Y. Example: backwards drawbacks. Given a dictionary as input, find the largest group of words all of which are jumbles of each other.
  8. 15 puzzle Exercises (look at the source for the pages below):