How?
How?Bit reversal
We use a recursive function to reverse the bits of the character c.
( g = k => // k = bit position counter
k-- && // decrement k; if it was not 0:
c >> k & 1 // bring the k-th bit of c at position 0 and isolate it
| g(k) // bitwise OR with a recursive call,
* 2 // whose result is doubled
)(8) // initial call with k = 8
Politeness
Starting with i = 0
, we insert a PLEASEpolite statement whenever the following expression is falsy:
This means that we insert a PLEASE onPLEASE
for the first processed character, and then every 4 characters starting with the 3rd one. There is no PLEASE on
Neither the leading instruction, nor on the two trailing instructions (markedare polite. They are marked as L
and TT
respectively in the following table).
length | output structure | 'please'politeness ratio
--------+-------------------------+------------------
1 | LPTT | 1/ 4 = 0.250
2 | LP-TT | 1/ 5 = 0.200
3 | LP-PTT | 2/ 6 ≈ 0.333
4 | LP-P-TT | 2/ 7 ≈ 0.286
5 | LP-P--TT | 2/ 8 = 0.250
6 | LP-P---TT | 2/ 9 ≈ 0.222
7 | LP-P---PTT | 3/10 = 0.300
8 | LP-P---P-TT | 3/11 ≈ 0.273
9 | LP-P---P--TT | 3/12 = 0.250
10 | LP-P---P---TT | 3/13 ≈ 0.231
11 | LP-P---P---PTT | 4/14 ≈ 0.286
12 | LP-P---P---P-TT | 4/15 ≈ 0.267
13 | LP-P---P---P--TT | 4/16 = 0.250
14 | LP-P---P---P---TT | 4/17 ≈ 0.235
15 | LP-P---P---P---PTT | 5/18 ≈ 0.278
16 | LP-P---P---P---P-TT | 5/19 ≈ 0.263
17 | LP-P---P---P---P--TT | 5/20 = 0.250
18 | LP-P---P---P---P---TT | 5/21 ≈ 0.238
19 | LP-P---P---P---P---PTT | 6/22 ≈ 0.273
20 | LP-P---P---P---P---P-TT | 6/23 ≈ 0.261