This commit is contained in:
Miloslav Ciz 2024-04-30 19:29:49 +02:00
parent c863684c6d
commit 0bfafcf00a
17 changed files with 1793 additions and 1756 deletions

View file

@ -143,7 +143,7 @@ Bear in mind the main purpose of this quiz is for you to test your understanding
40. Point out what's highly unusual or uncommon about this paragraph. That is find a quality of this paragraph that you wouldn't normally think to find if you took a random paragraph from, say, a random book in your library, or in similar work. It's not that difficult.
41. WARNING: VERY HARD. There are two integers, both greater than 1 and smaller than 100. *P* knows their product, *S* knows their sum. They have this conversation: *P* says: I don't know the numbers. *S* says: I know you don't, I don't know them either. *P* says: now I know them. *S* says: now I know them too. What are the numbers? To solve this you are allowed to use a programming language, pen and paper etc. { Holy shit this took me like a whole day. ~drummyfish }
42. Compare advantages and disadvantages of [hash](hash.md) tables vs binary [trees](tree.md) for storing text strings, especially in regards to searching the string database.
43. A woman gave birth to two sons in the span of a single hour, i.e. they are of the same age, but they aren't twins. How is this possible?
43. A [woman](woman.md) gave birth to two sons in the span of a single hour, i.e. they are of the same age, but they aren't twins. How is this possible?
44. Name at least two TCP/IP or OSI [network](network.md) layers: about each shortly explain its purpose, addressing and at least one protocol of this layer.
45. We know [HTTPS](https.md) is shit because it's [encrypted](encryption.md) and requires [certificates](certificate.md). Explain what these certificates are, why HTTPS needs them, how their absence could be "abused" and who issues them.
46. We have two barrels, one with water, one with wine, each having the same amount of liquid. We take a cup, fill it with water from the water barrel, pour it over to the wine barrel, mix it up, and then we fill the same cup with this mixture of water and wine from this barrel and pour it back to the water barrel. Both barrels now have the same amount of liquid again, but the liquids are mixed. What percentage of water is in the water barrel and what percentage of wine is in the wine barrel? Find a general formula for a cup of any size.
@ -153,9 +153,14 @@ Bear in mind the main purpose of this quiz is for you to test your understanding
50. Is [LGBT](lgbt.md) [good](good.md)?
51. Write a [C](c.md) function in 60 characters or fewer that takes a string (`char *`, consider zero terminated ASCII string) and replaces all semicolons in it with colons (`;` -> `:`). It can return nothing (`void`).
52. Order the following [people](people.md) by date of their birth from oldest: [Alan Turing](turing.md), Caesar, [Buddha](buddha.md) (Siddhartha Gautama), Johannes Gutenberg, Aristotle, [Charles Babbage](babbage.md), [Linus Torvalds](torvalds.md), [Jesus](jesus.md), [Adolf Hitler](hitler.md), Muhammad (prophet of Islam), [Albert Einstein](einstein.md), [Richard Stallman](rms.md), Napoleon, Leonardo da Vinci, [Karl Marx](marx.md).
53. State at least 5 reasons for why [Rust](rust.md) sucks so much.
54. Find at least one function *f(x)* that's defined for all non-negative integers and for which it holds that *x + f(x) - f(x + 1) = 0*. (It's enough if you show a sequence of numbers with obvious continuation.)
55. Did you enjoy this quiz?
53. Start with number 967; in each step you can either add all the digits (e.g. 456 -> 4 + 5 + 6 = 15), multiply all the digits (e.g. 45 -> 4 * 5 -> 20) or shuffle the digits in any way (e.g. 320 -> 23); your goal is to get to number 3. { This one is mine. ~drummyfish }
54. State at least 5 reasons for why [Rust](rust.md) sucks so much.
55. Find at least one function *f(x)* that's defined for all non-negative integers and for which it holds that *x + f(x) - f(x + 1) = 0*. (It's enough if you show a sequence of numbers with obvious continuation.)
56. What do we call a program that prints its own source code?
57. You receive a 1 bit (black&white) image of 8x8 resolution encoded as hexadecimal string 0xf91919ffff98989f. The string encodes consecutive rows of pixels from top to bottom, each pixel with 1 bit. What does the image show?
58. Show (even just geometrically) that for EVERY right triangle if we draw a circle going through all its vertices, the triangle's hypotenuse (longest side) will be the circle's diameter and the circle's center will lie in the middle of the hypotenuse.
59. What was the name of the computer that first beat the world's [chess](chess.md) champion in an official match and in which year, with tolerance plus/minus 2, did it happen?
60. Did you enjoy this quiz?
### Answers
@ -203,7 +208,7 @@ Bear in mind the main purpose of this quiz is for you to test your understanding
42. Hash table will only allow efficient searching of exact matches while binary tree will also allow efficient searching e.g. for all strings starting with some prefix. On the other hand hash table may be faster, in ideal case searching for the match in constant time, but this will depend on the quality of implementation (hash function, number of hash bits, ...), in worst case hash table can degenerate to a mere list. Binary trees will generally be a bit slower, with logarithmic time, but here we'll also have to ensure good implementation, especially balancing the tree -- badly implemented tree may also degenerate to a list.
43. They are two of triplets (or quadruplets, ...).
44. For example: application layer (highest level layer, concerned with applications communicating with each other, addressing by ports, protocols: HTTP, Gopher, FTP, DNS, SSH, ...), transport layer (middle level layer, concerned with delivering data over a potentially unreliable channel, implements establishment of connection, handshakes, reliable delivery, delivering in correct order etc., protocols: TCP, UDP, ...), network layer (below transport layer, concerned with delivering packets over a network, implements routing, forwarding etc., addressing by IP addresses, i.e. numerical machine addresses, protocols: IPv4, IPv6, ...), OSI physical layer (lowest level layer, concerned with sending bits between two directly connected devices, works with frequencies, electronic circuits etc., no addressing, protocols: ethernet, USB, Bluetooth, ...), ...
45. Certificate is a file that contains the domain's public key (needed to communicate using asymmetric cryptography) that is [digitally signed](digital_signature.md) by some "trusted authority", a business that declares itself to be trusted and lets itself be paid for cryptographically confirming that public keys belong to specific servers. Without certificates a [man in the middle](man_in_the_middle.md) "attack" could be performed in which a middle man could sneakily swap a public key that's being transmitted for his own public key which would then allow him to listen to the unencrypted communication.
45. Certificate is a file that contains the domain's public key (needed to communicate using asymmetric cryptography) that is [digitally signed](digital_signature.md) by some "trusted authority", a business that declares itself to be trusted and lets itself be paid for cryptographically confirming that public keys belong to specific servers. Without certificates a [man in the middle](man_in_the_middle.md) "attack" could be performed in which a middle man could sneakily swap a public key that's being exchanged for his own public key which would then allow him to listen to the unencrypted communication.
46. Let's say both barrels hold 1 unit of liquid volume at the beginning, *n* is the portion of one barrel we'll be pouring over (e.g. *n = 4* means 1/4th of a barrel), *x* is water, *y* is wine. At beginning we have the following in respective barrels: *x* and *y*. After first pour over we have: *x - x/n* and *y + x/n*. After pour back we'll have: *x - x/n + (y + x/n)/(n+1)* and *y + x/n - (y + x/n)/(n+1)*. Note: the division by *n + 1* is important, dividing by *n* would be an error (we are taking away a part of barrel that is over its original capacity). Now we can just simplify the expressions to see the amount of water and wine in each barrel, i.e. we'll get: *x * (1 - 1/n + 1/(n^2+n)) + y * 1/(n+1)* and *x * (1/n - 1/(n^2+n)) + y * (1 - 1/(n+1))*. So for example amount of water in the first barrel is *1 - 1/n + 1/(n^2+n)* which simplifies to *n/(n+1)* -- that is also the exact amount of wine in the other barrel (*1 - 1/(n+1)* simplifies to the same expression). So the answer is there is *n/(n+1)* of the barrel's original liquid (and 1 minus that of the other). Logically we see the purity of each barrel has to be the same just because of the conservation laws.
47. The details may differ from language to language, but generally *lvalues* and *rvalues* appear in assignment commands -- lvalue is any value or expression that may appear on the left side of assignment, rvalue is that which may appear on the right. For example in `myVariable = x + 4` the left side, `myVariable`, is lvalue, and the right side, `x + 4`, is rvalue. From this follow the conditions on lvalues and rvalues, i.e. rvalue must be something that returns some computed value and lvalue must be something that identifies a place where a value can be stored -- sometimes an expression can be both lvalue and rvalue at the same time. Examples: `123` is rvalue, `someVariable + 123` is rvalue, `someArray[20]` is both lvalue and rvalue, `*(somePointer + 4)` is also both and `someVariable` is both too.
48. The Sun. Some people get tricked here, not realizing Sun is a star.
@ -212,8 +217,13 @@ Bear in mind the main purpose of this quiz is for you to test your understanding
51. For example: `void r(char *s) { while (*s) s += (*s -= *s == ';') != 0; }`;
52. Buddha (< -480), Diogenes (-404), Aristotle (-384), Caesar (-100), Jesus (around -5), Muhammad (around 570), Gutenberg (around 1400), Da Vinci (1452), Napoleon (1769), Babbage (1791), Marx (1818), Einstein (1879), Hitler (1889), Turing (1912), Stallman (1953), Torvalds (1969).
53. For example: it's bloated, slow, can't be compiled on good computers, it's tranny software with toxic fascist community, it has issues with legal freedom (trademarks), it has [code of censorship](coc.md), it has no specification, it's obsessed with "safety", the name is complete shit, it is associated with [corporations](corporation.md), has some abomination of [OOP](oop.md), it's littered with dependencies, it's [capitalist monopoly software](capitalist_software.md), it's trying to display [C](c.md), it is hosted on [GitHub](github.md), the users are and devs idiots and so on and so forth.
54. We can rewrite the condition as *f(x + 1) = f(x) + x* from which it's clear that the next number in the sequence is the previous one minus its position (a bit similar to [Fibonacci](fibonacci.md) sequence), so for example this sequence will satisfy the equation: 0, 0, 1, 3, 6, 10, 15, ...
55. yes
54. `967 (*) --> 378 (*) --> 168 (*) --> 48 (+) --> 12 (+) --> 3`.
55. We can rewrite the condition as *f(x + 1) = f(x) + x* from which it's clear that the next number in the sequence is the previous one minus its position (a bit similar to [Fibonacci](fibonacci.md) sequence), so for example this sequence will satisfy the equation: 0, 0, 1, 3, 6, 10, 15, ...
56. [quine](quine.md)
57. swastika
58. Draw any right triangle; drawing an identical triangle mirrored by the hypotenuse clearly makes the both triangles together form a rectangle (it can be shown generally all angles in it will always be 90 degrees) in which the hypotenuse (that the both triangles share) is the rectangle's diagonal. Now draw also the other diagonal of the rectangle. If we draw a circle going through all the rectangle's verticles (which is the same circle that goes through the original triangle's vertices), it is clear (e.g. just by symmteries) its center lies in the middle of the rectangle, i.e. on the intersection of the diagonals; i.e. the circle's center lies in the middle of the hypotenuse, which also implies the hypotenuse is the circle's diameter (it's a straight line going through the circle's center).
59. [Deep Blue](deep_blue.md), 1997
60. yes
## Other