Question: Listing 28.14, NineTail.java, presents a solution for the nine tails problem. Revise this program for the 4 * 4 16 tails problem. Note that it
Listing 28.14, NineTail.java, presents a solution for the nine tails problem. Revise this program for the 4 * 4 16 tails problem. Note that it is possible that a solution may not exist for a starting pattern. If so, report that no solution exists.
Listing

1 import java.util.Scanner; 2 3 public class NineTail { 4 public static void main(String[] args) { // Prompt the user to enter nine coins' Hs and Ts System.out.print("Enter the initial nine coins Hs and Ts: "); Scanner input = new Scanner(System.in); String s = input.nextline(); char[] initialNode = s.toCharArray(); 10 11 12 13 14 15 16 17 18 19 20 } NineTailModel model = new NineTailModel(); java.util.List path = model.getShortestPath(NineTai1 Model.getIndex(initialNode)); System.out.println("The steps to flip the coins are "); for (int i = 0; i < path.size(); i++) NineTailModel.printNode( NineTail Model.getNode (path.get(i).intValue()));
Step by Step Solution
3.47 Rating (167 Votes )
There are 3 Steps involved in it
Program Plan Create class Exercise2813 which is the revised version of nine tails problem for sixteen tails which is mentioned in listing 2814 Create an inner static class TailModel which defines a mo... View full answer
Get step-by-step solutions from verified subject matter experts
