Skip to main content
revamped table
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
 length | output structure        | politeness ratio
--------+-------------------------+------------------
    1   | LPTT                    |   1/ 4 = 0.250
    2   | LP-TT                   |   1/ 5 = 0.200 <-- lower bound
    3   | LP-PTT                  |   2/ 6 ≈ 0.333 <-- upper bound
    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  |   61/22 ≈ 0.273
   20   | LP-P---P---P---P---P-TT5 |< r < 61/23 ≈ 0.2613
 length | output structure        | 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
 length | output structure   | politeness ratio
--------+--------------------+------------------
    1   | LPTT               |   1/ 4 = 0.250
    2   | LP-TT              |   1/ 5 = 0.200 <-- lower bound
    3   | LP-PTT             |   2/ 6 ≈ 0.333 <-- upper bound
    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
   ..   | ...                |   1/5 < r < 1/3
minor update
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

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

How?

Starting with i = 0, we insert a PLEASE whenever the following expression is falsy:

This means that we insert a PLEASE on the first character, and then every 4 characters starting with the 3rd one. There is no PLEASE on the leading instruction, nor on the two trailing instructions (marked as L and TT in the following table).

 length | output structure        | 'please' 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

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 polite statement whenever the following expression is falsy:

This means that we insert a PLEASE for the first processed character, and then every 4 characters starting with the 3rd one.

Neither the leading instruction nor on the two trailing instructions are polite. They are marked as L and TT respectively in the following table.

 length | output structure        | 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
saved 8 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

JavaScript (Node.js), 156 156  148 bytes

s=>Buffers=>`DO,1<-#${Buffer(s).map(c=>o+=`${i++&&~i&3?'':'PLEASE'}DO,1SUB#${i}<-#`+(p-(g=k=>p=k--&&c>>k&1|g(k)*2)(8)&255),i=p=0,o="DO,1<-#"+s.lengthi=p=o="")&&o+"DOREADOUT,1DOGIVEUP"i+o}DOREADOUT,1DOGIVEUP`

Try it online!Try it online!

JavaScript (Node.js), 156 bytes

s=>Buffer(s).map(c=>o+=`${i++&&~i&3?'':'PLEASE'}DO,1SUB#${i}<-#`+(p-(g=k=>p=k--&&c>>k&1|g(k)*2)(8)&255),i=p=0,o="DO,1<-#"+s.length)&&o+"DOREADOUT,1DOGIVEUP"

Try it online!

JavaScript (Node.js),  156  148 bytes

s=>`DO,1<-#${Buffer(s).map(c=>o+=`${i++&&~i&3?'':'PLEASE'}DO,1SUB#${i}<-#`+(p-(g=k=>p=k--&&c>>k&1|g(k)*2)(8)&255),i=p=o=""),i+o}DOREADOUT,1DOGIVEUP`

Try it online!

added an explanation
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
back to 156 bytes with the bug fixed differently
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
fixed a bug
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading