cube assignment #2 programming language, spring 2003

8
Cube Cube Assignment #2 Programming Language, Spring 2003

Upload: emery-pope

Post on 05-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cube Assignment #2 Programming Language, Spring 2003

CubeCubeAssignment #2

Programming Language, Spring 2003

Page 2: 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

Page 3: Cube Assignment #2 Programming Language, Spring 2003

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

Page 4: Cube Assignment #2 Programming Language, Spring 2003

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

Page 5: Cube Assignment #2 Programming Language, Spring 2003

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

Page 6: Cube Assignment #2 Programming Language, Spring 2003

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}

Page 7: Cube Assignment #2 Programming Language, Spring 2003

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• ...

Page 8: Cube Assignment #2 Programming Language, Spring 2003

Spec.

• Assignment Spec.– System

• Unix (junebug.snu.ac.kr)– Language

• Java– Compile

• Use Makefile• $>make

– Execution• $>java cube cube.in

– Test• $>./test