Computer Science Canada How do you randomize wordS? |
| Author: | Kharybdis [ Wed Jan 02, 2008 8:11 pm ] |
| Post subject: | How do you randomize wordS? |
Ok. Say, for example, i have a word - Robot. Can anyone give me any info on how i could go about randomizing the letters? But i don't need just help on how to do it with 5 letter words, but in general, for any word. Knowing randint only works for numbers, how do you go about randomizing words ... so robot would instead be shown as obtor. Would i have to use the ord value of each letter to randomize each individual word? |
|
| Author: | Clayton [ Wed Jan 02, 2008 8:19 pm ] | ||
| Post subject: | RE:How do you randomize wordS? | ||
Hint:
|
|||
| Author: | Tony [ Wed Jan 02, 2008 8:26 pm ] |
| Post subject: | Re: How do you randomize wordS? |
Kharybdis @ Wed Jan 02, 2008 8:11 pm wrote: Knowing randint only works for numbers...
Letter's position in a word (or an array... since a string is technically an array of characters) is a number... |
|
| Author: | Kharybdis [ Thu Jan 03, 2008 9:01 pm ] | ||
| Post subject: | Re: RE:How do you randomize wordS? | ||
Clayton @ Wed Jan 02, 2008 8:19 pm wrote: Hint:
hey ty..... i can do it for any word.............. but right now i'm just tring to figure out how to put the whole thing as random. Ty for hint. However, two last questions. How do you specify if a position of string say word(3) has already been used? How do you assign rand.Int (1, length(word))) to something like a variable. if (rand.int(1,length(word))) = index(word,letter) then ..... this is all i got.... i have no idea how to say if the position has been used to not use it again. |
|||
| Author: | Clayton [ Fri Jan 04, 2008 1:25 pm ] |
| Post subject: | RE:How do you randomize wordS? |
Remove the letter from the word. |
|
| Author: | Kharybdis [ Fri Jan 04, 2008 2:10 pm ] | ||
| Post subject: | Re: RE:How do you randomize wordS? | ||
Clayton @ Fri Jan 04, 2008 1:25 pm wrote: Remove the letter from the word.
but how.... All i got is :
And i have no idea at all how to do it so letter := the position randomized by Rand.Int (1, length(word))). |
|||
| Author: | Tony [ Fri Jan 04, 2008 2:24 pm ] |
| Post subject: | RE:How do you randomize wordS? |
hint: If you have a 5 letter word -- abcde And you remove a letter in the 3rd position -- c What "word" would have all of the remaining letters? |
|
| Author: | Kharybdis [ Fri Jan 04, 2008 2:44 pm ] | ||||
| Post subject: | Re: How do you randomize wordS? | ||||
But.. i still don't know how to assign
as something that can be manipulated... how to assign it as a variable. What i'm tryint to do is tell turing that when the position is randomized, that position is deleted from the word. I can't do it for just any individual word, but for all the words that can be entered.
|
|||||
| Author: | Gooie [ Sat Jan 05, 2008 12:58 am ] | ||||
| Post subject: | Re: How do you randomize wordS? | ||||
Kharybdis @ January 4th, 2:44 pm wrote: But.. i still don't know how to assign
as something that can be manipulated... how to assign it as a variable. What i'm tryint to do is tell turing that when the position is randomized, that position is deleted from the word. I can't do it for just any individual word, but for all the words that can be entered.
They're already assigned to variables, a 'string' is only an array of 'char'. What do you need to do with the word? There are different solutions for different problems. |
|||||
| Author: | Tony [ Sat Jan 05, 2008 2:09 am ] |
| Post subject: | Re: RE:How do you randomize wordS? |
@ Kharybdis Tony @ Fri Jan 04, 2008 2:24 pm wrote: hint:
If you have a 5 letter word -- abcde And you remove a letter in the 3rd position -- c What "word" would have all of the remaining letters? it's abde more specifically, since we are using the letter at the 3rd position, what we have left is 1..2 + 4..5 |
|
| Author: | Kharybdis [ Sat Jan 05, 2008 12:36 pm ] |
| Post subject: | Re: How do you randomize wordS? |
i got the answer before you posted tony, but that clarifies it even more. TY everyone! |
|