$scramble/x

By Phase on Jan 04, 2005

There's two 'identifiers'. $scramble and $scramblex
Synax: $scramble(word) $scramblex(word)
What $scramble does is rearranges the characters place in the identifer, and it can get the string you are trying to scramble. (eg: $scramble(blah) could return a lot of things including "blah.") Where as $scramblex will not return what you are trying to scramble.

alias scramble {
  set -u0 %scrmbl $1-
  unset %scrmbl.return
  while ($len(%scrmbl) > 1) {
    set -u0 %scrmbl.rand $rand(1,$len(%scrmbl))
    set -u0 %scrmbl.return %scrmbl.return $+ $mid(%scrmbl,%scrmbl.rand,1)
    if ((%scrmbl.rand != 1) && (%scrmbl.rand != $len(%scrmbl))) {
      set -u0 %scrmbl $mid(%scrmbl,1,$calc(%scrmbl.rand - 1)) $+ $mid(%scrmbl,$calc(%scrmbl.rand + 1),$calc($len(%scrmbl) - $calc(%scrmbl.rand - 1)))
    }
    elseif (%scrmbl.rand == 1) {
      set -u0 %scrmbl $mid(%scrmbl,$calc(%scrmbl.rand + 1),$calc($len(%scrmbl) - $calc(%scrmbl.rand - 1)))
    }
    else {
      set -u0 %scrmbl $mid(%scrmbl,1,$calc(%scrmbl.rand - 1))
    }
  }
  return $eval(%scrmbl.return $+ %scrmbl)
}
alias scramblex {
  set -u0 %tmp $scramble($1-)
  while (%tmp == $1-) { set -u0 %tmp $scramble($1-) } 
  return $eval(%tmp)
}

Comments

Sign in to comment.
Vengeance   -  Dec 05, 2007

way better than one i made

alias Scramble {
remini scramble.ini scramble_game
var %x 1
writeini scramble.ini Scramble_Game Word $1
while (%x <= $len($1)) {
writeini scramble.ini Scramble_game %letter $+ %x $mid($1,%x,1)
inc %x
}
}

alias Unscramble {
var %x 1
set %word $readini(scramble.ini,scramble_game,word)
set %len $len($readini(scramble.ini,scramble_game,word))
while (%x <= %len) {
set %removing $rand(1,$len(%word))
set %unscrambled %unscrambled $+ $mid(%word,%removing,1)
set %word $remove(%word,$mid(%word,%removing,1))
inc %x
}

 Respond  
Phase   -  Jan 04, 2005

ahh, cool

 Respond  
QuickStep   -  Jan 04, 2005

I posted something similar like this some time ago http://www.hawkee.com/snippet.php?snippet_id=326

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.