Re: scramble sentence, how to better program?
by S2 other posts by this author
May 8 2008 2:25PM messages near this date
Re: scramble sentence, how to better program?
|
windows prompt, how to write [ ] ?
globalrev wrote:
> i have written a program that takes a sentence as input and outputs
> the sentence with the words rearranged.
>
sentence = "this is a sentence with the word sentence repeaed"
sentence = sentence.split(' ')
scr = []
scri = []
while scri.length != sentence.length
i = rand(sentence.length)
scri << i unless scri.include? i
end
scri.each {|i| scr << sentence[i]}
p scr.join(' ')
Thread:
Globalrev
David A. Black
S2
S2
Globalrev
S2
7stud --
David A. Black
Rob Biedenharn
S2
S2
|