Word Scrambling
#6

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Well since strings are just arrays you can randomize your array pretty easy...

Код:
CMD:randword(playerid, arg[])
{

	RandomizeWord(arg);
	SendClientMessage(playerid, 0xFFFF0000, arg);
	return 1;
}

stock RandomizeWord(word[])
{
    new tmp;
    new r;

    for(new i = strlen(word) - 1; i >= 0; i--)
    {
        r=random(strlen(word));
        tmp = word[i];
	word[i] = word[r];
	word[r] = tmp;
    }
}
The only problem with that code is that if I randomized a word, say "computer", it could get scrambled as "mputccoo", as it has the possibility of re-using letters
Reply


Messages In This Thread
Word Scrambling - by venomlivno8 - 06.04.2013, 18:44
Re: Word Scrambling - by MP2 - 06.04.2013, 18:57
Re: Word Scrambling - by Pottus - 06.04.2013, 18:59
Re: Word Scrambling - by [ABK]Antonio - 06.04.2013, 19:04
Re: Word Scrambling - by Pottus - 06.04.2013, 19:05
Re: Word Scrambling - by MattyG - 06.04.2013, 19:06
Re: Word Scrambling - by [ABK]Antonio - 06.04.2013, 19:06
Re: Word Scrambling - by Pottus - 06.04.2013, 19:11
Re: Word Scrambling - by venomlivno8 - 06.04.2013, 20:26

Forum Jump:


Users browsing this thread: 2 Guest(s)