05AB1E, 77 74 74 54 bytes
0V‘‚µ‘©IÇv¼®¾4%3÷׫Yy₁+b¦RCDV-₁%¾‘DOÇ₁+₁šb퀨C¥(₁%€‘‚µ,1—¨#ÿ<1<-#ÿ‘«}¾‘DO#1€·,1<1—¨#1<-#ÿÿ€·‚Ø€Ä#ÿ€·‚Ø€Ä,1€·†¿€¾1‘J‘ÿ€·†¿€¾
Port of-20 bytes by porting @Lynn's Python answer@UnrelatedString's Jelly answer, so make sure to upvote him/her as well!!
Outputs with spaces at #1 DO,1 SUBSUB#
and, DO READ OUT,1
, and DO GIVE UP
.
Try it onlineTry it online or verify a few more test casesverify a few more test cases.
Try the output in INTERCAL.Try the output in INTERCAL.
0V # Set variable `Y` to 0 (it's 2 by default)
‘‚µ‘ # Push dictionary string "PLEASE"
Ç © # Store it in variableConvert `®`the (without poppingimplicit)
IÇ # Push the input, and convert it-string to a list of codepoint integers
v # Loop over each integer `y`:
¼ # Increment the counter_variable (0 by default)
¾ # Push the counter_variable
4% # Modulo-4
3÷ # Integer-divided by 3
® × # Repeat "PLEASE" from variable `®` that many times
₁+ « # AppendAdd it256 to theeach stringvalue
Y ₁š # Push the current `Y`
y #Prepend 256 Pushat the current codepoint
₁+ # Increasefront itof bythe 256list
b # Convert iteach value to a binary string
¦ í # Remove the leading 1 (the `₁+` and `¦` are to pad leadingReverse 0s)each
۬ R # Remove the #last digit Reverseof iteach
C # Convert iteach from binary back to a base-10 integer
DV ¥ # Store aTake copythe asforward newdifferences value(deltas) forof variablethis `Y`list
- ( # Subtract it from the `Y` we'veNegate pushedeach earlierdifference
₁% # Take Modulomodulo-256
on ¾each
€ # Map Pushover theeach counter_variableinteger:
‘DO‘‚µ,1—¨#ÿ<1<-#ÿ‘ # Push dictionary string "DO#1€·,1 SUB#ÿ<1—¨#1<-#ÿ"#ÿ€·‚Ø€Ä, where the `ÿ` are 1‘
# automaticallyPush filleddictionary withstring the"PLEASE,1<-#1 counter_variableDO,1 andSUB#1<-#ÿ `Y`%256
DO READ OUT",
« # Append it towhere the string`ÿ` asis well
}¾automatically filled with the integer
J # After the# loop:Join pushthis thelist counter_variable
of strings ‘DO,1<-#ÿÿ€·‚Ø€Ä,1€·†¿€¾together
‘ÿ€·†¿€¾ # Push dictionary string "DO,1<-#ÿÿ DO READ OUT,1"ÿ DO GIVE UP", where
# the `ÿ` are`y` automaticallyis filled with the counter_variable and
# string
# (after which the result is output implicitly)
See this 05AB1E tip of mine (section How to use the dictionary?) to understand why ‘‚µ‘
is "PLEASE"
; ‘DO‘‚µ,1—¨#ÿ<1<-#ÿ‘#1€·,1—¨#1<-#ÿ€·‚Ø€Ä,1‘
is "DO"PLEASE,1<-#1 DO,1 SUB#ÿ<SUB#1<-#ÿ"#ÿ DO READ OUT"
; and ‘DO,1<-#ÿÿ€·‚Ø€Ä,1€·†¿€¾‘ÿ€·†¿€¾
is "DO,1<-#ÿÿ DO READ OUT,1"ÿ DO GIVE UP"
.