This commit is contained in:
Miloslav Ciz 2025-03-12 16:58:53 +01:00
parent 5dbd5b164a
commit 53bd3b4b91
14 changed files with 1966 additions and 1937 deletions

View file

@ -528,11 +528,12 @@ Bear in mind this is not a school test that's supposed to decide if you get to a
118. [Jara Cimrman](jara_cimrman.md) invented a brilliant self-powered mine elevator design that worked as follows. When miners came to start a new shift in the mine, two of them would enter a down-coming lift, which by the weight of the two workers started to move down and lifted another lift up; in the up-coming lift one miner, ending his shift in the mine, would come up (as he was lighter than the two miners in the down-coming lift). However they soon realized this system had one fatal flaw. What was it?
119. Use only the logical function [NAND](nand.md) (which gives a negated result of [AND](and.md)) to implement the [XOR](xor.md) logical function.
120. We have a rubber rope 1 meter long. On one side there is an ant. He starts moving over the rubber towards its other end by the speed of 1 cm/s, however as he starts to move we start stretching the rubber also by the speed of 1 cm/s, so that after 1 second it's 101 cm long, after 2 seconds it's 102 cm long etc. The ant keeps the same speed. Will he ever reach the end? How long would it take him?
122. [Permutation](permutation.md) is a kind of "shuffling scheme", it says to which position we move items. For example a permutation 213 says the 1st item moves to position 2, 2nd item to position 1 and 3rd item stays in position 3. Applying this permutation to string "abc" would therefore give us "bac", and applying it the second time gets us back to "abc". Find a permutation of length 5 (i.e. some shufling of the string of digits 12345) which among all permutations of length 5 takes the longest possible number of steps to get back to the original arrangement.
123. Today in [slavery](work.md) I tried to fix 6 computers: I ended up destroying twice as many of them than I fixed. Every time I destroyed a computer my boss told me I'm a retard. How many times did my boss repeat I'm a retard?
124. What does constant [bitrate](bitrate.md) mean in relation to video encoding? What are some of its advantages and disadvantages against variable bitrate?
125. The ISS orbits 400 km above [Earth](earth.md) surface. The Earth radius is 6378 km. How far away (from the ISS) is the Earth's horizon?
126. Write the hexadecimal values of a pure green color in 24 bit RGB, [RGB565](rgb565.md) and [RGB332](rgb332.md) formats.
121. [Permutation](permutation.md) is a kind of "shuffling scheme", it says to which position we move items. For example a permutation 213 says the 1st item moves to position 2, 2nd item to position 1 and 3rd item stays in position 3. Applying this permutation to string "abc" would therefore give us "bac", and applying it the second time gets us back to "abc". Find a permutation of length 5 (i.e. some shufling of the string of digits 12345) which among all permutations of length 5 takes the longest possible number of steps to get back to the original arrangement.
122. Today in [slavery](work.md) I tried to fix 6 computers: I ended up destroying twice as many of them than I fixed. Every time I destroyed a computer my boss told me I'm a retard. How many times did my boss repeat I'm a retard?
123. What does constant [bitrate](bitrate.md) mean in relation to video encoding? What are some of its advantages and disadvantages against variable bitrate?
124. The ISS orbits 400 km above [Earth](earth.md) surface. The Earth radius is 6378 km. How far away (from the ISS) is the Earth's horizon?
125. Write the hexadecimal values of a pure green color in 24 bit RGB, [RGB565](rgb565.md) and [RGB332](rgb332.md) formats.
126. Someone wants to kill you in a very special way: he [magically](magic.md) shrinks you so that you're just 2 cm tall and puts you in a blender, but doesn't put the lid on as he's convinced you can't escape. The blender will be turned on in one minute. What do you do?
127. Did you enjoy this quiz?
### Answers
@ -658,12 +659,13 @@ sin(x) / cos(x) - log2(2) = tg(x) - 1*, so we get *tg(x) >= 1*. So that will hol
118. Two miners were coming down but only one up, more workers were entering the mine than were leaving, so the workers started to pile up in the mine. Cimrman solved this by advising the workers to eat a lot before the shift and then work hard to lose some weight so that two heavy miners would be able to lift two lighter ones.
119. a XOR b = (a AND NOT(b)) OR (NOT(a) AND b) = (a AND (b NAND b)) OR ((a NAND a) AND b) = NOT(a NAND (b NAND b)) AND ((a NAND a) NAND b) = (a NAND (b NAND b)) NAND ((a NAND a) NAND b).
120. Let *p* be the ant's relative position on the rubber, i.e. the fraction of the rubber he has already traveled; when *p = 1* he'll be in the finish. At the beginning his speed in fractions of the rubber per second is *v = 1/100*. As the rubber expands, the fractional speed decreases (he keeps moving at 1 cm/s but the total number of cm to be traveled increases): we can write the speed as a function of time: *v = 1/(100 + t)*. Now the fractional position *p* over time is an [integral](integral.md) of speed, i.e. *p = integrate 1/(100 + t) dt = log(100 + t) + C* and the initial position is *p = 0*, i.e. *C = -log(100)*, so *p = log(100 + t) - log(100)*. Now we just have to compute when *p* reaches 1, i.e. *log(100 + t) - log(100) = 1*, which gives us *t = 100 * (e - 1) ~= 171.83*. So the ant will reach the end in nearly 3 minutes.
121. Permutations can be represented in terms of cycles and the lowest common multiple of the cycle lengths is the permutation order, which says "after how many steps we get back to the start". So we are looking for the highest order permutation of length 5. The highest possible order is 6 -- this we get when we have one 3-cycle and one 2-cycle, which gives us LCM(2,3) = 6. So the cycles can be for example (123)(45), which written as before may start as 23154. Indeed, it takes 6 steps to get back to the same permutation: 23154 -> 31245 -> 12354 -> 23145 -> 31254 -> 12345 -> 23154.
121. Permutations can be represented in terms of cycles and the lowest common multiple of the cycle lengths is the permutation order, which says "after how many steps we get back to the start". So we are looking for the highest order permutation of length 5. The highest possible order is 6 -- this we get when we have one 3-cycle and one 2-cycle, which gives us LCM(2,3) = 6. So the cycles can be for example (123)(45), which written as before may start as 23154. Indeed, it takes 6 steps to get back to the same permutation: 23154 -> 31245 -> 12354 -> 23145 -> 31254 -> 12345 -> 23154.
122. 3: I destroyed 4 computers, so he told me 4 times I'm a retard, i.e. he first told me I'm a retard (this was not a repetition) and then repeated it three times.
123. Constant bitrate means a given time unit of the video will always be encoded with (at least approximately) the same number of [bits](bit.md). One second of the video will therefore take the same size no matter how complex or simple the encoded scene is. Advantages are for example being able to estimate size of any video just from its duration alone, easier seeking and rewinding to a random position, or that during streaming over network there will be a constant number of bits transferred per second, which is very predictable and good for many protocols. Disadvantage may be that sometimes space is wasted (we encode a simple scene with more bits than necessary) and that quality of the video won't be constant (scenes for which bits don't suffice will have to have their quality lowered).
124. Draw the shit on paper: draw a ball (Earth) and a point above it (ISS), then draw a tangent line from the point to the ball. Then draw a line from the ball center to the ISS and from the ball center to where the tangent line touches that ball (the horizon). Obviously there's a right angle at the tangent line touch point, so we have a right triangle. One side is the Earth radius and the longest side is the radius plus the orbit height. From this we compute the remaining side as *sqrt((6378 + 400)^2 - 6378^2)*, which gives us approx. 2293 km.
125. 24 bit RGB is easy: 00ff00. For 565 we want a 16 bit value whose upper and lower 5 bits are zero, with the middle bits being ones, i.e. 0000011111100000 in binary, which is 07e0 in hexadecimal. Similarly for 332 we get 1c.
126. yes
126. Apparently the expected answer is this: just jump out of the blender. How? If you're so small, you can jump much higher, just like bugs can, as physics on such a small scale work differently (which is why for example elephants can't jump at all while a cat can jump to a height many times its own height).
127. yes
## Other