Skip to content

Alphabet Soup - Word Search Solver Implementation

Alphabet Soup - Word Search Solver Implementation

A comprehensive Java implementation of a word search puzzle solver that finds words in a character grid with extensive unit testing and error handling.

Overview

This project implements a word search puzzle solver that can find words hidden in a character grid in all 8 directions (horizontal, vertical, and diagonal, both forward and backward).

Features

  • Multi-directional Search: Finds words in all 8 directions (horizontal, vertical, diagonal)
  • Bidirectional Support: Detects words reading both forward and backward
  • Space Handling: Automatically removes spaces from words during search
  • Case Insensitive: Handles mixed case input gracefully
  • Robust Error Handling: Comprehensive validation and error reporting
  • Comprehensive Testing: Thorough test coverage with edge cases and boundary conditions
  • Maven Build System: Dependency management and build automation

Architecture

The solution is built with the following architecture:

  • WordSearchSolver: Main solver class handling puzzle loading and word searching
  • Position: Immutable class representing grid coordinates
  • WordSearchResult: Result container with word and position information
  • WordSearchApplication: Main application entry point with CLI handling
  • ApplicationException: Custom exception for application-level errors

Input Format

The program accepts a file as input with the following format:

  1. First line: Grid dimensions in format rowsxcolumns (e.g., 5x5)
  2. Next N lines: Grid rows with space-separated characters
  3. Remaining lines: Words to find (one per line)

Example Input

5x5
H A S D F
G E Y B H
J K L Z X
C V B L N
G O O D O
HELLO
GOOD
BYE

Output Format

The program outputs each found word with its start and end positions:

HELLO 0:0 4:4
GOOD 4:0 4:3
BYE 1:3 1:1

Format: WORD startRow:startCol endRow:endCol

Sample Files

The testInputs/ directory contains various test files:

  • sample_input1.txt
  • sample_input2.txt
  • sample_input3.txt
  • sample_input4.txt
  • sample_input5.txt
  • sample_input6.txt
  • sample_input7.txt

Merge request reports

Loading