Interview Query

Drawing Balls From Bin

Start Timer

0:00:00

Upvote
16
Downvote
Save question
Mark as completed
View comments (32)
Next question

Write a function to simulate drawing balls from a jar. The colors of the balls are stored in a list named jar, with corresponding counts of the balls stored in the same index in a list called n_balls.

Example: 

Input:

jar = ['green', 'red', 'blue']
n_balls = [1, 10, 2]
# 1 green ball
# 10 red balls
# and 2 blue balls

Output

sample_multinomial(jar, n_balls) -> "blue"
.
.
.
.
.


Comments

Loading comments.