def generate(filenum, step, gap, length, time, hit) File.open(filenum.to_s, 'ab') do |f| f.puts " length equ #{length}" f.puts " gap equ #{gap}" f.puts " step equ #{step}" f.puts " time equ #{time}" f.puts " hit equ #{hit}" f.puts ' first equ paper+hit-step*time' f.puts 'paper mov #length, length' f.puts 'scan add #step+1, sptr' f.puts ' mov bmb, length - 1 && (pos + coresize - gap) % coresize > length - 1) || pos == 3 + gap || pos == 7 + gap pos = (pos + coresize - step) % coresize time += 1 end time end coresize = 8000 modulo = 1 filenum = 20000000 scores = [] (1..coresize).select { |n| coresize.gcd(n) == modulo }.each do |step| score = coresize - 1 high = low = pos = step until pos.zero? pos = (pos + step) % coresize high = [pos, high].max low = [pos, low].min score += coresize - high + low - 1 end scores << [step, score] end scores.sort_by(&:last)[0..99].map(&:first).each do |step| (10..15).each do |gap| (26..36).step(2) do |length| toptime = tophit = 0 [*0..9, *gap..gap + 9].each do |hit| time = calctime(step, gap, hit, 10, coresize) if time > toptime toptime = time tophit = hit end end generate(filenum, step, gap, length, toptime, tophit) filenum += 1 end end end