From: Yoan Blanc Date: 2008-01-21T04:52:25+09:00 Subject: Re: Fwd: Please Forward: Ruby Quiz Submission James Gray wrote: > Begin forwarded message: > >> From: Yoan Blanc >> Date: January 18, 2008 1:18:37 PM CST >> To: submission@rubyquiz.com >> Subject: Please Forward: Ruby Quiz Submission >> >> thanks. >> #!/usr/bin/ruby >> # author: Yoan Blanc >> # revision: 20080118 >> >> text = STDIN.read >> >> (text.length/2).downto 1 do |l| >> match = Regexp.new("(.{#{l}})\\1").match(text) while fail with text longer than (1 << 15)-1 which is the maximum string a quantifier can handle. >> if match >> puts text[match.offset(1)[0]..(match.offset(1)[1]-1)] >> break >> end >> end > >