This is an entry for the 16th Fortnightly Challenge.


I found this note on my colleague's desk:

note

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?

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

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.

  • Well, from the solution, you can see what the colleague assumed. And it is the other one. – Maria Deleva 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.

  • No equations are involved. Otherwise there would have been signs to justify that (+/-/=, etc.). – Maria Deleva Sep 30 '16 at 10:43
  • 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 :-).) – Gareth McCaughan Sep 30 '16 at 10:45
  • 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. – Maria Deleva Sep 30 '16 at 10:51
  • 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. – Gareth McCaughan Sep 30 '16 at 10:52
  • (My point about what I might write was merely to explain why I hadn't been troubled by the absence of +, -, etc.) – 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

Diagrammatically,

enter image description here

  • No equations are involved. Otherwise there would have been signs to justify that (+/-/=, etc.). – Maria Deleva Sep 30 '16 at 10:44
  • 1
    ok..i will try for other. – 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

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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