Interesting and Humour - page 3621

 
.
Google открыл для всех новый способ сжатия JPEG
Google открыл для всех новый способ сжатия JPEG
  • 2017.03.17
  • Владимир Королев
  • nplus1.ru
Компания Google открыла доступ к новому алгоритму сжатия изображения изображений формата JPEG — Guetzli (в переводе со швейцарского диалекта немецкого языка — «печенье»). Он позволяет получать высококачественные файлы изображений, объем которых на 35 процентов меньше, чем в результате работы стандартных алгоритмов. Это достигается благодаря...
 

not the hardest riddle in three minutes )

one minute to find a pencil and paper, one minute to draw all six options and one minute to formulate the answer.)

 
.
Подборка неожиданного, странного, местами безумного кода: самые необычные программы из когда-либо написанных
Подборка неожиданного, странного, местами безумного кода: самые необычные программы из когда-либо написанных
  • 2017.03.15
  • Иван Бирюков, страж правописания
  • tproger.ru
Сегодня мы поговорим о самых странных программах, какие вы когда-либо видели. И настолько непонятных, что даже прошаренные кодеры возьмутся за учебники.
 
A task that was given in job interviews at Apple. Imagine that you got a job as a cashier in a shop. Your boss happens to find out that you have programming skills and wants you to help him write a program.

The inputs are:

1.A specified amount of money.
2.An array with all available denominations of coins.
You need to write a function that outputs the number of all possible ways to get the specified amount of money using the different coin denominations available. For example, if you need to get 4 cents from coins of denominations 1, 2 and 3 cents, the function will return 4 - that's how many possible combinations there are of the numbers 1, 2 and 3 to get a total of 4:

1. 1, 1, 1, 1.
2. 1, 1, 2.
3. 1, 3.
4. 2, 2.
 
Server Muradasilov:
A task that was given in job interviews at Apple. Imagine that you got a job as a cashier in a shop. Your boss happens to find out that you have programming skills and wants you to help him write a program.

The inputs are:

1.A specified amount of money.
2.An array with all available denominations of coins.
You need to write a function that outputs the number of all possible ways to get the specified amount of money using the different coin denominations available. For example, if you need to get 4 cents from coins of denominations 1, 2 and 3 cents, the function will return 4 - that's how many possible combinations there are of the numbers 1, 2 and 3 to get a total of 4:

1. 1, 1, 1, 1.
2. 1, 1, 2.
3. 1, 3.
4. 2, 2.

To me, it is solved by writing a single recursive function, taking the value of the maximum available coin denomination for the current depth as one of the parameters.
(The array with the used coin denominations is pre-sorted and together with the amount of money is available for use in the recursive function)
 
 


 
 
 


There's even a solution to the problem on Wikipedia. For people nowadays, aliens are more real than gods.)))


"L'indovinello più difficile del mondo'[1] is the name of a logic problem proposed by the American philosopher and logician GeorgeBoulos in the Italian newspaper La Repubblicain 1992:

There are three gods, A, B and C, which are the gods of truth, falsehood and chance in an arbitrary order. The god of truth always tells the truth, the god of lies always deceives, the god of chance can tell both truth and lies in an arbitrary order. It is required to identify the gods by asking 3 questions that can be answered 'yes' or 'no'. Each question is asked to one god only, but you can ask one god more than one question. The gods understand the language, but they answer in their own language which has 2 words "da" and "ja", and it is not known which word stands for "yes" and which for "no".

Boulos also clarifies some points of the task:

  • One can ask one god more than one question (so other gods may not be asked any question at all).
  • What the next question will be and to whom it will be asked may depend on the answer to the previous question.
  • The God of chance answers randomly, depending on the flip of a coin hidden in his head: if the reverse comes out he answers truthfully, if the reverse, he lies.
  • The God of occasion answers "da" or "ja" to any question that can be answered with "yes" or "no".

Other comments:

  • No "paradox" questions that can be answered with both "da" and "ja", or cannot be answered in any way. For example, "Are you going to answer 'da' now?

Story

