From: S2 Date: 2008-05-09T06:25:29+09:00 Subject: Re: scramble sentence, how to better program? 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(' ')