Math and logic puzzle Flashcards
you have to bucket a 5/4 bucket and a 3/4 bucket, weirdly shaped, halh of the height is not half of the volume. An infinite amount of water. How do you measure 4/4 of water?
You should fill the 5/4 put in into the 3/4. Now you have 3/4 and 2/4. You throw the 3/4 away put the 2/4 in it and fill the 5/4 with that you fill the 3/4 or better the 1/4 missing and you are done.
Flatten pills: you have 20 bottles of pills. 19 have 1 gram pills one has 1.1g pills. how do you identify the heavy one by measuring with a precise scale only once??
You have one try. So most of the bottle needs to be used on the scale. If you do not use more than 1 you can not identify it. Also, you have to use them differently otherwise how do you identify the heavy one in the buck? So… Take a different number of pills from everyone 1 for first 2 from second etc… then you will be able to identify it,
Mutiledted dominos, can you cover a 8x8 checkboard with mutileted corners with 31 dominos (that covers 2 places?)?
No even if you can cover 31x2 62 squares and you have 62 squares a domino always cover one black and one white. if you cut 2 blacks you are screwed
combination n objects take k
you create permutations of length k of n objects but now order does not matter so you divide by k! the rearrangement of the k-subset objects n!/(k!(n-k)!)
Blue eye islander: on an island all the blue eyed people have to leave. There is on flight per night. You can see other people eye but you do not know your own and they can not tell you. Do not know how many blue eyes but know there is at least one
If only one person you can see all other no blue eyes. So you leave. If 2 you are not sure, cause you see another one with blue eyes. but if she does not leave the first night it means you also have blue eyes and on the second night you both leave. So it takes c+1 with c is the number of people with bljue eye
Permutations: how many string of n characters
n!
Relation between log_10 P and log_2P
Remember P=10^log_10(P)= 2^log_2(P) log_10(P) = log_2(P)/log_2(10) So they only differ by a constant factor.
9 balls one is heavier. Identify it using only 2 uses of a scale that tells you if left or right is heavier.
weight 3 and 3. Then either one of those 3 to identify which one is heavier or if they are the same the remaining 2 you have not weighted the first time.
sum of power of 2 say 2^0+2^1…2^n
- you can see it using binary try to sum up them in binary format and you will see it. it is 2^(n+1)-1
What is the sum ffor 1…N integers?
you can see this by writing them and grouping in couple them so that they sum up to n+1 (N+1)*N/2
Permutations with length
n characters you want k character string n!/(n-k)! because you can choose n characters for the fisr n-1 for the second etc but you stop at n-k+1
Given a generator of unbiased bernoulli numbers (0 or 1 with p=0.5), create a biased bernoulli trial generator (generate 0 or 1 with the specified 0 < p < 1)
How to write a function to make a biased coin from a fair coin and vice versa
How do we handle categorical variables in decision trees?
Random forest:
What happens when we have correlated features in our data?
Random Forest
What if instead of finding the best split, we randomly select a few splits and just select the best from them. Will it work?
RAndom forest
Is it easy to parallelize training of a random forest model? How can we do it?
What is gradient boosting trees?
What’s the difference between random forest and gradient boosting?
What are the main parameters in the gradient boosting model?
How do you select the number of trees in the gradient boosting model?