Skip to content

Instantly share code, notes, and snippets.

@harhogefoo
Created July 30, 2016 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harhogefoo/10470df9f6b20a52342ef546942c64ff to your computer and use it in GitHub Desktop.
Save harhogefoo/10470df9f6b20a52342ef546942c64ff to your computer and use it in GitHub Desktop.
require "date"
require 'benchmark'
result = Benchmark.realtime do
# 抽出対象の期間を設定
term = Date.parse('19641010')..Date.parse('20200724')
# 数値化
term_list = term.map { |d| d.strftime('%Y%m%d').to_i }
# 処理した結果が同じ値になるものを出力
puts term_list.select { |d| d == d.to_s(2).reverse.to_i(2)}
end
puts "普通の答えの実行時間 : #{result}s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment