| Bytes | Lang | Time | Link |
|---|---|---|---|
| 069 | AWK | 250908T194829Z | xrs |
| 003 | Thunno 2 Ṡ | 230610T165018Z | The Thon |
| 052 | sed | 220306T202520Z | Yelp |
| 166 | C# | 181004T114338Z | Azrael |
| 004 | BQN | 211216T185207Z | DLosc |
| 046 | Factor + grouping.extras | 211216T184953Z | chunes |
| 071 | Mathematica Wolfram Language 71 Characters | 211216T175032Z | Romanp |
| 023 | APOL | 211216T173733Z | Ginger |
| 4642 | JavaScript V8 | 211216T163007Z | Alan Bag |
| 005 | Vyxal | 211123T034218Z | emanresu |
| 034 | JavascriptES6 | 210212T052952Z | emanresu |
| 008 | Burlesque | 200122T154212Z | DeathInc |
| 204 | Kotlin Android | 181004T105517Z | Syed Ham |
| 372 | sed | 181018T090225Z | eush77 |
| 024 | Haskell | 181001T162739Z | ბიმო |
| 081 | Scala | 180924T120514Z | Shikkou |
| 007 | Brachylog | 180926T084641Z | Fatalize |
| 122 | Elixir | 180924T181450Z | DarckBle |
| 070 | Lua | 180924T205147Z | Marcio M |
| 091 | C clang | 180921T174452Z | user3604 |
| 073 | Twig | 180922T125954Z | Ismael M |
| 006 | Pyth | 180920T115627Z | u-ndefin |
| 024 | 16bit x86 assembly code | 180921T175224Z | peter fe |
| 153 | Pepe | 180920T111313Z | u-ndefin |
| 179 | Common Lisp | 180921T011017Z | JRowan |
| 021 | Haskell | 180918T225052Z | nimi |
| 067 | R | 180918T224754Z | Giuseppe |
| 129 | Pascal FPC | 180920T182402Z | AlexRace |
| 013 | K oK | 180920T150125Z | J. Sall& |
| 003 | Stax | 180920T153217Z | wastl |
| 174 | C++ clang | 180920T100530Z | QJot |
| nan | Multi User Forth121 bytes | 180920T085406Z | violet_w |
| 065 | Julia 0.7 | 180919T184224Z | Huanzo |
| 081 | Scala | 180919T213436Z | Ethan |
| 023 | GolfScript | 180920T035904Z | JosiahRy |
| 003 | Jelly | 180919T021215Z | dylnan |
| 038 | q | 180919T205919Z | Thaufeki |
| 006 | MathGolf | 180919T063038Z | Jo King |
| 028 | Attache | 180919T211252Z | Conor O& |
| 048 | Kotlin | 180919T191818Z | snail_ |
| 023 | Perl p | 180918T224016Z | Doorknob |
| 131 | Java | 180919T160005Z | Java Gon |
| 004 | Husk | 180918T234833Z | ბიმო |
| 086 | Python3 | 180919T103058Z | Vedant K |
| 009 | K4 / K oK | 180919T160459Z | mkst |
| 090 | Java JDK 10 | 180919T064951Z | Olivier |
| 4738 | Vim | 180919T114356Z | chambln |
| 058 | Python3 | 180919T132618Z | chambln |
| 090 | C# | 180919T104852Z | LiefdeWe |
| 066 | Red | 180919T091002Z | Galen Iv |
| 032 | Perl 6 | 180918T233111Z | Jo King |
| 097 | Scala | 180919T095350Z | Flo |
| 055 | Python 2 | 180919T095210Z | ElPedro |
| 087 | Kotlin | 180919T094806Z | sp0rk |
| 023 | Powershell | 180919T080034Z | mazzy |
| 016 | MATL | 180918T224326Z | Luis Men |
| 003 | Japt m | 180918T225608Z | Shaggy |
| 024 | Gema | 180919T082853Z | manatwor |
| 006 | Canvas | 180919T081351Z | dzaima |
| 005 | 05AB1E | 180919T061517Z | Emigna |
| 063 | Python 2 | 180919T064042Z | TFeld |
| 033 | JavaScript ES6 | 180918T230032Z | Arnauld |
| 049 | Python 3 | 180919T061025Z | Cameron |
| 033 | JavaScript Node.js | 180919T060443Z | jaytea |
| 064 | C gcc | 180919T055548Z | tsh |
| 042 | Ruby | 180919T055103Z | G B |
| 088 | JavaScript Node.js | 180919T051753Z | user5812 |
| 011 | Pip s | 180919T042400Z | DLosc |
| 009 | APLDyalog | 180919T001523Z | Quintec |
| 056 | brainfuck | 180918T234945Z | Jo King |
| 079 | C gcc | 180919T003739Z | gastropn |
| 014 | Charcoal | 180919T003314Z | Neil |
| 015 | Retina 0.8.2 | 180919T002648Z | Neil |
| 093 | brainfuck | 180918T232922Z | Jonathan |
| 074 | Python 3 | 180918T230839Z | Jo King |
| 094 | C gcc | 180918T230124Z | pizzapan |
AWK, 39 69 bytes
{for(;j++<NF;)for(i=1&&l=length($j);i++<l;)$j=$j substr($j,i,l-i+1)}1
This one works only on a single word:
{for(;i++<length;)x=x substr($0,i)}$0=x
Thunno 2 Ṡ, 3 bytes
€ṣṃ
Input as a list of words. Output as a single string.
Explanation
€ṣṃ # Implicit input
€ṣ # Suffixes of each string in the list
ṃ # Reverse each inner list
# Implicit output, joined
C#, 193 166 bytes
class a{static void Main(string[]b){foreach(var c in b)d(c,0);}static void d(string c,int e){if(e==c.Length)Console.Write(" ");else{Console.Write(c[e++..]);d(c,e);}}}
Since .NET automatically splits the arguments at spaces, it's possible to loop over them without splitting them manually.
Other than that, this uses recursion to subtract one character at a time using the overload of string.Substring that takes only 1 argument which is the index to start at.
BQN, 4 bytes
∾∘↓¨
Anonymous tacit function that takes and returns a list of strings. Run it online!
Explanation
∾∘↓¨
¨ For each element of the list:
↓ Get a list of its suffixes
∘ and
∾ join them into one string
Mathematica (Wolfram Language): 71 Characters
(a=Characters@#;StringJoin@Array[a[[#;;]] &,Length@a])&/@StringSplit[#]&
There pretty much has to be a better solution than this, but it works.
Explanation:
Takes a string and splits on spaces/newlines/punctuation, then iterates over this list. Finds a list of characters of each "word", then uses the Array to take all the elements, then all but the first, and so on. Then, these are joined (taking advantage of the fact that StringJoin ignores nested lists) and the function moves to the next word.
APOL, 23 bytes
ƒ(s(i) j(ƒ(∋ V(⋒ ∈)))))
Explanation
ƒ( List-builder for loop
s( String-split instruction (splits at spaces by default)
i Input
)
j( String join instruction
ƒ( List-builder for loop
∋ For item (the current word being processed)
V( Substring instruction
⋒ For iterator (the thing the current for loop is iterating through, in this case the current word)
∈ For counter
)
)
)
)
Vyxal, 5 bytes
ƛ[Ḣx+
(IMO) this is a really neat recursive solution. Port of my JS answer that came out really nicely.
ƛ # Foreach value as n
[ # If truthy (Not empty string)
x # Call this function (The function we're mapping with)
Ḣ # With n[1:] - remove first character
+ # Appended to the result
The "concatenation of suffixes" approach doesn't do any better:
Vyxal, 5 bytes
ƛṘ¦∑Ṙ
ƛ # Map...
Ṙ # Reverse
¦ # Cumulative sums (prefixes)
∑ # Concatenated
Ṙ # Reversed
Javascript(ES6), 34 bytes
s=>s.map(k=x=>x?x+k(x.slice(1)):x)
Takes input as array of words, returns array of words.
Aaah, the power of recursion...
Kotlin Android, 204 bytes
fun f(s:String){ val a=s.split(" ".toRegex()).dropLastWhile{it.isEmpty()}.toTypedArray();for(i in a.indices){var t=0;while(t<a[i].length){for(j in t until a[i].length){print(a[i][j]+"")};t++};print(" ")}
}
This Program is written in Kotlin Android.
sed, 42 37+2 bytes
s:\b:_:g
:A
s:_(.(\w*_))|__:\1\2:g
tA
Repeatedly match parts of words between underscores:
_hello_ _world_
hello_ello_ world_orld_
helloello_llo_ worldorld_rld_
helloellollo_lo_ worldorldrld_ld_
helloellollolo_o_ worldorldrldld_d_
helloellolloloo__ worldorldrldldd__
helloellolloloo worldorldrldldd
Haskell, 24 bytes
This solution is not optimal in two ways: 1) the other Haskell answer by nimi is 3 bytes shorter and 2) the input is limited to 9223372036854775807 characters (~36 exabytes), though I think it's an interesting find:
map.mconcat$drop<$>[0..]
Try it online! (sets a limit of 255 characters for TIO would time out otherwise)
Explanation
Since drop has type Int -> [a] -> [a] it forces [0..] to be [0..9223372036854775807] which is finite and thus the program terminates (eventually).
And mconcat takes the list of [drop 0, drop 1..] and gives us a function String -> String which is equivalent to:
\str-> drop 0 str ++ drop 1 str ++ .. ++ drop 9223372036854775807 str
Note: Once the argument of drop is greater or equal to the length of str it just appends empty strings.
Practical solution, 40 bytes
This won't take as long as the shorter solution but at a great cost of 16 bytes:
map$mconcat=<<map drop.zipWith pure[0..]
Scala, 81 bytes
def x(l:String):String=if(l=="")" "else l+x(l.tail)
println(args.map(x).mkString)
Brachylog, 7 bytes
{a₁ᶠc}ᵐ
Explanation
{ }ᵐ Map for each word:
a₁ᶠ Find all suffixes
c Concatenate into a single string
Elixir, 122 bytes
a = ["Hello","World"]
f = fn n,f -> if(n != "") do "#{n}#{f.(String.slice(n, 1..-1), f)}" end end
Enum.map(a, &(f.(&1,f)))
# OUTPUT
["Helloellolloloo", "Worldorldrldldd"]
Lua, 70 bytes
for i=1,#arg do x=arg[i]for i=1,#x do io.write(x:sub(i))end print()end
Explanation
The arguments in Lua are stored in the table arg starting at index 1. The unary operator # returns the size of the table and function s:sub(a,b) returns a substring
based on string s delimited by integers a and b, if b is not passed it will return the rest of the string.
I had to use io.write() instead of print() to avoid line breaking, and added print() at the end for the opposite reason.
C (clang), -DT=t=strtok -DZ=" ") 178 113 106 105 95 91 bytes
i;f(*a){char*t;for(T(a,Z;t;printf(Z,T(0,Z)for(i=0;t[i];)printf(t+i++);}
Twig, 73 bytes
Creates a macro with the function f() that receives an array of words, displaying the words separated by new lines.
{%macro f(a)%}{%for v in a%}{%for i in 0..v|length%}{{v[i:]}}{%endfor%}
{%endfor%}{%endmacro%}
To use it, just import:
{% import 'macro.twig' as a %}
{{ a.f(['a','sentence','is','a','list','of','words']) }}
{# to pass a string, you can split it #}
{{ a.f('a sentence is a list of words'|split(' ')) }}
You can try it on https://twigfiddle.com/8xech1
Warning: due to the way that output is handled in the link, I was forced to add a simple period (.) at the end of the line. This is NOT needed for normal operation.
Pyth, 8 6 bytes
m_s.__
Decreased byte(s?) thanks to @Steven H.
Try it online! Input and output are a list.
Expalanation:
- implicit output
m - map function d:
_ - ...d reversed...
._ - ...get all prefixes of it...
_s - ...joined and reversed
- ...over implicit Q (input)
16-bit x86 assembly code, 24 bytes
47 inc di
B020 mov al,20h
l1: 3806 cmp [si],al
7212 jb l5 ;less means end of string
7401 je l2 ;equal means space was seen
4F dec di ;overwrite extra space
l2: E80300 call l3
46 inc si ;move to next character in word
75F1 jne l1
l3: 56 push si
l4: 3806 cmp [si],al
A4 movsb ;copy character
77FB ja l4 ;until either zero or space is seen
5E pop si
l5: C3 ret
Call with si = pointer to source string, di = pointer to output buffer.
The source string requires a zero byte to end it.
The code is the same in 16- or 32- or 64-bit (si/di become either esi/edi or rsi/rdi).
32-bit code is two bytes larger because of the expanded call.
64-bit code is three bytes larger still because the inc/dec of rsi/rdi attracts a prefix (but if it is known that they are within 32-bit memory space, then they can be esi/edi again to avoid that penalty).
Pepe, 167 153 bytes
REEerEeeEeeeeeRrEEEEerEEEEEeerEErEEeerreErEEeErreEREEEEEEEreereErEerEEEErEEeerrEEreRRErEEEEreREEreeereReeRerEEEEEErEEEeerreEerEEeerEEEEerEEeEreereErEeree
Common Lisp, 179 bytes
(defun r(s)(cond((endp s)nil)((eql(first s)#\Space)(princ " ")(r(rest s)))(t(q s)(r(rest s)))))(defun q (l)(cond((eql(first l)#\Space)t)((endp l)t)(t(princ(first l))(q(rest l)))))
This is my first try at golfing any edits are welcome
Haskell, 36 21 bytes
map$concat.scanr(:)""
Edit: -15 bytes, because of new IO format (list of words instead of space separated words)
R, 82 75 67 bytes
write(sapply(x<-scan(,""),substring,1:(y=max(nchar(x))),y),1,y,,"")
Several bytes saved thanks to JayCe
Separates output with newlines.
The sapply(...) expression generates a matrix/column vector of the appropriate substrings, padding with "" as needed. write then prints the elements of the matrix, y per line, separating them with "".
Pascal (FPC), 129 bytes
var s:string;i,j:int32;begin read(s);repeat j:=Pos(' ',s);for i:=1to j do write(s[i..j-1]);write(' ');Delete(s,1,j)until s=''end.
Requires that the input ends in space, allowed in this comment.
K (oK), 17 13 bytes
{,/|:'|,\|x}'
Prefix anonymous function; Input is taken as a list of strings, which in turn are lists of characters.
Thanks @streetster for 4 bytes.
How:
{,/|:'|,\|x}' //Main function, argument x → ("ill";"eel")
' // For each element of the argument
|x} // Flip it. x → ("lli";"lee")
,\ // Concatenate each element, keeping intermediates. x → (("l";"ll";"lli");("l";"le";"lee")
| // Flip it again. x → (("lli";"ll";"l");("lee";"le";"l"))
|:' // Now flip each element. x → (("ill";"ll";"l");("eel";"el";"l"))
{,/ // Concatenation scan. x → ("illlll";"eelell")
Stax, 3 bytes
m|]
Explanation:
m Map over the lines
|] Get all suffixes (suffices?)
Implicit flatten and output
C++ (clang), 174 bytes
#include<map>
#include<string.h>
std::string r(std::string w){while(auto x=strchr(w.c_str(),32))return r(w.substr(0,x-w.c_str()))+" "+r(x+1);return w!=""?w+r(w.substr(1)):w;}
It's my first submission, and i didn't know if returning string instead of printing it is okay :)
Multi User Forth(121 bytes), Protomuck variant.
" " explode_array { swap foreach nip { swap begin dup 1 strcut nip dup not until }cat repeat }list " " array_join .tell
I guess if you want to require that I use entirely standard stuff, then .tell it becomes me @ swap notify which brings it up to 132 bytes. If you want to go the other direction, then I guess that swap could become .s and nip .n, dup .d etc, would turn it into
" " explode_array { .s foreach .n { .s begin .d 1 strcut .n .d not until }cat repeat }list " " array_join .tell
Which has 113 bytes.
Luckily we can continue further, begin turns into .b, until .u and explode_array .e, if we use our thinking caps we can turn foreach into .f by defining that into foreach nip (who needs the index of the array anyway?) and we end at 94 bytes.
" " .e { .s .f { .s begin .d 1 strcut .n .d not until }cat repeat }list " " array_join .tell
But, this is getting silly, and probably only hurting any chance of this being seen as a meaningful first post on codegolf.
Julia 0.7, 75 65 bytes
p(a)=for i in a for j=1:endof(i) print(i[j:end])end;print(" ")end
First codegolf. Yay
v0.7 becase it it just deprecates the endof method and 1.0 replaces it with lastindex.
Update: As mentioned in the comments I am not sure if an array of words as input is permitted. So I included the bytes to take a string as input
Update2: Apparently an array of strings is ok so here we go down to 65 bytes. Thx to @JonathanFrech for removing some more whitespace
Scala, 81 bytes
def e(s:List[String])=s.map(_.foldRight(("","")){(a,b)=>(a+b._1,a+b._1+b._2)}._2)
As per comments, this can receive and output a List[String]. This builds the output from right to left, starting with the rightmost letter, then prepending the two rightmost letters, and so on down the line.
Jelly, 3 bytes
ḊƬ€
Don’t need the Ks anymore since array input/output is now allowed.
ḊƬ€
€ For each word:
Ḋ Remove the first letter
Ƭ until there are none left.
q 78 38 bytes
" "sv{r::x;{x,r::1_r}/[count x;x]}each
MathGolf, 6 bytes
ÆÅ_╞↑
Outputs a trailing space, though you can add another byte to remove this.
Hopefully 6 bytes when implicit input is implemented. Yay.
Explanation:
Implicit input
Æ Implicit for loop over the next 5 instructions
Å ↑ While true without popping (empty string is false)
_╞ Duplicate the top of stack and remove the first letter
(space) Append a space to the stack
Implicitly output the stack joined together
Attache, 28 bytes
Join&sp##Sum@Suffixes=>Split
Alternatives
ReplaceF&(Sum@Suffixes)&/"\\w+" ?? 31 bytes
ReplaceF«_,/"\\w+",Sum@Suffixes» ?? 34 bytes, 32 chars
ReplaceF<~_,/"\\w+",Sum@Suffixes~> ?? 34 bytes
Explanation
Join&sp##Sum@Suffixes=>Split input, e.g.: "abc defg"
Split split the input on spaces
e.g.: ["abc", "defg"]
=> on each word:
e.g.: "abc"
Suffixes take the suffixes of that word
e.g.: ["abc", "bc", "c"]
Sum@ join them together
e.g.: "abcbcc"
## then
Join& join the result by:
sp spaces
Kotlin, 48 bytes
Lambda takes a List<String> as input and returns a List<String> as output, which is allowed. The extra code in the footer is just so the input can be tested easily.
{it.map{it.indices.fold(""){a,v->a+it.drop(v)}}}
Perl -p, 36 25 23 bytes
s!\b|\S!$'=~s/ .*//r!eg
This is a single regsub. First, it matches all word boundaries or non-space characters:
[][H][e][l][l][o] [][W][o][r][l][d]
Note that each of these matches should be replaced with the rest of the word:
[→Hello][H→ello][e→llo][l→lo][l→o][o→] (...)
We can accomplish this with the special variable $', which stores the part of the string after the match. However, we need to apply the nested regsub s/ .*// to it, which removes everything past the first space in $', in order to get rid of the remaining words in the input.
Thanks to @nwellnhof for 2 bytes.
Java, 131 bytes
char[]e(char[]a){int b=0,l=a.length,c,d=0;char[]n=new char[l*(l+1)/2];for(;b<l;b++){for(c=l-b;c>0;c--){n[d]=a[l-c];d++;}}return n;}
I know there is a better Java answer but, wanted to do it just with char arrays
char[] e(char[]a){
int b=0,l=a.length,c,d=0; //l to keep length, b for each iteration, c for each letter in iteration
char[] n= new char[l*(l+1)/2]; //Create new array with length based in triangular number sequence
for(;b<l;b++) {
for(c=l-b;c>0;c--) {
n[d]=a[l-c]; //Fill it
d++; //d keeps position in new array
}
}
return n;
}
Husk, 6 4 bytes
-2 bytes thanks to Jonathan Allan (taking input as a list)!
moΣṫ
Explanation
Takes input as a list of strings and maps the following function:
Σṫ -- example argument: "abc"
ṫ -- tails: ["abc","bc","c"]
Σ -- concat: "abcbcc"
Python3, 86 bytes
Reduced a lot, thanks to @ElPedro and @manatwork
def f(a):return a+f(a[1:])if''<a else''
for x in input().split():print(f(x),end=' ')
P.S. I tried removing split but then nothing is printing, its probably required in python3
K4 / K (oK), 9 bytes
Solution:
,/'(1_)\'
Explanation:
,/'(1_)\' / the solution
' / apply to each
\ / scan
( ) / do this together
1_ / drop first
,/' / flatten (,/) each (')
Java (JDK 10), 90 bytes
s->{var r="";for(var x:s){for(int i=0;i<x.length();)r+=x.substring(i++);r+=" ";}return r;}
Credits
- -11 bytes thanks to Kevin Cruijssen, notifying me of the rule change about the input.
Vim, 47 bytes (38 key strokes)
Start with your input as the sole line in a Vim buffer.
:s/<Space>/\r/g<CR>ggqaywPlxqqb99@aj0q99@bgg99J
Explanation
This puts each word on its own line, iterates over each line, then rejoins them all. Breaks if words are longer than 99 characters or if your input has more than 99 words.
:s/<Space>/\r/g<CR>replaces spaces with new lines (\r)ggpositions the cursor at the beginning of the first lineqabegins recording macro a:ywyanks the rest of the wordPputs it behind the cursorlxremoves the first letter of the latter wordqstops recording macro a
qbbegins recording macro b:99@aexecutes macro a ninety-nine times (introduces the character limit)j0positions the cursor at the start of the next lineqstops recording macro b
99@bexecutes macro b ninety-nine times (introduces the word limit)ggpositions the cursor at the first line99Jjoins the following ninety-nine lines with spaces (word limit again)
For another 2 bytes (2 key strokes) you could extend the word limit to 999. Another 4 bytes, 9999, etc.
Python3, 58 bytes
Takes a space-separated string of words from stdin and returns stdout likewise.
f=lambda x:x and x+f(x[1:])
print(*map(f,input().split()))
It works by splitting the string into a list of words and using map() to call the recursive function f on each element. Honestly, I don't know exactly how f works. When the stack reaches the end of the word, x becomes the empty string (''), so the and statement returns False, which I suspect acts as the base case to end recursion.
Here's the same idea but without the functional aspects:
def f(x):
return x and x + f(x[1:])
print(*( f(word) for word in input().split() ))
C#, 111 90 bytes
b=>string.Join(" ",(b.Split(' ').Select(x=>string.Concat(x.Select((y, i)=>x.Substring(i))))))
By Changing input and output to arrays, I saved a few bytes:
b=>b.Select(x=>string.Concat(x.Select((y,i)=>x.Substring(i)))).ToArray()
Perl 6, 44 32 bytes
-12 bytes thanks to nwellnhof!
~*.words>>.&{[~] $_,{S/.//}...0}
An anonymous Whatever lambda that takes a string and returns a string.
Explanation:
*.words # Split the given word by spaces
>>.&{ } # Map each word to
... # A list composed of
$_ # The initial string
,{S/.//} # Remove the first character
0 # Until it's empty
[~] # All joined together
~ # Convert the list to a string, which joins by spaces
Scala, 97 bytes
Scala main that takes a single String argument containing all the words.
args(0).split(" ").foreach(x=>{for(i<-0 to x.length)print(x.substring(i,x.length));print(" ")})
Python 2, 55 bytes
for x in input():
y=""
while x:y+=x;x=x[1:]
print y,
Takes input as a list. output is separated by spaces.
Kotlin, 87 bytes
fun f(s:String):String=if(s=="")s else s.split(" ").joinToString(" "){it+f(it.drop(1))}
Powershell, 29 23 bytes
Port of Javascript by @Arnauld
$args-replace'.',"$&$'"
Input and output are a list of word. Test script:
$f = {
$args-replace'.',"$&$'"
}
@(
,('illlll eelell', 'ill','eel')
,('laserasersererr batatt', 'laser','bat')
,('dartharthrththh vaderaderdererr', 'darth','vader')
) | % {
$e,$s = $_
$r = &$f @s
$r = "$r"
"$($r-eq$e): $r"
}
Output:
True: illlll eelell
True: laserasersererr batatt
True: dartharthrththh vaderaderdererr
MATL, 18 16 bytes
"@gXH"HX@Jh)]0&h
Input is a cell array of words. Try it online!
Explanation
" % Implicit input: cell array of strings. For each cell
@g % Push content of current cell, that is, a word
XH % Copy into clipboard H
" % For each letter
H % Push word
X@ % Push iteration index
Jh) % Index from that until the end into current word
] % End
0 % Push 0. Will be cast to char. Char(0) is displayed as space
&h % Concatenate horizontally all elements so far. Implicit display
Japt -m, 6 3 bytes
Input and output are arrays of words.
£sY
Explanation
:For each word in the input array
£ :Map each letter at index Y
sY : Slice the current word from index Y
Gema, 24 characters
<L>=@x{$0}
x:?*=?*@x{$2}
Sample run:
bash-4.4$ gema '<L>=@x{$0};x:?*=?*@x{$2}' <<< 'darth vader'
dartharthrththh vaderaderdererr
JavaScript (ES6), 33 bytes
Saved 1 byte thanks to @ShieruAsakoto
I/O format: array of words.
a=>a.map(g=w=>w&&w+g(w.slice(1)))
JavaScript (ES6), 35 bytes
I/O format: array of words.
a=>a.map(w=>w.replace(/./g,"$&$'"))
Python 3, 49 bytes
d=lambda s:' '.join(n+d(n[1:])for n in s.split())
This takes advantage of the fact that "".split() returns an empty array so that acts as the check for the base case in the recursion.
JavaScript (Node.js), 33 bytes
s=>s.replace(/\B(?=(\S+))/g,"$1")
I don't really know JavaScript, but I just copied Arnauld's syntax with an idea I had for the regex substitution :P
C (gcc), 64 bytes
f(s,t)char*s,*t;{for(;*s;t+=*s<33)for(strcpy(t,s++);*t&31;t++);}
Take two char* parameters: The first one for input, and the second one for output. The caller is responsible for malloc and free. Like most string functions in C, this one is designed to be vulnerable by overflow the buffer.
JavaScript (Node.js), 88 bytes
f=s=>s.split(' ').map(e=>[...e].map((_,i,a)=>a.slice(i,a.length).join``).join``).join` `
Pip -s, 11 bytes
J_@>,#_Mq^s
Takes the space-separated list of words from stdin. Try it online!
Explanation
s is space (implicit)
q Read a line of stdin
^s Split it on spaces
M Map this lambda function to each word:
_ The word...
@> sliced starting at index...
,#_ range(len(word))
This creates len(word) slices ["word" "ord" "rd" "d"]
J Join those into a single string
The resulting list of modified words is printed; the -s flag uses space
as the separator
APL(Dyalog), 19 9 bytes
{⌽∊,\⌽⍵}¨
thanks to @H.PWiz for jogging my brain
This works because all strings in APL are character arrays.
{⌽∊,\⌽⍵}¨
¨ - for each string
⍵} - string argument - ex. "hello"
⌽ - reverse - "olleh"
,\ - scan magic - "o" "ol" "oll" "olle" "olleh"
∊ - enlist(join together) "oolollolleolleh"
{⌽ - reverse - "helloellolloloo"
brainfuck, 60 56 bytes
,[>++++++++[-<----<++++>>]<[>>]<[[<]>.[[-]>[.>]<[<]>]],]
Requires a trailing space and prints a leading space. Both of these could be circumvented, but that ends up at 112 bytes.
Explanation
,[ Loop over each byte of input
Tape: 32 w o r-32 d'
>++++++++[-<----<++++>>] Subtract 32 from the character and add 32 to the previous char
Tape: 32 w o r d-32 0'
<[>>]< If the last character was a space
Tape: 32 w o r d-32 0'
or
Tape: 32 w o r d' space-32
[
[<]>. Move to the end of the word and print out the space
[ Loop over each letter
[-] Remove the first letter (initially space)
>[.>] Print the rest of the word
<[<]> Move back to the first letter
]
Tape: clear
]
,] Get the next byte of input
C (gcc), 79 bytes
f(s,t)char*s,*t;{for(;*s;printf("%.*s",*s^32?t?t-s:~0:1,s),s++)t=strchr(s,32);}
Charcoal, 14 bytes
⪫E⪪S ⭆ι✂ιμLι¹
Try it online! Note: Trailing space. Link is to verbose version of code. Explanation:
S Input string
⪪ Split on spaces
E Map over each word
ι Current word
⭆ Map over each character and join
ι Current word
μ Current index
ι Current word
L Length
¹ Literal 1
✂ Slice
⪫ Join with spaces
Implicitly print
Retina 0.8.2, 15 bytes
¶
.
$&$%'
¶
Try it online! Note: trailing spaces. Explanation:
¶
Split on spaces.
.
$&$%'
Append its suffix to each letter. The % means that we only get the word's suffix.
¶
Join with spaces.
brainfuck, 94 93 bytes
-[-[-<]>>+<]>-<<+[[[-]<,[->+>+<<]>[-<+>]>>[-<->>+<]<]<<[>>+<<[-]]<[<]>[[.>]<[<]>[-]>]>>>>.<<]
- Saved one byte thanks to Nitrodon -- golfing
.[-]>[.>]<[<]>to[.>]<[<]>[-]>.
Explanation
[[[ (dynamic) tape layout: ... NUL STR ... STR CHR FLG BUF SPC NUL ... ]]]
load a 32 into SPC
-[-[-<]>>+<]>-
while FLG
<<+[
read a word
[
clear FLG; read CHR
[-]<,
copy CHR to BUF (using FLG as a temporary)
[->+>+<<]>[-<+>]
subtract SPC from BUF and save SPC
>>[-<->>+<]
move tape layout one to the right
<
]
strip trailing space; set FLG to true
<< [>>+<<[-]]
to STR's first character
<[<]>
print word in all reduced forms
[
[.>]<[<]>[-]>
]
print SPC; move to FLG
>>>>.<<
]
Attribution
Esolang's brainfuck constant collection was used for the initial space load.
Python 3, 79 74 bytes
-5 bytes thanks to mypetlion
print(*map(lambda x:''.join(x[n:]for n in range(len(x))),input().split()))
A full program that takes input from stdin and outputs to stdout.
C (gcc), 94 bytes
f(char*s){char*e=s+strlen(s),*i=s;for(;i<e;*i++=*i-32?*i:0);for(i=s;i<e;i++)printf(*i?i:" ");}
Saves a pointer to the end of the string in char *e, then replaces spaces with null characters, then prints the string starting with each character and ending at the next null character, but printing a space if the current character is a null character.