No description
| data | ||
| src | ||
| util | ||
| .gitignore | ||
| AUTHORS | ||
| README | ||
word_graph - very simple program to find all distinct paths in a graph that
spell out a word.
This "project" started when my wife brought home a puzzle from her work place,
which asked how many different ways you could spell the word LEVEL given the
following:
L-E-V-E-L
|\ / \ /|
E E E E
|/ \ / \|
V V V
|\ / \ /|
E E E E
|/ \ / \|
L-E-V-E-L
I initially found the answer by hand, which is tedious. Why not let a
computer find the answer for me :)
Take even a simple example like this:
B-O-B
|\ /|
O O O
|/ \|
B-O-B
There are 32 different paths that can be taken to spell 'BOB'. These paths
can be found and listed with this program. Try this:
cd src/c
make
cd src/go
./build/sh
./word_graph -l ../data/bob.dat
B[0,0]-O[0,2]-B[0,0]
B[0,0]-O[0,2]-B[0,4]
B[0,0]-O[2,0]-B[0,0]
B[0,0]-O[2,0]-B[4,0]
B[0,0]-O[2,2]-B[0,0]
B[0,0]-O[2,2]-B[0,4]
B[0,0]-O[2,2]-B[4,0]
B[0,0]-O[2,2]-B[4,4]
B[0,4]-O[0,2]-B[0,0]
B[0,4]-O[0,2]-B[0,4]
B[0,4]-O[2,2]-B[0,0]
B[0,4]-O[2,2]-B[0,4]
B[0,4]-O[2,2]-B[4,0]
B[0,4]-O[2,2]-B[4,4]
B[0,4]-O[2,4]-B[0,4]
B[0,4]-O[2,4]-B[4,4]
B[4,0]-O[2,0]-B[0,0]
B[4,0]-O[2,0]-B[4,0]
B[4,0]-O[2,2]-B[0,0]
B[4,0]-O[2,2]-B[0,4]
B[4,0]-O[2,2]-B[4,0]
B[4,0]-O[2,2]-B[4,4]
B[4,0]-O[4,2]-B[4,0]
B[4,0]-O[4,2]-B[4,4]
B[4,4]-O[2,2]-B[0,0]
B[4,4]-O[2,2]-B[0,4]
B[4,4]-O[2,2]-B[4,0]
B[4,4]-O[2,2]-B[4,4]
B[4,4]-O[2,4]-B[0,4]
B[4,4]-O[2,4]-B[4,4]
B[4,4]-O[4,2]-B[4,0]
B[4,4]-O[4,2]-B[4,4]
The top-left column of the graph is location row 0 column 0, displayed as [0,0]
# Animate paths in terminal using curses
./view_paths.sh ../data/level.dat
# At maximum speed:
./view_paths.sh -d 0 -D 0 ../data/madamimadam.dat