Programmer tries to explain binary search to the police

The Picard Maneuver@startrek.website to Programmer Humor@programming.dev – 2488 points –
409

You are viewing a single comment

A police officer being unable to think in such a fashion is exactly why no one could solve the see-saw riddle on Brooklyn 99.

For those looking for the handout:

person: A B C D E F G H I J K L

round 1: L L L L R R R R — — — -

round 2: L L R R R — — — L R L -

round 3: L R R — — L R — L L — R

This would be easier to parse with a monospaced font. I'm not sure how that works in lemmy so this might take an edit or two...


round 1: L L L L R R R R — — — -

round 2: L L R R R — — — L R L -

round 3: L R R — — L R — L L — R```

Oh i get it. So if in round 1 it tilted down on the right. Round 2 it was even then round 3 it tilted down on the right then it was person G and they are heavier. However if it was reversed and tilted on the left then even then left then it was still person G but they are lighter. Because that pattern only occurs once. This is brilliant. Thankyou to you and the person you corrected the formatting of.

How do you solve that? I saw a solution in the comments where it says to start with numbering all the people and butting 1234 and 5678 on the see saw, then it says if they weight the same then continue and that seems to work. But if they dont weigh the same it doesnt work and it doesnt say what to do in that case.

you can do it like you weight 6v6 then 3v3 then for the last weighing you weight the 2 out of 3.

or you weigh 4v4 to find out which grouping of 4 the light weight person is in, then do 2v2 and 1v1.

You don't know if the person is lighter or heavier yet.

That's not the question. Either the scales balance, and the third is heavier or lighter, or the scales don't balance and you get both answers, but the question is purposely framed this way

I mean that not knowing it is part of the question, and the proposed solution doesn't work without knowing if the person is heavier or lighter.

If you know if the person is heavier or lighter, the question becomes trivial.

The question is to figure out who is different, not how they are different. That takes one more step, half the time.

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.

The question was to find who doesnt weigh the same and if its heavier or lighter. Watch the clip again.

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.

Thats 4 uses of the seesaw. It has to be 3.

That three dude

Im sorry when i read weigh two of them i counted it as two separate weighings of two sets of groups. My bad.

What about the 4th group? There are 12 people

Well I meant to write 3 groups of four. Same general thought just adjust the logic somewhat

1 more...
1 more...
1 more...
1 more...
1 more...
1 more...
1 more...
1 more...
1 more...
1 more...
1 more...

If 1234 and 5678 don't weigh the same youd need 4 seesaws in some cases

1 more...
2 more...