Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ECE 103 Engineering Programming Spring 2018 Problem #2 Suppose you have five bal

ID: 2291437 • Letter: E

Question

ECE 103 Engineering Programming Spring 2018 Problem #2 Suppose you have five balls that are labeled "A", "B", "C", "D", "E" You also have six cups labeled sequentially "O", "1", "2", "3", "4", "5". These cups are glued to a flat board, so they cannot be removed or rearranged. The balls are placed in the cups in a specific order. The first cup is empty. The initial state Si looks like this: Initial State Si The balls are moved from cup to cup. The final state Sf looks like this: Final State Si Basically, the order of the balls in the cups needs to be reversed. Task Write a detailed and complete list of ball move instructions to go from the initial state Si to the final state Sr under the following constraints: 1. A cup can contain at most one ball at a time 2. The rearranging of the balls in the cups is accomplished by consecutive move operations. 3. A move operation consists of moving a single ball from its current cup to an empty cup 4. A ball may jump over at most one other ball in a single move, and only if there is an empty cup available on the other side Example syntax: move ball in cup 2 to cup 0

Explanation / Answer

Detailed List of Instructions are:

Move ball from 3 to 1

Move ball from 2 to 3

Move ball from 4 to 2

Move ball from 3 to 4

Move ball from 5 to 3

Move ball from 4 to 5

Move ball from 6 to 4

Move ball from 5 to 6

Move ball from 3 to 5

Move ball from 4 to 3

Move ball from 4 to 3

Move ball from 2 to 4

Move ball from 1 to 2

Move ball from 3 to 1

Move ball from 2 to 3

Move ball from 4 to 2

Move ball from 5 to 4

Move ball from 3 to 5

Move ball from 4 to 3

Move ball from 2 to 4

Move ball from 1 to 2

After last instruction the initial state will be achieved.