Apple
3.8 of 5
www.apple.com Cupertino, CA 5000+ Employees

# AppleSoftware Engineer Interview Question

I interviewed in Cupertino, CA and was asked:
"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."

Part of a Software Engineer Interview Review - one of 1,760 Apple Interview Reviews

2
of 10
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 Jun 22, 2012 Flag Response
3
of 10
agree with 2nd ans
- Anonymous on Jun 23, 2012 Flag Response
28
of 33
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 Jul 9, 2012 Flag Response
1
of 8
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 Aug 29, 2012 Flag Response
1
of 1
vote
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 Jan 16, 2013 Flag Response
7
of 8
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 Mar 28, 2013 Flag Response
0
of 0
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 Jul 28, 2013 Flag Response
0
of 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 Jul 29, 2013 Flag Response
0
of 1
vote
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 Jul 29, 2013 Flag Response
0
of 0
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 & every coin has a head side so dividing the pile equally achieves that.
- addmony on Jul 29, 2013 Flag Response
0
of 1
vote
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 Aug 8, 2013 Flag Response
0
of 0
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 Nov 1, 2013 Flag Response