Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Iceclaw
Apprentice


Joined: 11 Sep 2005
Posts: 124

PostPosted: Fri Nov 11, 2005 12:45 pm   

(UN)Scrambles
 
I need to take a scrambled phrase, and determine if it is any part of a string list
scrambled phrases can be multiple words, and ocassionally have punctuation , but the number of letters between spaces (actual white space character) is never scrambled. Might be able to take each word seperately and compare off of that, but I have no clue)

»»-Quest-Taphath-> Figure out this word or phrase for a nice but random reward.
»»-Quest-Taphath-> -->toeanag dttziioen<--
»»-Quest-Taphath-> HINT: -->Musical Composer<--

»»-Quest-Taphath-> Everyone failed to Figure out this word or phrase for a nice but random reward.
»»-Quest-Taphath-> -->toeanag dttziioen<--
»»-Quest-Taphath-> HINT: -->Musical Composer<--
»»-Quest-Taphath-> ANSWER: -->Gaetano Donizetti<--
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Fri Nov 11, 2005 1:43 pm   
 
Your question isn't really clear. You ask if it's possible to compare a scramble phrase to a string list. The short answer is yes. You can split the phrase into a string list based on white like so

Code:
 #TRIGGER {»»-Quest-Taphath-~> --~>(*)~<--} { #VAR PhraseList %replace ("%1", " ", "|") }


Then you can do a #FORALL against this list and check it against whatever like so

Code:
 #FORALL PhraseList { #ECHO %i; //Compare %i to something }


However since I think you want to actually solve the riddle, for this to be useful to you would really be required to a) Have a list of scrambled phrase to check against, b) try all permutations of the string against a list of known answers (or a dictionary) or c) some combination of the above.

Now to do a phrase lookup, %ismember should work fine for you.

Code:
 #FORALL PhraseList { #ECHO %i;#VAR Match %ismember(%i, @ScrambledList);  #IF (@Match) { #SHOW %item(@ScrambledList, @Match) ; #UNVAR Match} }


Doing all permutations is a bit trickier. You'll likely have more luck with a perl reg expression. Good ways to narrow it down is select all the words in your dictionary by size, then match all those that have all the letters you have, after that you may need to do a brute force approach.
_________________
Asati di tempari!
Reply with quote
Iceclaw
Apprentice


Joined: 11 Sep 2005
Posts: 124

PostPosted: Fri Nov 11, 2005 1:48 pm   
 
I've generated an acceptable Phrase List, so far, I'm looking for more help with the perl reg expression to figure out how to sort it like you suggest
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Fri Nov 11, 2005 1:53 pm   
 
Don't have zmud to hand, so can't offer any code, but perhaps an easier way than the brute force method would be to have a copy of the answers scrambled into alphabetical order...

So
'Gaetano Donizetti'

would be linked to
'aaegnotdeiinottz'


Then when you are given
'toeanag dttziioen'

you would also sort it alphabetically, then you could read the original value off...

So you'd want a function...

#show mystringlist.%reSort(toeanag dttziioen)

which would really look for mystringlist.aaegnotdeiinottz
which would equal 'Gaetano Donizetti'

you'd have to write a reSort function, but that'd be pretty trivial

I'm sure Vijilante could write the lot from memory ;)
Reply with quote
Slaem
Apprentice


Joined: 20 Sep 2005
Posts: 135

PostPosted: Sun Nov 13, 2005 7:03 am   
 
Both are nice ideas. Since they both require a second list/db to check against, then without a limited Q&A list/db wouldn't the required resources be beyond our scope? For composers alone, searching through all historical composers could be too much. Gaetano Donizetti was born 1797! A limited list of "great" historical composers would be in the hundreds (e.g. List of great classical music composers). Although I found a decent list you could use, there's another limitation: knowing what lists you need, researching them, and building them. Sounds very time consuming.

Another option would be to create a script that would show all possible scrambles for the given letters. This would spit out 'n' scrambles for which you would manually have to select the correct unscrambled answer.

The spam could be overwhelming, though. "toeanag" has 7 letters (2 repeating), giving (7!/2!) = 2,520 combinations! And foreign names would be hard to decipher the correct spelling: toeanag -> gaetano, gataneo, tageano, etc...

But, I'm not a wizard or guru, so maybe someone else has a better mind for building something for you.

Either way, your trivia sounds like fun. Good luck!
_________________
Show your love.
Support Zugg Software!
Donate to zugg@zuggsoft.com with PayPal Send Money.
Reply with quote
Iceclaw
Apprentice


Joined: 11 Sep 2005
Posts: 124

PostPosted: Sun Nov 13, 2005 2:46 pm   
 
I've got a word list, and I have a way of storing the mixup answers it gives. I'm just having problems getting the alphabetical sort to work, I don't even know how to go about it, my real problem is returning each character in the string seperately, how to compare it to the existing alphabetized string, and then determining where in the alphabetized string it should go.
Thanks for Any help writing this script.
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Sun Nov 13, 2005 4:20 pm   
 
I don't have zMud atm, so this is untested, but something like
Code:
#AL reSort {sortedString = null;#LOOP 1, len(%-1) {#ADDITEM sortedString %copy(%-1,%i,1)};sortedString = %trim(%expandlist(%sort(sortedString),""))}

should do it

it will create a stringlist containing each letter separately, then sort that list, then remove the separators so that it's just a string again.

So if you type
resort This Is A Test
#show @sortedString

it should return
AehiIssstTT
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net