# Assignment 5

Solution

## Important dates

 Assigned 29 Mar 2017 @ 23:00h Due 5 Apr 2017 @ 23:59h

## Description

Implement functions to check Rubik’s Cube solutions.

A Rubik’s cube is a 3D puzzle. It has six sides, each side being a 3 $\times$ 3 grid of stickers. Each sticker is one of six colours: white, red, blue, orange, green or yellow. The goal of the puzzle is to rotate parts of the cube until each side has stickers of the same colour, i.e., there is an entirely-white side, an entirely-red side, etc.

The objective of this assignment is to write functions that can analyze an array that represents a Rubik’s Cube to determine whether or not the puzzle has been solved. The data representation for the Cube is an array of char values of size $6 \times N \times N$, where $N$ is the length of one side. A standard Rubik’s Cube has 3 $\times$ 3 faces, but other sizes are possible for more challenging problems (e.g., you can apparently buy 7 $\times$ 7 cubes). Each char value in the array should contain one of six values: 'W', 'R', 'B', 'O', 'G' or 'Y'.

You need to write two functions for this assignment: one to analyze the solution of a single side of a cube and one to check whether the entire cube has been solved. One of these problems is more challenging than the other, but both will have the same weight in terms of functional marking. I suggest you start by creating two stub functions, as a submission that compiles correctly but only returns correct answers for one function will still be eligible for half of the functionality marks. Then, attack the problems a little bit at a time, using a divide and conquer approach wherever possible.

You should submit a file entitled assign5.cpp that contains the definition of a function called movingAverage as declared in cube.h. Your source file may contain a main function for your own testing, but is not required to. Your sideSolved and cubeSolved definitions must exactly match the declarations in cube.h. This header file is also visible below: