Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter de Kraker peterdk

View GitHub Profile
@peterdk
peterdk / 3 - find the min.rb
Last active Dec 11, 2015
My O(K) solution for hackercup 2013, qualification round, problem 3: find the min. Ran in 0.3 seconds on my core 2 duo macbook, using Ruby 1.9.3 =update= Unfortunately the code is not fully correct. It failed on 1/20 cases.
View 3 - find the min.rb
require 'set'
def find_min_better3(a,b,c,r,k,n)
m = []
m << a
(k - 1).times do |k|
m << ((b * m[k] + c) % r)
end