Apple Interview Question: You have a 100 coins laying f... | Glassdoor.co.in

## Interview Question

Software Engineer Interview Cupertino, CA (US)

# You have a 100 coins laying flat on a table, each with a

head side and a tail side. 10 of them are heads up, 90 are tails up. You can't feel, see or in any other way find out which side is up. Split the coins into two piles such that there are the same number of heads in each pile.
Tags:
programming, coins

75

Answer #1: Place 50 coins into two piles on its edges so that both have the same amount of heads in each pile, neither facing up or down.
Answer #2: Trick question, place 50 coins in both piles and in theory they all have heads just not necessarily facing up or down.

Luis Marquez on 22-Jun-2012
17

agree with 2nd ans

Anonymous on 23-Jun-2012
162

Split into two piles, one with 90 coins and the other with 10. Flip over every coin in the pile with 10 coins.

Anonymous on 09-Jul-2012
24

Just split into two piles, each with 50 coins. The question only asks 50 heads in each one, it doesn't ask for the number of heads up!!!

JianMin on 29-Aug-2012
8

Pick 10 coins from the pile, flip it and put it in the other pile. This will ensure that the number of heads up are equal in both the piles

Anonymous on 16-Jan-2013
83

Pick 10 coins from the original 100 and put them in a separate pile. Then flip those 10 coins over. The two piles are now guaranteed to have the same number of heads. For a general solution of N heads and a total of M coins:
1.) Pick any N coins out of the original group and form a second pile.
2.) Flip the new pile of N coins over. Done.

Example (N=2, M=6):
Original group is HHTTTT (mixed randomly). Pick any two of these and flip them over. There are only three possible scenarios:

1: The two coins you picked are both tails. New groups are {HHTT} {TT} and when you flip the 2nd group you have {HHTT} and {HH}.

2.) The two coins you picked consist of one head and one tail. New groups are {HTTT} and {HT} and when you flip the 2nd group you have {HTTT} and {TH}.

3.) The two coins you picked are both heads. New groups are {TTTT} and {HH} and when you flip the 2nd group you have {TTTT} and {TT}.

ishapiro on 28-Mar-2013
6

The question says "'You' can't feel, see or in any other way find out which side is up....' Can a team member? Cooperate with a fellow engineer, or other colleague, who can see the coins to solve the problem?

JennS on 28-Jul-2013
4

Question has its answer in it...
90 coins are tail down..... so it means all 90 coins are head up....

Now, all you have to do is to split it into half. 50/50

Gagan on 29-Jul-2013
6

Let's generalise the question to where there are n heads and any number of tails on the table.

Select any n coins. This set will contain m heads, where m is between 0 and n inclusive, and n - m tails. The other n - m heads will be in the remaining coins.

We now have two piles: the selection of n coins with n-m tails and the remainder with n-m heads. All we have to do is flip the selection so that the n-m tails become n-m heads, the same number as the heads in the remainder.

This is a straightforward extension of the 'pick any 10 coins and flip' answer correctly given above by several people.

Bootlebarth on 29-Jul-2013
4

All of you are over thinking it. Read the last bloody line,

"Split the coins into two piles such that there are the same number of heads in each pile"

They're not asking for the heads to be up or down, just an equal amount &amp; every coin has a head side so dividing the pile equally achieves that.

2

100 coins total, 10 of them are heads up, 90 are tails up. Meaning all of them are heads up AND tails down. Split it 50/50 and you are done.

Daniel on 08-Aug-2013
7

It is not as easy as to just split it. And it says heads UP tails UP.
Given 10 h, 90 t. Pick some random 10 coins call it P1. Rest is P2.
In P1, (10-x) heads, (x) tails
In P2, (x) heads, (90-x) tails
Flip the coins in P1.
In P1, (x) heads and (10-x) tails
P1 and P2 have the same number of heads.

Shafiq on 01-Nov-2013
19

trev on 20-Feb-2014
1

I agree to trev, don't think anyone read the question.

Anonymous on 02-Aug-2014
0

we already have 2 piles --&gt; 90 coins with tails up and 10 coins with heads up, just flip over 10 of the coins from 90 coins that have tails up, we will have same number of coins with heads up in each pile.

bugaboo on 27-Feb-2015
1

get all coins in your hands, shake them, drop them.
for each coin there is a 50% probability to lay heads up, and 50% probability for tails down. now split i half

paninies on 11-Apr-2015
0

question doesn't need to look faces of which side is up after splitting it in two piles. split all coins in two part of 50 50 and they all have heads ...and thats what questioner asking..!

Kamal Bharakhda on 14-Apr-2015
0

and move them to the 10-coin pile.

Take 40 coins from 90-coin pile, flip them over on 09-May-2015
0

Take 40coins from 90-coin pile, flip them over and move to the 10-coin pile.

Anonymous on 09-May-2015
2

It's really depends on whether Apple is hiring Software Engineers who are collaborators, mathematicians or tricksters. It's clear that Apple does hire Engineers who listen to the question accurately.

Anonymous on 18-Jun-2015
2

Make two groups at random for 10 and 90 coins.

Example:-

G1(10) G2(90)
case 1:- 6H,4T 4H,86T
case2:- 3H,7T 7H,83T

Now flip all coins of smaller group G1(10). The result will always have same Heads in each pile.

G1(10) G2(90)
case 1:- 6T,4H 4H,86T
case2:- 3T,7H 7H,83T

