Skip to content

Instantly share code, notes, and snippets.

@shakemurasan
Last active July 2, 2016 08:52
Show Gist options
  • Save shakemurasan/41c5bc9f418bf3267890ff53a4132663 to your computer and use it in GitHub Desktop.
Save shakemurasan/41c5bc9f418bf3267890ff53a4132663 to your computer and use it in GitHub Desktop.
プログラマ脳を鍛える数学パズル:Q01
# -- 処理時間計測の自作ライブラリ --
require './process_measure.rb'
# ------------------------------
def search_reversible_num(offset)
i = offset;
loop do
n2 = i.to_s(2)
n8 = i.to_s(8)
n10 = i.to_s(10)
i += 1
next unless (n2 == n2.reverse) && (n8 == n8.reverse) && (n10 == n10.reverse)
puts n10
break
end
end
measure_do { search_reversible_num(10) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment