This is an entry for the 16th Fortnightly Challenge.

I found this note on my colleague's desk:


I am pretty sure he was solving a puzzle. Can anyone help me figure out what the puzzle was? I am pretty sure he mentioned something about an interview question - maybe this is relevant?

  • $\begingroup$ Just to be clear, you do not know what the puzzle was? And maybe you have some more background information for us? :) $\endgroup$ – Foitn Sep 30 '16 at 7:26
  • 1
    $\begingroup$ Alrighty, let's have some fun then :D $\endgroup$ – Foitn Sep 30 '16 at 7:30
  • 4
    $\begingroup$ Was he trying to remember what letter comes after A and B? :) $\endgroup$ – Ivanhoe Sep 30 '16 at 9:56
  • 1
    $\begingroup$ (The usual notation for logical operations would make AB mean "A and B".) $\endgroup$ – Gareth McCaughan Sep 30 '16 at 10:54
  • 1
    $\begingroup$ @Maria Deleva Nice question.. $\endgroup$ – KSR Sep 30 '16 at 13:18

I think your colleague is trying to solve the following:

There are three boxes, one containing only Apples (A), one only Bananas (B), and one containing both Apples and Bananas (AB). They are labelled 'A','AB' and 'B', but it is known that none of the boxes are labelled correctly. Opening just one box, and without looking in the box, you take out one piece of fruit. By looking at the fruit, how can you immediately label all of the boxes correctly?

In that case,

the first row denotes the order of given labellings. He picks up a fruit from the box labelled 'AB' (as indicated by the second row) and mentally assumes it's a banana WLOG. Then the third row is the only possible ordering of the actual contents of the boxes.

  • $\begingroup$ Well, from the solution, you can see what the colleague assumed. And it is the other one. $\endgroup$ – Maria Ivanova Sep 30 '16 at 11:40

There is a question sometimes used in programming interviews: how to

swap the numbers in two variables (or machine registers) without using a temporary variable/register

to which there are various answers along the lines of

a=a+b; b=a-b; a=a-b -- there are variants that begin with a subtraction or an exclusive-or.

These notes seem somewhat reminiscent of that, using AB to signify

whatever combination of A and B we start with and then use to compute each of A,B from the other.

I can't say I'm terribly convinced, though.

  • $\begingroup$ No equations are involved. Otherwise there would have been signs to justify that (+/-/=, etc.). $\endgroup$ – Maria Ivanova Sep 30 '16 at 10:43
  • $\begingroup$ Fair enough. (If I were scribbling notes to remind myself of the solution to the puzzle described in my answer, or to help explain it to someone else, they might look like "a b (new line) ab b (new line) ab a (new line) b a". But I'll take your word for it about your imaginary colleague :-).) $\endgroup$ – Gareth McCaughan Sep 30 '16 at 10:45
  • $\begingroup$ But what you just wrote still looks different, though. You have 2 entries per line and 4 lines. Here you have 3 on the first, 1 on the second, 3 on the third and a check mark on the fourth. $\endgroup$ – Maria Ivanova Sep 30 '16 at 10:51
  • $\begingroup$ That's why I said I didn't find it terribly convincing :-). But you never know what peculiar things people will write down while solving a problem. $\endgroup$ – Gareth McCaughan Sep 30 '16 at 10:52
  • $\begingroup$ (My point about what I might write was merely to explain why I hadn't been troubled by the absence of +, -, etc.) $\endgroup$ – Gareth McCaughan Sep 30 '16 at 10:52

The answer is:

A=1   B=-1

A  X  AB  =  B  i.e..,   1  X  -1   =  -1  which is equal to B

A  X  AB  =  AB  i.e..,  1  X  -1  =  -1  which is equal to AB

AB  X  B  =  A  i.e..,  -1  X  -1  = 1  which is equal to A


enter image description here

  • $\begingroup$ No equations are involved. Otherwise there would have been signs to justify that (+/-/=, etc.). $\endgroup$ – Maria Ivanova Sep 30 '16 at 10:44
  • 1
    $\begingroup$ ok..i will try for other. $\endgroup$ – KSR Sep 30 '16 at 10:44

ok, my answer

One of those river-crossing puzzles- perhaps the grain, the goat and the tiger puzzle First A goes over, then AB(the 3rd object), B. Farmer returns with the object, then takes them to the other shore again in the manner..

I would say I am not too sure about this because I can't make out which is A and which is B...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.