LoginSignup
1
1

More than 5 years have passed since last update.

等差数列

Last updated at Posted at 2013-10-15
hena11pre.rb
#!/usr/bin/env ruby
#http://qiita.com/items/c206fbc645c255cb7de6
#http://nabetani.sakura.ne.jp/hena/ord11arithseq/
STDOUT.sync=true
while gets
    h={}
    $_.chomp.chars{|e|h[e.to_i(36)]=1} # because already sorted...
    r=1
    0.step(35){|i|
        if h.has_key?(i)
            1.step(35){|j|
                k=1
                while h.has_key?(i+j*k) do k+=1 end
                r=[r,k].max
            }
        end
    }
    p r
end
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1