| Bytes | Lang | Time | Link |
|---|---|---|---|
| 126 | Raku Perl 6 rakudo | 241211T164234Z | xrs |
| 127 | AWK | 250421T152501Z | xrs |
| 168 | Python 3 | 241221T022257Z | a random |
| 221 | Wolfram Language Mathematica | 241220T142629Z | Introduc |
| 089 | C clang | 241210T135333Z | jdt |
| 135 | sed r | 241210T230648Z | Jan Blum |
| 049 | Uiua | 241210T091014Z | bb94 |
| 189 | Setanta | 241210T084652Z | bb94 |
| 067 | Perl 5 p | 241209T200440Z | Xcali |
| 107 | APL+WIN | 241209T163602Z | Graham |
| 040 | Japt v2.0a0 | 241208T214742Z | Shaggy |
| 035 | 05AB1E | 241209T091342Z | Kevin Cr |
| 098 | JavaScript Node.js | 241209T001806Z | Arnauld |
| 032 | Vyxal | 241209T004007Z | emanresu |
| 100 | JavaScript Node.js | 241209T000152Z | l4m2 |
| 046 | Charcoal | 241208T220856Z | Neil |
| 072 | Retina | 241208T215034Z | Neil |
| 042 | Jelly | 241208T213456Z | Jonathan |
Raku (Perl 6) (rakudo), 142 126 bytes
my@c='allworkandnoplaymakesjackadullboy'.comb;say @*ARGS.comb.map({/[A..Za..z]/??($_ eq .uc??@c.shift.uc!!@c.shift)!!$_}).join
Note that this doesn't appear to work in ATO or TIO.
my @c='allworkandnoplaymakesjackadullboy'.comb; # split into array
my @s=@*ARGS.comb; # input into array
@s.=map({ # for each element
$_~~/\w/ # if it's a alpha character
??($_ eq .uc # if uppercase
??@c.shift.uc # pop character and uppercase
!!@c.shift.lc) # pop character and lowercase
!!$_}); # if not alpha, copy char
say @s.join; # prettier print
AWK, 127 bytes
{for(split("allworkandnonplaymakesjackadullboy",s,X);i<=NF;i++)printf $i~/[A-Za-z]/?$i~/[A-Z]/?toupper(s[x++%26]):s[x++%26]:$i}
{for( # loop and special sentence
split("allworkandnonplaymakesjackadullboy"
,s,X); # split at each char into array s
i<=NF; # go through all chars of input
i++) # inc
printf $i~/[A-Za-z]/? # if char is letter
$i~/[A-Z]/? # if uppercase
toupper(s[x++%26]): # uppercase from special string
s[x++%26]: # keep lowercase
$i} # or alternate not letter char
Python 3, 168 bytes
x=''
c=0
s='allworkandnoplaymakesjackadullboy'
for i in input():x+=i if not i.isalpha()else s[c%33]if i.islower()else s[c%33].upper();c+=1 if i.isalpha()else 0
print(x)
more readable:
x=''
c=0
s='allworkandnoplaymakesjackadullboy'
for i in input():
x+=i if not i.isalpha()else s[c%33]if i.islower()else s[c%33].upper()
c+=1if i.isalpha()else 0
print(x)
explanation: (scroll to the right)
x=''
c=0
s='allworkandnoplaymakesjackadullboy'
for i in input():
x+=i if not i.isalpha()else s[c%33]if i.islower()else s[c%33].upper()
c+=1if i.isalpha()else 0
print(x)
x='' # init solution variable
c=0 # init counter
s='allworkandnoplaymakesjackadullboy' # the string to convert into
for i in input(): # loop around input
x+=i # add current char to x as is
if not i.isalpha() # if the current character is not a letter
else s[c%33] # otherwise add the c'th value of the string to x
if i.islower() # if the current character is lowercase
else s[c%33].upper() # or add the uppercase c'th value of the string to x (only other case)
c+=1if i.isalpha()else 0 # if the current character is a letter, increment c
print(x) # output x
💎
Created with the help of Luminespire.
(noob solution, hopefully it's not that bad)
Wolfram Language (Mathematica), 221 bytes 229 bytes
(w=#~StringCases~LetterCharacter;j=1;StringJoin[If[LetterQ@#,#/.Thread[w->MapThread[If[#2,ToUpperCase@#,#]&,{Characters@StringTake["allworkandnoplaymakesjackadullboy",Length@w],UpperCaseQ/@w}]][[j++]],#]&/@Characters@#])&
C (clang), 91 89 bytes
i;f(*s){for(i=0;*s++=isalpha(*s)?"ALLWORKANDNOPLAYMAKESJACKADULLBOY"[i++%33]|*s&32:*s;);}
- -2 bytes thanks to WeirdGlyphs
sed -r, 135 bytes
Needs to be run with LC_COLLATE=C to make sure that the range expression [A-Z] actually means "uppercase letters".
The script of 135 bytes (TIO link) is pure ASCII, and contains four different non-printable control characters; these are visually represented by Ø, ø, ¦, and ™ in the listing below (the latter being encoding-dependent, and possibly longer than one byte).
s/[A-Z]/Ø/g
s/[a-z]/ø/g
:1
/¦y/!s/$/¦yoblludakcajsekamyalpondnakrowlla/
s/(Ø|ø)(.+)(.)$/\1™\3\2/
s/Ø™(.)/\u\1/
s/ø™(.)/\l\1/
t1
s/¦.*//
Try it online! (Wrapped in bash to force the C locale)
Setanta, 189 bytes
gniomh(s){t:=""j:=0le i idir(0,fad@s){i=s[i]ma'@'<i&i<'[' t+="ALLWORKANDNOPLAYMAKESJACKADULLBOY"[j]no ma'`'<i&i<'{' t+="allworkandnoplaymakesjackadullboy"[j]no{j-=1t+=i}j=(j+1)%33}toradh t}
Perl 5 -p, 67 bytes
s,\pL,($&&$")|(ALLWORKANDNOPLAYMAKESJACKADULLBOY=~/./g)[$i++%33],ge
APL+WIN, 107 bytes
Prompts for string.
⎕av[(48×j)+(v×i=0)+i←i\(+/i←((v>17)^v<44)∨j←(v>65)^(v←⎕av⍳⎕)<92)⍴s←⎕av⍳'allworkandnoplaymakesjackadullboy']
Japt v2.0a0, 40 bytes
r\l@T°g`a¥wŽk„dnoplayµkƒjàÚÍé¾y`c^H*Xè\A
r\l@T°g`...`c^H*Xè\A :Implicit input of string
r :Replace
\l :RegEx /[a-z]/gi
@ :Pass each match X through the following function
T° : Postfix increment T (initially 0)
g : 0-based index into
`...` : Compressed string "allworkandnoplaymakesjackadullboy"
c : Map charcodes
^ : Bitwise XOR with
H : 32
* : Multiplied by
Xè : Count the occurrences in X of
\A : RegEx /[A-Z]/
05AB1E, 35 bytes
εDai’€Ÿ‚Ÿ€ƒ€¸†•ŠŽ—Éadullíå’¾è¼s.uiu
Output as a list of characters.
Try it online or verify all test cases.
Explanation:
ε # Map over each character of the (implicit) input:
D # Duplicate the current character
ai # Pop the copy, and if it's a letter:
’€Ÿ‚Ÿ€ƒ€¸†•ŠŽ—Éadullíå’
# Push dictionary string "allworkandnoplaymakesjackadullboy"
¾è # Get the 0-based `¾`'th character from this string (starts at 0)
¼ # Then increase `¾` by 1 for the next iteration
s # Swap so the current letter is at the top again
.ui # Pop, and if it's uppercase:
u # Uppercase the indexed letter as well
# (implicit else: leave it lowercase)
# (implicit else: use the current duplicated character instead)
# (after which the resulting character-list is output implicitly)
See this 05AB1E tip of mine (section How to use the dictionary?) to understand why ’€Ÿ‚Ÿ€ƒ€¸†•ŠŽ—Éadullíå’ is "allworkandnoplaymakesjackadullboy" (although a compressed string .•1Á› Aƶ5~]ô/;ÖYµ¯?*mò• is apparently the exact same length in this case: try it online.)
JavaScript (Node.js), 98 bytes
-2 thanks to @l4m2
Expects and returns a string.
s=>(B=Buffer)(s).map(c=>(c-65&95)<26?B("ALLWORKANDNOPLAYMAKESJACKADULLBOY")[i++%33]|c&32:c,i=0)+""
JavaScript (Node.js), 88 bytes
Expects and returns a buffer.
a=>a.map(c=>(c-65&95)<26?Buffer("ALLWORKANDNOPLAYMAKESJACKADULLBOY")[i++%33]|c&32:c,i=0)
Vyxal, 32 bytes
fǍT≬L`λæƛ¢an∩„∨¯»¦¢₴a∩‛l½ė`Ẏ¢∑?•
f # Convert to a list of chars
T # And find the indices where
Ǎ # Removing non-letters yields a truthy string i.e. char is letter
≬-------¢ # Apply the following to the values at those indices, together:
Ẏ # Take the first
L # (length of values) characters, wrapping as necessary, of
`...` # compressed string "allworkandnoplaymakesjackadullboy"
∑ # Concatenate
?• # And transfer the case of the input.
JavaScript (Node.js), 100 bytes
x=>x.replace(/[a-z]/gi,c=>c<{t:t='allworkandnoplaymakesjackadullboy'[i++%33]}?t.toUpperCase():t,i=0)
Charcoal, 46 bytes
⭆S⎇№α↥ι⭆§”&⌊⊟“⬤T>τïL⦄⁻!ζPA;>εü⌈≔”L⊞Oυω⎇№αι↥λλι
Try it online! Link is to verbose version of code. Explanation:
S Input string
⭆ Map over characters and join
α Predefined variable uppercase alphabet
№ Contains
ι Current character
↥ Uppercased
⎇ If true then
”...” 1-indexed phrase
§ Indexed by
ω Empty string
⊞O Pushed to
υ Predefined variable empty list
L Take the length
⭆ Map over character
α Predefined variable uppercase alphabet
№ Contains
ι Outer character
⎇ If true then
λ Inner character
↥ Uppercased
λ Otherwise inner character
ι Otherwise outer character
Implicitly print
Retina, 72 bytes
T`l`\o
[A-Z]
Ao
Y`o`a\l\l\workan\dn-p\laymakesjacka\du\l\lboy
T`Al`_L`A.
Try it online! Link includes test cases. Explanation:
T`l`\o
Change all lowercase letters to os. o has to be quoted because it's magic and I don't want it to be magic here. (l is also magic but that's deliberate.)
[A-Z]
Ao
Change all uppercase letters to Aos.
Y`o`a\l\l\workan\dn-p\laymakesjacka\du\l\lboy
Cyclically transliterate as to the given phrase. d, l, o, p and w are normally magic and have to be quoted, but fortunately I get to use n-p in place of no\p, and o isn't magic when it appears on both sides.
T`Al`_L`A.
Capitalise letters following As, deleting those As.
Jelly, 42 bytes
nŒsÄị“ṢhqQẋøḤ×HßżṘĊo6.Ṿ§@Þƒ»a@Ʋo⁸Œu⁸=ŒuT¤¦
A monadic Link that accepts the clue as a list of characters and yields the encrypted clue as a list of characters.
How?
nŒsÄị“...»a@Ʋo⁸Œu⁸=ŒuT¤¦ - Link: list of characters, Clue
Œs - swap case {Clue}
n - {Clue} not equal {that} (vectorises) -> isLetterVector
Ʋ - last four links as a monad - f(isLetterVector):
Ä - cumulative sums
“...» - "allworkandnoplaymakesjackadullboy"
ị - {CumSums} index into {that} (modular) (vectorises)
a@ - {isLetterVector} logical AND {that} (vectorises)
o⁸ - logical OR {Clue} (vectorises)
¦ - sparse application...
¤ - ...to indices: nilad followed by links as a nilad:
⁸ - Clue
Œu - {Clue} to uppercase
= - equal? (vectorises)
T - truthy indices
Œu - ...apply: uppercase