Boulos points out the logic of RaymondSmallian as the author of the problem and of JohnMcCarthyism as a result of the unclear interpretation of "da" and "ja". You can find similar problems in the books by Smallian[2], for example, he describes an island where half of the residents are zombies (they constantly lie), and the other half are humans (they constantly tell the truth). The situation is complicated by the fact that the inhabitants of the island understand us perfectly, but the Old Testament forbids them to use non-native words. So they use the answers "bal" or "da", which mean "yes" and "no" and it is not clear which one means what. There are a number of similar puzzles in the book "The Riddle of Scheherazade". These are all variations on the well-knownKnight and Liar puzzlesof Smallian.

One such problem was highlighted in the film "The Labyrinth": there are 2 doors and 2 guards, one always tells the truth, the other always lies. One door leads to the castle, the other leads to death. The point of the puzzle is to find out which door leads to the castle by asking one question to one guard. In the film, Sarah asks, "Will he [the other guard] tell me that this door leads to the castle?"[3]

The solution to the problem

Boulos offered a solution to the problem in the same article where he published the problem itself. He stated that the first question we have to find a god who is not a god of chance, i.e. is either a god of truth or a god of lies. There are many questions that can be asked to achieve this goal. One strategy is to use complex logical connections in the question itself.

Boulos's question: "Does 'da' mean 'yes' if and only if you are a god of truth and god B is a god of chance?". Another version of the question: "Is the number of true statements in the following list odd: you are the god of lies, 'ja' means 'yes', B is the god of chance?"

The solution of the problem can be simplified by using contradictory statements( counterfactuals)[4][5]. The idea of this solution is that for any question Q that requires a 'yes' or 'no' answer, ask the god of truth or the god of lies:

  • If I ask you Q, will you answer "ja"?

The answer is "ja" if the correct answer to Q is "yes", and "da" if the correct answer is "no". To prove this, we can look at the eight possible choices suggested by Boulos himself.

  • Suppose "ja" stands for "yes" and "da" stands for "no":
    • We asked the god of truth and he answered "ja". Since he is telling the truth and the correct answer to Q is "ja", it stands for "yes".
    • We asked the god of truth and he answered "da". Since he speaks the truth and the correct answer to the question Q is "da", it denotes "no".
    • We asked the god of lies and he answered "ja". Since he always lies, therefore the answer to question Q is "da". So the correct answer to the question is "ja", which means "yes".
    • We asked the god of lies and he answered "da". Since he always lies, so to question Q he will answer "ja". So the correct answer to the question is "da", which means "no".
  • Suppose "ja" stands for "no" and "da" stands for "yes":
    • We asked God the truth and he answered "ja". Since he is telling the truth and the correct answer to question Q is "da", it stands for "yes".
    • We asked the god of truth and he answered "da". Since he speaks the truth and the correct answer to the question Q is "ja", it denotes "no".
    • We asked the god of lies and he answered 'ja'. Since he is always lying, therefore the answer to question Q is "ja". But because he lies, the correct answer to question Q is "da", which means "yes".
    • We asked the god of lies and he answered "da". Since he always lies, therefore the answer to question Q is "da". But because he lies, the correct answer to question Q is "ja", which means "no".

Using this fact, we can ask questions:[4]

  • Let's ask god B: "If I ask you "Is god A a god of chance?", will you answer "ja"?". If god B answers "ja", then either he is a god of chance (and answers randomly), or he is not a god of chance, and in fact god A is a god of chance. Either way, god C is not a god of chance. If B answers 'da', then either he is a god of chance (and answers randomly), or B is not a god of chance, which means that god A is also not a god of chance. Either way, god A is not a god of chance.
  • Let's ask a god who is not a god of chance (based on the results of the previous question, either A or C): "If I ask you, 'are you a god of lies?', will you answer 'ja'?" Since he is not a god of chance, the answer "da" denotes that he is a god of truth, and the answer "ja" denotes that he is a god of lies.
  • Let us ask the same god "If I ask you, "God B is a god of chance?", will you answer "ja"?". If the answer is "ja" then god B is a god of chance, if the answer is "da" then the god not yet spoken to is a god of chance.

The remaining god is determined by the method of elimination.

Reason: