Hey! Thanks for visiting my puzzles page! This is where I'll be publishing some of the puzzles I find interesting! Hope you'll enjoy them as well!
Suppose you're a grocery clerk filling banana 🍌 orders. The customer may order any number of banana they desire. Now, bananas come in bundles ranging from a single banana upwards to hundreds of bananas. Your job as a grocery clerk is to fill these banana orders to the best of your ability without breaking any bananas. If there are multiple solutions that allow you to fill these bananas without breaking a bundle, your job is to minimize the number of bundles you take! If there are multiple combination of bundles that minimize the number of bundles, any one of them will work!
Example:
- Desired -> 10
- Bundles -> [4, 3, 5, 5, 6, 3, 2]
- Expected -> (4, 6) or (5, 5) since 4 + 6 = 10 and 5 + 5 = 10, and 2 is the minimum number of bundles to take since there are no single bundles of 10.
Function:
minBananaBundle :: Int -> List -> ListSuppose there are 100 prisoners. Every prisoner is given either a black or white cap. Prisoners are then randomly selected to guess the colour of their cap. If they were to guess correctly, they're freed. Otherwise, they die. Before given the caps, prisoner's are allowed to communicate with each other to develope a strategy to maximize survival. The guess of the randomly selected prisoner is made known to all the prisoners and the result is also known to everyone (freedom or death). What is the optimal strategy for maximal survival? (Such strategy should free a minimum of 99 prisoners)
Let a, b, c, d be integers and (a, b) and (c, d) be two pairs of integers. We then define two operations,
- (a, b) -> (a + b, b)
- (a, b) -> (a, a + b)
Given two pairs of such integers, determine if it's possible for (a, b) to become (c, d) via these two operations.
Example:
- (a, b) = (2, 4)
- (c, d) = (6, 10)
- Expected: Yes, by performing (2, 4) -> (2 + 4, 4) = (6, 4) -> (6, 4 + 6) = (6, 10)
Function
isReachable :: (Int, Int) (Int, Int) -> BoolSuppose you have a 3x3x3 cube, made of 27 tiny cubes. And suppose you painted the exteriors of the cube. Now, you break up the cube into it's 27 parts and take one die out and roll it. It turns out all five visible sides of the die are unpainted, what is the probability that the hiddne face is also unpainted?
What is the probability that four randomly chosen primes from the first 20 primes is odd?