Created
May 10, 2023 11:24
-
-
Save taku0/2c847f528d661b948cda0b33341453d5 to your computer and use it in GitHub Desktop.
マイナンバーカードのコンビニ交付を1年に89000件処理したときに、秒単位で付けたファイル名がかぶる確率
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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