Consider the word:
'cowboycaddogcowcowboyboycatdodogcaddodocowboytoycaddye'
the alphabet:
cowboy
caddy
boytoy
co
cow
boy
cat
cats
do
dog
dye
eddie
eyes
kowtow
toy
tow
tyco
and the juncture rules:
t|d => dd
cats|eyes => caddye
There are 24 ungluings and I am posting them here. The algorithm I used is of a branch-and-bound genus, and employs a breadth first search on the decision space.
Here are the details: Potential *ungluings* are added to a queue. Elements of the queue are rejected when no possible ungluings can be formed on their right hand side (i.e. their as-of-yet-not-unlgued-bit). The solution and runtime stats for this example are as follows:
0.0215 seconds
143 iterations
largest queue memory usage: 15,612 bytes
largest queue length: 24 items
cow-boy-cat-dog-cow-cow-boy-boy-cat-do-dog-cat-do-do-cow-boy-toy-cats-eyes
cowboy-cat-dog-cow-cow-boy-boy-cat-do-dog-cat-do-do-cow-boy-toy-cats-eyes
cow-boy-cat-dog-cow-cowboy-boy-cat-do-dog-cat-do-do-cow-boy-toy-cats-eyes
cow-boy-cat-dog-cow-cow-boy-boy-cat-do-dog-cat-do-do-cowboy-toy-cats-eyes
cow-boy-cat-dog-cow-cow-boy-boy-cat-do-dog-cat-do-do-cow-boytoy-cats-eyes
cowboy-cat-dog-cow-cowboy-boy-cat-do-dog-cat-do-do-cow-boy-toy-cats-eyes
cowboy-cat-dog-cow-cow-boy-boy-cat-do-dog-cat-do-do-cowboy-toy-cats-eyes
cowboy-cat-dog-cow-cow-boy-boy-cat-do-dog-cat-do-do-cow-boytoy-cats-eyes
cow-boy-cat-dog-cow-cowboy-boy-cat-do-dog-cat-do-do-cowboy-toy-cats-eyes
cow-boy-cat-dog-cow-cowboy-boy-cat-do-dog-cat-do-do-cow-boytoy-cats-eyes
cow-boy-cat-dog-cow-cow-boy-boy-cat-do-dog-cat-do-do-cow-boy-toy-cat-dye
cowboy-cat-dog-cow-cowboy-boy-cat-do-dog-cat-do-do-cowboy-toy-cats-eyes
cowboy-cat-dog-cow-cowboy-boy-cat-do-dog-cat-do-do-cow-boytoy-cats-eyes
cowboy-cat-dog-cow-cow-boy-boy-cat-do-dog-cat-do-do-cow-boy-toy-cat-dye
cow-boy-cat-dog-cow-cowboy-boy-cat-do-dog-cat-do-do-cow-boy-toy-cat-dye
cow-boy-cat-dog-cow-cow-boy-boy-cat-do-dog-cat-do-do-cowboy-toy-cat-dye
cow-boy-cat-dog-cow-cow-boy-boy-cat-do-dog-cat-do-do-cow-boytoy-cat-dye
cowboy-cat-dog-cow-cowboy-boy-cat-do-dog-cat-do-do-cow-boy-toy-cat-dye
cowboy-cat-dog-cow-cow-boy-boy-cat-do-dog-cat-do-do-cowboy-toy-cat-dye
cowboy-cat-dog-cow-cow-boy-boy-cat-do-dog-cat-do-do-cow-boytoy-cat-dye
cow-boy-cat-dog-cow-cowboy-boy-cat-do-dog-cat-do-do-cowboy-toy-cat-dye
cow-boy-cat-dog-cow-cowboy-boy-cat-do-dog-cat-do-do-cow-boytoy-cat-dye
cowboy-cat-dog-cow-cowboy-boy-cat-do-dog-cat-do-do-cowboy-toy-cat-dye
cowboy-cat-dog-cow-cowboy-boy-cat-do-dog-cat-do-do-cow-boytoy-cat-dye
The code is relatively simple. Say the word and Ill post it. (In case you'd like to have the crack at it yourself).
Could you share an actual example of your problem with us?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.