The mirror number $$\overset\leftrightarrow{n}$$ of a number $$n \in \mathbb{N}$$ is obtained by putting the digits of $$n$$ in reverse order. For example, the mirror number of 1234 is 4321.
The $$i$$-reduction $$n_i$$ ($$i = 0, 1, \ldots, m - 1$$) of an $$m$$-digit number $$n \in \mathbb{N}$$ ($$n \geq 10$$, $$m \geq 2$$) is obtained by discarding the digit at position $$i$$ in $$n$$. Positions of digits in $$n$$ are numbered from left to right starting at zero. For example, the 2-reduction of 12345 is 1245.
De catch $$\mathcal{C}(n)$$ of an $$m$$-digit number $$n \in \mathbb{N}$$ ($$n \geq 10$$, $$m \geq 2$$) is computed by adding all $$i$$-reductions $$n_i$$ and all mirror numbers $$\overset\leftrightarrow{n_i}$$ of the $$i$$-reductions ($$i = 0, 1, \ldots, m - 1$$), and dividing this result by the sum of the $$m$$ digits in $$n$$. For example, the catch of 27847 is \[ \mathcal{C}(27847) = \frac{54197}{28} = 1935.607142857143 \] The numerator of this fraction is computed as:
$$i$$ | $$n_i$$ | $$\overset\leftrightarrow{n_i}$$ | $$n_i + \overset\leftrightarrow{n_i}$$ |
---|---|---|---|
0 | 7847 | 7487 | 15334 |
1 | 2847 | 7482 | 10329 |
2 | 2747 | 7472 | 10219 |
3 | 2787 | 7872 | 10659 |
4 | 2784 | 4872 | 7656 |
numerator: | 54197 |
Write a function mirror_number that takes a number $$n \in \mathbb{N}$$ (int) and returns its mirror number $$\overset\leftrightarrow{n}$$ (int).
Write a function reduction that takes two arguments: i) an $$m$$-digit number $$n \in \mathbb{N}$$ ($$n \geq 10$$, $$m \geq 2$$) and ii) the position $$i$$ (int; $$0 \leq i < m$$) of a digit in $$n$$. The function must return the $$i$$-reduction $$n_i$$.
Write a function numerator that takes an $$m$$-digit number $$n \in \mathbb{N}$$ ($$n \geq 10$$, $$m \geq 2$$) and returns the numerator (int) of the fraction to compute the catch $$\mathcal{C}(n)$$: the sum of all $$i$$-reductions $$n_i$$ and all mirror numbers $$\overset\leftrightarrow{n_i}$$ of the $$i$$-reductions for $$i = 0, 1, \ldots, m - 1$$.
Write a function denominator that takes an $$m$$-digit number $$n \in \mathbb{N}$$ ($$n \geq 10$$, $$m \geq 2$$) and returns the denominator (int) of the fraction to compute the catch $$\mathcal{C}(n)$$: the sum of the $$m$$ digits in $$n$$.
Write a function catch that takes an $$m$$-digit number $$n \in \mathbb{N}$$ ($$n \geq 10$$, $$m \geq 2$$) and returns its catch $$\mathcal{C}(n)$$ (float).
>>> mirror_number(7847)
7487
>>> mirror_number(37865)
56873
>>> reduction(27847, 0)
7847
>>> reduction(27847, 1)
2847
>>> reduction(27847, 2)
2747
>>> numerator(27847)
54197
>>> numerator(937865)
865739
>>> denominator(27847)
28
>>> denominator(937865)
38
>>> catch(27847)
1935.607142857143
>>> catch(937865)
22782.605263157893
Pick a three-digit number in which all the digits are different. Example: 314. Now list every possible combination of two digits from the chosen number. In our example, these are 13, 14, 31, 34, 41 and 43. Divide the sum of these two-digit numbers by the sum of the three digits in the original number. Note that for a three-digit number $$n$$ this is the calculation for its catch $$\mathcal{C}(n)$$. Whatever three-digit number you choose, the catch is always 22. In our example: \[ \mathcal{C}(314) = \frac{13 + 14 + 31 + 34 + 41 + 43}{3 + 1 + 4} = \frac{176}{8} = 22 \] This happens because for a three-digit number $$abc$$ we have that $$10a + b$$, $$10a + c$$, $$10b + a$$, $$10b + c$$, $$10c + a$$ and $$10c + b$$ sum to $$22a + 22b + 22c = 22(a + b + c)$$, so dividing by $$a + b + c$$ will always give 22.
A catch-22 is a paradoxical situation in which it impossible to achieve a desired outcome because of contradictions in the "rules". The term was coined by Joseph Heller1, who used it in his 1961 novel Catch-222 to describe a general situation in which an individual must accomplish two actions that are mutually dependent on the other action being completed first.
An example of such a situation occurs when looking for a job, where a catch-22 happens when one cannot get a job without work experience, but one cannot get work experience without a job. A catch-22 somewhat resembles a vicious cycle. However, a catch-22 involves a continuation of the status quo, whereas a vicious cycle usually leads to deterioration.