ID:142773
 
Code:
mob/verb/scramble(t as text)
if(!t||!istext(t))return t
var/tt
while(t)
world<<"t=[t]"
world<<"tt=[tt]"
var/p=rand(1,length(t))
tt+=copytext(t,p,p+1)
t=addtext(copytext(t,1,p),copytext(t,p+1))
return tt


Problem description:
Your supposed to input text, and it scrambles the text.
so i input "!!!!" i'd doesn't matter how much you scramble !!!! it will always end up as !!!!, but of course this code is returning !! or !!! or !.
Alternative:

mob/verb/Scramble(text as text)
src << "[text] --> [scrambletext(text)]"


// Rearranges the letters in a line of text.
proc/scrambletext(text)
if(!text || !istext(text))
return text

var/list/letters = list()
var/t = copytext(text, 1, 2)

while(t)
letters += t
text = copytext(text, 2, 0)
t = copytext(text, 1, 2)

var/result = ""
while(letters.len)
var/letter = pick(letters)
letters -= letter
result += letter

return result
In response to Foomer
No! list! If any of the letters repeat(more than likely) it only displays them once >_>.
In response to Tubutas
Tubutas wrote:
No! list! If any of the letters repeat(more than likely) it only displays them once >_>.

That's only for associated lists.
In response to Foomer
oh?... why is that?