> Your task for this quiz, then, is to take a text as input and output the > text in this fashion. Scramble each word's center (leaving the first and > last letters of each word intact). Whitespace, punctuation, numbers -- > anything that isn't a word -- should also remain unchanged. _________________________________________ solution one _________________________________________ harp:~ > cat a.rb class String def scramble on = '' re = %r/( (?:\b \w \w{2,} \w \b) | \s+ | . )/iox scan(re){|words| on << words.first.scrambled} on end def scrambled self[1..-2] = self[1..-2].split(%r//).sort_by{rand}.to_s if size >= 4 self end end ARGF.read.scramble STDOUT harp:~ > ruby a.rb < a.rb cslas Srntig def srbcamle on = '' re = %r/( (?:\b \w \w{2,} \w \b) | \s+ | . )/iox sacn(re){|wrods| on << wodrs.fisrt.salbercmd} on end def sclmaebrd slef[1..-2] = slef[1..-2].split(%r//).s_botry{rnad}.t_os if size >= 4 slef end end ARGF.read.srcalbme SUDOTT _________________________________________ solution two (golfing) _________________________________________ harp:~ > ruby -npae 'gsub!(/\b(\w)(\w{2,})(\w)\b/){_=$3;[$1,$2.split(//).sort_by{rand},_]}' a.rb calss Snrtig def sbcarlme on = '' re = %r/( (?:\b \w \w{2,} \w \b) | \s+ | . )/iox sacn(re){|wdros| on << wdros.first.slramcebd} on end def smlcbaerd self[1..-2] = slef[1..-2].siplt(%r//).srbt_oy{rand}.t_os if size >= 4 self end end ARGF.read.smclarbe SUTODT harp:~ > wc -c gsub!(/\b(\w)(\w{2,})(\w)\b/){_=$3;[$1,$2.split(//).sort_by{rand},_]} 70 thanks for the fun quiz! -a -- be kind whenever possible... it is always possible. - h.h. the 14th dali lama