Answered step by step
Verified Expert Solution
Question
1 Approved Answer
It is in JAVA You have been given a puzzle consisting of a row of squares each containing an integer, like this: 36 4 1
It is in JAVA
You have been given a puzzle consisting of a row of squares each containing an integer, like this: 36 4 1 3 4 2 53 0 The initial square will always be the first square in your puzzle and should be marked by a circle. This circle should move along the squares in your puzzle as your program attempts to solve it. At each step in the puzzle, the circle can move the number of squares indicated by the integer in the square where it currently resides. The circle can move either left or right along the puzzle but may not move past either end of the puzzle. For example, the only initial move that is legal is to move the circle three squares to the right since there are no squares to the left of the initial square to move the circle into. The goal of the puzzle is to move the marker to the 0 at the far end of the row. In this configuration, you can solve the puzzle by making the following set of moves: Starting position 3 6 | 4 1 34 | 25 3 0 Step 1: Move right 3 6 4 3 4 25 30 Step 2: Move left 3 6 (4 1 34 | 25 30 Step 3: Move right 3 64 1 3 4 (2) 5 3 0 Step 4: Move right 3 64 1 3 | 4 | 25 30 Step 5: Move left 3 6 4 13 (4) 2 5 30 Starting position 36 4 1 3 4 2 5 | 30 Step 1: Move right 3 64 (13 4 2 5 30 Step 2: Move left 3 6 (4 1 3 4 | 2. 5 | 3 0 Step 3: Move right 3 64 1 3 4 (2) 5 3 0 Step 4: Move right 3 64 1 3 4 2 5 30 Step 5: Move left 3 64 1 3 (4) 2 5 30 Step 6: Move right 3 64 1 3 4 2 5 3 0 This puzzle is solvableand indeed has more than one solutionsome puzzles of this form may be impossible to solve, such as the following one: 31 2 3 10 In this puzzle, you can only bounce between the two 3's and thus you cannot reach any other squares. Write a program that takes the initial position of the circle and lets the user know if it is possible or not to solve the puzzle based on the values contained in the given row of squares. The puzzle should consists of a maximum of 10 positions. Your input should be entered via the keyboard by the end user when the program is initially executed. Your output should consist of a depiction of the circle's position in the row (the square where it would placed) each time a move is made. (the above illustrates what this should look like) and after completing all possible attempts a string that either indicates the puzzle was solvable or not. You may assume all the integers in the vector are positive except for the last entry, the goal square, which is always zero. The values of the elements in the vector must be the same after calling your function as they are beforehand, (which is to say if you change them during processing, you need to change them back!) NOTE: This assignment MUST use RECURSION. Please add comments to your program! Please follow the design and implementation strategies discussed under Programming Assignment Information under Week O. Note that documentation accounts for 50% of your grade. The format required for each programming assignment can also be viewed under Programming Assignment Information Your submission should be submitted in Canvas on the due date, no later than 12:00 (NOON) Make sure to submit the following: documentation code (java file(s)) screen shots or files of I/O which show all possible combinations and that error checking occurredStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started