It took me a lot of time to make this, pls like. (YouTube Comments #1)crossed out 44 is still regular 44...
Python Pandas - difference between 'loc' and 'where'?
How to not let the Identify spell spoil everything?
Scripture(s) saying not to look at the sun during his rising and setting time
Why does photorec keep finding files after I have filled the disk free space as root?
Can I announce prefix 161.117.25.0/24 even though I don't have all of /24 IPs?
How would an AI self awareness kill switch work?
How to make ice magic work from a scientific point of view?
Airplane generations - how does it work?
Citing paywalled articles accessed via illegal web sharing
When can a QA tester start his job?
How to deal with possible delayed baggage?
How can a large fleets maintain formation in interstellar space?
Salsa20 Implementation: Sum of 2 Words with Carries Suppressed
Clues on how to solve these types of problems within 2-3 minutes for competitive exams
If I delete my routers history can my ISP still provide it to my parents?
How much mayhem could I cause as a sentient fish?
Alien invasion to probe us, why?
Why was Lupin comfortable with saying Voldemort's name?
Move fast ...... Or you will lose
Should I reinstall Linux when changing the laptop's CPU?
How do you catch Smeargle in Pokemon Go?
Line of Bones to Travel and Conform to Curve (Like Train on a Track, Snake...)
Cat is tipping over bed-side lamps during the night
What is a good reason for every spaceship to carry a weapon on board?
It took me a lot of time to make this, pls like. (YouTube Comments #1)
crossed out 44 is still regular 44 ;(Interpret /// (pronounced 'slashes')Do you want to code a snowman?Generate fractals from bit patterns in ASCII“Hello world” that creates a different “Hello world” programCount common Game of Life patternsGeneralization of abbreviationsDraw an indexed fractalIs my emoji dry?Figure Out the Android Lock PatternOne more LUL and I'm out
$begingroup$
Hold up..... this isn't trolling.
Background
These days on YouTube, comment sections are littered with such patterns:
S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S
where String
is a mere placeholder and refers to any combination of characters. These patterns are usually accompanied by a It took me a lot of time to make this, pls like
or something, and often the OP succeeds in amassing a number of likes.
The Task
Although you've got a great talent of accumulating upvotes on PPCG with your charming golfing skills, you're definitely not the top choice for making witty remarks or referencing memes in YouTube comment sections. Thus, your constructive comments made with deliberate thought amass a few to no 'likes' on YouTube. You want this to change. So, you resort to making the abovementioned clichéd patterns to achieve your ultimate ambition, but without wasting any time trying to manually write them.
Simply put, your task is to take a string, say s
, and output 2*s.length - 1
substrings of s, delimited by a newline, so as to comply with the following pattern:
(for s
= "Hello")
H
He
Hel
Hell
Hello
Hell
Hel
He
H
Input
A single string s
. Input defaults of the community apply.
Output
Several lines separated by a newline, constituting an appropriate pattern as explained above. Output defaults of the community apply.
Test Case
A multi-word test case:
Input => "Oh yeah yeah"
Output =>
O
Oh
Oh
Oh y
Oh ye
Oh yea
Oh yeah
Oh yeah
Oh yeah y
Oh yeah ye
Oh yeah yea
Oh yeah yeah
Oh yeah yea
Oh yeah ye
Oh yeah y
Oh yeah
Oh yeah
Oh yea
Oh ye
Oh y
Oh
Oh
O
Note that there are apparent distortions in the above test case's output's shape (for instance, line 1 and line 2 of the output appear the same). Those are because we can't see the trailing whitespaces. Your program need NOT to try to fix these distortions.
Winning Criterion
This is code-golf, so the shortest code in bytes in each language wins!
code-golf string ascii-art
$endgroup$
add a comment |
$begingroup$
Hold up..... this isn't trolling.
Background
These days on YouTube, comment sections are littered with such patterns:
S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S
where String
is a mere placeholder and refers to any combination of characters. These patterns are usually accompanied by a It took me a lot of time to make this, pls like
or something, and often the OP succeeds in amassing a number of likes.
The Task
Although you've got a great talent of accumulating upvotes on PPCG with your charming golfing skills, you're definitely not the top choice for making witty remarks or referencing memes in YouTube comment sections. Thus, your constructive comments made with deliberate thought amass a few to no 'likes' on YouTube. You want this to change. So, you resort to making the abovementioned clichéd patterns to achieve your ultimate ambition, but without wasting any time trying to manually write them.
Simply put, your task is to take a string, say s
, and output 2*s.length - 1
substrings of s, delimited by a newline, so as to comply with the following pattern:
(for s
= "Hello")
H
He
Hel
Hell
Hello
Hell
Hel
He
H
Input
A single string s
. Input defaults of the community apply.
Output
Several lines separated by a newline, constituting an appropriate pattern as explained above. Output defaults of the community apply.
Test Case
A multi-word test case:
Input => "Oh yeah yeah"
Output =>
O
Oh
Oh
Oh y
Oh ye
Oh yea
Oh yeah
Oh yeah
Oh yeah y
Oh yeah ye
Oh yeah yea
Oh yeah yeah
Oh yeah yea
Oh yeah ye
Oh yeah y
Oh yeah
Oh yeah
Oh yea
Oh ye
Oh y
Oh
Oh
O
Note that there are apparent distortions in the above test case's output's shape (for instance, line 1 and line 2 of the output appear the same). Those are because we can't see the trailing whitespaces. Your program need NOT to try to fix these distortions.
Winning Criterion
This is code-golf, so the shortest code in bytes in each language wins!
code-golf string ascii-art
$endgroup$
2
$begingroup$
I am planning to make some more YouTube comments related challenges in the future; hence theYouTube Comments #1
in the title.
$endgroup$
– Arjun
4 hours ago
1
$begingroup$
Is returning a array of lines allowed?
$endgroup$
– someone
4 hours ago
$begingroup$
@someone Yes, it is allowed, in accordance with standard I/O defaults
$endgroup$
– Arjun
4 hours ago
$begingroup$
Can we take input as an array of characters and return an array of arrays of characters?
$endgroup$
– Shaggy
3 hours ago
add a comment |
$begingroup$
Hold up..... this isn't trolling.
Background
These days on YouTube, comment sections are littered with such patterns:
S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S
where String
is a mere placeholder and refers to any combination of characters. These patterns are usually accompanied by a It took me a lot of time to make this, pls like
or something, and often the OP succeeds in amassing a number of likes.
The Task
Although you've got a great talent of accumulating upvotes on PPCG with your charming golfing skills, you're definitely not the top choice for making witty remarks or referencing memes in YouTube comment sections. Thus, your constructive comments made with deliberate thought amass a few to no 'likes' on YouTube. You want this to change. So, you resort to making the abovementioned clichéd patterns to achieve your ultimate ambition, but without wasting any time trying to manually write them.
Simply put, your task is to take a string, say s
, and output 2*s.length - 1
substrings of s, delimited by a newline, so as to comply with the following pattern:
(for s
= "Hello")
H
He
Hel
Hell
Hello
Hell
Hel
He
H
Input
A single string s
. Input defaults of the community apply.
Output
Several lines separated by a newline, constituting an appropriate pattern as explained above. Output defaults of the community apply.
Test Case
A multi-word test case:
Input => "Oh yeah yeah"
Output =>
O
Oh
Oh
Oh y
Oh ye
Oh yea
Oh yeah
Oh yeah
Oh yeah y
Oh yeah ye
Oh yeah yea
Oh yeah yeah
Oh yeah yea
Oh yeah ye
Oh yeah y
Oh yeah
Oh yeah
Oh yea
Oh ye
Oh y
Oh
Oh
O
Note that there are apparent distortions in the above test case's output's shape (for instance, line 1 and line 2 of the output appear the same). Those are because we can't see the trailing whitespaces. Your program need NOT to try to fix these distortions.
Winning Criterion
This is code-golf, so the shortest code in bytes in each language wins!
code-golf string ascii-art
$endgroup$
Hold up..... this isn't trolling.
Background
These days on YouTube, comment sections are littered with such patterns:
S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S
where String
is a mere placeholder and refers to any combination of characters. These patterns are usually accompanied by a It took me a lot of time to make this, pls like
or something, and often the OP succeeds in amassing a number of likes.
The Task
Although you've got a great talent of accumulating upvotes on PPCG with your charming golfing skills, you're definitely not the top choice for making witty remarks or referencing memes in YouTube comment sections. Thus, your constructive comments made with deliberate thought amass a few to no 'likes' on YouTube. You want this to change. So, you resort to making the abovementioned clichéd patterns to achieve your ultimate ambition, but without wasting any time trying to manually write them.
Simply put, your task is to take a string, say s
, and output 2*s.length - 1
substrings of s, delimited by a newline, so as to comply with the following pattern:
(for s
= "Hello")
H
He
Hel
Hell
Hello
Hell
Hel
He
H
Input
A single string s
. Input defaults of the community apply.
Output
Several lines separated by a newline, constituting an appropriate pattern as explained above. Output defaults of the community apply.
Test Case
A multi-word test case:
Input => "Oh yeah yeah"
Output =>
O
Oh
Oh
Oh y
Oh ye
Oh yea
Oh yeah
Oh yeah
Oh yeah y
Oh yeah ye
Oh yeah yea
Oh yeah yeah
Oh yeah yea
Oh yeah ye
Oh yeah y
Oh yeah
Oh yeah
Oh yea
Oh ye
Oh y
Oh
Oh
O
Note that there are apparent distortions in the above test case's output's shape (for instance, line 1 and line 2 of the output appear the same). Those are because we can't see the trailing whitespaces. Your program need NOT to try to fix these distortions.
Winning Criterion
This is code-golf, so the shortest code in bytes in each language wins!
code-golf string ascii-art
code-golf string ascii-art
edited 4 hours ago
Arjun
asked 4 hours ago
ArjunArjun
2,6791451
2,6791451
2
$begingroup$
I am planning to make some more YouTube comments related challenges in the future; hence theYouTube Comments #1
in the title.
$endgroup$
– Arjun
4 hours ago
1
$begingroup$
Is returning a array of lines allowed?
$endgroup$
– someone
4 hours ago
$begingroup$
@someone Yes, it is allowed, in accordance with standard I/O defaults
$endgroup$
– Arjun
4 hours ago
$begingroup$
Can we take input as an array of characters and return an array of arrays of characters?
$endgroup$
– Shaggy
3 hours ago
add a comment |
2
$begingroup$
I am planning to make some more YouTube comments related challenges in the future; hence theYouTube Comments #1
in the title.
$endgroup$
– Arjun
4 hours ago
1
$begingroup$
Is returning a array of lines allowed?
$endgroup$
– someone
4 hours ago
$begingroup$
@someone Yes, it is allowed, in accordance with standard I/O defaults
$endgroup$
– Arjun
4 hours ago
$begingroup$
Can we take input as an array of characters and return an array of arrays of characters?
$endgroup$
– Shaggy
3 hours ago
2
2
$begingroup$
I am planning to make some more YouTube comments related challenges in the future; hence the
YouTube Comments #1
in the title.$endgroup$
– Arjun
4 hours ago
$begingroup$
I am planning to make some more YouTube comments related challenges in the future; hence the
YouTube Comments #1
in the title.$endgroup$
– Arjun
4 hours ago
1
1
$begingroup$
Is returning a array of lines allowed?
$endgroup$
– someone
4 hours ago
$begingroup$
Is returning a array of lines allowed?
$endgroup$
– someone
4 hours ago
$begingroup$
@someone Yes, it is allowed, in accordance with standard I/O defaults
$endgroup$
– Arjun
4 hours ago
$begingroup$
@someone Yes, it is allowed, in accordance with standard I/O defaults
$endgroup$
– Arjun
4 hours ago
$begingroup$
Can we take input as an array of characters and return an array of arrays of characters?
$endgroup$
– Shaggy
3 hours ago
$begingroup$
Can we take input as an array of characters and return an array of arrays of characters?
$endgroup$
– Shaggy
3 hours ago
add a comment |
25 Answers
25
active
oldest
votes
$begingroup$
JavaScript (ES6), 36 bytes
f=([c,...r],s=`
`)=>c?s+f(r,s+c)+s:s
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 2, 60 52 bytes
f=lambda s,n=1:s[n:]and[s[:n]]+f(s,n+1)+[s[:n]]or[s]
Try it online!
Python 3.8 (pre-release), 50 bytes
f=lambda s,n=1:s>(x:=s[:n])and[x,*f(s,n+1),x]or[s]
Try it online!
$endgroup$
add a comment |
$begingroup$
Perl 6, 31 bytes
{[~](@_)[0...@_-1...0]}o*.comb
Try it online!
Anonymous code block that takes a string and returns a list of lines.
$endgroup$
add a comment |
$begingroup$
05AB1E (legacy), 4 3 bytes
Crossed out 4
is no longer 4 :)
η.∊
Try it online or verify all test cases.
Explanation:
η # Get the prefixes of the (implicit) input-string
.∊ # Vertically mirror everything with the last line overlapping
# (which implicitly joins by newlines in the legacy version of 05AB1E)
# (and output the result implicitly)
In the new version of 05AB1E, and explicit »
is required after the η
, which is why I use the legacy version of 05AB1E here to save a byte.
$endgroup$
add a comment |
$begingroup$
Japt, 9 7 bytes
-2 bytes thanks to Shaggy
Êõ@¯XÃê
Try it online!
$endgroup$
$begingroup$
7 bytes
$endgroup$
– Shaggy
3 hours ago
1
$begingroup$
@Shaggy oh wait...Ã
is a thing
$endgroup$
– ASCII-only
3 hours ago
$begingroup$
Another 300 rep on its way as soon as this question is eligible for a bounty.
$endgroup$
– Shaggy
2 hours ago
1
$begingroup$
5 bytes? (different approach)
$endgroup$
– Quintec
1 hour ago
$begingroup$
@Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
$endgroup$
– Shaggy
38 mins ago
|
show 1 more comment
$begingroup$
C# (Visual C# Interactive Compiler), 123 109 94 84 74 bytes
Assumes we can return a char array array (I believe we can, as a char array is a valid representation for a string and a string array is a valid representation for multiple lines)
a=>new int[a.Length*2-1].Select((b,i)=>a.SkipLast(Math.Abs(a.Length-i-1)))
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (Node.js), 90 bytes
This can probably be golfed alot more, Arnauld already has a way shorter one but I had fun atleast!
s=>{a=[];for(c=s.length-1;c--;)a[c]=s.slice(0,c+1);return[...a,s,...a.reverse()].join`n`}
Try it online!
$endgroup$
add a comment |
$begingroup$
Japt -R, 4 bytes
å+ ê
Cumulative reduce on a string.
-1 byte thanks to @Shaggy
Try it online!
$endgroup$
$begingroup$
Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
$endgroup$
– Flying Thunder
18 mins ago
$begingroup$
@FlyingThunder Be a skeptic no more :) see here
$endgroup$
– Quintec
5 mins ago
add a comment |
$begingroup$
C (gcc), 68 67 bytes
i,j,t;f(char*s){for(;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}
Try it online!
$endgroup$
add a comment |
$begingroup$
MATL, 8 bytes
nZv"G@:)
Try it online!
Please like this post for the smiley :)
in the code it took me a lot of time to make.
n % Length of the input string
Zv % Symmetric range ([1 2 ... n ... 1])
" % For each k in above range
G % Push input
@: % Push [1 2 ... k]
) % Index
$endgroup$
add a comment |
$begingroup$
APL (Dyalog Unicode), 9 bytesSBCS
Anonymous tacit prefix function. Returns list of strings.
(⊢,1↓⌽),
Try it online!
,
the list of prefixes (lit, the cumulative concatenation)
(
…)
apply the following function to that list:
⌽
the reversed list
1↓
drop the first item
,
prepend
⊢
the unmodified list
$endgroup$
add a comment |
$begingroup$
Charcoal, 5 bytes
G^Lθθ
Try it online! Link is to verbose version of code. Explanation: G
draws a filled polygon, ^
specifies that the sides are down right and down left (the polygon then automatically closes itself), Lθ
specifies the length of those sides as being the length of the original input and the final θ
specifies the fill string.
$endgroup$
add a comment |
$begingroup$
Perl 5 (-p
), 26 bytes
s,.,$=$`.$/.$;"$`$&
",ge
TIO
$endgroup$
$begingroup$
Nice! But that adds an extra blank line after printing the full string, right?
$endgroup$
– terdon
1 hour ago
add a comment |
$begingroup$
Ruby, 51 42 40 bytes
f=->s,i=1{s[i]?[t=s[0,i],*f[s,i+1],t]:s}
Try it online!
Thanks to Doorknob for -2 bytes.
$endgroup$
1
$begingroup$
You can save 2 bytes by replacing...
with,
$endgroup$
– Doorknob♦
1 hour ago
add a comment |
$begingroup$
J, 11 bytes
Anonymous tacit prefix function. Returns a space-padded character matrix.
[:(}:,|.)]
Try it online!
]
the list of prefixes
[:(
…)
apply the following function to that list
|.
the reverse list
,
prepended with
}:
the curtailed (without last item) list
$endgroup$
2
$begingroup$
[:(
and}:,|
look so sad…
$endgroup$
– Adám
3 hours ago
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 82 bytes
x=>{int l=x.Length,i=0;for(;i<l*2-1;)WriteLine(x.Substring(0,l-Math.Abs(++i-l)));}
Try it online!
String as input and output to std
$endgroup$
add a comment |
$begingroup$
J, 12 bytes
],[:}.@|.]
Try it online!
Still 1 byte longer than Adám's
Initial solution:
J, 17 16 bytes
{."{~#-|@i:@<:@#
Try it online!
An example REPL session:
# 'String'
6
i:#'String'
_6 _5 _4 _3 _2 _1 0 1 2 3 4 5 6
i:<:#'String'
_5 _4 _3 _2 _1 0 1 2 3 4 5
|i:<:#'String'
5 4 3 2 1 0 1 2 3 4 5
(#'String')-|i:<:#'String'
1 2 3 4 5 6 5 4 3 2 1
'String'{."0 1~(#'String')-|i:<:#'String'
S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S
$endgroup$
1
$begingroup$
Did I outgolf the master‽
$endgroup$
– Adám
3 hours ago
$begingroup$
@Adám I'm far from being a J master :) There are many J coders here better than I am.
$endgroup$
– Galen Ivanov
3 hours ago
add a comment |
$begingroup$
Julia, 44 bytes
s->(a=cumprod([s...]);[a;reverse(a)[2:end]])
Try it online!
Gets the first half by taking the cumulative product (*
is string concatenation in Julia) of the array of characters, then adds this array to itself reversed minus the first element.
$endgroup$
add a comment |
$begingroup$
Octave, 58 bytes
for k=1:(n=nnz(s=input(''))*2)-1
disp(s(1:min(k,n-k)))
end
Try it online!
$endgroup$
add a comment |
$begingroup$
Red, 78 bytes
func[s][repeat n l: length? s[print copy/part s n]loop l[take/last s print s]]
Try it online!
$endgroup$
add a comment |
$begingroup$
Brachylog, 8 bytes
a₀ᶠ;Lc.↔
Try it online!
Explanation
a₀ᶠ Find all prefixes of the input
;Lc. The output is that list of prefixes with something unknown appended at the end
.↔ The output reversed is itself (i.e. it's a palindrome)
$endgroup$
add a comment |
$begingroup$
R, 86 bytes
x=utf8ToInt(scan(,''))
for(i in c(y<-1:sum(x|1),rev(y)[-1]))cat(intToUtf8(x[1:i]),"
")
Try it online!
I'm learning more and more about better ways to manipulate strings in R, so I'm somewhat proud of this answer. The only part I don't like is the for loop portion, which I feel could definitely be golfed.
$endgroup$
add a comment |
$begingroup$
MBASIC, 103 bytes
1 INPUT S$:N=1
2 PRINT LEFT$(S$,N):IF N<LEN(S$) THEN N=N+1:GOTO 2
3 N=N-1:PRINT LEFT$(S$,N):IF N>1 THEN 3
$endgroup$
add a comment |
$begingroup$
PowerShell, 89 bytes
param($a)0..($d=$a.Length-1)|%{[string[]]$b+=,$a[0..$_]};($c=$b-replace' ')+$c[($d-1)..0]
Try it online!
$endgroup$
add a comment |
$begingroup$
Pyke, 6 bytes
BE 27 4F 5F 2B 58
Try it here!
- input() (implicit)
.> - prefixes(^) (1 byte)
'O_ - ^[:-1], reversed(^)
+ - [^]
X - "n".join(reversed(^))
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f180509%2fit-took-me-a-lot-of-time-to-make-this-pls-like-youtube-comments-1%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
25 Answers
25
active
oldest
votes
25 Answers
25
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
JavaScript (ES6), 36 bytes
f=([c,...r],s=`
`)=>c?s+f(r,s+c)+s:s
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (ES6), 36 bytes
f=([c,...r],s=`
`)=>c?s+f(r,s+c)+s:s
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (ES6), 36 bytes
f=([c,...r],s=`
`)=>c?s+f(r,s+c)+s:s
Try it online!
$endgroup$
JavaScript (ES6), 36 bytes
f=([c,...r],s=`
`)=>c?s+f(r,s+c)+s:s
Try it online!
answered 4 hours ago
ArnauldArnauld
77k693323
77k693323
add a comment |
add a comment |
$begingroup$
Python 2, 60 52 bytes
f=lambda s,n=1:s[n:]and[s[:n]]+f(s,n+1)+[s[:n]]or[s]
Try it online!
Python 3.8 (pre-release), 50 bytes
f=lambda s,n=1:s>(x:=s[:n])and[x,*f(s,n+1),x]or[s]
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 2, 60 52 bytes
f=lambda s,n=1:s[n:]and[s[:n]]+f(s,n+1)+[s[:n]]or[s]
Try it online!
Python 3.8 (pre-release), 50 bytes
f=lambda s,n=1:s>(x:=s[:n])and[x,*f(s,n+1),x]or[s]
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 2, 60 52 bytes
f=lambda s,n=1:s[n:]and[s[:n]]+f(s,n+1)+[s[:n]]or[s]
Try it online!
Python 3.8 (pre-release), 50 bytes
f=lambda s,n=1:s>(x:=s[:n])and[x,*f(s,n+1),x]or[s]
Try it online!
$endgroup$
Python 2, 60 52 bytes
f=lambda s,n=1:s[n:]and[s[:n]]+f(s,n+1)+[s[:n]]or[s]
Try it online!
Python 3.8 (pre-release), 50 bytes
f=lambda s,n=1:s>(x:=s[:n])and[x,*f(s,n+1),x]or[s]
Try it online!
edited 4 hours ago
answered 4 hours ago
TFeldTFeld
15.3k21245
15.3k21245
add a comment |
add a comment |
$begingroup$
Perl 6, 31 bytes
{[~](@_)[0...@_-1...0]}o*.comb
Try it online!
Anonymous code block that takes a string and returns a list of lines.
$endgroup$
add a comment |
$begingroup$
Perl 6, 31 bytes
{[~](@_)[0...@_-1...0]}o*.comb
Try it online!
Anonymous code block that takes a string and returns a list of lines.
$endgroup$
add a comment |
$begingroup$
Perl 6, 31 bytes
{[~](@_)[0...@_-1...0]}o*.comb
Try it online!
Anonymous code block that takes a string and returns a list of lines.
$endgroup$
Perl 6, 31 bytes
{[~](@_)[0...@_-1...0]}o*.comb
Try it online!
Anonymous code block that takes a string and returns a list of lines.
edited 4 hours ago
answered 4 hours ago
Jo KingJo King
23.8k257123
23.8k257123
add a comment |
add a comment |
$begingroup$
05AB1E (legacy), 4 3 bytes
Crossed out 4
is no longer 4 :)
η.∊
Try it online or verify all test cases.
Explanation:
η # Get the prefixes of the (implicit) input-string
.∊ # Vertically mirror everything with the last line overlapping
# (which implicitly joins by newlines in the legacy version of 05AB1E)
# (and output the result implicitly)
In the new version of 05AB1E, and explicit »
is required after the η
, which is why I use the legacy version of 05AB1E here to save a byte.
$endgroup$
add a comment |
$begingroup$
05AB1E (legacy), 4 3 bytes
Crossed out 4
is no longer 4 :)
η.∊
Try it online or verify all test cases.
Explanation:
η # Get the prefixes of the (implicit) input-string
.∊ # Vertically mirror everything with the last line overlapping
# (which implicitly joins by newlines in the legacy version of 05AB1E)
# (and output the result implicitly)
In the new version of 05AB1E, and explicit »
is required after the η
, which is why I use the legacy version of 05AB1E here to save a byte.
$endgroup$
add a comment |
$begingroup$
05AB1E (legacy), 4 3 bytes
Crossed out 4
is no longer 4 :)
η.∊
Try it online or verify all test cases.
Explanation:
η # Get the prefixes of the (implicit) input-string
.∊ # Vertically mirror everything with the last line overlapping
# (which implicitly joins by newlines in the legacy version of 05AB1E)
# (and output the result implicitly)
In the new version of 05AB1E, and explicit »
is required after the η
, which is why I use the legacy version of 05AB1E here to save a byte.
$endgroup$
05AB1E (legacy), 4 3 bytes
Crossed out 4
is no longer 4 :)
η.∊
Try it online or verify all test cases.
Explanation:
η # Get the prefixes of the (implicit) input-string
.∊ # Vertically mirror everything with the last line overlapping
# (which implicitly joins by newlines in the legacy version of 05AB1E)
# (and output the result implicitly)
In the new version of 05AB1E, and explicit »
is required after the η
, which is why I use the legacy version of 05AB1E here to save a byte.
edited 4 hours ago
answered 4 hours ago
Kevin CruijssenKevin Cruijssen
38.8k557200
38.8k557200
add a comment |
add a comment |
$begingroup$
Japt, 9 7 bytes
-2 bytes thanks to Shaggy
Êõ@¯XÃê
Try it online!
$endgroup$
$begingroup$
7 bytes
$endgroup$
– Shaggy
3 hours ago
1
$begingroup$
@Shaggy oh wait...Ã
is a thing
$endgroup$
– ASCII-only
3 hours ago
$begingroup$
Another 300 rep on its way as soon as this question is eligible for a bounty.
$endgroup$
– Shaggy
2 hours ago
1
$begingroup$
5 bytes? (different approach)
$endgroup$
– Quintec
1 hour ago
$begingroup$
@Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
$endgroup$
– Shaggy
38 mins ago
|
show 1 more comment
$begingroup$
Japt, 9 7 bytes
-2 bytes thanks to Shaggy
Êõ@¯XÃê
Try it online!
$endgroup$
$begingroup$
7 bytes
$endgroup$
– Shaggy
3 hours ago
1
$begingroup$
@Shaggy oh wait...Ã
is a thing
$endgroup$
– ASCII-only
3 hours ago
$begingroup$
Another 300 rep on its way as soon as this question is eligible for a bounty.
$endgroup$
– Shaggy
2 hours ago
1
$begingroup$
5 bytes? (different approach)
$endgroup$
– Quintec
1 hour ago
$begingroup$
@Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
$endgroup$
– Shaggy
38 mins ago
|
show 1 more comment
$begingroup$
Japt, 9 7 bytes
-2 bytes thanks to Shaggy
Êõ@¯XÃê
Try it online!
$endgroup$
Japt, 9 7 bytes
-2 bytes thanks to Shaggy
Êõ@¯XÃê
Try it online!
edited 3 hours ago
answered 4 hours ago
ASCII-onlyASCII-only
3,8201236
3,8201236
$begingroup$
7 bytes
$endgroup$
– Shaggy
3 hours ago
1
$begingroup$
@Shaggy oh wait...Ã
is a thing
$endgroup$
– ASCII-only
3 hours ago
$begingroup$
Another 300 rep on its way as soon as this question is eligible for a bounty.
$endgroup$
– Shaggy
2 hours ago
1
$begingroup$
5 bytes? (different approach)
$endgroup$
– Quintec
1 hour ago
$begingroup$
@Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
$endgroup$
– Shaggy
38 mins ago
|
show 1 more comment
$begingroup$
7 bytes
$endgroup$
– Shaggy
3 hours ago
1
$begingroup$
@Shaggy oh wait...Ã
is a thing
$endgroup$
– ASCII-only
3 hours ago
$begingroup$
Another 300 rep on its way as soon as this question is eligible for a bounty.
$endgroup$
– Shaggy
2 hours ago
1
$begingroup$
5 bytes? (different approach)
$endgroup$
– Quintec
1 hour ago
$begingroup$
@Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
$endgroup$
– Shaggy
38 mins ago
$begingroup$
7 bytes
$endgroup$
– Shaggy
3 hours ago
$begingroup$
7 bytes
$endgroup$
– Shaggy
3 hours ago
1
1
$begingroup$
@Shaggy oh wait...
Ã
is a thing$endgroup$
– ASCII-only
3 hours ago
$begingroup$
@Shaggy oh wait...
Ã
is a thing$endgroup$
– ASCII-only
3 hours ago
$begingroup$
Another 300 rep on its way as soon as this question is eligible for a bounty.
$endgroup$
– Shaggy
2 hours ago
$begingroup$
Another 300 rep on its way as soon as this question is eligible for a bounty.
$endgroup$
– Shaggy
2 hours ago
1
1
$begingroup$
5 bytes? (different approach)
$endgroup$
– Quintec
1 hour ago
$begingroup$
5 bytes? (different approach)
$endgroup$
– Quintec
1 hour ago
$begingroup$
@Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
$endgroup$
– Shaggy
38 mins ago
$begingroup$
@Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
$endgroup$
– Shaggy
38 mins ago
|
show 1 more comment
$begingroup$
C# (Visual C# Interactive Compiler), 123 109 94 84 74 bytes
Assumes we can return a char array array (I believe we can, as a char array is a valid representation for a string and a string array is a valid representation for multiple lines)
a=>new int[a.Length*2-1].Select((b,i)=>a.SkipLast(Math.Abs(a.Length-i-1)))
Try it online!
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 123 109 94 84 74 bytes
Assumes we can return a char array array (I believe we can, as a char array is a valid representation for a string and a string array is a valid representation for multiple lines)
a=>new int[a.Length*2-1].Select((b,i)=>a.SkipLast(Math.Abs(a.Length-i-1)))
Try it online!
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 123 109 94 84 74 bytes
Assumes we can return a char array array (I believe we can, as a char array is a valid representation for a string and a string array is a valid representation for multiple lines)
a=>new int[a.Length*2-1].Select((b,i)=>a.SkipLast(Math.Abs(a.Length-i-1)))
Try it online!
$endgroup$
C# (Visual C# Interactive Compiler), 123 109 94 84 74 bytes
Assumes we can return a char array array (I believe we can, as a char array is a valid representation for a string and a string array is a valid representation for multiple lines)
a=>new int[a.Length*2-1].Select((b,i)=>a.SkipLast(Math.Abs(a.Length-i-1)))
Try it online!
edited 2 hours ago
answered 4 hours ago
someonesomeone
522416
522416
add a comment |
add a comment |
$begingroup$
JavaScript (Node.js), 90 bytes
This can probably be golfed alot more, Arnauld already has a way shorter one but I had fun atleast!
s=>{a=[];for(c=s.length-1;c--;)a[c]=s.slice(0,c+1);return[...a,s,...a.reverse()].join`n`}
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (Node.js), 90 bytes
This can probably be golfed alot more, Arnauld already has a way shorter one but I had fun atleast!
s=>{a=[];for(c=s.length-1;c--;)a[c]=s.slice(0,c+1);return[...a,s,...a.reverse()].join`n`}
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (Node.js), 90 bytes
This can probably be golfed alot more, Arnauld already has a way shorter one but I had fun atleast!
s=>{a=[];for(c=s.length-1;c--;)a[c]=s.slice(0,c+1);return[...a,s,...a.reverse()].join`n`}
Try it online!
$endgroup$
JavaScript (Node.js), 90 bytes
This can probably be golfed alot more, Arnauld already has a way shorter one but I had fun atleast!
s=>{a=[];for(c=s.length-1;c--;)a[c]=s.slice(0,c+1);return[...a,s,...a.reverse()].join`n`}
Try it online!
answered 53 mins ago
T. DirksT. Dirks
1665
1665
add a comment |
add a comment |
$begingroup$
Japt -R, 4 bytes
å+ ê
Cumulative reduce on a string.
-1 byte thanks to @Shaggy
Try it online!
$endgroup$
$begingroup$
Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
$endgroup$
– Flying Thunder
18 mins ago
$begingroup$
@FlyingThunder Be a skeptic no more :) see here
$endgroup$
– Quintec
5 mins ago
add a comment |
$begingroup$
Japt -R, 4 bytes
å+ ê
Cumulative reduce on a string.
-1 byte thanks to @Shaggy
Try it online!
$endgroup$
$begingroup$
Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
$endgroup$
– Flying Thunder
18 mins ago
$begingroup$
@FlyingThunder Be a skeptic no more :) see here
$endgroup$
– Quintec
5 mins ago
add a comment |
$begingroup$
Japt -R, 4 bytes
å+ ê
Cumulative reduce on a string.
-1 byte thanks to @Shaggy
Try it online!
$endgroup$
Japt -R, 4 bytes
å+ ê
Cumulative reduce on a string.
-1 byte thanks to @Shaggy
Try it online!
edited 5 mins ago
answered 36 mins ago
QuintecQuintec
1,6181723
1,6181723
$begingroup$
Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
$endgroup$
– Flying Thunder
18 mins ago
$begingroup$
@FlyingThunder Be a skeptic no more :) see here
$endgroup$
– Quintec
5 mins ago
add a comment |
$begingroup$
Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
$endgroup$
– Flying Thunder
18 mins ago
$begingroup$
@FlyingThunder Be a skeptic no more :) see here
$endgroup$
– Quintec
5 mins ago
$begingroup$
Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
$endgroup$
– Flying Thunder
18 mins ago
$begingroup$
Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
$endgroup$
– Flying Thunder
18 mins ago
$begingroup$
@FlyingThunder Be a skeptic no more :) see here
$endgroup$
– Quintec
5 mins ago
$begingroup$
@FlyingThunder Be a skeptic no more :) see here
$endgroup$
– Quintec
5 mins ago
add a comment |
$begingroup$
C (gcc), 68 67 bytes
i,j,t;f(char*s){for(;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}
Try it online!
$endgroup$
add a comment |
$begingroup$
C (gcc), 68 67 bytes
i,j,t;f(char*s){for(;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}
Try it online!
$endgroup$
add a comment |
$begingroup$
C (gcc), 68 67 bytes
i,j,t;f(char*s){for(;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}
Try it online!
$endgroup$
C (gcc), 68 67 bytes
i,j,t;f(char*s){for(;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}
Try it online!
edited 4 hours ago
answered 4 hours ago
jaeyong sungjaeyong sung
896
896
add a comment |
add a comment |
$begingroup$
MATL, 8 bytes
nZv"G@:)
Try it online!
Please like this post for the smiley :)
in the code it took me a lot of time to make.
n % Length of the input string
Zv % Symmetric range ([1 2 ... n ... 1])
" % For each k in above range
G % Push input
@: % Push [1 2 ... k]
) % Index
$endgroup$
add a comment |
$begingroup$
MATL, 8 bytes
nZv"G@:)
Try it online!
Please like this post for the smiley :)
in the code it took me a lot of time to make.
n % Length of the input string
Zv % Symmetric range ([1 2 ... n ... 1])
" % For each k in above range
G % Push input
@: % Push [1 2 ... k]
) % Index
$endgroup$
add a comment |
$begingroup$
MATL, 8 bytes
nZv"G@:)
Try it online!
Please like this post for the smiley :)
in the code it took me a lot of time to make.
n % Length of the input string
Zv % Symmetric range ([1 2 ... n ... 1])
" % For each k in above range
G % Push input
@: % Push [1 2 ... k]
) % Index
$endgroup$
MATL, 8 bytes
nZv"G@:)
Try it online!
Please like this post for the smiley :)
in the code it took me a lot of time to make.
n % Length of the input string
Zv % Symmetric range ([1 2 ... n ... 1])
" % For each k in above range
G % Push input
@: % Push [1 2 ... k]
) % Index
answered 2 hours ago
SanchisesSanchises
5,98712351
5,98712351
add a comment |
add a comment |
$begingroup$
APL (Dyalog Unicode), 9 bytesSBCS
Anonymous tacit prefix function. Returns list of strings.
(⊢,1↓⌽),
Try it online!
,
the list of prefixes (lit, the cumulative concatenation)
(
…)
apply the following function to that list:
⌽
the reversed list
1↓
drop the first item
,
prepend
⊢
the unmodified list
$endgroup$
add a comment |
$begingroup$
APL (Dyalog Unicode), 9 bytesSBCS
Anonymous tacit prefix function. Returns list of strings.
(⊢,1↓⌽),
Try it online!
,
the list of prefixes (lit, the cumulative concatenation)
(
…)
apply the following function to that list:
⌽
the reversed list
1↓
drop the first item
,
prepend
⊢
the unmodified list
$endgroup$
add a comment |
$begingroup$
APL (Dyalog Unicode), 9 bytesSBCS
Anonymous tacit prefix function. Returns list of strings.
(⊢,1↓⌽),
Try it online!
,
the list of prefixes (lit, the cumulative concatenation)
(
…)
apply the following function to that list:
⌽
the reversed list
1↓
drop the first item
,
prepend
⊢
the unmodified list
$endgroup$
APL (Dyalog Unicode), 9 bytesSBCS
Anonymous tacit prefix function. Returns list of strings.
(⊢,1↓⌽),
Try it online!
,
the list of prefixes (lit, the cumulative concatenation)
(
…)
apply the following function to that list:
⌽
the reversed list
1↓
drop the first item
,
prepend
⊢
the unmodified list
edited 3 hours ago
answered 3 hours ago
AdámAdám
28.6k274203
28.6k274203
add a comment |
add a comment |
$begingroup$
Charcoal, 5 bytes
G^Lθθ
Try it online! Link is to verbose version of code. Explanation: G
draws a filled polygon, ^
specifies that the sides are down right and down left (the polygon then automatically closes itself), Lθ
specifies the length of those sides as being the length of the original input and the final θ
specifies the fill string.
$endgroup$
add a comment |
$begingroup$
Charcoal, 5 bytes
G^Lθθ
Try it online! Link is to verbose version of code. Explanation: G
draws a filled polygon, ^
specifies that the sides are down right and down left (the polygon then automatically closes itself), Lθ
specifies the length of those sides as being the length of the original input and the final θ
specifies the fill string.
$endgroup$
add a comment |
$begingroup$
Charcoal, 5 bytes
G^Lθθ
Try it online! Link is to verbose version of code. Explanation: G
draws a filled polygon, ^
specifies that the sides are down right and down left (the polygon then automatically closes itself), Lθ
specifies the length of those sides as being the length of the original input and the final θ
specifies the fill string.
$endgroup$
Charcoal, 5 bytes
G^Lθθ
Try it online! Link is to verbose version of code. Explanation: G
draws a filled polygon, ^
specifies that the sides are down right and down left (the polygon then automatically closes itself), Lθ
specifies the length of those sides as being the length of the original input and the final θ
specifies the fill string.
answered 3 hours ago
NeilNeil
81.1k744178
81.1k744178
add a comment |
add a comment |
$begingroup$
Perl 5 (-p
), 26 bytes
s,.,$=$`.$/.$;"$`$&
",ge
TIO
$endgroup$
$begingroup$
Nice! But that adds an extra blank line after printing the full string, right?
$endgroup$
– terdon
1 hour ago
add a comment |
$begingroup$
Perl 5 (-p
), 26 bytes
s,.,$=$`.$/.$;"$`$&
",ge
TIO
$endgroup$
$begingroup$
Nice! But that adds an extra blank line after printing the full string, right?
$endgroup$
– terdon
1 hour ago
add a comment |
$begingroup$
Perl 5 (-p
), 26 bytes
s,.,$=$`.$/.$;"$`$&
",ge
TIO
$endgroup$
Perl 5 (-p
), 26 bytes
s,.,$=$`.$/.$;"$`$&
",ge
TIO
answered 3 hours ago
Nahuel FouilleulNahuel Fouilleul
2,55529
2,55529
$begingroup$
Nice! But that adds an extra blank line after printing the full string, right?
$endgroup$
– terdon
1 hour ago
add a comment |
$begingroup$
Nice! But that adds an extra blank line after printing the full string, right?
$endgroup$
– terdon
1 hour ago
$begingroup$
Nice! But that adds an extra blank line after printing the full string, right?
$endgroup$
– terdon
1 hour ago
$begingroup$
Nice! But that adds an extra blank line after printing the full string, right?
$endgroup$
– terdon
1 hour ago
add a comment |
$begingroup$
Ruby, 51 42 40 bytes
f=->s,i=1{s[i]?[t=s[0,i],*f[s,i+1],t]:s}
Try it online!
Thanks to Doorknob for -2 bytes.
$endgroup$
1
$begingroup$
You can save 2 bytes by replacing...
with,
$endgroup$
– Doorknob♦
1 hour ago
add a comment |
$begingroup$
Ruby, 51 42 40 bytes
f=->s,i=1{s[i]?[t=s[0,i],*f[s,i+1],t]:s}
Try it online!
Thanks to Doorknob for -2 bytes.
$endgroup$
1
$begingroup$
You can save 2 bytes by replacing...
with,
$endgroup$
– Doorknob♦
1 hour ago
add a comment |
$begingroup$
Ruby, 51 42 40 bytes
f=->s,i=1{s[i]?[t=s[0,i],*f[s,i+1],t]:s}
Try it online!
Thanks to Doorknob for -2 bytes.
$endgroup$
Ruby, 51 42 40 bytes
f=->s,i=1{s[i]?[t=s[0,i],*f[s,i+1],t]:s}
Try it online!
Thanks to Doorknob for -2 bytes.
edited 1 hour ago
answered 4 hours ago
Kirill L.Kirill L.
4,6551523
4,6551523
1
$begingroup$
You can save 2 bytes by replacing...
with,
$endgroup$
– Doorknob♦
1 hour ago
add a comment |
1
$begingroup$
You can save 2 bytes by replacing...
with,
$endgroup$
– Doorknob♦
1 hour ago
1
1
$begingroup$
You can save 2 bytes by replacing
...
with ,
$endgroup$
– Doorknob♦
1 hour ago
$begingroup$
You can save 2 bytes by replacing
...
with ,
$endgroup$
– Doorknob♦
1 hour ago
add a comment |
$begingroup$
J, 11 bytes
Anonymous tacit prefix function. Returns a space-padded character matrix.
[:(}:,|.)]
Try it online!
]
the list of prefixes
[:(
…)
apply the following function to that list
|.
the reverse list
,
prepended with
}:
the curtailed (without last item) list
$endgroup$
2
$begingroup$
[:(
and}:,|
look so sad…
$endgroup$
– Adám
3 hours ago
add a comment |
$begingroup$
J, 11 bytes
Anonymous tacit prefix function. Returns a space-padded character matrix.
[:(}:,|.)]
Try it online!
]
the list of prefixes
[:(
…)
apply the following function to that list
|.
the reverse list
,
prepended with
}:
the curtailed (without last item) list
$endgroup$
2
$begingroup$
[:(
and}:,|
look so sad…
$endgroup$
– Adám
3 hours ago
add a comment |
$begingroup$
J, 11 bytes
Anonymous tacit prefix function. Returns a space-padded character matrix.
[:(}:,|.)]
Try it online!
]
the list of prefixes
[:(
…)
apply the following function to that list
|.
the reverse list
,
prepended with
}:
the curtailed (without last item) list
$endgroup$
J, 11 bytes
Anonymous tacit prefix function. Returns a space-padded character matrix.
[:(}:,|.)]
Try it online!
]
the list of prefixes
[:(
…)
apply the following function to that list
|.
the reverse list
,
prepended with
}:
the curtailed (without last item) list
edited 36 mins ago
answered 3 hours ago
AdámAdám
28.6k274203
28.6k274203
2
$begingroup$
[:(
and}:,|
look so sad…
$endgroup$
– Adám
3 hours ago
add a comment |
2
$begingroup$
[:(
and}:,|
look so sad…
$endgroup$
– Adám
3 hours ago
2
2
$begingroup$
[:(
and }:,|
look so sad…$endgroup$
– Adám
3 hours ago
$begingroup$
[:(
and }:,|
look so sad…$endgroup$
– Adám
3 hours ago
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 82 bytes
x=>{int l=x.Length,i=0;for(;i<l*2-1;)WriteLine(x.Substring(0,l-Math.Abs(++i-l)));}
Try it online!
String as input and output to std
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 82 bytes
x=>{int l=x.Length,i=0;for(;i<l*2-1;)WriteLine(x.Substring(0,l-Math.Abs(++i-l)));}
Try it online!
String as input and output to std
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 82 bytes
x=>{int l=x.Length,i=0;for(;i<l*2-1;)WriteLine(x.Substring(0,l-Math.Abs(++i-l)));}
Try it online!
String as input and output to std
$endgroup$
C# (Visual C# Interactive Compiler), 82 bytes
x=>{int l=x.Length,i=0;for(;i<l*2-1;)WriteLine(x.Substring(0,l-Math.Abs(++i-l)));}
Try it online!
String as input and output to std
answered 18 mins ago
aloisdgaloisdg
1,3441122
1,3441122
add a comment |
add a comment |
$begingroup$
J, 12 bytes
],[:}.@|.]
Try it online!
Still 1 byte longer than Adám's
Initial solution:
J, 17 16 bytes
{."{~#-|@i:@<:@#
Try it online!
An example REPL session:
# 'String'
6
i:#'String'
_6 _5 _4 _3 _2 _1 0 1 2 3 4 5 6
i:<:#'String'
_5 _4 _3 _2 _1 0 1 2 3 4 5
|i:<:#'String'
5 4 3 2 1 0 1 2 3 4 5
(#'String')-|i:<:#'String'
1 2 3 4 5 6 5 4 3 2 1
'String'{."0 1~(#'String')-|i:<:#'String'
S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S
$endgroup$
1
$begingroup$
Did I outgolf the master‽
$endgroup$
– Adám
3 hours ago
$begingroup$
@Adám I'm far from being a J master :) There are many J coders here better than I am.
$endgroup$
– Galen Ivanov
3 hours ago
add a comment |
$begingroup$
J, 12 bytes
],[:}.@|.]
Try it online!
Still 1 byte longer than Adám's
Initial solution:
J, 17 16 bytes
{."{~#-|@i:@<:@#
Try it online!
An example REPL session:
# 'String'
6
i:#'String'
_6 _5 _4 _3 _2 _1 0 1 2 3 4 5 6
i:<:#'String'
_5 _4 _3 _2 _1 0 1 2 3 4 5
|i:<:#'String'
5 4 3 2 1 0 1 2 3 4 5
(#'String')-|i:<:#'String'
1 2 3 4 5 6 5 4 3 2 1
'String'{."0 1~(#'String')-|i:<:#'String'
S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S
$endgroup$
1
$begingroup$
Did I outgolf the master‽
$endgroup$
– Adám
3 hours ago
$begingroup$
@Adám I'm far from being a J master :) There are many J coders here better than I am.
$endgroup$
– Galen Ivanov
3 hours ago
add a comment |
$begingroup$
J, 12 bytes
],[:}.@|.]
Try it online!
Still 1 byte longer than Adám's
Initial solution:
J, 17 16 bytes
{."{~#-|@i:@<:@#
Try it online!
An example REPL session:
# 'String'
6
i:#'String'
_6 _5 _4 _3 _2 _1 0 1 2 3 4 5 6
i:<:#'String'
_5 _4 _3 _2 _1 0 1 2 3 4 5
|i:<:#'String'
5 4 3 2 1 0 1 2 3 4 5
(#'String')-|i:<:#'String'
1 2 3 4 5 6 5 4 3 2 1
'String'{."0 1~(#'String')-|i:<:#'String'
S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S
$endgroup$
J, 12 bytes
],[:}.@|.]
Try it online!
Still 1 byte longer than Adám's
Initial solution:
J, 17 16 bytes
{."{~#-|@i:@<:@#
Try it online!
An example REPL session:
# 'String'
6
i:#'String'
_6 _5 _4 _3 _2 _1 0 1 2 3 4 5 6
i:<:#'String'
_5 _4 _3 _2 _1 0 1 2 3 4 5
|i:<:#'String'
5 4 3 2 1 0 1 2 3 4 5
(#'String')-|i:<:#'String'
1 2 3 4 5 6 5 4 3 2 1
'String'{."0 1~(#'String')-|i:<:#'String'
S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S
edited 2 hours ago
answered 3 hours ago
Galen IvanovGalen Ivanov
6,86711034
6,86711034
1
$begingroup$
Did I outgolf the master‽
$endgroup$
– Adám
3 hours ago
$begingroup$
@Adám I'm far from being a J master :) There are many J coders here better than I am.
$endgroup$
– Galen Ivanov
3 hours ago
add a comment |
1
$begingroup$
Did I outgolf the master‽
$endgroup$
– Adám
3 hours ago
$begingroup$
@Adám I'm far from being a J master :) There are many J coders here better than I am.
$endgroup$
– Galen Ivanov
3 hours ago
1
1
$begingroup$
Did I outgolf the master‽
$endgroup$
– Adám
3 hours ago
$begingroup$
Did I outgolf the master‽
$endgroup$
– Adám
3 hours ago
$begingroup$
@Adám I'm far from being a J master :) There are many J coders here better than I am.
$endgroup$
– Galen Ivanov
3 hours ago
$begingroup$
@Adám I'm far from being a J master :) There are many J coders here better than I am.
$endgroup$
– Galen Ivanov
3 hours ago
add a comment |
$begingroup$
Julia, 44 bytes
s->(a=cumprod([s...]);[a;reverse(a)[2:end]])
Try it online!
Gets the first half by taking the cumulative product (*
is string concatenation in Julia) of the array of characters, then adds this array to itself reversed minus the first element.
$endgroup$
add a comment |
$begingroup$
Julia, 44 bytes
s->(a=cumprod([s...]);[a;reverse(a)[2:end]])
Try it online!
Gets the first half by taking the cumulative product (*
is string concatenation in Julia) of the array of characters, then adds this array to itself reversed minus the first element.
$endgroup$
add a comment |
$begingroup$
Julia, 44 bytes
s->(a=cumprod([s...]);[a;reverse(a)[2:end]])
Try it online!
Gets the first half by taking the cumulative product (*
is string concatenation in Julia) of the array of characters, then adds this array to itself reversed minus the first element.
$endgroup$
Julia, 44 bytes
s->(a=cumprod([s...]);[a;reverse(a)[2:end]])
Try it online!
Gets the first half by taking the cumulative product (*
is string concatenation in Julia) of the array of characters, then adds this array to itself reversed minus the first element.
answered 1 hour ago
Doorknob♦Doorknob
54.9k17115352
54.9k17115352
add a comment |
add a comment |
$begingroup$
Octave, 58 bytes
for k=1:(n=nnz(s=input(''))*2)-1
disp(s(1:min(k,n-k)))
end
Try it online!
$endgroup$
add a comment |
$begingroup$
Octave, 58 bytes
for k=1:(n=nnz(s=input(''))*2)-1
disp(s(1:min(k,n-k)))
end
Try it online!
$endgroup$
add a comment |
$begingroup$
Octave, 58 bytes
for k=1:(n=nnz(s=input(''))*2)-1
disp(s(1:min(k,n-k)))
end
Try it online!
$endgroup$
Octave, 58 bytes
for k=1:(n=nnz(s=input(''))*2)-1
disp(s(1:min(k,n-k)))
end
Try it online!
answered 1 hour ago
Luis MendoLuis Mendo
74.5k888291
74.5k888291
add a comment |
add a comment |
$begingroup$
Red, 78 bytes
func[s][repeat n l: length? s[print copy/part s n]loop l[take/last s print s]]
Try it online!
$endgroup$
add a comment |
$begingroup$
Red, 78 bytes
func[s][repeat n l: length? s[print copy/part s n]loop l[take/last s print s]]
Try it online!
$endgroup$
add a comment |
$begingroup$
Red, 78 bytes
func[s][repeat n l: length? s[print copy/part s n]loop l[take/last s print s]]
Try it online!
$endgroup$
Red, 78 bytes
func[s][repeat n l: length? s[print copy/part s n]loop l[take/last s print s]]
Try it online!
edited 1 hour ago
answered 3 hours ago
Galen IvanovGalen Ivanov
6,86711034
6,86711034
add a comment |
add a comment |
$begingroup$
Brachylog, 8 bytes
a₀ᶠ;Lc.↔
Try it online!
Explanation
a₀ᶠ Find all prefixes of the input
;Lc. The output is that list of prefixes with something unknown appended at the end
.↔ The output reversed is itself (i.e. it's a palindrome)
$endgroup$
add a comment |
$begingroup$
Brachylog, 8 bytes
a₀ᶠ;Lc.↔
Try it online!
Explanation
a₀ᶠ Find all prefixes of the input
;Lc. The output is that list of prefixes with something unknown appended at the end
.↔ The output reversed is itself (i.e. it's a palindrome)
$endgroup$
add a comment |
$begingroup$
Brachylog, 8 bytes
a₀ᶠ;Lc.↔
Try it online!
Explanation
a₀ᶠ Find all prefixes of the input
;Lc. The output is that list of prefixes with something unknown appended at the end
.↔ The output reversed is itself (i.e. it's a palindrome)
$endgroup$
Brachylog, 8 bytes
a₀ᶠ;Lc.↔
Try it online!
Explanation
a₀ᶠ Find all prefixes of the input
;Lc. The output is that list of prefixes with something unknown appended at the end
.↔ The output reversed is itself (i.e. it's a palindrome)
answered 1 hour ago
FatalizeFatalize
27.4k448136
27.4k448136
add a comment |
add a comment |
$begingroup$
R, 86 bytes
x=utf8ToInt(scan(,''))
for(i in c(y<-1:sum(x|1),rev(y)[-1]))cat(intToUtf8(x[1:i]),"
")
Try it online!
I'm learning more and more about better ways to manipulate strings in R, so I'm somewhat proud of this answer. The only part I don't like is the for loop portion, which I feel could definitely be golfed.
$endgroup$
add a comment |
$begingroup$
R, 86 bytes
x=utf8ToInt(scan(,''))
for(i in c(y<-1:sum(x|1),rev(y)[-1]))cat(intToUtf8(x[1:i]),"
")
Try it online!
I'm learning more and more about better ways to manipulate strings in R, so I'm somewhat proud of this answer. The only part I don't like is the for loop portion, which I feel could definitely be golfed.
$endgroup$
add a comment |
$begingroup$
R, 86 bytes
x=utf8ToInt(scan(,''))
for(i in c(y<-1:sum(x|1),rev(y)[-1]))cat(intToUtf8(x[1:i]),"
")
Try it online!
I'm learning more and more about better ways to manipulate strings in R, so I'm somewhat proud of this answer. The only part I don't like is the for loop portion, which I feel could definitely be golfed.
$endgroup$
R, 86 bytes
x=utf8ToInt(scan(,''))
for(i in c(y<-1:sum(x|1),rev(y)[-1]))cat(intToUtf8(x[1:i]),"
")
Try it online!
I'm learning more and more about better ways to manipulate strings in R, so I'm somewhat proud of this answer. The only part I don't like is the for loop portion, which I feel could definitely be golfed.
answered 1 hour ago
Sumner18Sumner18
5607
5607
add a comment |
add a comment |
$begingroup$
MBASIC, 103 bytes
1 INPUT S$:N=1
2 PRINT LEFT$(S$,N):IF N<LEN(S$) THEN N=N+1:GOTO 2
3 N=N-1:PRINT LEFT$(S$,N):IF N>1 THEN 3
$endgroup$
add a comment |
$begingroup$
MBASIC, 103 bytes
1 INPUT S$:N=1
2 PRINT LEFT$(S$,N):IF N<LEN(S$) THEN N=N+1:GOTO 2
3 N=N-1:PRINT LEFT$(S$,N):IF N>1 THEN 3
$endgroup$
add a comment |
$begingroup$
MBASIC, 103 bytes
1 INPUT S$:N=1
2 PRINT LEFT$(S$,N):IF N<LEN(S$) THEN N=N+1:GOTO 2
3 N=N-1:PRINT LEFT$(S$,N):IF N>1 THEN 3
$endgroup$
MBASIC, 103 bytes
1 INPUT S$:N=1
2 PRINT LEFT$(S$,N):IF N<LEN(S$) THEN N=N+1:GOTO 2
3 N=N-1:PRINT LEFT$(S$,N):IF N>1 THEN 3
answered 52 mins ago
wooshinyobjectwooshinyobject
1516
1516
add a comment |
add a comment |
$begingroup$
PowerShell, 89 bytes
param($a)0..($d=$a.Length-1)|%{[string[]]$b+=,$a[0..$_]};($c=$b-replace' ')+$c[($d-1)..0]
Try it online!
$endgroup$
add a comment |
$begingroup$
PowerShell, 89 bytes
param($a)0..($d=$a.Length-1)|%{[string[]]$b+=,$a[0..$_]};($c=$b-replace' ')+$c[($d-1)..0]
Try it online!
$endgroup$
add a comment |
$begingroup$
PowerShell, 89 bytes
param($a)0..($d=$a.Length-1)|%{[string[]]$b+=,$a[0..$_]};($c=$b-replace' ')+$c[($d-1)..0]
Try it online!
$endgroup$
PowerShell, 89 bytes
param($a)0..($d=$a.Length-1)|%{[string[]]$b+=,$a[0..$_]};($c=$b-replace' ')+$c[($d-1)..0]
Try it online!
answered 33 mins ago
Gabriel MillsGabriel Mills
474212
474212
add a comment |
add a comment |
$begingroup$
Pyke, 6 bytes
BE 27 4F 5F 2B 58
Try it here!
- input() (implicit)
.> - prefixes(^) (1 byte)
'O_ - ^[:-1], reversed(^)
+ - [^]
X - "n".join(reversed(^))
$endgroup$
add a comment |
$begingroup$
Pyke, 6 bytes
BE 27 4F 5F 2B 58
Try it here!
- input() (implicit)
.> - prefixes(^) (1 byte)
'O_ - ^[:-1], reversed(^)
+ - [^]
X - "n".join(reversed(^))
$endgroup$
add a comment |
$begingroup$
Pyke, 6 bytes
BE 27 4F 5F 2B 58
Try it here!
- input() (implicit)
.> - prefixes(^) (1 byte)
'O_ - ^[:-1], reversed(^)
+ - [^]
X - "n".join(reversed(^))
$endgroup$
Pyke, 6 bytes
BE 27 4F 5F 2B 58
Try it here!
- input() (implicit)
.> - prefixes(^) (1 byte)
'O_ - ^[:-1], reversed(^)
+ - [^]
X - "n".join(reversed(^))
answered 14 mins ago
BlueBlue
23.7k73889
23.7k73889
add a comment |
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f180509%2fit-took-me-a-lot-of-time-to-make-this-pls-like-youtube-comments-1%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
$begingroup$
I am planning to make some more YouTube comments related challenges in the future; hence the
YouTube Comments #1
in the title.$endgroup$
– Arjun
4 hours ago
1
$begingroup$
Is returning a array of lines allowed?
$endgroup$
– someone
4 hours ago
$begingroup$
@someone Yes, it is allowed, in accordance with standard I/O defaults
$endgroup$
– Arjun
4 hours ago
$begingroup$
Can we take input as an array of characters and return an array of arrays of characters?
$endgroup$
– Shaggy
3 hours ago