7. Coin Swap

Implement an App Lab interface for the Coin Swap puzzle. This is played with 4 coins on 5 squares in a row. Play starts with two coins that are heads ("H") in the leftmost two squares, and two coins that are tails ("T") in the rightmost two squares, with the middle square blank. The objective is to swap the pieces.

Heads can only move to the right into an empty square or can jump over a single Tails piece into an empty square. Tails can only move to the left into an empty square or can jump over a single Heads piece into an empty square. The starter code in App Lab gives you the following interface:

Coin Swap

Running the finished program looks like the following:

Submission

Get the link to your group's solution using the Share near the top-left of that page:

Share Link

Post the link to your App Lab solution using this google form. The title should be: Coin Swap. Be sure to type in all group member names on the submissions form as well as within your code!

Rubric:

This lab is more challenging and lengthy than usual. You should have enough time to get 1 point (as described below), but it is a challenge to get more than that in the time allotted to you.

0: Program runs however all valid single moves have not been implemented

1: Valid moves into adjacent empty squares can be made for all locations. Invalid moves should not be allowed.

2: (Time permitting) Valid jump moves over opposite pieces into empty squares can be made

3: Extra credit: All moves can be made and message is given at end when puzzle has been solved.