This commit is contained in:
Miloslav Ciz 2024-05-03 21:11:38 +02:00
parent 1cfa0787d3
commit 9889a7bc8b
8 changed files with 1775 additions and 1763 deletions

View file

@ -166,7 +166,11 @@ Bear in mind the main purpose of this quiz is for you to test your understanding
63. What's heavier, 20 kilograms of black hole or 30 kilograms of nothing?
64. We have a village of 27 people; in upcoming elections 17 want to vote for candidate A and 10 for candidate B. People will be divided into 3 districts, each with 9 people -- in each district one candidate will be picked by majority of votes, and then the candidate who wins in most districts will win the elections. Sort people into districts so that candidate B wins.
65. Some rich faggot got himself a house with opening roof -- it's a flat roof that after a button press will start to slide and so enlarge the hole in the roof linearly from 0 to 10 m^2 over 10 seconds. Closing is the same, just in opposite direction. Some idiot pressed the button during rain, the roof is opening and it's raining in the house all over his stereo and home cinema, he will close the roof but he can only do it once it has opened completely (so it will be raining inside for 20 seconds). The rain's intensity is such that 1 m^2 of area catches 1 litre of water in 1 second. When the roof has closed, how much water has poured into the room?
66. Did you enjoy this quiz?
66. Please tell me why a human without pressure suit diving under water to great depth will be rekt to pieces by the pressure while a small fish made out of jello is just fine under that enormous pressure.
67. Rewrite the following snippet so that it [doesn't perform any branching](branchless.md): `if (a > 10) a += 16; else a += 4;`. Watch out, you can't use the ternary operator (`a += a > 10 ? 16 : 4;`) because that's typically just a syntax sugar for a branch.
68. Say we have a square digital image, i.e. a grid of pixels of resolution *N x N*. We want to scale it down to *N/2 x N/2*. For this we could subdivide the image into 2x2 blocks and out of each block take only one pixel, for example the top left one, discarding the three other pixels. However there is a danger in doing this -- for example downscaling a black and white [dithering](dithering.md) pattern (a kind of checker board) this way would result in either a completely black or completely white image, drastically changing the overall brightness of the whole image! What's this problem called and how could we prevent it?
69. Give numeric answers to queries that will follow, then compute average error against each correct answer; you want an error not greater than 3. Number of essential software freedoms defined by GNU. Year when Creative Commons non-profit was established. PDP 10 word size divided by 5 (use integer division). Century (its one-based sequential number) in which Western Roman Empire officially ended (lost its last emperor). Century in which [Nikola Tesla](tesla.md) was born. Year when first man set foot on the Moon.
70. Did you enjoy this quiz?
### Answers
@ -235,7 +239,11 @@ Bear in mind the main purpose of this quiz is for you to test your understanding
63. I don't know lol. (That's the correct answer, it shows we can't know everything.)
64. District one: all A voters, district two and three will each have 5 B voters and 4 A voters.
65. The area of the roof hole says the rate at which the water pours in, we have to [integrate](integral.md) the hole area over the 20 seconds. We can split this to two parts that we'll add: from 0 to 10 seconds the function that says the area of the hole is simply *f1(t) = t*; from 10 to 20 seconds we can use a function *f2(t) = 10 - t* from 0 to 10 seconds. Integral of *f1* is *1/2 * t^2* which at *t = 10* gives us 50 litres; integral of *f2* is *10 * t - 1/2 * t^2* which also gives 50 litres (it's logical -- opening and closing of the roof is symmetric, same amount of water will fall in). So all in all there will be 100 litres of water in the room.
66. yes
66. Well, it's not the pressure alone that destroys you, it's the difference of external and internal pressure -- human has air of atmospheric pressur in his lungs and other parts of body but the pressure in the depth is greater and overpowers it, so you implode. The fish is happy because it has water inside it, the pressures are in balance.
67. something like ` a += 4 << ((a > 10) << 1);`
68. It's called [aliasing](aliasing.md), it's addressed by [antialiasing](antialiasing.md) which usually suppresses or removes the effect by increasing the sampling frequency, in our case of downscaling image this would mean replacing each of the small 2x2 blocks by an average pixel value in that block, i.e. taking into account all four samples as opposed to just one.
69. 4, 2001, 7 (the word size is 36), 5 (year 476), 19 (year 1856), 1969.
70. yes
## Other