No description
Find a file
2020-12-23 08:22:57 -06:00
data A new data file 2016-12-15 16:04:58 -06:00
src Buffer path output to stdout 2020-12-23 08:22:57 -06:00
util Reorganized a bit 2016-12-15 21:02:22 -06:00
.gitignore Update ignore file for git 2020-03-05 11:10:15 -06:00
AUTHORS Props 2016-12-15 21:07:17 -06:00
README Don't strip spaces from graph 2020-03-03 19:44:40 -06:00

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