Im doing a code house test on unity, using C#, where they gave me the following exercise but i wasn’t able to do. but still i want to know how must be done
The exercise is:
Stack the boxes on the platform “A”, in order of size (the biggest at the bottom).
Rules
You work in an automated factory that controls a robotic arm to move boxes. The boxes
are positioned in 3 stacks: “A”, “B” and “C”. The arm can move above each Stack to pick or
release a box. Your goal is to rearrange the boxes to Stack all of them onto the platform
W, in order of size.
Your method is given 3 lists. Each list contains the size of every box in the corresponding
stack (from bottom to top).
To succeed, your program must output the list of commands for the arm to execute. A
command is composed of two letters separated by a space: the source Stack from which
to pick a box, and the destination stack onto which to drop the box.
It is not necessary to minimize the number of commands but this number should not
exceed 200.
Implementation
Implement the method Solve(boxesA, boxesB, boxesC) which takes 3 arrays of
integers: boxesA, boxesB and boxesC. The method must return an array of strings: the
name of the source stack and the name of the destination stack, separated by a space.
For example, your method may return the following list of actions “A C”, “B C” and “A B” in
order to move a box from A to C, then a box from B to C and then a box from A to B.
Victory Conditions
All boxes are Piled on Stack A, in order of size.
Lose Conditions
- Your program outputs an invalid command.
- Your program needs more than 200 commands.
Constrains
- 20 =< size =< 200
- 3 =< number of boxes =< 8
The code must have the following method def:
public static string[] Solve(int[] boxesA, int[] boxesB, int[] boxesC){
// code here
}