MIT6_042JS10_lec13_sol

# MIT6_042JS10_lec13_sol - Massachusetts Institute of...

This preview shows pages 1–2. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Massachusetts Institute of Technology 6.042J/18.062J, Spring ’10 : Mathematics for Computer Science March 3 Prof. Albert R. Meyer revised March 1, 2010, 826 minutes Solutions to In-Class Problems Week 5, Wed. By now you are very familiar with the 6.042 icon that appears on the course webpage and lecture slides. This icon is a picture of a game called the Fifteen Puzzle . The following problem may help you appreciate why this icon was chosen as the course logo. Problem 1. In this problem you will establish a basic property of a puzzle toy called the Fifteen Puzzle using the method of invariants. The Fifteen Puzzle consists of sliding square tiles numbered 1 ,..., 15 held in a 4 × 4 frame with one empty square. Any tile adjacent to the empty square can slide into it. The standard initial position is 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 We would like to reach the target position (known in my youth as “the impossible” — ARM): 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 A state machine model of the puzzle has states consisting of a 4 × 4 matrix with 16 entries consisting of the integers 1 ,..., 15 as well as one “empty” entry—like each of the two arrays above. The state transitions correspond to exchanging the empty square and an adjacent numbered tile. For example, an empty at position (2 , 2) can exchange position with tile above it, namely, at posi- tion (1 , 2) : n 1 n 2 n 3 n 4 n 5 n 6 n 7 n 8 n 9 n 10 n 11 n 12 n 13 n 14 n 15 −→ n 1 n 3 n 4 n 5 n 2 n 6 n 7 n 8 n 9 n 10 n 11 n 12 n 13 n 14 n 15 We will use the invariant method to prove that there is no way to reach the target state starting from the initial state. We begin by noting that a state can also be represented as a pair consisting of two things: 1. a list of the numbers 1 ,..., 15 in the order in which they appear—reading rows left-to-right from the top row down, ignoring the empty square, and Creative Commons 2010, Prof. Albert R. Meyer . 2...
View Full Document

{[ snackBarMessage ]}

### Page1 / 5

MIT6_042JS10_lec13_sol - Massachusetts Institute of...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online