Skip to content

Instantly share code, notes, and snippets.

@taku0
Created May 10, 2023 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taku0/2c847f528d661b948cda0b33341453d5 to your computer and use it in GitHub Desktop.
Save taku0/2c847f528d661b948cda0b33341453d5 to your computer and use it in GitHub Desktop.
マイナンバーカードのコンビニ交付を1年に89000件処理したときに、秒単位で付けたファイル名がかぶる確率
# 1年の秒数
total = 365 * 24 * 60 * 60 # 31,536,000
# 1年の処理件数
count = 89000
# 被らない確率
safe_probability = 1.0
# クジを引いて、まだ残っている数
rest = total
count.times do |i|
rest -= 1
safe_probability *= rest.to_f / total
end
puts(safe_probability)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment