Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interview puzzle: 4 switches on a circular plate controlling a light bulb #116

Open
FredWe opened this issue Feb 4, 2017 · 0 comments
Open

Comments

@FredWe
Copy link
Owner

FredWe commented Feb 4, 2017

(Translated & rewritten from http://www.xuebuyuan.com/211840.html, hoping for original source)

Question:

You are given a black box, which contains 4 switches on a circular plate. They compose a cyclic square. You can see a light bulb controlled by these switches outside the box. These 4 switches satisfy following conditions:

  1. Every switch has only 2 states: ON or OFF. When you touch a switch, its state will be changed (ON to OFF or OFF to ON)

  2. You cannot see which state of any switch, neither judge it by touching.

  3. In each operation, you are allowed to touch only ONE or TWO switches.

  4. After one operation, the circular plate will turn to a random position

  5. Since the distance between diagonal summits is different from which between adjacent summits, so when you change 2 switches, you could know which you operated are diagonals or adjacents.

  6. When switches are ALL ON or ALL OFF, congrats, light bulb shines and you will win.

The question is, is there any strict operation process making all initial switches' states reach the target, shining the target light bulb ?

Solution:

Possible states:

First of all, assuming '1' represents a switch ON, '0' represents a switch OFF. Listing all possible initial situations is easy: 0001, 0010, 0011 ... 1111

Since ALL ON or ALL OFF could make the target (so, for example, 1110 and 0001 are symmetric because only 1 change to last switch could finish process), and those 4 switches makes a circle (so as a result, 1001 & 0011 can be consider together). So here, all possibilities can merge into 4 basic situations:

  • T: 0000, or 1111
  • A: 0001, or 0010 0100 1000 1110 1101 1011 0111
  • B: 0011, or 0110 1100 1001
  • C: 0101, or 1010

Since 0000 or 1111 is already the result, so initial situations can be only merged to 3 possibilities:

  • A: 0001;
  • B: 0011;
  • C: 0101

States transitions:

For one operation, there could be either 1 switch or 2 switches touched. And from the question description, the operator has only 3 following options by its free will:
a: to touch 1 switch; b: to touch 2 adjacents switches; c: to touch 2 diagonals switches

Next step is considering every possible combinations:

  • Aa: 0001 -> 0011 (1001) or 0101 or 0000 <==> A --a--> B, C, T
  • Ab: 0001 -> 0001 (1000, 0010, 0111, 1101) <==> A --b--> A
  • Ac: 0001 -> 0001 (0100, 1011) <==> A --c--> A
  • Ba: 0011 -> 0001 (0010, 0111, 1011) <==> B --a--> A
  • Bb: 0011 -> 0000 (1111) or 0101 (1010) <==> B --b--> C, T
  • Bc: 0011 -> 0011 (0110, 1001) <==> B --c--> B

For situation 0101, the key point is finding the following operation, which could 100% reach the target:

  • Cc: 0101 -> 1111 or 0000 <==> C --c--> T !

Conclusion:

Operation \ Situation A: 0001 B: 0011 C: 0101
c: 2 diagonals A --c--> A B --c--> B C --c--> T [Light ON !]
b: 2 adjacents A --b--> A B --b--> T [Light ON !] ---
------------ -------------- or: B --b--> C ---
c: 2 diagonals A --c--> A C --c--> T [Light ON !] ---
a: 1 switch A --a--> T [Light ON !] --- ---
------------ or: A --a--> C --- ---
------------ or: A --a--> B --- ---
c: 2 diagonals C --c--> T [Light ON !] --- ---
------------ or: B --c--> B --- ---
b: 2 adjacents B --b--> T [Light ON !] --- ---
------------ or: B --b--> C --- ---
c: 2 diagonals C --c--> T [Light ON !] --- ---
@FredWe FredWe changed the title Interview puzzle: 4 light bulbs on a circular plate Interview puzzle: 4 switches on a circular plate control a light bulb Feb 4, 2017
@FredWe FredWe changed the title Interview puzzle: 4 switches on a circular plate control a light bulb Interview puzzle: 4 switches on a circular plate controlling a light bulb Feb 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant