String rotation - output string repeatedly moving first character to the end
The challenge here is to take a string and output all its rotations, by repeatedly moving the first character to the end, once per character in the string, ending with the original string:
john -> ohnj, hnjo, njoh, john
You may also cycle in the other direction, moving characters from the end:
john -> njoh, hnjo, ohnj, john
You should still output one rotation per letter even if the original word is reached before that:
heehee -> eeheeh, eheehe, heehee, eeheeh, eheehe, heehee
Character arrays are allowed, as long as the result works as shown above.
Shortest answer wins!
code-golf string
|
show 5 more comments
The challenge here is to take a string and output all its rotations, by repeatedly moving the first character to the end, once per character in the string, ending with the original string:
john -> ohnj, hnjo, njoh, john
You may also cycle in the other direction, moving characters from the end:
john -> njoh, hnjo, ohnj, john
You should still output one rotation per letter even if the original word is reached before that:
heehee -> eeheeh, eheehe, heehee, eeheeh, eheehe, heehee
Character arrays are allowed, as long as the result works as shown above.
Shortest answer wins!
code-golf string
5
If a string likeheehee
returns to the original order in fewer cycles than its length, do we stop there? I expect this would make a big difference for many answers.
– xnor
Dec 8 at 22:43
May we cycle in the other direction?
– xnor
Dec 8 at 22:45
2
I edited the question including your clarifications, feel free to change it if it's not what you intended.
– xnor
Dec 8 at 23:28
1
@xnor that looks much clearer than my original post, thanks so much!
– I_P_Edwards
Dec 9 at 13:38
1
Are we allowed to input/output character arrays? (The distinction can be important in some languages.)
– LegionMammal978
Dec 9 at 18:09
|
show 5 more comments
The challenge here is to take a string and output all its rotations, by repeatedly moving the first character to the end, once per character in the string, ending with the original string:
john -> ohnj, hnjo, njoh, john
You may also cycle in the other direction, moving characters from the end:
john -> njoh, hnjo, ohnj, john
You should still output one rotation per letter even if the original word is reached before that:
heehee -> eeheeh, eheehe, heehee, eeheeh, eheehe, heehee
Character arrays are allowed, as long as the result works as shown above.
Shortest answer wins!
code-golf string
The challenge here is to take a string and output all its rotations, by repeatedly moving the first character to the end, once per character in the string, ending with the original string:
john -> ohnj, hnjo, njoh, john
You may also cycle in the other direction, moving characters from the end:
john -> njoh, hnjo, ohnj, john
You should still output one rotation per letter even if the original word is reached before that:
heehee -> eeheeh, eheehe, heehee, eeheeh, eheehe, heehee
Character arrays are allowed, as long as the result works as shown above.
Shortest answer wins!
code-golf string
code-golf string
edited Dec 9 at 20:44
asked Dec 8 at 22:14
I_P_Edwards
786
786
5
If a string likeheehee
returns to the original order in fewer cycles than its length, do we stop there? I expect this would make a big difference for many answers.
– xnor
Dec 8 at 22:43
May we cycle in the other direction?
– xnor
Dec 8 at 22:45
2
I edited the question including your clarifications, feel free to change it if it's not what you intended.
– xnor
Dec 8 at 23:28
1
@xnor that looks much clearer than my original post, thanks so much!
– I_P_Edwards
Dec 9 at 13:38
1
Are we allowed to input/output character arrays? (The distinction can be important in some languages.)
– LegionMammal978
Dec 9 at 18:09
|
show 5 more comments
5
If a string likeheehee
returns to the original order in fewer cycles than its length, do we stop there? I expect this would make a big difference for many answers.
– xnor
Dec 8 at 22:43
May we cycle in the other direction?
– xnor
Dec 8 at 22:45
2
I edited the question including your clarifications, feel free to change it if it's not what you intended.
– xnor
Dec 8 at 23:28
1
@xnor that looks much clearer than my original post, thanks so much!
– I_P_Edwards
Dec 9 at 13:38
1
Are we allowed to input/output character arrays? (The distinction can be important in some languages.)
– LegionMammal978
Dec 9 at 18:09
5
5
If a string like
heehee
returns to the original order in fewer cycles than its length, do we stop there? I expect this would make a big difference for many answers.– xnor
Dec 8 at 22:43
If a string like
heehee
returns to the original order in fewer cycles than its length, do we stop there? I expect this would make a big difference for many answers.– xnor
Dec 8 at 22:43
May we cycle in the other direction?
– xnor
Dec 8 at 22:45
May we cycle in the other direction?
– xnor
Dec 8 at 22:45
2
2
I edited the question including your clarifications, feel free to change it if it's not what you intended.
– xnor
Dec 8 at 23:28
I edited the question including your clarifications, feel free to change it if it's not what you intended.
– xnor
Dec 8 at 23:28
1
1
@xnor that looks much clearer than my original post, thanks so much!
– I_P_Edwards
Dec 9 at 13:38
@xnor that looks much clearer than my original post, thanks so much!
– I_P_Edwards
Dec 9 at 13:38
1
1
Are we allowed to input/output character arrays? (The distinction can be important in some languages.)
– LegionMammal978
Dec 9 at 18:09
Are we allowed to input/output character arrays? (The distinction can be important in some languages.)
– LegionMammal978
Dec 9 at 18:09
|
show 5 more comments
38 Answers
38
active
oldest
votes
1 2
next
Jelly, 2 bytes
ṙJ
A monadic Link accepting a list of characters which yields a list of lists of characters
Try it online! (footer pretty prints by calling the link and joining with newline characters)
add a comment |
Haskell, 27 bytes
scanl((a:b)_->b++[a])=<<id
Try it online!
add a comment |
APL (Dyalog Unicode), 6 bytesSBCS
⍳∘≢⌽¨⊂
Try it online!
⍳
the indices
∘
of
≢
the tally
⌽¨
each rotate (to the left)
⊂
the entire string
add a comment |
JavaScript (ES6), 37 32 bytes
Returns an array of strings.
s=>[...s].map(c=>s=s.slice(1)+c)
Try it online!
add a comment |
Python 2, 38 bytes
s=input()
for c in s:s=s[1:]+c;print s
Try it online!
Python 3 is only 9 more bytes.
– wizzwizz4
Dec 9 at 18:42
@wizzwizz4 Where'd you get 9? Python 3 - 39 bytes (stdin input without quotes)
– pizzapants184
Dec 12 at 6:09
@pizzapants184 I forgot that strings were immutable; you're right; it's only 1 more byte.
– wizzwizz4
Dec 12 at 6:56
add a comment |
Japt, 5 3 bytes
Takes input as a character array, outputs an array of character arrays
£=é
Try it here
:Implicit input of character array U
£ :Map
é : Rotate right
= : Reassign to U for next iteration
add a comment |
MATL, 6 5 bytes
tf&+)
1 byte saved thanks to @luis!
Try it at MATL Online!
Explanation:
# Implicitly grab input string
t # Duplicate the input
f # Create an array [1, ..., N] where N is the number of characters in the input
&+ # Add the transpose of this array to itself to create a 2D array of indices
#
# + 1 2 3 4
# ----------
# 1 | 2 3 4 5
# 2 | 3 4 5 6
# 3 | 4 5 6 7
# 4 | 5 6 7 8
#
) # Use this 2D array to index into the original string using periodic indexing
# Implicitly display the resulting character array
@LuisMendo Clever! Thanks!
– Suever
Dec 12 at 10:50
add a comment |
05AB1E, 3 bytes
ā._
Try it online!
add a comment |
Attache, 13 bytes
Rotate#{1:#_}
Try it online!
Explanation
Rotate#{1:#_}
# fork(f, g) = ${ f[x, g[x]] }; this forks:
Rotate rotate's the input by
{1:#_} each number from 1 to the length of the input
Alternatives
15 bytes: {_&Rotate!1:#_}
16 bytes: {Rotate[_,1:#_]}
16 bytes: Rotate@Rotations
16 bytes: Rotate#(1&`:@`#)
17 bytes: Rotate#{1+Iota@_}
18 bytes: Rotate#(1&`+@Iota)
19 bytes: Rotate#(Succ=>Iota)
add a comment |
R, 58 bytes
function(s,`[`=substring)paste0(s[n<-nchar(s):1],s[1,n-1])
Try it online!
add a comment |
brainfuck, 59 bytes
,[>,]<[>>[>]+[<]<[<]>-[[>]>[>]<+[<]<[<]>-]>[.>]>[.>]<[<].<]
Try it online!
Outputs each string separated by null bytes.
Explanation:
,[>,] # Get input
<[ # Start loop over input
>>[>] # Go to end of the string
+ # Set it to one to mark it
[<]<[<]> # Move to the beginning of input
-[[>]>[>]<+[<]<[<]>-] # Transfer the first character to the end
>[.>]>[.>] # Print the rotated string
<[<]. # Print a nul byte
<] # Repeat loop while input
add a comment |
Wolfram Language (Mathematica), 35 26 bytes
Partition[#,Tr[1^#],1,-1]&
Try it online!
Takes a list of characters as input.
Partition
(but not its variant StringPartition
used below) has an optional fourth argument for treating its input as cyclic (and for specifying how exactly to do so), which makes this solution simpler than the string one - in addition to not having any 15-character built-in functions.
Wolfram Language (Mathematica), 44 bytes
Rest@StringPartition[#<>#,StringLength@#,1]&
Try it online!
The same, but takes a string as input.
Turns "john"
into "johnjohn"
, then takes all the length-StringLength["john"]
substrings of this string with offset 1, producing {"john","ohnj","hnjo","njoh","john"}
, then drops the first of these with Rest
.
Since character arrays are allowed,Rest@Partition[#~Join~#,Length@#,1]&
would be 36 bytes.
– LegionMammal978
Dec 9 at 22:23
@LegionMammal978 Thanks! There's probably also a shorter approach with character arrays, though I haven't thought of anything yet.
– Misha Lavrov
Dec 9 at 22:45
add a comment |
Charcoal, 10 bytes
⮌Eθ⭆θ§θ⁻μκ
Try it online! Link is to verbose version of code. Explanation:
θ Input string
E Map over characters
θ Input string
⭆ Map over characters and join
θ Input string
§ Circularly indexed by
⁻ Difference between
μ Inner index
κ Outer index
⮌ Reversed
Implicitly print each string on its own line
To rotate in the opposite direction, replace Minus
with Plus
.
add a comment |
J, 7 bytes
#|."{]
Try it online!
Explanation:
|."{ - rotate ( "{ is short for "0 1 - rank 0 1 )
] - the input
# - lenght of the successive prefixes of the input
1
Using"
like that is very clever, and requires dictionary knowledge of the language. Is there also a verb with rank1 0
?
– Adám
Dec 9 at 16:24
@Adám I think it's"#:
. I learnt this here from Frownyfrog
– Galen Ivanov
Dec 9 at 18:34
add a comment |
Red, 49 43 bytes
func[s][forall s[print move head s tail s]]
Try it online!
add a comment |
Python 2, 54 48 bytes
lambda i:[i[x:]+i[:x]for x in range(1,len(i)+1)]
Try it online!
Well beaten by xnor but posted as an alternative approach anyway.
add a comment |
Perl 6, 32 bytes
{m:ex/^(.*)(.+)$/».&{[R~] @$_}}
Try it online!
m:ex/^(.*)(.+)$/
ex
haustively m
atches the given regex, splitting the input string at every possible place, except that the second substring must have at least one character--that prevents the input string from showing up twice in the output. Then each of the resulting Match
objects' capture groups are reduced () to a single string with
R~
, the reversed string concatenation operator.
add a comment |
C# (Visual C# Interactive Compiler), 34 bytes
x=>x.Select(c=>x=x.Substring(1)+c)
Try it online!
add a comment |
V, 8 bytes
ýñx$pÙñd
Try it online!
Hexdump:
00000000: fdf1 7824 70d9 f164 ..x$p..d
ýñx$pÙñd
gives 8 by removing the need toH
tio.run/##K/v///DewxsrVAoOzzy8MeX/f6/8jDwA
– Cows quack
Dec 9 at 19:43
@Cowsquack Even better:ý<M-->ñx$pÙ
– DJMcMayhem♦
Dec 9 at 20:54
Doesn't that repeat the last line?
– Cows quack
Dec 10 at 6:18
add a comment |
Tcl, 80 91 bytes
proc P s {time {puts [set s [string ra $s 1 e][string in $s 0]]} [string le $s]}
Try it online!
Reassign text at each time saves some bytesproc R t {time {puts [set t [string ra $t 1 end][string in $t 0]]} [string len $t]}
– david
Dec 9 at 18:05
Got it down to 80 bytes, thanks to @david
– sergiol
Dec 10 at 10:54
add a comment |
C (32-bit), 58 51 bytes
i;f(s){for(i=0;i++<printf("%s%.*sn",s+i,i,s)-2;);}
Try it online!
Degolf
i; // "Global" i.
f(s){ // s is pointer to string, which conveniently fits in a 32 bit integer.
for(i=0; // Initialize i.
// Post-increment i, compare to return value of printf,
// which just happens to be the number of chars printed, i.e.
// the length of string s plus 1. Because the printf() is
// evaluated before the comparison, we need to deduct 2 instead
// of 1 from the return value.
i++ < printf("%s%.*sn",s+i,i,s);)-2;
// The printf prints two strings: first until the terminating ,
// the second until a or until i chars have been printed.
}
add a comment |
Ruby, 39 bytes
->s{a=s.chars.to_a;a.map{a.rotate!*''}}
Try it online!
1
Welcome to the site! It doesn't look like your TIO link corresponds to your answer. It also seems your answer doesn't fit with our input/output requirements. You can use either a function or STDIN/STDOUT but we don't allow variable reassignment.
– Wît Wisarhd
Dec 11 at 5:10
Thanks Garf. Not sure how I managed to mess both of those up. Should be all good now.
– acornellier
Dec 13 at 4:45
add a comment |
Pyth, 11 bytes
VSlQ+>QN<QN
Try it online!
Pretty much just a port of my Python answer
Explanation
==================================================
assign('Q',eval_input())
for N in num_to_range(Psorted(Plen(Q))):
imp_print(plus(gt(Q,N),lt(Q,N)))
==================================================
V # for N in
S # 1-indexed range
lQ # length of evaluated input
+ # concatanate
>QN # all characters after index N in Q (Q[N:])
<QN # and all characters before index N in Q (Q[:N])
add a comment |
Tcl, 78 bytes
proc R t {time {puts [set t [regsub -all (.?)(.*) $t {21}]]} [string le $t]}
Try it online!
add a comment |
Pushy, 4 bytes
L:{"
Try it online!
L: Length of the string times do:
{ Cyclically shift left once
" Print
add a comment |
Perl 6, 20 bytes
{.rotate(all 1..$_)}
Try it online!
Anonymous code block that has input/output as a list of characters. The output is a Junction object that contains all the rotated arrays. I'm not sure how legal this is, since extracting values from a Junction is not normal.
Explanation:
{ } # Anonymous codeblock
.rotate( ) # Rotate the input list
all 1..$_ # By all of the range 1 to length of the input array
# all creates a junction of values
# And it runs the function on each value
The all
can be replaced by any of any
, one
, [&]
, [|]
, [^]
.
If the Junction isn't allowed, here's an alternate solution for 22 bytes:
{.&{.rotate(++$)xx$_}}
Try it online!
There's probably a better way to reset the anonymous variable ++$
than by wrapping the code in another code block...
add a comment |
JavaScript, 48 43 bytes
-5 bytes courtesy of @Bubbler
s=>[...s].map(_=>([a,...b]=s,s=b.join``+a))
Try it online!
1
43 bytes.
– Bubbler
Dec 10 at 1:54
add a comment |
Powershell, 44 bytes
($s=$args|% t*y)|%{$h,$t=$s;-join($s=$t+$h)}
Test script:
$f = {
($s=$args|% t*y)|%{$h,$t=$s;-join($s=$t+$h)}
}
@(
,('john', 'ohnj', 'hnjo', 'njoh', 'john')
,('heehee', 'eeheeh', 'eheehe', 'heehee', 'eeheeh', 'eheehe', 'heehee')
) | % {
$s,$expected = $_
$result = &$f $s
"$result"-eq"$expected"
$result
}
output:
True
ohnj
hnjo
njoh
john
True
eeheeh
eheehe
heehee
eeheeh
eheehe
heehee
add a comment |
Pepe, 64 bytes
REEeRREeeeREEEEEREErEEEEErRREEEEEEEREEEeeReReeeReeErRrEEEEEEERee
Try it online! Uses newlines for separation.
add a comment |
Java (JDK), 85 bytes
s->{for(int i=s.length();i-->0;)System.out.println(s.substring(i)+s.substring(0,i));}
Try it online!
add a comment |
1 2
next
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%2f177221%2fstring-rotation-output-string-repeatedly-moving-first-character-to-the-end%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
38 Answers
38
active
oldest
votes
38 Answers
38
active
oldest
votes
active
oldest
votes
active
oldest
votes
1 2
next
Jelly, 2 bytes
ṙJ
A monadic Link accepting a list of characters which yields a list of lists of characters
Try it online! (footer pretty prints by calling the link and joining with newline characters)
add a comment |
Jelly, 2 bytes
ṙJ
A monadic Link accepting a list of characters which yields a list of lists of characters
Try it online! (footer pretty prints by calling the link and joining with newline characters)
add a comment |
Jelly, 2 bytes
ṙJ
A monadic Link accepting a list of characters which yields a list of lists of characters
Try it online! (footer pretty prints by calling the link and joining with newline characters)
Jelly, 2 bytes
ṙJ
A monadic Link accepting a list of characters which yields a list of lists of characters
Try it online! (footer pretty prints by calling the link and joining with newline characters)
edited Dec 8 at 23:30
answered Dec 8 at 22:53
Jonathan Allan
50.7k534165
50.7k534165
add a comment |
add a comment |
Haskell, 27 bytes
scanl((a:b)_->b++[a])=<<id
Try it online!
add a comment |
Haskell, 27 bytes
scanl((a:b)_->b++[a])=<<id
Try it online!
add a comment |
Haskell, 27 bytes
scanl((a:b)_->b++[a])=<<id
Try it online!
Haskell, 27 bytes
scanl((a:b)_->b++[a])=<<id
Try it online!
answered Dec 8 at 22:41
nimi
31.3k32085
31.3k32085
add a comment |
add a comment |
APL (Dyalog Unicode), 6 bytesSBCS
⍳∘≢⌽¨⊂
Try it online!
⍳
the indices
∘
of
≢
the tally
⌽¨
each rotate (to the left)
⊂
the entire string
add a comment |
APL (Dyalog Unicode), 6 bytesSBCS
⍳∘≢⌽¨⊂
Try it online!
⍳
the indices
∘
of
≢
the tally
⌽¨
each rotate (to the left)
⊂
the entire string
add a comment |
APL (Dyalog Unicode), 6 bytesSBCS
⍳∘≢⌽¨⊂
Try it online!
⍳
the indices
∘
of
≢
the tally
⌽¨
each rotate (to the left)
⊂
the entire string
APL (Dyalog Unicode), 6 bytesSBCS
⍳∘≢⌽¨⊂
Try it online!
⍳
the indices
∘
of
≢
the tally
⌽¨
each rotate (to the left)
⊂
the entire string
answered Dec 8 at 22:22
Adám
28.7k269188
28.7k269188
add a comment |
add a comment |
JavaScript (ES6), 37 32 bytes
Returns an array of strings.
s=>[...s].map(c=>s=s.slice(1)+c)
Try it online!
add a comment |
JavaScript (ES6), 37 32 bytes
Returns an array of strings.
s=>[...s].map(c=>s=s.slice(1)+c)
Try it online!
add a comment |
JavaScript (ES6), 37 32 bytes
Returns an array of strings.
s=>[...s].map(c=>s=s.slice(1)+c)
Try it online!
JavaScript (ES6), 37 32 bytes
Returns an array of strings.
s=>[...s].map(c=>s=s.slice(1)+c)
Try it online!
edited Dec 11 at 20:33
answered Dec 8 at 23:28
Arnauld
72.4k689303
72.4k689303
add a comment |
add a comment |
Python 2, 38 bytes
s=input()
for c in s:s=s[1:]+c;print s
Try it online!
Python 3 is only 9 more bytes.
– wizzwizz4
Dec 9 at 18:42
@wizzwizz4 Where'd you get 9? Python 3 - 39 bytes (stdin input without quotes)
– pizzapants184
Dec 12 at 6:09
@pizzapants184 I forgot that strings were immutable; you're right; it's only 1 more byte.
– wizzwizz4
Dec 12 at 6:56
add a comment |
Python 2, 38 bytes
s=input()
for c in s:s=s[1:]+c;print s
Try it online!
Python 3 is only 9 more bytes.
– wizzwizz4
Dec 9 at 18:42
@wizzwizz4 Where'd you get 9? Python 3 - 39 bytes (stdin input without quotes)
– pizzapants184
Dec 12 at 6:09
@pizzapants184 I forgot that strings were immutable; you're right; it's only 1 more byte.
– wizzwizz4
Dec 12 at 6:56
add a comment |
Python 2, 38 bytes
s=input()
for c in s:s=s[1:]+c;print s
Try it online!
Python 2, 38 bytes
s=input()
for c in s:s=s[1:]+c;print s
Try it online!
answered Dec 9 at 0:00
xnor
89.7k18184439
89.7k18184439
Python 3 is only 9 more bytes.
– wizzwizz4
Dec 9 at 18:42
@wizzwizz4 Where'd you get 9? Python 3 - 39 bytes (stdin input without quotes)
– pizzapants184
Dec 12 at 6:09
@pizzapants184 I forgot that strings were immutable; you're right; it's only 1 more byte.
– wizzwizz4
Dec 12 at 6:56
add a comment |
Python 3 is only 9 more bytes.
– wizzwizz4
Dec 9 at 18:42
@wizzwizz4 Where'd you get 9? Python 3 - 39 bytes (stdin input without quotes)
– pizzapants184
Dec 12 at 6:09
@pizzapants184 I forgot that strings were immutable; you're right; it's only 1 more byte.
– wizzwizz4
Dec 12 at 6:56
Python 3 is only 9 more bytes.
– wizzwizz4
Dec 9 at 18:42
Python 3 is only 9 more bytes.
– wizzwizz4
Dec 9 at 18:42
@wizzwizz4 Where'd you get 9? Python 3 - 39 bytes (stdin input without quotes)
– pizzapants184
Dec 12 at 6:09
@wizzwizz4 Where'd you get 9? Python 3 - 39 bytes (stdin input without quotes)
– pizzapants184
Dec 12 at 6:09
@pizzapants184 I forgot that strings were immutable; you're right; it's only 1 more byte.
– wizzwizz4
Dec 12 at 6:56
@pizzapants184 I forgot that strings were immutable; you're right; it's only 1 more byte.
– wizzwizz4
Dec 12 at 6:56
add a comment |
Japt, 5 3 bytes
Takes input as a character array, outputs an array of character arrays
£=é
Try it here
:Implicit input of character array U
£ :Map
é : Rotate right
= : Reassign to U for next iteration
add a comment |
Japt, 5 3 bytes
Takes input as a character array, outputs an array of character arrays
£=é
Try it here
:Implicit input of character array U
£ :Map
é : Rotate right
= : Reassign to U for next iteration
add a comment |
Japt, 5 3 bytes
Takes input as a character array, outputs an array of character arrays
£=é
Try it here
:Implicit input of character array U
£ :Map
é : Rotate right
= : Reassign to U for next iteration
Japt, 5 3 bytes
Takes input as a character array, outputs an array of character arrays
£=é
Try it here
:Implicit input of character array U
£ :Map
é : Rotate right
= : Reassign to U for next iteration
edited Dec 10 at 16:56
answered Dec 8 at 22:38
Shaggy
18.9k21666
18.9k21666
add a comment |
add a comment |
MATL, 6 5 bytes
tf&+)
1 byte saved thanks to @luis!
Try it at MATL Online!
Explanation:
# Implicitly grab input string
t # Duplicate the input
f # Create an array [1, ..., N] where N is the number of characters in the input
&+ # Add the transpose of this array to itself to create a 2D array of indices
#
# + 1 2 3 4
# ----------
# 1 | 2 3 4 5
# 2 | 3 4 5 6
# 3 | 4 5 6 7
# 4 | 5 6 7 8
#
) # Use this 2D array to index into the original string using periodic indexing
# Implicitly display the resulting character array
@LuisMendo Clever! Thanks!
– Suever
Dec 12 at 10:50
add a comment |
MATL, 6 5 bytes
tf&+)
1 byte saved thanks to @luis!
Try it at MATL Online!
Explanation:
# Implicitly grab input string
t # Duplicate the input
f # Create an array [1, ..., N] where N is the number of characters in the input
&+ # Add the transpose of this array to itself to create a 2D array of indices
#
# + 1 2 3 4
# ----------
# 1 | 2 3 4 5
# 2 | 3 4 5 6
# 3 | 4 5 6 7
# 4 | 5 6 7 8
#
) # Use this 2D array to index into the original string using periodic indexing
# Implicitly display the resulting character array
@LuisMendo Clever! Thanks!
– Suever
Dec 12 at 10:50
add a comment |
MATL, 6 5 bytes
tf&+)
1 byte saved thanks to @luis!
Try it at MATL Online!
Explanation:
# Implicitly grab input string
t # Duplicate the input
f # Create an array [1, ..., N] where N is the number of characters in the input
&+ # Add the transpose of this array to itself to create a 2D array of indices
#
# + 1 2 3 4
# ----------
# 1 | 2 3 4 5
# 2 | 3 4 5 6
# 3 | 4 5 6 7
# 4 | 5 6 7 8
#
) # Use this 2D array to index into the original string using periodic indexing
# Implicitly display the resulting character array
MATL, 6 5 bytes
tf&+)
1 byte saved thanks to @luis!
Try it at MATL Online!
Explanation:
# Implicitly grab input string
t # Duplicate the input
f # Create an array [1, ..., N] where N is the number of characters in the input
&+ # Add the transpose of this array to itself to create a 2D array of indices
#
# + 1 2 3 4
# ----------
# 1 | 2 3 4 5
# 2 | 3 4 5 6
# 3 | 4 5 6 7
# 4 | 5 6 7 8
#
) # Use this 2D array to index into the original string using periodic indexing
# Implicitly display the resulting character array
edited Dec 12 at 10:50
answered Dec 9 at 21:49
Suever
9,5421345
9,5421345
@LuisMendo Clever! Thanks!
– Suever
Dec 12 at 10:50
add a comment |
@LuisMendo Clever! Thanks!
– Suever
Dec 12 at 10:50
@LuisMendo Clever! Thanks!
– Suever
Dec 12 at 10:50
@LuisMendo Clever! Thanks!
– Suever
Dec 12 at 10:50
add a comment |
05AB1E, 3 bytes
ā._
Try it online!
add a comment |
05AB1E, 3 bytes
ā._
Try it online!
add a comment |
05AB1E, 3 bytes
ā._
Try it online!
05AB1E, 3 bytes
ā._
Try it online!
edited Dec 8 at 22:58
answered Dec 8 at 22:28
Okx
12.5k127102
12.5k127102
add a comment |
add a comment |
Attache, 13 bytes
Rotate#{1:#_}
Try it online!
Explanation
Rotate#{1:#_}
# fork(f, g) = ${ f[x, g[x]] }; this forks:
Rotate rotate's the input by
{1:#_} each number from 1 to the length of the input
Alternatives
15 bytes: {_&Rotate!1:#_}
16 bytes: {Rotate[_,1:#_]}
16 bytes: Rotate@Rotations
16 bytes: Rotate#(1&`:@`#)
17 bytes: Rotate#{1+Iota@_}
18 bytes: Rotate#(1&`+@Iota)
19 bytes: Rotate#(Succ=>Iota)
add a comment |
Attache, 13 bytes
Rotate#{1:#_}
Try it online!
Explanation
Rotate#{1:#_}
# fork(f, g) = ${ f[x, g[x]] }; this forks:
Rotate rotate's the input by
{1:#_} each number from 1 to the length of the input
Alternatives
15 bytes: {_&Rotate!1:#_}
16 bytes: {Rotate[_,1:#_]}
16 bytes: Rotate@Rotations
16 bytes: Rotate#(1&`:@`#)
17 bytes: Rotate#{1+Iota@_}
18 bytes: Rotate#(1&`+@Iota)
19 bytes: Rotate#(Succ=>Iota)
add a comment |
Attache, 13 bytes
Rotate#{1:#_}
Try it online!
Explanation
Rotate#{1:#_}
# fork(f, g) = ${ f[x, g[x]] }; this forks:
Rotate rotate's the input by
{1:#_} each number from 1 to the length of the input
Alternatives
15 bytes: {_&Rotate!1:#_}
16 bytes: {Rotate[_,1:#_]}
16 bytes: Rotate@Rotations
16 bytes: Rotate#(1&`:@`#)
17 bytes: Rotate#{1+Iota@_}
18 bytes: Rotate#(1&`+@Iota)
19 bytes: Rotate#(Succ=>Iota)
Attache, 13 bytes
Rotate#{1:#_}
Try it online!
Explanation
Rotate#{1:#_}
# fork(f, g) = ${ f[x, g[x]] }; this forks:
Rotate rotate's the input by
{1:#_} each number from 1 to the length of the input
Alternatives
15 bytes: {_&Rotate!1:#_}
16 bytes: {Rotate[_,1:#_]}
16 bytes: Rotate@Rotations
16 bytes: Rotate#(1&`:@`#)
17 bytes: Rotate#{1+Iota@_}
18 bytes: Rotate#(1&`+@Iota)
19 bytes: Rotate#(Succ=>Iota)
answered Dec 9 at 0:40
Conor O'Brien
29.1k263162
29.1k263162
add a comment |
add a comment |
R, 58 bytes
function(s,`[`=substring)paste0(s[n<-nchar(s):1],s[1,n-1])
Try it online!
add a comment |
R, 58 bytes
function(s,`[`=substring)paste0(s[n<-nchar(s):1],s[1,n-1])
Try it online!
add a comment |
R, 58 bytes
function(s,`[`=substring)paste0(s[n<-nchar(s):1],s[1,n-1])
Try it online!
R, 58 bytes
function(s,`[`=substring)paste0(s[n<-nchar(s):1],s[1,n-1])
Try it online!
answered Dec 9 at 17:43
digEmAll
2,43148
2,43148
add a comment |
add a comment |
brainfuck, 59 bytes
,[>,]<[>>[>]+[<]<[<]>-[[>]>[>]<+[<]<[<]>-]>[.>]>[.>]<[<].<]
Try it online!
Outputs each string separated by null bytes.
Explanation:
,[>,] # Get input
<[ # Start loop over input
>>[>] # Go to end of the string
+ # Set it to one to mark it
[<]<[<]> # Move to the beginning of input
-[[>]>[>]<+[<]<[<]>-] # Transfer the first character to the end
>[.>]>[.>] # Print the rotated string
<[<]. # Print a nul byte
<] # Repeat loop while input
add a comment |
brainfuck, 59 bytes
,[>,]<[>>[>]+[<]<[<]>-[[>]>[>]<+[<]<[<]>-]>[.>]>[.>]<[<].<]
Try it online!
Outputs each string separated by null bytes.
Explanation:
,[>,] # Get input
<[ # Start loop over input
>>[>] # Go to end of the string
+ # Set it to one to mark it
[<]<[<]> # Move to the beginning of input
-[[>]>[>]<+[<]<[<]>-] # Transfer the first character to the end
>[.>]>[.>] # Print the rotated string
<[<]. # Print a nul byte
<] # Repeat loop while input
add a comment |
brainfuck, 59 bytes
,[>,]<[>>[>]+[<]<[<]>-[[>]>[>]<+[<]<[<]>-]>[.>]>[.>]<[<].<]
Try it online!
Outputs each string separated by null bytes.
Explanation:
,[>,] # Get input
<[ # Start loop over input
>>[>] # Go to end of the string
+ # Set it to one to mark it
[<]<[<]> # Move to the beginning of input
-[[>]>[>]<+[<]<[<]>-] # Transfer the first character to the end
>[.>]>[.>] # Print the rotated string
<[<]. # Print a nul byte
<] # Repeat loop while input
brainfuck, 59 bytes
,[>,]<[>>[>]+[<]<[<]>-[[>]>[>]<+[<]<[<]>-]>[.>]>[.>]<[<].<]
Try it online!
Outputs each string separated by null bytes.
Explanation:
,[>,] # Get input
<[ # Start loop over input
>>[>] # Go to end of the string
+ # Set it to one to mark it
[<]<[<]> # Move to the beginning of input
-[[>]>[>]<+[<]<[<]>-] # Transfer the first character to the end
>[.>]>[.>] # Print the rotated string
<[<]. # Print a nul byte
<] # Repeat loop while input
answered Dec 9 at 23:23
Jo King
20.7k247109
20.7k247109
add a comment |
add a comment |
Wolfram Language (Mathematica), 35 26 bytes
Partition[#,Tr[1^#],1,-1]&
Try it online!
Takes a list of characters as input.
Partition
(but not its variant StringPartition
used below) has an optional fourth argument for treating its input as cyclic (and for specifying how exactly to do so), which makes this solution simpler than the string one - in addition to not having any 15-character built-in functions.
Wolfram Language (Mathematica), 44 bytes
Rest@StringPartition[#<>#,StringLength@#,1]&
Try it online!
The same, but takes a string as input.
Turns "john"
into "johnjohn"
, then takes all the length-StringLength["john"]
substrings of this string with offset 1, producing {"john","ohnj","hnjo","njoh","john"}
, then drops the first of these with Rest
.
Since character arrays are allowed,Rest@Partition[#~Join~#,Length@#,1]&
would be 36 bytes.
– LegionMammal978
Dec 9 at 22:23
@LegionMammal978 Thanks! There's probably also a shorter approach with character arrays, though I haven't thought of anything yet.
– Misha Lavrov
Dec 9 at 22:45
add a comment |
Wolfram Language (Mathematica), 35 26 bytes
Partition[#,Tr[1^#],1,-1]&
Try it online!
Takes a list of characters as input.
Partition
(but not its variant StringPartition
used below) has an optional fourth argument for treating its input as cyclic (and for specifying how exactly to do so), which makes this solution simpler than the string one - in addition to not having any 15-character built-in functions.
Wolfram Language (Mathematica), 44 bytes
Rest@StringPartition[#<>#,StringLength@#,1]&
Try it online!
The same, but takes a string as input.
Turns "john"
into "johnjohn"
, then takes all the length-StringLength["john"]
substrings of this string with offset 1, producing {"john","ohnj","hnjo","njoh","john"}
, then drops the first of these with Rest
.
Since character arrays are allowed,Rest@Partition[#~Join~#,Length@#,1]&
would be 36 bytes.
– LegionMammal978
Dec 9 at 22:23
@LegionMammal978 Thanks! There's probably also a shorter approach with character arrays, though I haven't thought of anything yet.
– Misha Lavrov
Dec 9 at 22:45
add a comment |
Wolfram Language (Mathematica), 35 26 bytes
Partition[#,Tr[1^#],1,-1]&
Try it online!
Takes a list of characters as input.
Partition
(but not its variant StringPartition
used below) has an optional fourth argument for treating its input as cyclic (and for specifying how exactly to do so), which makes this solution simpler than the string one - in addition to not having any 15-character built-in functions.
Wolfram Language (Mathematica), 44 bytes
Rest@StringPartition[#<>#,StringLength@#,1]&
Try it online!
The same, but takes a string as input.
Turns "john"
into "johnjohn"
, then takes all the length-StringLength["john"]
substrings of this string with offset 1, producing {"john","ohnj","hnjo","njoh","john"}
, then drops the first of these with Rest
.
Wolfram Language (Mathematica), 35 26 bytes
Partition[#,Tr[1^#],1,-1]&
Try it online!
Takes a list of characters as input.
Partition
(but not its variant StringPartition
used below) has an optional fourth argument for treating its input as cyclic (and for specifying how exactly to do so), which makes this solution simpler than the string one - in addition to not having any 15-character built-in functions.
Wolfram Language (Mathematica), 44 bytes
Rest@StringPartition[#<>#,StringLength@#,1]&
Try it online!
The same, but takes a string as input.
Turns "john"
into "johnjohn"
, then takes all the length-StringLength["john"]
substrings of this string with offset 1, producing {"john","ohnj","hnjo","njoh","john"}
, then drops the first of these with Rest
.
edited Dec 12 at 21:21
answered Dec 9 at 0:04
Misha Lavrov
4,181424
4,181424
Since character arrays are allowed,Rest@Partition[#~Join~#,Length@#,1]&
would be 36 bytes.
– LegionMammal978
Dec 9 at 22:23
@LegionMammal978 Thanks! There's probably also a shorter approach with character arrays, though I haven't thought of anything yet.
– Misha Lavrov
Dec 9 at 22:45
add a comment |
Since character arrays are allowed,Rest@Partition[#~Join~#,Length@#,1]&
would be 36 bytes.
– LegionMammal978
Dec 9 at 22:23
@LegionMammal978 Thanks! There's probably also a shorter approach with character arrays, though I haven't thought of anything yet.
– Misha Lavrov
Dec 9 at 22:45
Since character arrays are allowed,
Rest@Partition[#~Join~#,Length@#,1]&
would be 36 bytes.– LegionMammal978
Dec 9 at 22:23
Since character arrays are allowed,
Rest@Partition[#~Join~#,Length@#,1]&
would be 36 bytes.– LegionMammal978
Dec 9 at 22:23
@LegionMammal978 Thanks! There's probably also a shorter approach with character arrays, though I haven't thought of anything yet.
– Misha Lavrov
Dec 9 at 22:45
@LegionMammal978 Thanks! There's probably also a shorter approach with character arrays, though I haven't thought of anything yet.
– Misha Lavrov
Dec 9 at 22:45
add a comment |
Charcoal, 10 bytes
⮌Eθ⭆θ§θ⁻μκ
Try it online! Link is to verbose version of code. Explanation:
θ Input string
E Map over characters
θ Input string
⭆ Map over characters and join
θ Input string
§ Circularly indexed by
⁻ Difference between
μ Inner index
κ Outer index
⮌ Reversed
Implicitly print each string on its own line
To rotate in the opposite direction, replace Minus
with Plus
.
add a comment |
Charcoal, 10 bytes
⮌Eθ⭆θ§θ⁻μκ
Try it online! Link is to verbose version of code. Explanation:
θ Input string
E Map over characters
θ Input string
⭆ Map over characters and join
θ Input string
§ Circularly indexed by
⁻ Difference between
μ Inner index
κ Outer index
⮌ Reversed
Implicitly print each string on its own line
To rotate in the opposite direction, replace Minus
with Plus
.
add a comment |
Charcoal, 10 bytes
⮌Eθ⭆θ§θ⁻μκ
Try it online! Link is to verbose version of code. Explanation:
θ Input string
E Map over characters
θ Input string
⭆ Map over characters and join
θ Input string
§ Circularly indexed by
⁻ Difference between
μ Inner index
κ Outer index
⮌ Reversed
Implicitly print each string on its own line
To rotate in the opposite direction, replace Minus
with Plus
.
Charcoal, 10 bytes
⮌Eθ⭆θ§θ⁻μκ
Try it online! Link is to verbose version of code. Explanation:
θ Input string
E Map over characters
θ Input string
⭆ Map over characters and join
θ Input string
§ Circularly indexed by
⁻ Difference between
μ Inner index
κ Outer index
⮌ Reversed
Implicitly print each string on its own line
To rotate in the opposite direction, replace Minus
with Plus
.
answered Dec 8 at 23:54
Neil
79.3k744177
79.3k744177
add a comment |
add a comment |
J, 7 bytes
#|."{]
Try it online!
Explanation:
|."{ - rotate ( "{ is short for "0 1 - rank 0 1 )
] - the input
# - lenght of the successive prefixes of the input
1
Using"
like that is very clever, and requires dictionary knowledge of the language. Is there also a verb with rank1 0
?
– Adám
Dec 9 at 16:24
@Adám I think it's"#:
. I learnt this here from Frownyfrog
– Galen Ivanov
Dec 9 at 18:34
add a comment |
J, 7 bytes
#|."{]
Try it online!
Explanation:
|."{ - rotate ( "{ is short for "0 1 - rank 0 1 )
] - the input
# - lenght of the successive prefixes of the input
1
Using"
like that is very clever, and requires dictionary knowledge of the language. Is there also a verb with rank1 0
?
– Adám
Dec 9 at 16:24
@Adám I think it's"#:
. I learnt this here from Frownyfrog
– Galen Ivanov
Dec 9 at 18:34
add a comment |
J, 7 bytes
#|."{]
Try it online!
Explanation:
|."{ - rotate ( "{ is short for "0 1 - rank 0 1 )
] - the input
# - lenght of the successive prefixes of the input
J, 7 bytes
#|."{]
Try it online!
Explanation:
|."{ - rotate ( "{ is short for "0 1 - rank 0 1 )
] - the input
# - lenght of the successive prefixes of the input
answered Dec 9 at 7:52
Galen Ivanov
6,31711032
6,31711032
1
Using"
like that is very clever, and requires dictionary knowledge of the language. Is there also a verb with rank1 0
?
– Adám
Dec 9 at 16:24
@Adám I think it's"#:
. I learnt this here from Frownyfrog
– Galen Ivanov
Dec 9 at 18:34
add a comment |
1
Using"
like that is very clever, and requires dictionary knowledge of the language. Is there also a verb with rank1 0
?
– Adám
Dec 9 at 16:24
@Adám I think it's"#:
. I learnt this here from Frownyfrog
– Galen Ivanov
Dec 9 at 18:34
1
1
Using
"
like that is very clever, and requires dictionary knowledge of the language. Is there also a verb with rank 1 0
?– Adám
Dec 9 at 16:24
Using
"
like that is very clever, and requires dictionary knowledge of the language. Is there also a verb with rank 1 0
?– Adám
Dec 9 at 16:24
@Adám I think it's
"#:
. I learnt this here from Frownyfrog– Galen Ivanov
Dec 9 at 18:34
@Adám I think it's
"#:
. I learnt this here from Frownyfrog– Galen Ivanov
Dec 9 at 18:34
add a comment |
Red, 49 43 bytes
func[s][forall s[print move head s tail s]]
Try it online!
add a comment |
Red, 49 43 bytes
func[s][forall s[print move head s tail s]]
Try it online!
add a comment |
Red, 49 43 bytes
func[s][forall s[print move head s tail s]]
Try it online!
Red, 49 43 bytes
func[s][forall s[print move head s tail s]]
Try it online!
edited Dec 9 at 9:15
answered Dec 9 at 8:42
Galen Ivanov
6,31711032
6,31711032
add a comment |
add a comment |
Python 2, 54 48 bytes
lambda i:[i[x:]+i[:x]for x in range(1,len(i)+1)]
Try it online!
Well beaten by xnor but posted as an alternative approach anyway.
add a comment |
Python 2, 54 48 bytes
lambda i:[i[x:]+i[:x]for x in range(1,len(i)+1)]
Try it online!
Well beaten by xnor but posted as an alternative approach anyway.
add a comment |
Python 2, 54 48 bytes
lambda i:[i[x:]+i[:x]for x in range(1,len(i)+1)]
Try it online!
Well beaten by xnor but posted as an alternative approach anyway.
Python 2, 54 48 bytes
lambda i:[i[x:]+i[:x]for x in range(1,len(i)+1)]
Try it online!
Well beaten by xnor but posted as an alternative approach anyway.
edited Dec 9 at 15:56
answered Dec 9 at 9:03
ElPedro
3,4631023
3,4631023
add a comment |
add a comment |
Perl 6, 32 bytes
{m:ex/^(.*)(.+)$/».&{[R~] @$_}}
Try it online!
m:ex/^(.*)(.+)$/
ex
haustively m
atches the given regex, splitting the input string at every possible place, except that the second substring must have at least one character--that prevents the input string from showing up twice in the output. Then each of the resulting Match
objects' capture groups are reduced () to a single string with
R~
, the reversed string concatenation operator.
add a comment |
Perl 6, 32 bytes
{m:ex/^(.*)(.+)$/».&{[R~] @$_}}
Try it online!
m:ex/^(.*)(.+)$/
ex
haustively m
atches the given regex, splitting the input string at every possible place, except that the second substring must have at least one character--that prevents the input string from showing up twice in the output. Then each of the resulting Match
objects' capture groups are reduced () to a single string with
R~
, the reversed string concatenation operator.
add a comment |
Perl 6, 32 bytes
{m:ex/^(.*)(.+)$/».&{[R~] @$_}}
Try it online!
m:ex/^(.*)(.+)$/
ex
haustively m
atches the given regex, splitting the input string at every possible place, except that the second substring must have at least one character--that prevents the input string from showing up twice in the output. Then each of the resulting Match
objects' capture groups are reduced () to a single string with
R~
, the reversed string concatenation operator.
Perl 6, 32 bytes
{m:ex/^(.*)(.+)$/».&{[R~] @$_}}
Try it online!
m:ex/^(.*)(.+)$/
ex
haustively m
atches the given regex, splitting the input string at every possible place, except that the second substring must have at least one character--that prevents the input string from showing up twice in the output. Then each of the resulting Match
objects' capture groups are reduced () to a single string with
R~
, the reversed string concatenation operator.
answered Dec 9 at 19:35
Sean
3,35636
3,35636
add a comment |
add a comment |
C# (Visual C# Interactive Compiler), 34 bytes
x=>x.Select(c=>x=x.Substring(1)+c)
Try it online!
add a comment |
C# (Visual C# Interactive Compiler), 34 bytes
x=>x.Select(c=>x=x.Substring(1)+c)
Try it online!
add a comment |
C# (Visual C# Interactive Compiler), 34 bytes
x=>x.Select(c=>x=x.Substring(1)+c)
Try it online!
C# (Visual C# Interactive Compiler), 34 bytes
x=>x.Select(c=>x=x.Substring(1)+c)
Try it online!
edited Dec 10 at 1:55
answered Dec 9 at 23:26
dana
40135
40135
add a comment |
add a comment |
V, 8 bytes
ýñx$pÙñd
Try it online!
Hexdump:
00000000: fdf1 7824 70d9 f164 ..x$p..d
ýñx$pÙñd
gives 8 by removing the need toH
tio.run/##K/v///DewxsrVAoOzzy8MeX/f6/8jDwA
– Cows quack
Dec 9 at 19:43
@Cowsquack Even better:ý<M-->ñx$pÙ
– DJMcMayhem♦
Dec 9 at 20:54
Doesn't that repeat the last line?
– Cows quack
Dec 10 at 6:18
add a comment |
V, 8 bytes
ýñx$pÙñd
Try it online!
Hexdump:
00000000: fdf1 7824 70d9 f164 ..x$p..d
ýñx$pÙñd
gives 8 by removing the need toH
tio.run/##K/v///DewxsrVAoOzzy8MeX/f6/8jDwA
– Cows quack
Dec 9 at 19:43
@Cowsquack Even better:ý<M-->ñx$pÙ
– DJMcMayhem♦
Dec 9 at 20:54
Doesn't that repeat the last line?
– Cows quack
Dec 10 at 6:18
add a comment |
V, 8 bytes
ýñx$pÙñd
Try it online!
Hexdump:
00000000: fdf1 7824 70d9 f164 ..x$p..d
V, 8 bytes
ýñx$pÙñd
Try it online!
Hexdump:
00000000: fdf1 7824 70d9 f164 ..x$p..d
edited Dec 10 at 7:35
answered Dec 8 at 22:21
DJMcMayhem♦
40.9k11145309
40.9k11145309
ýñx$pÙñd
gives 8 by removing the need toH
tio.run/##K/v///DewxsrVAoOzzy8MeX/f6/8jDwA
– Cows quack
Dec 9 at 19:43
@Cowsquack Even better:ý<M-->ñx$pÙ
– DJMcMayhem♦
Dec 9 at 20:54
Doesn't that repeat the last line?
– Cows quack
Dec 10 at 6:18
add a comment |
ýñx$pÙñd
gives 8 by removing the need toH
tio.run/##K/v///DewxsrVAoOzzy8MeX/f6/8jDwA
– Cows quack
Dec 9 at 19:43
@Cowsquack Even better:ý<M-->ñx$pÙ
– DJMcMayhem♦
Dec 9 at 20:54
Doesn't that repeat the last line?
– Cows quack
Dec 10 at 6:18
ýñx$pÙñd
gives 8 by removing the need to H
tio.run/##K/v///DewxsrVAoOzzy8MeX/f6/8jDwA– Cows quack
Dec 9 at 19:43
ýñx$pÙñd
gives 8 by removing the need to H
tio.run/##K/v///DewxsrVAoOzzy8MeX/f6/8jDwA– Cows quack
Dec 9 at 19:43
@Cowsquack Even better:
ý<M-->ñx$pÙ
– DJMcMayhem♦
Dec 9 at 20:54
@Cowsquack Even better:
ý<M-->ñx$pÙ
– DJMcMayhem♦
Dec 9 at 20:54
Doesn't that repeat the last line?
– Cows quack
Dec 10 at 6:18
Doesn't that repeat the last line?
– Cows quack
Dec 10 at 6:18
add a comment |
Tcl, 80 91 bytes
proc P s {time {puts [set s [string ra $s 1 e][string in $s 0]]} [string le $s]}
Try it online!
Reassign text at each time saves some bytesproc R t {time {puts [set t [string ra $t 1 end][string in $t 0]]} [string len $t]}
– david
Dec 9 at 18:05
Got it down to 80 bytes, thanks to @david
– sergiol
Dec 10 at 10:54
add a comment |
Tcl, 80 91 bytes
proc P s {time {puts [set s [string ra $s 1 e][string in $s 0]]} [string le $s]}
Try it online!
Reassign text at each time saves some bytesproc R t {time {puts [set t [string ra $t 1 end][string in $t 0]]} [string len $t]}
– david
Dec 9 at 18:05
Got it down to 80 bytes, thanks to @david
– sergiol
Dec 10 at 10:54
add a comment |
Tcl, 80 91 bytes
proc P s {time {puts [set s [string ra $s 1 e][string in $s 0]]} [string le $s]}
Try it online!
Tcl, 80 91 bytes
proc P s {time {puts [set s [string ra $s 1 e][string in $s 0]]} [string le $s]}
Try it online!
edited Dec 10 at 10:54
answered Dec 8 at 23:50
sergiol
2,4921925
2,4921925
Reassign text at each time saves some bytesproc R t {time {puts [set t [string ra $t 1 end][string in $t 0]]} [string len $t]}
– david
Dec 9 at 18:05
Got it down to 80 bytes, thanks to @david
– sergiol
Dec 10 at 10:54
add a comment |
Reassign text at each time saves some bytesproc R t {time {puts [set t [string ra $t 1 end][string in $t 0]]} [string len $t]}
– david
Dec 9 at 18:05
Got it down to 80 bytes, thanks to @david
– sergiol
Dec 10 at 10:54
Reassign text at each time saves some bytes
proc R t {time {puts [set t [string ra $t 1 end][string in $t 0]]} [string len $t]}
– david
Dec 9 at 18:05
Reassign text at each time saves some bytes
proc R t {time {puts [set t [string ra $t 1 end][string in $t 0]]} [string len $t]}
– david
Dec 9 at 18:05
Got it down to 80 bytes, thanks to @david
– sergiol
Dec 10 at 10:54
Got it down to 80 bytes, thanks to @david
– sergiol
Dec 10 at 10:54
add a comment |
C (32-bit), 58 51 bytes
i;f(s){for(i=0;i++<printf("%s%.*sn",s+i,i,s)-2;);}
Try it online!
Degolf
i; // "Global" i.
f(s){ // s is pointer to string, which conveniently fits in a 32 bit integer.
for(i=0; // Initialize i.
// Post-increment i, compare to return value of printf,
// which just happens to be the number of chars printed, i.e.
// the length of string s plus 1. Because the printf() is
// evaluated before the comparison, we need to deduct 2 instead
// of 1 from the return value.
i++ < printf("%s%.*sn",s+i,i,s);)-2;
// The printf prints two strings: first until the terminating ,
// the second until a or until i chars have been printed.
}
add a comment |
C (32-bit), 58 51 bytes
i;f(s){for(i=0;i++<printf("%s%.*sn",s+i,i,s)-2;);}
Try it online!
Degolf
i; // "Global" i.
f(s){ // s is pointer to string, which conveniently fits in a 32 bit integer.
for(i=0; // Initialize i.
// Post-increment i, compare to return value of printf,
// which just happens to be the number of chars printed, i.e.
// the length of string s plus 1. Because the printf() is
// evaluated before the comparison, we need to deduct 2 instead
// of 1 from the return value.
i++ < printf("%s%.*sn",s+i,i,s);)-2;
// The printf prints two strings: first until the terminating ,
// the second until a or until i chars have been printed.
}
add a comment |
C (32-bit), 58 51 bytes
i;f(s){for(i=0;i++<printf("%s%.*sn",s+i,i,s)-2;);}
Try it online!
Degolf
i; // "Global" i.
f(s){ // s is pointer to string, which conveniently fits in a 32 bit integer.
for(i=0; // Initialize i.
// Post-increment i, compare to return value of printf,
// which just happens to be the number of chars printed, i.e.
// the length of string s plus 1. Because the printf() is
// evaluated before the comparison, we need to deduct 2 instead
// of 1 from the return value.
i++ < printf("%s%.*sn",s+i,i,s);)-2;
// The printf prints two strings: first until the terminating ,
// the second until a or until i chars have been printed.
}
C (32-bit), 58 51 bytes
i;f(s){for(i=0;i++<printf("%s%.*sn",s+i,i,s)-2;);}
Try it online!
Degolf
i; // "Global" i.
f(s){ // s is pointer to string, which conveniently fits in a 32 bit integer.
for(i=0; // Initialize i.
// Post-increment i, compare to return value of printf,
// which just happens to be the number of chars printed, i.e.
// the length of string s plus 1. Because the printf() is
// evaluated before the comparison, we need to deduct 2 instead
// of 1 from the return value.
i++ < printf("%s%.*sn",s+i,i,s);)-2;
// The printf prints two strings: first until the terminating ,
// the second until a or until i chars have been printed.
}
edited Dec 12 at 9:10
answered Dec 9 at 18:47
Rogem
68112
68112
add a comment |
add a comment |
Ruby, 39 bytes
->s{a=s.chars.to_a;a.map{a.rotate!*''}}
Try it online!
1
Welcome to the site! It doesn't look like your TIO link corresponds to your answer. It also seems your answer doesn't fit with our input/output requirements. You can use either a function or STDIN/STDOUT but we don't allow variable reassignment.
– Wît Wisarhd
Dec 11 at 5:10
Thanks Garf. Not sure how I managed to mess both of those up. Should be all good now.
– acornellier
Dec 13 at 4:45
add a comment |
Ruby, 39 bytes
->s{a=s.chars.to_a;a.map{a.rotate!*''}}
Try it online!
1
Welcome to the site! It doesn't look like your TIO link corresponds to your answer. It also seems your answer doesn't fit with our input/output requirements. You can use either a function or STDIN/STDOUT but we don't allow variable reassignment.
– Wît Wisarhd
Dec 11 at 5:10
Thanks Garf. Not sure how I managed to mess both of those up. Should be all good now.
– acornellier
Dec 13 at 4:45
add a comment |
Ruby, 39 bytes
->s{a=s.chars.to_a;a.map{a.rotate!*''}}
Try it online!
Ruby, 39 bytes
->s{a=s.chars.to_a;a.map{a.rotate!*''}}
Try it online!
edited Dec 13 at 4:47
answered Dec 11 at 4:57
acornellier
112
112
1
Welcome to the site! It doesn't look like your TIO link corresponds to your answer. It also seems your answer doesn't fit with our input/output requirements. You can use either a function or STDIN/STDOUT but we don't allow variable reassignment.
– Wît Wisarhd
Dec 11 at 5:10
Thanks Garf. Not sure how I managed to mess both of those up. Should be all good now.
– acornellier
Dec 13 at 4:45
add a comment |
1
Welcome to the site! It doesn't look like your TIO link corresponds to your answer. It also seems your answer doesn't fit with our input/output requirements. You can use either a function or STDIN/STDOUT but we don't allow variable reassignment.
– Wît Wisarhd
Dec 11 at 5:10
Thanks Garf. Not sure how I managed to mess both of those up. Should be all good now.
– acornellier
Dec 13 at 4:45
1
1
Welcome to the site! It doesn't look like your TIO link corresponds to your answer. It also seems your answer doesn't fit with our input/output requirements. You can use either a function or STDIN/STDOUT but we don't allow variable reassignment.
– Wît Wisarhd
Dec 11 at 5:10
Welcome to the site! It doesn't look like your TIO link corresponds to your answer. It also seems your answer doesn't fit with our input/output requirements. You can use either a function or STDIN/STDOUT but we don't allow variable reassignment.
– Wît Wisarhd
Dec 11 at 5:10
Thanks Garf. Not sure how I managed to mess both of those up. Should be all good now.
– acornellier
Dec 13 at 4:45
Thanks Garf. Not sure how I managed to mess both of those up. Should be all good now.
– acornellier
Dec 13 at 4:45
add a comment |
Pyth, 11 bytes
VSlQ+>QN<QN
Try it online!
Pretty much just a port of my Python answer
Explanation
==================================================
assign('Q',eval_input())
for N in num_to_range(Psorted(Plen(Q))):
imp_print(plus(gt(Q,N),lt(Q,N)))
==================================================
V # for N in
S # 1-indexed range
lQ # length of evaluated input
+ # concatanate
>QN # all characters after index N in Q (Q[N:])
<QN # and all characters before index N in Q (Q[:N])
add a comment |
Pyth, 11 bytes
VSlQ+>QN<QN
Try it online!
Pretty much just a port of my Python answer
Explanation
==================================================
assign('Q',eval_input())
for N in num_to_range(Psorted(Plen(Q))):
imp_print(plus(gt(Q,N),lt(Q,N)))
==================================================
V # for N in
S # 1-indexed range
lQ # length of evaluated input
+ # concatanate
>QN # all characters after index N in Q (Q[N:])
<QN # and all characters before index N in Q (Q[:N])
add a comment |
Pyth, 11 bytes
VSlQ+>QN<QN
Try it online!
Pretty much just a port of my Python answer
Explanation
==================================================
assign('Q',eval_input())
for N in num_to_range(Psorted(Plen(Q))):
imp_print(plus(gt(Q,N),lt(Q,N)))
==================================================
V # for N in
S # 1-indexed range
lQ # length of evaluated input
+ # concatanate
>QN # all characters after index N in Q (Q[N:])
<QN # and all characters before index N in Q (Q[:N])
Pyth, 11 bytes
VSlQ+>QN<QN
Try it online!
Pretty much just a port of my Python answer
Explanation
==================================================
assign('Q',eval_input())
for N in num_to_range(Psorted(Plen(Q))):
imp_print(plus(gt(Q,N),lt(Q,N)))
==================================================
V # for N in
S # 1-indexed range
lQ # length of evaluated input
+ # concatanate
>QN # all characters after index N in Q (Q[N:])
<QN # and all characters before index N in Q (Q[:N])
edited Dec 9 at 18:10
answered Dec 9 at 13:36
ElPedro
3,4631023
3,4631023
add a comment |
add a comment |
Tcl, 78 bytes
proc R t {time {puts [set t [regsub -all (.?)(.*) $t {21}]]} [string le $t]}
Try it online!
add a comment |
Tcl, 78 bytes
proc R t {time {puts [set t [regsub -all (.?)(.*) $t {21}]]} [string le $t]}
Try it online!
add a comment |
Tcl, 78 bytes
proc R t {time {puts [set t [regsub -all (.?)(.*) $t {21}]]} [string le $t]}
Try it online!
Tcl, 78 bytes
proc R t {time {puts [set t [regsub -all (.?)(.*) $t {21}]]} [string le $t]}
Try it online!
answered Dec 9 at 18:38
david
12419
12419
add a comment |
add a comment |
Pushy, 4 bytes
L:{"
Try it online!
L: Length of the string times do:
{ Cyclically shift left once
" Print
add a comment |
Pushy, 4 bytes
L:{"
Try it online!
L: Length of the string times do:
{ Cyclically shift left once
" Print
add a comment |
Pushy, 4 bytes
L:{"
Try it online!
L: Length of the string times do:
{ Cyclically shift left once
" Print
Pushy, 4 bytes
L:{"
Try it online!
L: Length of the string times do:
{ Cyclically shift left once
" Print
answered Dec 9 at 21:57
FlipTack
9,12834089
9,12834089
add a comment |
add a comment |
Perl 6, 20 bytes
{.rotate(all 1..$_)}
Try it online!
Anonymous code block that has input/output as a list of characters. The output is a Junction object that contains all the rotated arrays. I'm not sure how legal this is, since extracting values from a Junction is not normal.
Explanation:
{ } # Anonymous codeblock
.rotate( ) # Rotate the input list
all 1..$_ # By all of the range 1 to length of the input array
# all creates a junction of values
# And it runs the function on each value
The all
can be replaced by any of any
, one
, [&]
, [|]
, [^]
.
If the Junction isn't allowed, here's an alternate solution for 22 bytes:
{.&{.rotate(++$)xx$_}}
Try it online!
There's probably a better way to reset the anonymous variable ++$
than by wrapping the code in another code block...
add a comment |
Perl 6, 20 bytes
{.rotate(all 1..$_)}
Try it online!
Anonymous code block that has input/output as a list of characters. The output is a Junction object that contains all the rotated arrays. I'm not sure how legal this is, since extracting values from a Junction is not normal.
Explanation:
{ } # Anonymous codeblock
.rotate( ) # Rotate the input list
all 1..$_ # By all of the range 1 to length of the input array
# all creates a junction of values
# And it runs the function on each value
The all
can be replaced by any of any
, one
, [&]
, [|]
, [^]
.
If the Junction isn't allowed, here's an alternate solution for 22 bytes:
{.&{.rotate(++$)xx$_}}
Try it online!
There's probably a better way to reset the anonymous variable ++$
than by wrapping the code in another code block...
add a comment |
Perl 6, 20 bytes
{.rotate(all 1..$_)}
Try it online!
Anonymous code block that has input/output as a list of characters. The output is a Junction object that contains all the rotated arrays. I'm not sure how legal this is, since extracting values from a Junction is not normal.
Explanation:
{ } # Anonymous codeblock
.rotate( ) # Rotate the input list
all 1..$_ # By all of the range 1 to length of the input array
# all creates a junction of values
# And it runs the function on each value
The all
can be replaced by any of any
, one
, [&]
, [|]
, [^]
.
If the Junction isn't allowed, here's an alternate solution for 22 bytes:
{.&{.rotate(++$)xx$_}}
Try it online!
There's probably a better way to reset the anonymous variable ++$
than by wrapping the code in another code block...
Perl 6, 20 bytes
{.rotate(all 1..$_)}
Try it online!
Anonymous code block that has input/output as a list of characters. The output is a Junction object that contains all the rotated arrays. I'm not sure how legal this is, since extracting values from a Junction is not normal.
Explanation:
{ } # Anonymous codeblock
.rotate( ) # Rotate the input list
all 1..$_ # By all of the range 1 to length of the input array
# all creates a junction of values
# And it runs the function on each value
The all
can be replaced by any of any
, one
, [&]
, [|]
, [^]
.
If the Junction isn't allowed, here's an alternate solution for 22 bytes:
{.&{.rotate(++$)xx$_}}
Try it online!
There's probably a better way to reset the anonymous variable ++$
than by wrapping the code in another code block...
answered Dec 9 at 22:56
Jo King
20.7k247109
20.7k247109
add a comment |
add a comment |
JavaScript, 48 43 bytes
-5 bytes courtesy of @Bubbler
s=>[...s].map(_=>([a,...b]=s,s=b.join``+a))
Try it online!
1
43 bytes.
– Bubbler
Dec 10 at 1:54
add a comment |
JavaScript, 48 43 bytes
-5 bytes courtesy of @Bubbler
s=>[...s].map(_=>([a,...b]=s,s=b.join``+a))
Try it online!
1
43 bytes.
– Bubbler
Dec 10 at 1:54
add a comment |
JavaScript, 48 43 bytes
-5 bytes courtesy of @Bubbler
s=>[...s].map(_=>([a,...b]=s,s=b.join``+a))
Try it online!
JavaScript, 48 43 bytes
-5 bytes courtesy of @Bubbler
s=>[...s].map(_=>([a,...b]=s,s=b.join``+a))
Try it online!
edited Dec 10 at 1:59
answered Dec 10 at 0:58
guest271314
317211
317211
1
43 bytes.
– Bubbler
Dec 10 at 1:54
add a comment |
1
43 bytes.
– Bubbler
Dec 10 at 1:54
1
1
43 bytes.
– Bubbler
Dec 10 at 1:54
43 bytes.
– Bubbler
Dec 10 at 1:54
add a comment |
Powershell, 44 bytes
($s=$args|% t*y)|%{$h,$t=$s;-join($s=$t+$h)}
Test script:
$f = {
($s=$args|% t*y)|%{$h,$t=$s;-join($s=$t+$h)}
}
@(
,('john', 'ohnj', 'hnjo', 'njoh', 'john')
,('heehee', 'eeheeh', 'eheehe', 'heehee', 'eeheeh', 'eheehe', 'heehee')
) | % {
$s,$expected = $_
$result = &$f $s
"$result"-eq"$expected"
$result
}
output:
True
ohnj
hnjo
njoh
john
True
eeheeh
eheehe
heehee
eeheeh
eheehe
heehee
add a comment |
Powershell, 44 bytes
($s=$args|% t*y)|%{$h,$t=$s;-join($s=$t+$h)}
Test script:
$f = {
($s=$args|% t*y)|%{$h,$t=$s;-join($s=$t+$h)}
}
@(
,('john', 'ohnj', 'hnjo', 'njoh', 'john')
,('heehee', 'eeheeh', 'eheehe', 'heehee', 'eeheeh', 'eheehe', 'heehee')
) | % {
$s,$expected = $_
$result = &$f $s
"$result"-eq"$expected"
$result
}
output:
True
ohnj
hnjo
njoh
john
True
eeheeh
eheehe
heehee
eeheeh
eheehe
heehee
add a comment |
Powershell, 44 bytes
($s=$args|% t*y)|%{$h,$t=$s;-join($s=$t+$h)}
Test script:
$f = {
($s=$args|% t*y)|%{$h,$t=$s;-join($s=$t+$h)}
}
@(
,('john', 'ohnj', 'hnjo', 'njoh', 'john')
,('heehee', 'eeheeh', 'eheehe', 'heehee', 'eeheeh', 'eheehe', 'heehee')
) | % {
$s,$expected = $_
$result = &$f $s
"$result"-eq"$expected"
$result
}
output:
True
ohnj
hnjo
njoh
john
True
eeheeh
eheehe
heehee
eeheeh
eheehe
heehee
Powershell, 44 bytes
($s=$args|% t*y)|%{$h,$t=$s;-join($s=$t+$h)}
Test script:
$f = {
($s=$args|% t*y)|%{$h,$t=$s;-join($s=$t+$h)}
}
@(
,('john', 'ohnj', 'hnjo', 'njoh', 'john')
,('heehee', 'eeheeh', 'eheehe', 'heehee', 'eeheeh', 'eheehe', 'heehee')
) | % {
$s,$expected = $_
$result = &$f $s
"$result"-eq"$expected"
$result
}
output:
True
ohnj
hnjo
njoh
john
True
eeheeh
eheehe
heehee
eeheeh
eheehe
heehee
answered Dec 10 at 9:08
mazzy
2,0851315
2,0851315
add a comment |
add a comment |
Pepe, 64 bytes
REEeRREeeeREEEEEREErEEEEErRREEEEEEEREEEeeReReeeReeErRrEEEEEEERee
Try it online! Uses newlines for separation.
add a comment |
Pepe, 64 bytes
REEeRREeeeREEEEEREErEEEEErRREEEEEEEREEEeeReReeeReeErRrEEEEEEERee
Try it online! Uses newlines for separation.
add a comment |
Pepe, 64 bytes
REEeRREeeeREEEEEREErEEEEErRREEEEEEEREEEeeReReeeReeErRrEEEEEEERee
Try it online! Uses newlines for separation.
Pepe, 64 bytes
REEeRREeeeREEEEEREErEEEEErRREEEEEEEREEEeeReReeeReeErRrEEEEEEERee
Try it online! Uses newlines for separation.
answered Dec 10 at 11:44
u_ndefined
654114
654114
add a comment |
add a comment |
Java (JDK), 85 bytes
s->{for(int i=s.length();i-->0;)System.out.println(s.substring(i)+s.substring(0,i));}
Try it online!
add a comment |
Java (JDK), 85 bytes
s->{for(int i=s.length();i-->0;)System.out.println(s.substring(i)+s.substring(0,i));}
Try it online!
add a comment |
Java (JDK), 85 bytes
s->{for(int i=s.length();i-->0;)System.out.println(s.substring(i)+s.substring(0,i));}
Try it online!
Java (JDK), 85 bytes
s->{for(int i=s.length();i-->0;)System.out.println(s.substring(i)+s.substring(0,i));}
Try it online!
edited Dec 10 at 16:35
answered Dec 10 at 16:16
Olivier Grégoire
8,77711843
8,77711843
add a comment |
add a comment |
1 2
next
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).
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f177221%2fstring-rotation-output-string-repeatedly-moving-first-character-to-the-end%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
5
If a string like
heehee
returns to the original order in fewer cycles than its length, do we stop there? I expect this would make a big difference for many answers.– xnor
Dec 8 at 22:43
May we cycle in the other direction?
– xnor
Dec 8 at 22:45
2
I edited the question including your clarifications, feel free to change it if it's not what you intended.
– xnor
Dec 8 at 23:28
1
@xnor that looks much clearer than my original post, thanks so much!
– I_P_Edwards
Dec 9 at 13:38
1
Are we allowed to input/output character arrays? (The distinction can be important in some languages.)
– LegionMammal978
Dec 9 at 18:09