Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ Anagrams

Anagrams

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by ErockMahan   (81 posts)  Bio
Date Tue 06 Jul 2010 02:42 PM (UTC)
Message
I'm hoping there is an easier way to do this than what I'm thinking, so I thank you in advance for helping me accomplish this.

I've got a variable string that is a set word. I'll use 'Stabs' as an example. I am then given 5 items, each of which has several key letters assigned to it. "Key of Aberforth" "Stick" "Blunt Knife" and "Tablecloth" "Orb of Spheres" (Capital Letters would be the keys for each)

With some difficulty, I've figured out how to obtain the key letters from each item, and I can even add each to a variable per item seperated however I choose.

WHAT I'M TRYING TO DO is run a script that will determine whether or not the letters from these items can be used to obtain the target word. In the example, it works because you use [S]tick [T]ablecloth [A]berforth [B]lunt [S]pheres.

I hope I don't have to explain the difficulty and challenges faced while attempting this?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Tue 06 Jul 2010 03:31 PM (UTC)
Message
Pseudo-code...


keyWords = set of key words in input strings
for letter in wordToForm:
  word = find a word in keyWords starting with letter
  if 'word' was found:
    remove 'word' from keyWords
    continue to next letter
  else:
    report failure; we can't form wordToForm


VBscript might make this rather annoying due to its container types, but the algorithm isn't really that hard.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,678 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.