1 / 11

3D Puzzle

3D Puzzle. Assignment #1 Programming Language, Spring 2003. 3D Puzzle. Characteristics Consist of 4ⅹ4ⅹ4 frame Contains 63 small cells of equal size 1 empty position that was the same size as a small cell A unique number of integer was printed on each small cell

Download Presentation

3D Puzzle

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 3D Puzzle Assignment #1 Programming Language, Spring 2003

  2. 3D Puzzle • Characteristics • Consist of • 4ⅹ4ⅹ4 frame • Contains • 63 small cells of equal size • 1 empty position that was the same size as a small cell • A unique number of integer was printed on each small cell • Empty position is marked with ‘$’

  3. Making out a Puzzle • Puzzle • Solving a puzzle • Make the frame display the numbers in order • Operation • Small cell can be moved into empty position • If it were immediately to the right, to the left, in the front, in the rear, above, or below the empty position

  4. Assignment • Objectives • Slide cells into the empty position so that the frame displays the numbers in order • Requirements • Input initial puzzle from file • Show current frame status • Can slide cell into the empty position • by command line input • by sliding-sequence file • Can output complete solution of sliding-sequence into file

  5. Input Convention • Command • Sliding operations • 1 : The square above the empty position moves • 2 : The square below the empty position moves • 3 : The square to the left of the empty position moves • 4 : The square to the right of the empty position moves • 5 : The square in the front of the empty position moves • 6 : The square in the rear of the empty position moves

  6. Source Code • puzzle.c • Input initial puzzle file • Get file name by program argument • $>./puzzle puzzle.in • Show current frame status • Command line input • Input ‘1~6’ command to slide cell • File input • Input ‘1~6’ command from sliding-sequence file • Each line contains maximum 10 command • Output complete solution • Output complete sliding-sequence solution into file • puzzle.out

  7. Initial Puzzle • puzzle.in • 4ⅹ4ⅹ4 matrix • Consist of 1st, 2nd, 3rd,and 4th planes(4ⅹ4 matrix) • Total 16 lines • Example • 5 6 7 8 • 21 22 23 24 • 13 $ 15 16 • 17 18 19 20 • … • 30 33 41 60

  8. Input Command • Command Line • Input • sliding command • 1~6 • Input sequence file name • $>in [filename] • Output sequence file name • $>out [filename] • Example • $>1 • $>6 • $>in seq.in • $>out seq.out • $>3

  9. Sliding-Sequence File • In File • Contain lines of cell sliding-sequence • Each line contains maximum 10 operations • Example • 1364524351 • 2625342516 • 53…

  10. Output Puzzle • Command Line • Current puzzle status • Consist of 1st, 2nd, 3rd,and 4th planes(4ⅹ4 matrix) • Example • 5 6 7 8 | 25 26 27 28 | 33 40 41 43 | 44 45 46 47 • 21 22 23 24 | 1 2 3 4 | 34 39 42 48 | 53 54 55 56 • 9 10 11 12 | 29 30 31 32 | 35 38 49 50 | 57 58 59 60 • 13 $ 15 16 | 17 18 19 20 | 36 37 51 52 | 61 62 63 14

  11. Spec. • Assignment Spec. • System • Unix (junebug.snu.ac.kr) • Language • C/C++ • Compile • Use Makefile • $>make • Execution • $>./puzzle puzzle.in

More Related