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

Write a program of wordSearch puzzle that use the following text file as an inpu

ID: 3784291 • Letter: W

Question

Write a program of wordSearch puzzle that use the following text file as an input. The output should be like this: PIXEL found (left) at (0,9). ( Use JAVA Array ) .Please do not use arrylist and the likes! (solve for searchRight() only )

Hints
• The puzzle can be represented as a right-sized two-dimensional array of characters (char).
• A String can be converted into a right-sized array of characters via the String method toCharArray.

. • Consider writing separate methods such as:
private boolean searchRight ( int x, int y, String word ) {
that look for a word starting from position (x,y) in the puzzle and proceeding
in the designated direction (right in this case). The method returns true if the
word is found in the designated direction starting from the indicated position.

text file

18 18
T P I R C S A V A J L E X I P I G E
L I A M E M O R Y M M O U S E N I L
C R A B K S A T X I N U Y H S T F G
D N D I R E C T O R Y E T A O E O O
P O W E R S U P P L Y N I R F R L O
U C O A S A E V A S S C R E T N D G
K I R O P K T Y P S H R U W W E E L
C D D E C P R E E A H Y C A A T R M
A N R I M A L L T D R P E R R E A T
B O L E N M E I E K E T S E E P H H
R C K I P R A F C V R I I R S U L M
E E B E I A R R I A B O O T M B O R
N S T W R A P R G R T N W B I N G O
N O O S G N D L O O D I N T I O I S
A N G M A K A U L A R A O T E A N R
C A E A S P T L T A I P O N R N D U
S N F I R E W A L L W R E I K O O C
T F D P R D H T O O T E U L B Y T E
JAVASCRIPT
PIXEL
INTERNET
GIF
GOOGLE
LCD
EMAIL
MEMORY
MOUSE
SHAREWARE
TASKBAR
UNIX
SECURITY
SOFTWARE
FOLDER
ICON
DIRECTORY

Explanation / Answer

import java.io.File;
import java.util.Scanner;

public class WordSearchPuzzle {

   /**
   * @param args
   */
   public static void main(String[] args) {
       // TODO Auto-generated method stub

       boolean flag = new WordSearchPuzzle().searchRight(1, 3, "MEMORY");
       if (flag)
           System.out.println("Word found");
       else
           System.out.println("Word not found");

       boolean flag1 = new WordSearchPuzzle().searchRight(0, 1, "PIXEL");
       if (flag1)
           System.out.println("Word found");
       else
           System.out.println("Word not found");

   }

   /**
   * @param x
   * @param y
   * @param word
   * @return
   */
   private boolean searchRight(int x, int y, String word) {

       char[][] puzzleGrid = new char[18][18];
       char[] wordArr = word.toCharArray();
       Scanner scanner = null;
       try {

           scanner = new Scanner(new File("puzzle.txt"));
           for (int i = 0; i < puzzleGrid.length; i++) {
               for (int j = 0; j < puzzleGrid[i].length; j++) {
                   puzzleGrid[i][j] = scanner.next().charAt(0);

               }

           }
           int count = 0;
           for (int i = x; i < puzzleGrid.length; i++) {

               for (int j = y; j < puzzleGrid[i].length; j++) {
                   if (count == wordArr.length)
                       return true;
                   else if (puzzleGrid[i][j] == wordArr[count])
                       count++;
                   else
                       return false;

               }

           }

           System.out.println(" " + count);
       } catch (Exception e) {
           // TODO: handle exception
       } finally {

           scanner.close();
       }

       return true;
   }
}

puzzle.txt

T P I R C S A V A J L E X I P I G E
L I A M E M O R Y M M O U S E N I L
C R A B K S A T X I N U Y H S T F G
D N D I R E C T O R Y E T A O E O O
P O W E R S U P P L Y N I R F R L O
U C O A S A E V A S S C R E T N D G
K I R O P K T Y P S H R U W W E E L
C D D E C P R E E A H Y C A A T R M
A N R I M A L L T D R P E R R E A T
B O L E N M E I E K E T S E E P H H
R C K I P R A F C V R I I R S U L M
E E B E I A R R I A B O O T M B O R
N S T W R A P R G R T N W B I N G O
N O O S G N D L O O D I N T I O I S
A N G M A K A U L A R A O T E A N R
C A E A S P T L T A I P O N R N D U
S N F I R E W A L L W R E I K O O C
T F D P R D H T O O T E U L B Y T E

OUTPUT:

Word found
Word not found

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote