Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

removed condition, updated readme with instructions

  • Loading branch information...
commit 1deb2163b23ba3875c68fa92674b64cb270ace47 1 parent 0d2995a
@benjaminplee authored
Showing with 21 additions and 15 deletions.
  1. +20 −14 README.md
  2. +1 −1  src/word.erl
View
34 README.md
@@ -1,24 +1,30 @@
word-ladder
===========
-basic idea:
+http://en.wikipedia.org/wiki/Word_ladder
-Gen-Event-Manager (for words that exist)
-Gen-Events for each valid word in dictionary as state
- if incoming event matches state
- spawn new process to handle word
+implementation creates process for each word in dictionary, sends lookup
+to start word and each process sends out messages to others as
+candidates in the chain/ladder, not knowing if it is a word or not
-initialize: add all words from file as event handlers
+hacked together a a discussion piece and not as an example of fine code.
+only supports 4 letter words
-Find-Ladder call to look
- trigger event for start word with it as history as nothing
+currently, to run
-Link module
- if word = goal word, print
- otherwise
- needs to spawn event for switching every letter in the word
- with all other characters possible (ascii #)
+# from shell, will get dependencies (gproc), clean, compile and run erl with your binaries
+./start.sh
-SCREW TESTING AND SUPERVISION TREES (for now)
+# in erl
+word_ladder_app:start().
+word_ladder_app:initialize().
+word_ladder_app:find("cold", "warm").
+currently when a process finds a solution, it kills the spawning process
+(erl shell I believe) which kills all other word processes. this means
+that the system doesn't run forever (using a fair bit of memory as it
+constructs some LONG chains) but also means that initialize needs to be
+called before each "find".
+
+produce dictionary file of 4 letter words:
cat /usr/share/dict/words | grep -e '^....$' > four_letter_words.txt
View
2  src/word.erl
@@ -12,7 +12,7 @@ loop() ->
io:format("Solution! ~p~n", [Chain]),
exit("Found a solution"),
ok;
- {Link, Chain, Goal} when length(Chain) < 10 ->
+ {Link, Chain, Goal} ->
find_next_link(Link, Chain, Goal),
loop()
end.
Please sign in to comment.
Something went wrong with that request. Please try again.