"MADAM, I'M ADAM" is an example of a palindrome (it reads the same backwards as forwards).   It was mankind's first pickup line.

In how many different ways can you read "MADAM, I'M ADAM", starting at any one of the M's on the border, spelling by moving up or down, left or right, to adjacent letters until you reach the I in the center, and then back to the border again?




Click here for a Printer version




Scroll down for the answer ...








The answer is 15,376 different ways.

There are 124 ways of reaching the I in the center.   Then there are the same number of ways back out to the edge, so the answer is 124 x 124 = 15,376.

The diagram below shows how many ways you can get to a particular letter.

There are 20 starting positions (M) along the outside, so each of these squares is marked with a 1.

There are 3 ways that you can get to the square marked with an A in the 2nd row, 2nd column.   You can get there from the top, left, or the right.

There are 2 ways that you can reach the A in the third row, second column -- from the top or from the left.

There are 7 ways that you can reach the D in the third row, third column -- from the top, from the left, or from the right.   So, add the numbers in those squares (3, 2, and 2) to get 7.


To get to the I in the very middle, there are four ways to reach it -- from the top, the bottom, the left, and the right.   So add the numbers in those squares (31 + 31 + 31 + 31) to get 124.