Cube Assignment 2 Programming Language Spring 2003 Cube
Cube Assignment #2 Programming Language, Spring 2003
Cube • Cube – 3 by 3 cube built of 27 smaller cubes • Cube is fallen apart into 7 pieces • 7 pieces can be assembled in many ways to again form the cube
Assembled Cube • Representation – Linearized form string • Substrings representing the front, middle and back plane • Substrings representing the top, middle and bottom row • Substrings representing the left, middle and right cell – Example • adcaccaacddgbfgffedggbfebee • aababbadcffegfcddcfeeggedgc
Assignment • Objectives – Computes all possibilities of assembling the cube • But suppress solutions that are mere rotations of another solution • Choose only one from the possibilities
Source Code • cube. java – Input file • Get input name by program argument • $>java cube. in – Output • All possibilities of assembling the cube • Output file name – cube. out
Input • cube. in – Contains • Number of pieces of the cube • Lines with symbol and linearized form of each piece – Example • • 7 a{aaaa 000000000000} b{bb 0 b 000000000000} c{ccc 0 c 00000000000} d{dd 000000000000} e{ee 0 e 00000000000} f{ff 0 f 00000000000000} g{gg 0 g 00000000000}
Output • cube. out – All possibilities of assembling the cube • Suppress solutions that are mere rotations of another – Choose only one from the possibilities • Output string is a linearized form of the cube – Example • • aaaabbcdbeffcggcddeefegfcgd aaaabbcdbeggcgfcddeegeffcfd aaaabbcdbggecdfcdfgeegdecff. . .
Spec. • Assignment Spec. – System • Unix (junebug. snu. ac. kr) – Language • Java – Compile • Use Makefile • $>make – Execution • $>java cube. in – Test • $>. /test
- Slides: 8