Skip to content

Instantly share code, notes, and snippets.

@devkato
Created January 4, 2015 07:28
Show Gist options
  • Save devkato/5e7ae3097df0e5c7378e to your computer and use it in GitHub Desktop.
Save devkato/5e7ae3097df0e5c7378e to your computer and use it in GitHub Desktop.
バイナリデータを作成する
N = 100000
f = open("./bin.#{N}.dat", 'w')
result = [0, 0]
1.upto(N) do |i|
ret = rand() > 0.5 ? 1 : 0
result[ret] += 1
f.write ret
end
result.each.with_index do |r, i|
puts "#{i} : #{r}"
end
f.flush
f.close
@devkato
Copy link
Author

devkato commented Jan 4, 2015

0と1のビット数も表示するように(後で確認するため)

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