Skip to content

A C program that places the string '.NET_CORE' into a randomly sized matrix using a self-avoiding random walk algorithm. It ensures characters are placed sequentially in adjacent cells (Up/Down/Left/Right) without overlapping.

License

Notifications You must be signed in to change notification settings

ShotsMan2/Random-Walk-Word-Placement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Random Walk Word Placement

This project implements a matrix generation algorithm in C that embeds a specific string (.NET_CORE) using a Self-Avoiding Random Walk.

⚙️ Logic

  1. Grid Initialization: Creates a random $N \times N$ grid filled with placeholders (#).
  2. Start: Places the first character . at a random coordinate.
  3. Walk:
    • Randomly selects a valid neighbor (Up, Down, Left, Right).
    • Moves to that neighbor and places the next character.
    • Constraint: Cannot move to a cell that is already occupied or out of bounds.
  4. Retry Mechanism: If the algorithm gets "trapped" (no empty neighbors left but word isn't finished), it resets and tries again.

🚀 Example Output

Target: .NET_CORE

#  #  O  R  E 
#  #  C  _  # 
#  #  T  #  # 
#  .  E  N  # 
#  #  #  #  #

About

A C program that places the string '.NET_CORE' into a randomly sized matrix using a self-avoiding random walk algorithm. It ensures characters are placed sequentially in adjacent cells (Up/Down/Left/Right) without overlapping.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages