-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPuzzle.java
62 lines (52 loc) · 2.43 KB
/
Puzzle.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//package org.example;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.List;
public interface Puzzle {
/**
* Returns the list of words associated with the puzzle.
* @return A list of words.
*/
List<String> getWords();
/**
* Searches the puzzle data for all occurrences of a specific character.
* @param character The character to be located in the puzzle.
* @return A stack containing positions of the specified character.
*/
ArrayStack<Position> findAllOccurrencesOfCharacter(String character);
/**
* Determines if the character at a specified position matches the provided character.
* @param position The position within the puzzle's grid to check.
* @param character The character for comparison.
* @return True if the characters match, otherwise false.
*/
boolean isCharacterAtPosition(Position position, String character);
/**
* Finds valid neighboring positions of a given position containing the specified character.
* @param pos The starting position for the search.
* @param character The character to identify valid neighbors.
* @return A stack containing valid neighboring positions.
*/
ArrayStack<Position> findValidNeighbors(Position pos, String character);
/**
* Constructs and prints a representation of the specified word using a sequence of positions.
* @param word The word to represent.
* @param positionsDeque The sequence of positions forming the word.
*/
void printDequeOfPositions(String word, ArrayDeque<Position> positionsDeque);
/**
* Checks if the characters at the specified positions form the given word.
* @param positionsDeque The sequence of positions to be validated.
* @param word The target word for validation.
* @return True if the sequence of characters matches the word, otherwise false.
*/
boolean validateWord(ArrayDeque<Position> positionsDeque, String word);
/**
* Computes possible sequences of positions to form the target word.
* @param positionsDeque A deque containing the current sequence of positions.
* @param targetWord The word to be formed.
* @param i The current character index of the target word being processed.
*/
void computeTreeOfWords(ArrayDeque<Position> positionsDeque, String targetWord, int i);
}