Skip to main content
added 77 characters in body
Source Link
SimpleGeek
  • 503
  • 5
  • 8

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!

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

Shortest answer wins!

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!

Tweeted twitter.com/StackCodeGolf/status/1071645748675133440
Incorporated clarification edit, cleaned up.
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652

String Inversionsrotation - Printoutput string repeatedly moving first character to the end, and continuing inversion

The challenge here is to take a string: "john", for example

And print and output all possible inversions of itits rotations, untilby repeatedly moving the characters arefirst character to the end, once per character in their original orderthe string, as shown belowending with the original string:

john

john -> ohnj, hnjo, njoh, john

ohnjYou may also cycle in the other direction, moving characters from the end:

hnjo

john -> njoh, hnjo, ohnj, john

njohYou should still output one rotation per letter even if the original word is reached before that:

john

heehee -> eeheeh, eheehe, heehee, eeheeh, eheehe, heehee

Shortest answer wins!

EDIT:

To clarify, the first string is the input, and I'd like to see the string cycled through until the original, or input form is printed. If the string can be reached quicker than looping through the entire string, I'd still like to see the whole string gone through. Cycling in the other direction should be just fine, as long as the proper result is still reached.

String Inversions - Print string moving first character to the end, and continuing inversion

The challenge here is to take a string: "john", for example

And print all possible inversions of it, until the characters are in their original order, as shown below:

john

ohnj

hnjo

njoh

john

Shortest answer wins!

EDIT:

To clarify, the first string is the input, and I'd like to see the string cycled through until the original, or input form is printed. If the string can be reached quicker than looping through the entire string, I'd still like to see the whole string gone through. Cycling in the other direction should be just fine, as long as the proper result is still reached.

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

Shortest answer wins!

added 378 characters in body
Source Link
SimpleGeek
  • 503
  • 5
  • 8

The challenge here is to take a string: "john", for example

And print all possible inversions of it, until the characters are in their original order, as shown below:

john

ohnj

hnjo

njoh

john

Shortest answer wins!

EDIT:

To clarify, the first string is the input, and I'd like to see the string cycled through until the original, or input form is printed. If the string can be reached quicker than looping through the entire string, I'd still like to see the whole string gone through. Cycling in the other direction should be just fine, as long as the proper result is still reached.

The challenge here is to take a string: "john", for example

And print all possible inversions of it, until the characters are in their original order, as shown below:

john

ohnj

hnjo

njoh

john

Shortest answer wins!

The challenge here is to take a string: "john", for example

And print all possible inversions of it, until the characters are in their original order, as shown below:

john

ohnj

hnjo

njoh

john

Shortest answer wins!

EDIT:

To clarify, the first string is the input, and I'd like to see the string cycled through until the original, or input form is printed. If the string can be reached quicker than looping through the entire string, I'd still like to see the whole string gone through. Cycling in the other direction should be just fine, as long as the proper result is still reached.

Source Link
SimpleGeek
  • 503
  • 5
  • 8
Loading