The question was to find who doesnt weigh the same and if its heavier or lighter. Watch the clip again.
Comment on Programmer tries to explain binary search to the police
Sagifurius@lemm.ee 11 months agoThe question is to figure out who is different, not how they are different. That takes one more step, half the time.
Mr_Dr_Oink@lemmy.world 11 months ago
Sagifurius@lemm.ee 11 months ago
That’s easy enough to answer, but he really should work on his grammar. In that case you just do 3 groups of three, weigh two of them. If they’re even, the third group is different. Weigh 2 membres of the third group, they’ll either be even or one heavier. Weight the last member against the heavier one from step 2 to see if they’re even or not for your answer.
ChairmanMeow@programming.dev 11 months ago
Yes, I’m aware. But with 12 people you can’t simply divvy the groups in threes constantly, because if you weigh and the groups are unequal, then you don’t know in which group the different person is (yet). E.g., weighing ABCD - EFGH can tell you the different person is in IJKL if the groups are even, but if they’re uneven you don’t know in which of the other two groups the different person is.