mIRC Home    About    Download    Register    News    Help

Print Thread
#205729 30/10/08 01:14 AM
L
lolwutz
lolwutz
L
I have a question.
Is it possible for MIRC to unscramble words without a list of words that's being used?

For example, some user is providing letters to the bot.
The bot follows dictionaries to unscramble the word.
Would that be possible?

#205730 30/10/08 01:40 AM
Joined: Oct 2005
Posts: 1,671
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,671
Yes, it could be done. The easiest way would be to alphabetically sort the letters in each dictionary entry, and then store those sorted letters, along with the word in its original form, in memory or a file. Then everytime you want to 'unscramble' a word, you would sort it the same way as the sorted dictionary file, and then search for that sorted form in the dictionary file. Everytime you found a match in the dictionary file, you would have a possibility for unscrambling the word.

Example:

(dictionary file)

EHLLO=HELLO
EEHRT=THERE
ENO=ONE
OTW=TWO
EEHRT=THREE
FORU=FOUR
EFIV=FIVE
ETHER=EEHRT


A 'scrambled' word, sorted:

RETHE -> EEHRT


Search through the dictionary file, possible matches:

THERE <- EEHRT
THREE <- EEHRT
ETHER <- EEHRT

Matches: there, three, ether

Here is a code that you can use to sort the letters within a single word:

Code:

alias sort {
  tokenize 32 $$1-
  var %s = $1
  var %hname = $+(asort.,$ticks)
  if ($hget(%hname)) hfree %hname
  var %i = 0, %ii = $len(%s)
  while (%i < %ii) {
    inc %i
    hadd -m %hname $+(s.,%i) $asc($mid(%s,%i,1))
  }
  var %x, %i = 0, %ii = $calc($len(%s) - 1)
  while (%i < %ii) {
    inc %i
    %x = %i
    var %j = %i, %jj = $calc(%ii + 1)
    while (%j < %jj) {
      inc %j
      if ($hget(%hname,$+(s.,%x)) >= $hget(%hname,$+(s.,%j))) { %x = %j }
    }
    var %t = $hget(%hname,$+(s.,%i))
    hadd %hname $+(s.,%i) $hget(%hname,$+(s.,%x))
    hadd %hname $+(s.,%x) %t
  }
  var %ss, %i = 0, %ii = $len(%s)
  while (%i < %ii) {
    inc %i
    %ss = $+(%ss,$chr($hget(%hname,$+(s.,%i))))
  }
  $iif($isid,return,echo -a) %ss
  hfree %hname
}



Just loop through every word in your dictionary, and sort them with the above code. You will have to decide how you want to store the sorted dictionary so that it can be searched later. The easiest would be a txt file, as in my example above <SORTED>=<UNSORTED> . Then you can search the text file for all lines that begin with SORTED= and then return the UNSORTED text after the = char.

-genius_at_work


L
lolwutz
lolwutz
L
Would it be possible for mIRC to get the result from a site called
http://www.zachwordunscrambler.com/

Would that work? That would be easier rather than the dictionary file, as a list will have to be typed. =(


Link Copied to Clipboard