Discuss Scratch

mathwhiz11
Scratcher
23 posts

Word Scrambler

Could someone help me come up with a word scrambler? The following steps must happen:

1. The computer must ask the person the number of letters in the word. If the number of letters is less than 3 or greater than 8, the computer must reject it.
2. The computer must ask the person for the word.
3. The computer must scramble the word, however you think best.

Thanks!
lederniersamourai
Scratcher
500+ posts

Word Scrambler

For 1) you use
askthe numberandwait
then the answer is put into the variable
answer

For testing the number of letters you use:

ifthen....

with the test such as
3<answer


For 2) you do the same as fr step 1), but the user will answer with the word


For 3) this is more difficult. There is no simple solution. You put each letter into a list, then scramble the list, then put back the letters into a new word.
theonlygusti
Scratcher
1000+ posts

Word Scrambler

Why ask the length of the word and then the word? Why not just ask for the word?

This can be your entire script:

whenclickedaskwhat word would you like scrambled?andwaitif3>lengthofansweror8<lengthofanswerthensaysorry, your word was not the right lengthelsesetcto0deleteallofwordrepeatlengthofanswerchangecby1addlettercofanswertoworddeleteallofscramblerepeatlengthofwordsetctopickrandom1tolengthofwordadditemcofwordtoscrambledeletecofwordsayscramble

Last edited by theonlygusti (Oct. 6, 2014 18:20:37)

lederniersamourai
Scratcher
500+ posts

Word Scrambler

theonlygusti wrote:

Why ask the length of the word and then the word? Why not just ask for the word?

This can be your entire script:

whenclickedaskwhat word would you like scrambled?andwaitif3>lengthofansweror8<lengthofanswerthensaysorry, your word was not the right lengthelse. . .
end


The problem with this answer, is that you might have given the complete solution to an homework … Hope this was not the case … ;-)

Last edited by lederniersamourai (Oct. 7, 2014 16:02:45)

mathwhiz11
Scratcher
23 posts

Word Scrambler

This is the script I'm going to use. Thank you so much for giving me this!

theonlygusti wrote:

Why ask the length of the word and then the word? Why not just ask for the word?

This can be your entire script:

whenclickedaskwhat word would you like scrambled?andwaitif3>lengthofansweror8<lengthofanswerthensaysorry, your word was not the right lengthelsesetcto0deleteallofwordrepeatlengthofanswerchangecby1addlettercofanswertoworddeleteallofscramblerepeatlengthofwordsetctopickrandom1tolengthofwordadditemcofwordtoscrambledeletecofwordsayscrambleend/quote

Last edited by mathwhiz11 (Oct. 7, 2014 18:13:43)

Powered by DjangoBB