math and logic puzzles 6.1 - 6.6
This commit is contained in:
parent
d364c0a405
commit
f4f0f3b332
|
|
@ -0,0 +1,29 @@
|
|||
# 6.1. The heavy pill
|
||||
|
||||
> You have 20 bottles of pills. 19 bottles have 1.0 gram pills, but one has pills of weight 1.1 grams. Given a scale that provides an exact measurement, how would you find the heavy bottle? You can only use the scale once
|
||||
|
||||
To reduce the entropy, using one measurement we can get to 10 bottles. It'd take log(20) measurements to find the bottle.
|
||||
|
||||
## Hints
|
||||
|
||||
> You can only use the scale once. This means that all, or almost all, of the bottles must be used. They also must be handled in different ways or else you couldn't distinguish between them
|
||||
|
||||
Handled in different ways?
|
||||
|
||||
> What happens if you put one pill from each bottle on the scale? What if you put two pills from each bottle on the scale?
|
||||
|
||||
One pill from each bottle we get 19g + 1.1g = 20.1g. Two pills per bottle, 38g + 2.2g = 40.2g. But that still gives us no info as to which is the bottle.
|
||||
|
||||
> Imagine there were just three bottles and one had heavier pills. Suppose you put different numbers of pills from each bottle on the scale (for example, bottle 1 has 5 pills, bottle 2 has 2 pills, and bottle 3 has 9 pills). What would the scale show?
|
||||
|
||||
The scale depends on how many pills you put from each bottle. If we put 1 pill for bottle1, 2 for bottle2, 3 for bottle3
|
||||
|
||||
* if bottle1 is the heavy one: scale = 6.1
|
||||
* if bottle2 is the heavy one: scale = 6.2
|
||||
* if bottle3 is the heavy one: scale = 6.3
|
||||
|
||||
> You should be able to have an equation that tells you the heavy bottle based on the weight
|
||||
|
||||
`scale = sum(range(len(bottles))) + 0.1 * bottles.index(heavy + 1)`
|
||||
|
||||
We have the scale number and the bottle list, we solve for `heavy`. sum(range(len(bottles))) = 20 * 21 / 2 = 210.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# 6.2. Basketball
|
||||
|
||||
> You have a basketball hoop and someone says that you can play one of two games. Game 1: You get one shot to make the hoop. Game 2: You get three shots and you have to make two of three shots. If p is the probability of making a particular shot, for which values of p should you pick one game or the other?
|
||||
|
||||
p of game2 is p(2/3) + p(3/3) = 3(p-1) * p ^ 2 + p ^ 3 = 3p2 - 2p3.
|
||||
|
||||
You should play game1 if p > 3p2 - 2p3; (2p - 1)(p - 1) > 0
|
||||
|
||||
(see book). 2p - 1 < 0; p < 0.5.
|
||||
|
||||
If p < 0.5, play the first game. Else, play game 2. If p=0, p=0.5, p=1, doesn't matter.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# 6.3. Dominos
|
||||
|
||||
> There is an 8x8 chessboard in which two diagonally opposite corners have been cut off. You are given 31 dominos, and a single domino can cover exactly two squares. Can you use the 31 dominos to cover the entire board? Prove your answer (by providing an example or showing why it's impossible).
|
||||
|
||||
With the opposite corners left, it'd take 8/2 * 8 = 36 dominos to cover it.
|
||||
|
||||
With the two diagonally opposite corners cut off, we can traversely cross each cell diagonally from one cutoff to another in an L. This takes 13 dominos. Keep doing diagonals in the center, we'll have to do some verticals/horizontals on the edges. The smaller pieces atke 18 dominoes. Up to a total of 31 dominos.
|
||||
|
||||
## Solution
|
||||
|
||||
The dominos are supposed to cover the whole cell so diagonals aren't allowed. So it's impossible to cover it with 31 dominos.
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# 6.4. Ants on a triangle
|
||||
|
||||
> There are three ants on different vertices of a triangle. What is the probability of collision (between any two or all of them) if they start walking on the sides of the triangle? Assume that each ant randomly picks a direction, with either direction being equally likely to be chosen, and that they walk at the same speed. Similarly, find the probability of collision with n ants on an n-vertex polygon.
|
||||
|
||||
prob of no collision = p(right) ^ 3 + p(left) ^ 3 = 2 * 0.5 ^ 3 = 0.25. So prob of collision is 0.75.
|
||||
|
||||
This is the probability that all 3 ants go to the right, or all 3 ants go to the left.
|
||||
|
||||
With n ants on a n-vertex polygon, prob_collision = 1 - 2 * 0.5 ^ n = 1 - 0.5 ^ (n-1)
|
||||
|
||||
* n = 4, prob_collision = 0.875
|
||||
* n = 5, prob_collision = 0.9375
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# 6.5. Jugs of water
|
||||
|
||||
> You have a five-quart jug, a three-quart jug, and an unlimited supply of water (but no measuring cups). How would you come up with exactly four quarts of water? Note that the jugs are oddly shaped, such that filling up exactly "half" of the jug would be impossible.
|
||||
|
||||
How about filling the 5-quart jug to the top, then pour it to the 3-quart jug to the top. There are 2-quarts remaining in the big jug. Do that twice, you get the 4 quarts. But how to save?
|
||||
|
||||
1. Fill big one
|
||||
2. Transfer to small
|
||||
3. Dump small
|
||||
4. Transfer the 2q to small
|
||||
5. Fill big one again, now we have 5q in big and 2q in small
|
||||
6. Transfer 1q to the small until full, we're left with 4q in the big one.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# 6.6. Blue-eyed Island
|
||||
|
||||
> A bunch of people are living on an island, when a visitor comes with a strange order: all blue-eyed people must leave the island as soon as possible. There will be a flight out at 8:00 pm every evening. Each person can see everyone else's eye color, but they do not know their own (nor is anyone allowed to tell them). Additionally, they do not know how many people have blue eyes, although they do know that at least one person does. How many days will it take the blue-eyed people to leave?
|
||||
|
||||
Hints:#278, #282, #341, #370
|
||||
|
||||
Loading…
Reference in New Issue