Suppose you have three pen drives P1, P2 and P3 each having 1GB capacity. You have also 3GB data. You have to divide these data into P1, P2 and P3 such that if any one of the pen drive among P1, P2, P3 got crashed than you should be able to recover all the data from remaining two pen drives.

For example – if P1 is crashed then you should be able to recover 3GB data from P2 and P3.

Similarly in the case of P2 and P3.

**Answer :**

Suppose the 3GB data is divided into three groups A, B and C. Then the distribution would be like this

P1-> A^B

P2-> B^C

P3-> C^A

Now suppose pen drive P3 is lost and we are left with data of P1 and P2. As we know that

P1 contains data which is xor of A and B.

P2 contains data which is xor of B and C.

We can perform below steps to recover the whole data.

**Step 1 :** XOR of P1 and P2 gives (A^B)^(B^C) = B

**Step 2 :** XOR of this B which is obtained from step 1 with P1 gives (A^B)^B = A

**Step 3 :** XOR of this B which is obtained form step 1 with P2 gives (B^C)^C = C.

Performing the above-mentioned steps will give the data A, B, and C.

Similarly, we can perform these steps in the case of P1 and P2.

## Recommended Posts:

- Puzzle 15 | (Camel and Banana Puzzle)
- Puzzle 24 | (10 Coins Puzzle)
- Puzzle 27 | (Hourglasses Puzzle)
- Puzzle 28 | (Newspaper Puzzle)
- Puzzle 29 | (Car Wheel Puzzle)
- Puzzle 31 | (Minimum cut Puzzle)
- Puzzle 33 | ( Rs 500 Note Puzzle )
- Puzzle 34 | (Prisoner and Policeman Puzzle)
- Puzzle 36 | (Matchstick Puzzle)
- Puzzle 38 | (Tic Tac Toe Puzzle)
- Puzzle 39 | (100 coins puzzle)
- Puzzle 51| Cheryl’s Birthday Puzzle and Solution
- Puzzle 81 | 100 people in a circle with gun puzzle
- Puzzle 85 | Chain Link Puzzle
- Puzzle | Elevator Puzzle
- Puzzle | 3 Priests and 3 devils Puzzle
- Puzzle 6 | (Monty Hall problem)
- Puzzle | (4 Matchstick Problem)
- Puzzle | Strict Pill Schedule Problem
- Puzzle | Secret Mail Problem

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.