Question
*The Code is in JAVA* PROBLEM : Given an array containing the digits 0 3 to direct a walker along a path, find the ending
*The Code is in JAVA*
PROBLEM: Given an array containing the digits 0 3 to direct a walker along a path, find the ending location of the walker. This problem will use a 4x4 array. In the diagram below, location (1, 1) is at the upper left hand corner of the array and contains a 0. If the walker encounters a 0, he moves to the right. If he encounters a 1, he moves to the left. If he encounters a 2, he moves up. If he encounters a 3 he moves down. After leaving a cell, the cell value increments by 1. A 3 becomes a 0. If a cell value directs a walker to a boundary of the array, he is transported to the opposite side of the array. Ex: a walker at (2, 4) who must move right would move to (2, 1).
INPUT: There will be 6 lines of input. The first line will contain 4 numerical character strings that will give the array values. If the string has fewer than 4 characters, add 0s on the left side of the string. The first string will fill the top row of the array. The 0 in that top row is at location (1, 1). The next 5 lines of input will each have 2 integers giving the ordered pair starting location (row, col). Always revert back to the original array to start each walk.
OUTPUT: For each line of input (2 - 6) print the final location of the walker in row/col order after 6 moves.
TEST INPUT TEST OUTPUT
1. 31, 203, 1, 3120 1. 4, 1
2. 3, 4 2. 3, 3
3. 1, 1 3. 3, 2
4. 3, 2 4. 2, 1
5. 2, 3 5. 2, 4
6. 4, 4
The inputs should be read from a text file. Here are some sample inputs:
231 1233 1302 1201 1 1 2 4 3 2 4 4 2 2
another one:
31 203 1 3120 3 4 1 1 3 2 2 3 4 4
1321 3300 2232 1321 3300 2232Step 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