Last active
July 2, 2016 08:53
-
-
Save shakemurasan/ad05155e3cdb64e7cca90ca243ee9eec to your computer and use it in GitHub Desktop.
プログラマ脳を鍛える数学パズル:Q03
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -- 処理時間計測の自作ライブラリ -- | |
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