LoginSignup
1
0

More than 5 years have passed since last update.

プログラマ脳を鍛える数学パズル『Q01 10進数で回文』をCrystalで

Posted at

https://carc.in/#/cr で実行しました。

version: 0.10.2

require "benchmark"

time = Benchmark.measure do
  num = 11

  while true
    if num.to_s == num.to_s.reverse && \
        num.to_s(2) == num.to_s(2).reverse && \
        num.to_s(8) == num.to_s(8).reverse
      puts num
      break
    end
    num += 2
  end
end

puts time

585
  0.000000   0.000000   0.000000 (  0.000240)

Rubyと全然変わらないのでネタバレ感ひどいですけど・・・。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0