Last active
July 2, 2016 08:52
-
-
Save shakemurasan/41c5bc9f418bf3267890ff53a4132663 to your computer and use it in GitHub Desktop.
プログラマ脳を鍛える数学パズル:Q01
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 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