Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

all the information that was given to me is on the pictures I posted. I am asking the professor for clarification but as of now

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
all the information that was given to me is on the pictures I posted. I am asking the professor for clarification but as of now I am going based on the examples.
CS 288 2020S Section 006 Homework 01 Due: Thursday February 6, 2020 at 2:00pm Task: Write a C program to simulate, not solve, a Twist Cube. The Twist Cube is a three dimensional combination puzzle invented by Larry D. Nichols in March 1970. This 2x2x2 cube is a simpler version of the traditional 3x3x3 Rubik's cube, invented by the Hungarian sculptor and professor of architecture Erno Rubik in January 1975. Just like any cubical shape, the Twist Cube has six faces. Each of the six faces is covered by four colored stickers. Each sticker can be one of six solid colors: White, Red, Blue, Orange, Green, and Yellow. For the puzzle to be solved, each face must have exactly one color. When the puzzle is solved, white is opposite yellow, blue is opposite green, and orange is opposite red, and the red, white, and blue are arranged in that order in a clockwise arrangement. Write a program that will print the cube's three visible faces to the console. The colors are represented by the first letter of their name in uppercase. The layout of the solved cube must match the following output sample Move Notation An internal pivot mechanism enables each face in the cube to turn independently, thus mixing up the colors. Twist Cube enthusiasts use a notation developed by David Singmaster to denote moves. A move is a 1/4 tum rotation of a face, either clockwise or counterclockwise. The faces are named as follows: F (Front) B (Back) U (Up) D (Down) L (Left) R (Right) - the side currently facing the solver - the side opposite the front - the side above or on top of the front side - the side opposite the top - the side directly to the left of the front - the side directly to the right of the front A letter by itself indicates a clockwise move while a letter with a plus sign (+) after it indicates a counterclockwise move. These directions are as one is looking at the specified face directly. A letter followed by the digit two (2) denotes two moves (direction is irrelevant in this case since a 1/2 turn can be correctly made in either direction). For example, starting with a solved cube, after applying the move "L+", the cube would look as follows: WW/ Applying the move "F" immediately after, we end up with the following: WR/ /BR/Y ---+Y | RGB B + RY The letters X, Y, and Z are used to indicate that the entire cube should be turned about one of its axes, corresponding to R U, and F turns respectively. When X, Y, or Z are followed by a plus sign, it is an indication that the cube must be rotated in a counterclockwise direction. When they are followed by the digit two, the cube must be rotated 180 degrees. For example, starting with a solved cube, after applying the move "Y", the cube would look as follows: /WW/ /WW/01 +-----+0 IBB01 10+ BB Input/Output and Program Termination The simulator must accept a string of moves through a command-line argument. After parsing the string of moves to break it into individual moves, the simulator should apply the moves in the order given starting with a solved cube. After all the moves have been applied, the program should print the cube's three visible faces (Left, Up, and Front) to standard output. Lastly, if the cube, after processing all the moves, is solved, the simulator should print the string "Hurrah!" to standard output. The simulator will then exit. Deliverables A file named twist.c containing the ANSI C source code. Grading Policy Students found in violation of the University Policy on Academic Integrity will face disciplinary action. This is an individual project; collaboration is not permitted. All work that you represent as your own must, in fact, be your own. The submission will not receive a grade if the file twist.c produces compilation warnings or errors. So, before submitting your solution, make sure it compiles cleanly using the gcc compiler as follows: $ gcc -ansi-Wall - Wextra - Wpedantic - Werfor twist.c Sample Session 1: Command Line and Output $ ./a.out F2L+U +-- ---+ /BW/1 /B Y /01 +-- -+R IWB BI Y + IRRI / Sample Session 2: Command Line and Output $ ./a.out R2D2B+F /RR/ 100 /B +---- +B I I W WIG G + | YY/ Sample Session 3: Command Line and Output $ ./a.out RZD+ /RR/ /RR/BI ----+B IY YIB B + IY YI / Hurrah! Sample Session 4: Command Line and Output $ ./a.out X+Z+Y /0 0/1 100 /B + = = +B I W WIB 1 B + | WW/ Hurrah! CS 288 2020S Section 006 Homework 01 Due: Thursday February 6, 2020 at 2:00pm Task: Write a C program to simulate, not solve, a Twist Cube. The Twist Cube is a three dimensional combination puzzle invented by Larry D. Nichols in March 1970. This 2x2x2 cube is a simpler version of the traditional 3x3x3 Rubik's cube, invented by the Hungarian sculptor and professor of architecture Erno Rubik in January 1975. Just like any cubical shape, the Twist Cube has six faces. Each of the six faces is covered by four colored stickers. Each sticker can be one of six solid colors: White, Red, Blue, Orange, Green, and Yellow. For the puzzle to be solved, each face must have exactly one color. When the puzzle is solved, white is opposite yellow, blue is opposite green, and orange is opposite red, and the red, white, and blue are arranged in that order in a clockwise arrangement. Write a program that will print the cube's three visible faces to the console. The colors are represented by the first letter of their name in uppercase. The layout of the solved cube must match the following output sample Move Notation An internal pivot mechanism enables each face in the cube to turn independently, thus mixing up the colors. Twist Cube enthusiasts use a notation developed by David Singmaster to denote moves. A move is a 1/4 tum rotation of a face, either clockwise or counterclockwise. The faces are named as follows: F (Front) B (Back) U (Up) D (Down) L (Left) R (Right) - the side currently facing the solver - the side opposite the front - the side above or on top of the front side - the side opposite the top - the side directly to the left of the front - the side directly to the right of the front A letter by itself indicates a clockwise move while a letter with a plus sign (+) after it indicates a counterclockwise move. These directions are as one is looking at the specified face directly. A letter followed by the digit two (2) denotes two moves (direction is irrelevant in this case since a 1/2 turn can be correctly made in either direction). For example, starting with a solved cube, after applying the move "L+", the cube would look as follows: WW/ Applying the move "F" immediately after, we end up with the following: WR/ /BR/Y ---+Y | RGB B + RY The letters X, Y, and Z are used to indicate that the entire cube should be turned about one of its axes, corresponding to R U, and F turns respectively. When X, Y, or Z are followed by a plus sign, it is an indication that the cube must be rotated in a counterclockwise direction. When they are followed by the digit two, the cube must be rotated 180 degrees. For example, starting with a solved cube, after applying the move "Y", the cube would look as follows: /WW/ /WW/01 +-----+0 IBB01 10+ BB Input/Output and Program Termination The simulator must accept a string of moves through a command-line argument. After parsing the string of moves to break it into individual moves, the simulator should apply the moves in the order given starting with a solved cube. After all the moves have been applied, the program should print the cube's three visible faces (Left, Up, and Front) to standard output. Lastly, if the cube, after processing all the moves, is solved, the simulator should print the string "Hurrah!" to standard output. The simulator will then exit. Deliverables A file named twist.c containing the ANSI C source code. Grading Policy Students found in violation of the University Policy on Academic Integrity will face disciplinary action. This is an individual project; collaboration is not permitted. All work that you represent as your own must, in fact, be your own. The submission will not receive a grade if the file twist.c produces compilation warnings or errors. So, before submitting your solution, make sure it compiles cleanly using the gcc compiler as follows: $ gcc -ansi-Wall - Wextra - Wpedantic - Werfor twist.c Sample Session 1: Command Line and Output $ ./a.out F2L+U +-- ---+ /BW/1 /B Y /01 +-- -+R IWB BI Y + IRRI / Sample Session 2: Command Line and Output $ ./a.out R2D2B+F /RR/ 100 /B +---- +B I I W WIG G + | YY/ Sample Session 3: Command Line and Output $ ./a.out RZD+ /RR/ /RR/BI ----+B IY YIB B + IY YI / Hurrah! Sample Session 4: Command Line and Output $ ./a.out X+Z+Y /0 0/1 100 /B + = = +B I W WIB 1 B + | WW/ Hurrah

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Compare and contrast unicast, broadcast, and multicast messages.

Answered: 1 week ago