← Quiz: Consistent Hashing: all 15 questions
Quiz: Consistent Hashing · Question 13 of 15
What does this print? (code)
What does this print?
import bisect
points = [(40, "A"), (130, "B"), (220, "C")]
def owner(pos):
i = bisect.bisect(points, (pos,))
return points[i % len(points)][1]
print(owner(10), owner(131), owner(250))
- A.A C C
- B.B C A
- C.A B C
- D.A C A
Answer & explanation
Correct answer: A C A
10 goes to A at 40; 131 is just past B so it goes to C; 250 is past C and wraps to A.
Can you get the rest right without peeking?
Take the timed Quiz: Consistent Hashing quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →