Your company makes Rubik's cubes and recently bought a machine that creates the individual blocks that make up a Rubik's cube. It seems that some rats got in and stole some of the blocks while the machine was running during the weekend. Your company now has a pile of mixed up blocks and it's not clear what the best path forward is.
You think your managers might need the following information to make some good business decisions:
Question 1: What is the largest number of valid cubes that can be created?
Question 2: What is the largest valid cube that can be created? (ie: for an NxNxN cube, return N)
Question 3: What is the largest number of blocks that can be assembled into valid cubes?
Assumptions and restrictions:
There are 3 types of blocks: corner blocks (having 3 colours), edge blocks (having 2 colours) and center blocks (having 1 colour).
You can assume each Rubik's cube is cube-shaped (ie: its width is the same as its height and depth) with a minimum size of 2x2x2.
You can assume all blocks have valid colour combinations, blocks are produced to make cubes in the standard Rubik’s colour scheme (ex: no blocks would have white+yellow since those are on opposite sides of a cube).
You can ignore the internal workings of the cubes.
Please submit a .zip file containing all of the relevant files for your solution.
Your solution should implement the BlockVerifier interface.
Java is preferred, but other languages are also acceptable.
Feel free to augment the following classes as needed.
public interface BlockVerifier {
int getMaxCubes(List blocks); // question 1
int getLargestCube(List blocks); // question 2
int mostBlocksUsed(List blocks); // question 3
}
public enum Colour {
RED,
GREEN,
BLUE,
ORANGE,
WHITE,
YELLOW
}
public class Block {
public Set colours = new HashSet<>();
}