Skip to content

Instantly share code, notes, and snippets.

@kjunichi
Last active June 17, 2016 01:02
Show Gist options
  • Save kjunichi/aed962e0ed87120c41bd03e2929756e0 to your computer and use it in GitHub Desktop.
Save kjunichi/aed962e0ed87120c41bd03e2929756e0 to your computer and use it in GitHub Desktop.
2016/4/21

2016/4/21

time mruby/bin/mruby 100dice.rb                                                              
dekita!! 2, 169015542

real    14m27.481s
user    14m23.068s
sys     0m1.729s
outside = 0
num = Array.new(100, 0)

while true
  base = rand(6)+1
  outside += 1

  done = true
  11.times do |inside|
    eye = rand(6)+1
    unless base == eye
      #print "#{outside}回目の挑戦は#{inside}回目の試行で失敗しました。"
      num[inside] += 1
      done = false
    end
  end
  if(done) then
    puts "dekita!! #{base}, #{outside}"
    break
  end
  
end

CRuby

 time ruby 100dice.rb                                                                         
dekita!! 5, 20292418

real    1m0.493s
user    0m56.155s
sys     0m0.158s

サロゲートペアの扱い

/*
 * runstant
 */

window.onload = function() {
  // TODO: write code
  // console.log("Hello, runstant!");
  console.log(String.fromCharCode(0x3042));
  console.log(String.fromCharCode(0xD867)+String.fromCharCode(0xDE3D));
  console.log(String.fromCodePoint(0x29E3D));
  
  for(let i=0x3042; i < 0x3042+90; i++) {
    console.log(String.fromCodePoint(i));
  }
  
};

関連

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment