Skip to content

Instantly share code, notes, and snippets.

@shakemurasan
Last active July 2, 2016 08:53
Show Gist options
  • Save shakemurasan/ad05155e3cdb64e7cca90ca243ee9eec to your computer and use it in GitHub Desktop.
Save shakemurasan/ad05155e3cdb64e7cca90ca243ee9eec to your computer and use it in GitHub Desktop.
プログラマ脳を鍛える数学パズル:Q03
# -- 処理時間計測の自作ライブラリ --
require './process_measure.rb'
# ------------------------------
def reverse_card_open(card_num)
cards = Array.new(card_num, false)
1.upto(card_num) do |i|
i.step(card_num, i+1) do |j|
cards[j] = !cards[j]
end
end
card_num.times do |i|
print "#{i + 1} " if cards[i] == false
end
end
measure_do { reverse_card_open(100) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment