80 likes | 507 Views
Cube. Assignment #2 Programming Language, Spring 2003. Cube. Cube 3 by 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
E N D
Cube Assignment #2 Programming Language, Spring 2003
Cube • Cube • 3 by 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 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{aaaa00000000000000000000000} • b{bb0b00000000000000000000000} • c{ccc0c0000000000000000000000} • d{dd00dd000000000000000000000} • e{ee0e00000e00000000000000000} • f{ff0f00000000f00000000000000} • g{gg0g000000g0000000000000000}
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 cube.in • Test • $>./test