Expand Cut Tags

No cut tags
topaz: (Morgan - sneer)
[personal profile] topaz
$ ./lcwg.rb bike vole
bike dike fike hike kike like mike pike sike sake bake cake fake hake jake lake 
make nake rake take wake woke boke coke doke joke loke moke poke roke soke toke 
yoke yore bore core fore gore kore lore more pore sore tore wore ware bare care 
dare fare gare hare mare pare rare sare tare vare yare yere bere cere dere here 
mere qere sere were wire aire dire fire hire lire mire sire tire vire vice bice 
dice fice mice nice pice rice sice tice wice wace dace face lace mace nace pace 
race rafe safe sife fife life nife rife wife wide aide bide fide hide lide mide 
nide ride side tide tade bade cade dade fade gade hade jade lade made sade vade 
wade yade yede cede lede mede rede wede wode bode code dode gode lode mode node 
rode tode tobe dobe lobe robe ribe gibe jibe kibe kipe hipe pipe ripe sipe tipe 
wipe wype gype rype type tape cape gape jape nape pape rape rope cope dope hope 
lope mope nope pope sope tope tole

There may be some opportunities for optimization.

Date: 2008-02-28 11:49 am (UTC)
From: [identity profile] feste-sylvain.livejournal.com
bike
bile
bole
vole


Yeah, a shorter path exists.

Date: 2008-02-28 01:35 pm (UTC)
fraterrisus: A bald man in a tuxedo, grinning. (Default)
From: [personal profile] fraterrisus
it just needs to be a breadth-first search instead of depth-first. which, sure, takes up more storage space.

alternately, you could get smarter about not replacing the same letter twice in a row; i.e. if the last move you made was to replace letter #1, then only look for #2 #3 and #4 this time. that will prune the search tree some, too.

i was sort of wondering if someone had done this :)

Date: 2008-02-28 01:39 pm (UTC)
ext_86356: (Quinn GNARR)
From: [identity profile] qwrrty.livejournal.com
Breadth-first search would certainly be guaranteed to find the shortest path. I was thinking of applying a heuristic by assigning every guess a score: one point for each letter that matches the goal word, then sort all guesses by score and try the best guesses first. My guess is that would find a better path in most cases even if it's not always the best one.

In its current state the algorithm is actually almost certain to find the longest possible path for any given set of words, which is itself sort of a neat trick.

Date: 2008-02-28 02:47 pm (UTC)
wotw: (Default)
From: [personal profile] wotw
Why would you want to turn a bike into a vole? I think
it would be much more useful to turn a vole into a bike.

Date: 2008-02-28 04:33 pm (UTC)
From: [identity profile] khedron.livejournal.com
*twitch*

*twitch*

*not using this as an excuse to learn Ruby. today. instead of working.*

*twitch*

Date: 2008-02-28 04:52 pm (UTC)
ext_86356: (thinky)
From: [identity profile] qwrrty.livejournal.com
I am really not at all sure that you want to use my Ruby in order to see how it's done.

And I'm sure you know this, but all in all I'd just as soon be using Scheme. :-)

Date: 2008-02-28 05:16 pm (UTC)
From: [identity profile] khedron.livejournal.com
I know several Lisp types who've said that Ruby is a halfway acceptable Lisp. Do you agree?

(Hmm, I haven't asked them about this in a while. Maybe it's time to pose the question again.)

Date: 2008-02-28 06:13 pm (UTC)
ext_86356: (Dutch Apple Nun)
From: [identity profile] qwrrty.livejournal.com
I've heard that, and I want to go read some of those comments to understand why they've said so.

My own reaction is that Ruby seems like it would be a perfectly nice little language if it hadn't gotten all this syntax all over it.

Ruby does some nice things: for example, just about everything, including array references and assignment, is implemented under the hood as a method. That allows you to override operations in base classes very cleanly, so that a statement like, say, "foo[bar] = baz" might update a database rather than modify an array.

Then it also does some totally crack-addled things. I have a rant waiting to get out about this, but it implements at least two kinds of procedural objects: closures and "blocks". A block is a chunk of executable code but it's not closed over its lexical environment. It's not a first-class object and you can't just pass it around between functions; it plays a special role in the language syntax. You cannot supply a method or a closure where the syntax demands a block. There are ways of extracting a block from a closure but they are very arcane. I'm mystified why anyone would write a language like this except out of pure orneriness.

Date: 2008-02-28 08:43 pm (UTC)
From: [identity profile] moominmolly.livejournal.com
*giggle*

No! Really! That result is pretty good! You should always use that program when playing against me. *nod*

Date: 2008-02-29 02:04 am (UTC)
ext_86356: (respect the bike)
From: [identity profile] qwrrty.livejournal.com
So my scoring idea does yield better solutions, but definitely not optimal ones:

$ ./lcwg.rb three great
three shree soree doree boree borne boone booze boozy boody 
goody goofy goosy goose gorse garse garce gorce gorge gouge 
gauge gauze gauzy gaudy gardy lardy mardy bardy birdy birny 
girny girly gilly golly gally galey galet galei galea galla 
galga ganga ganja ganta ganza ganda vanda danda banda benda 
penda penna penny genny genty denty deity deify reify reefy 
reedy weedy weepy weeny teeny teety beety beery jeery veery 
peery peepy seepy seely seedy deedy needy feedy heedy heezy 
heeze weeze neeze neele neese reese reest geest guest quest 
queet queer queen quean queak queal quell querl quarl quart 
quirt quint quiet quilt guilt guily guild guile guise guige 
gunge gudge gurge purge purre puree pured purer porer gorer 
gomer goner toner toyer tozer toper doper duper duler ruler 
runer runed tuned tined tiled timed tided tired tored lored 
pored poked pokey poley pomey poney money monny sonny bonny 
benny wenny jenny jinny ginny gunny gunne dunne dunny tunny 
tunna tunca tunga munga mungy lungy bungy bunty banty banky 
yanky hanky hawky gawky gawby gauby gabby gibby gobby bobby 
sobby lobby hobby hubby nubby cubby dubby debby webby wabby 
tabby tubby tubba kubba qubba hubba dubba dabba labba lamba 
gamba gamma gumma guama grama gramp grimp grime grice grece 
grege grego grebo grebe glebe glede gledy glady glary glaky 
glazy glaze graze grape grade grane grant graft grift grist 
frist fritt frett freet greet great

Amusing as hell, though.
Edited Date: 2008-02-29 02:05 am (UTC)

May 2018

S M T W T F S
  12345
6789101112
13141516171819
20212223242526
27282930 31  

Most Popular Tags

Style Credit

Page generated Mar. 5th, 2026 03:57 am
Powered by Dreamwidth Studios