書いてみた

https://gist.github.com/k5342/7023854

https://gist.github.com/k5342/7023854

  • タグ:
  • タグはありません
chars = [*"a".."z"]
per=[12.31959369,0.8250647611,0,1.9310338607,6.7622950682,0.0191191647,1.8584790696,2.6301082644,11.740626672,0,5.9303670688,0,2.4648992608,7.4677425668,10.614067677,0.1907012631,0,4.6787983637,5.3219860638,6.6799356681,8.884030162,0.0078437652,2.140363965,0,3.7282335687,1.38148096]

MAX = (ARGV.shift || 100).to_i


out = ""
per.each_with_index do |p, i|
  out += chars[i]*(0.01*p*MAX).to_i
end

out = out.ljust(MAX, " ")

puts out.chars.shuffle.map{ |c| (Random.rand(2)==0)? c.upcase : c }.join