Skip to content

.NET 8 + C# demo. Finds the most frequent words from a stream in a character matrix (rows & columns). Includes xUnit tests and GitHub Actions CI.

License

Notifications You must be signed in to change notification settings

mgomez-dev-code/WordFinder

Repository files navigation

WordFinder (.NET + C#)

.NET Language: C# Tests: xUnit .NET CI License: MIT

A small library + console sample to search a character matrix for the Top 10 most repeated words coming from a word stream.
Matches are scanned horizontally (left→right) and vertically (top→bottom).

Features

  • 🔍 Finds words spanning rows and columns.
  • 🔟 Returns the Top 10 words by frequency in the input stream that also exist in the matrix (ties resolved alphabetically).
  • 🅰️ Case-sensitive matching (inputs must match exactly).
  • 🧪 Unit tests with xUnit.

Project Structure

WordFinder.sln
├─ WordFinderLib/          # WordFinder class (library)
│  └─ WordFinder.cs
├─ WordFinderApp/          # Optional console app (manual run)
│  └─ Program.cs
└─ WordFinder.Tests/       # xUnit tests
   └─ WordFinderTests.cs

Getting Started

1) Build & Test (CLI)

dotnet build
dotnet test

2) Run the console sample

dotnet run --project WordFinderApp

Example

Matrix

a b c d c
f g w i o
c h i l l
p q n s d
u v d x y

Word stream

["cold", "wind", "snow", "chill"]

Result

["chill", "cold", "wind"]

How it works (brief)

  • Precomputes a set with all substrings from every row and every column.
  • For every word in the input stream, increments its count if it exists in that set.
  • Finally sorts by count desc, then word asc, and takes Top 10.

Complexity (sketch): building the set is roughly O(R*C*(R+C)) substrings with hashing; lookups are O(1) average per stream item.

Notes

  • Case-sensitive search (e.g., Chillchill).
  • Duplicates in the stream increase the count (e.g., if "wind" appears twice, it counts twice).
  • Returns an empty list if there are no matches.

License

This project is licensed under the MIT License. See LICENSE for details.

About

.NET 8 + C# demo. Finds the most frequent words from a stream in a character matrix (rows & columns). Includes xUnit tests and GitHub Actions CI.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages