Skip to content

Instantly share code, notes, and snippets.

@p1366
Last active July 19, 2022 12:14
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 p1366/28cdbfd5e9291f18d73f3ae3b26bb65b to your computer and use it in GitHub Desktop.
Save p1366/28cdbfd5e9291f18d73f3ae3b26bb65b to your computer and use it in GitHub Desktop.
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 )] }
@bhavya-bhatia0302
Copy link

I need help regarding this question ..can you help me in this ??

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