Anonymous on 19-Jul-2015
0

We just get 5 coins head up put in each piles ==&gt; we get the same number of head up in each pile. They just ask we "Split the coins into two piles such that there are the same number of heads in each pile" . They didn't say that we don't kow what is coin head up and they mixed together.

Tam on 16-Sep-2015
1

"The question says "'You' can't feel, see or in any other way find out which side is up....' Can a team member? Cooperate with a fellow engineer, or other colleague, who can see the coins to solve the problem?"

This is the best answer yet! Completely out of the box answer and yet so simple.

The M on 03-Oct-2015
0

Flip every other coin, 90 Tails will get split into 45 Heads and 45 Tails. Similarly 10 Heads will get converted to 5 Head and 5 Tails, so now we have 50 heads (45 + 5) and 50 tails (45 + 5). Then just split them into two equal groups.

Saurabh Pandit on 17-Nov-2015
0

Tom on 18-Nov-2015
2

Make a pile of 10 and flip them over. Then the number of heads is equal in both piles.

Patrick on 19-Nov-2015
0

question says both group should have equal heads, but doesnt specifiy, it should be up, hence, just grouping 50 each would solve the problem

Panchaxari on 19-Jan-2016
0

This is a screw you question, but yeah if you take out 10 coins you can have anywhere between 0-10 heads for every head you have you have one less head in the other pile and one less tail in your pile of 10 coins.

So if you have 100 coins 10 heads and you take lets say 10 coins

1 heads, 9 tails. The 90 coins has 9 heads (you stole one when selecting 10 coins).
2 heads, 8 tails. The 90 coins has 8 heads (same you stole 2 when selecting 10 coins ect).

This stands true for any pile that you know the amount of one category and 2 options, If you know you have 25 of one things, despite how many things there are if each thing had only two options like heads or tails, you know selecting 25 of them the same amount you know of one thing that when taking out 25 or the equal number of what you know of one thing is in there that what you unsucessfully try to filter out is the inverse of what you selected successfully to take out.

Graham on 19-Feb-2016
0

Pick 10 coins, flip them and form a separate pile. The no.of tails in both pile will be equal inspite of your choice being a tails up coins or a heads up coins. Coz when u pick a tails up coin u r reducing the no.of tails up in the first pile and since u flip it its gonna b a heads up coin the second pile, if u r picking up a heads up a coin u turn it into a tails up coin in the second pile so that it can cancel out one tails up coin in the existing first pile.

Anonymous on 13-May-2016
1

If it means heads up then separate the coins into one pile of 90 one pile of 10 then flip the ten coins it works with all scenarios Of sides you ended up choosing also like to point out that we can't feel them so we probably can't use our hands to flip them but I assume they would allow us to use something as how else would we separate them

James on 07-Oct-2016
0

The answer lies in the exact wording of the question "Split the coins into two piles such that there are the same number of heads in each pile. " It does not specify heads need to be face up, so you would simply split the piles in 50 each and you have the same number of coins with heads in each pile.

Paul Ricci on 27-Mar-2017
0

Take ten coins (consider as one pile, Pile A and other 90 coins as another pile, Pile B).
Now you have two piles. Turn all coins as in pile A, you will end up with same number of heads in both piles.

Ex: Scenario 1: Consider in Pile A, there are 2 heads and 8 tails. Hence in Pile B there will 8 heads.Now when you turn all the coins in Pile A you will end with 8 heads in Pile A.
Hence both Pile A and Pile B have same number of heads.

Scenario 2: Consider in Pile A, there are 10 heads. Hence in Pile B there will be 0 heads.Now when you turn all the coins in Pile A, you will end with 0 heads in Pile A.
Hence both Pile A and Pile B have same number of heads.

Scenario 3: Consider in Pile A, there are 0 heads. Hence in Pile B there will be 10 heads.Now when you turn all the coins in Pile A, you will end with 10 heads in Pile A.
Hence both Pile A and Pile B have same number of heads.

Vamshi Nandan on 18-May-2017
0

Take 10 coins.Split into two piles of 5 each.Flip all coins in one pile.Both piles now have equal heads and tails.Take another 10 and go through the same procedure.Follow the same process for the entire original pile.You end up with two sets of 5 piles having equal no. of heads and tails.Combine all 5 piles on each side and it's done.

Anonymous on 22-Nov-2017
0

Its very simple.

step 1

take group of 10 coins from all

now flip this pile

how?

lets see cases

100 total ( 10 H + 90T)

so you get group of 10 from them

so lets assume you will get 4 h+6T , and (6H + 84T)

then flip this smaller one

new group will be 4T+ 6H

so now we 2 groups 1 new 1 old

4t+6h and 6h+85T

both have same number of heads ....

Vinay Mahipal on 13-Mar-2019
1

LITERAL ANGLE
Split 50/50. Both piles have the same number of heads. Parameters do not require each pile to have the same number of heads facing upward.

TEAMWORK ANGLE
Ask the most efficient, skilled coin identification analyst at Apple to identify the coins so the skilled sorting robot can separate the piles equally.

PATRONIZING ANGLE
Take a picture of the table with your iPhone and sending to a laborer hired to come sort for you via a services app in the app store.

NEXT LEVEL QUANTUM ANGLE
If the coins are in no way observable, the question is impossible to answer because the coins are sitting next to Schrodinger's cat and thus are in a state of both heads and tails until observed.

Tevyn on 27-Mar-2019

One or more comments have been removed.