Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

3 of 7
added 417 characters in body
Sumner18
  • 1.9k
  • 10
  • 20

R, 86 bytes

x=utf8ToInt(scan(,''));s=sapply;cat(gsub(" .+"," ",s(s(x,`:`,97),intToUtf8)),sep="\n")

Ungolfed:

x=utf8ToInt(scan(,'')) #Takes input, converts to ASCII
s=sapply; #Alias sapply function to save a byte
 s(x,`:`,97) #Create vector from 97 to respective ASCII value
 s( ,intToUtf8) #Convert to character
 gsub(" .+"," ", ) #Removes everything after space
cat( ,sep="\n") #Outputs to console

Try it online!

Could likely be golfed.

NOTE: It does not use recursion. I do not know whether that would be shorter or not. I'll experiment later.

R, 80 bytes by Giuseppe

L=letters;for(l in el(strsplit(scan(,''),"")))cat(L[match(l,L,0):0],'\n',sep="")

Try it online!

Sumner18
  • 1.9k
  • 10
  • 20

AltStyle によって変換されたページ (->オリジナル) /