Last active
July 19, 2022 12:14
-
-
Save p1366/28cdbfd5e9291f18d73f3ae3b26bb65b to your computer and use it in GitHub Desktop.
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
class Simalation | |
TOPICS = (0..21).to_a | |
N = 1_000_000 | |
def call( k ) | |
success = 0 | |
N.times do | |
success += 1 if sample.any?{ |e| e < k } | |
end | |
success.to_f / N | |
end | |
def sample | |
TOPICS.shuffle.first( 8 ) | |
end | |
end | |
sumulation = Simalation.new | |
(1..22).each{ |k| puts '%2s: %s' % [k, sumulation.( k )] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I need help regarding this question ..can you help me in this ??