Skip to content

Instantly share code, notes, and snippets.

@tatsuosakurai
Created October 7, 2011 09:42
Show Gist options
  • Save tatsuosakurai/1269914 to your computer and use it in GitHub Desktop.
Save tatsuosakurai/1269914 to your computer and use it in GitHub Desktop.
9桁の数字を求める
# 1
(rand(900000000)+10 ** 9).to_s
# 2
([(0..9).to_a]*9).map{|i|i.sample}.join
# 3
sprintf("%09d", rand(10 ** 9))
# 4
Array.new(9){ Array(0..9).sample }.join
# 5
9.times.map{rand 10}.join
# 6
"#{rand(10 ** 9)}".rjust(9, '0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment