4 kyu

String -> X-Iterations -> String

105 of 338Jomopipi

Description:

This kata is blatantly copied from inspired by This Kata

Welcome

this is the second in the series of the string iterations kata!

Here we go!


We have a string s

Let's say you start with this: "String"

The first thing you do is reverse it: "gnirtS"

Then you will take the string from the 1st position and reverse it again: "gStrin"

Then you will take the string from the 2nd position and reverse it again: "gSnirt"

Then you will take the string from the 3rd position and reverse it again: "gSntri"

Continue this pattern until you have done every single position, and then you will return the string you have created. For this particular string, you would return: "gSntir"

now,

The Task:

In this kata, we also have a number x

take that reversal function, and apply it to the string x times.

return the result of the string after applying the reversal function to it x times.

example where s = "String" and x = 3:

after 0 iteration  s = "String"
after 1 iteration  s = "gSntir"
after 2 iterations s = "rgiStn"
after 3 iterations s = "nrtgSi"

so you would return "nrtgSi".

Note

String lengths may exceed 2 million

x exceeds a billion

be ready to optimize

if this is too hard, go here https://www.codewars.com/kata/string-%3E-n-iterations-%3E-string/java

Algorithms
Puzzles
Mathematics
Language Features

Stats:

CreatedApr 29, 2018
PublishedApr 29, 2018
Warriors Trained3178
Total Skips497
Total Code Submissions4092
Total Times Completed338
Java Completions105
Python Completions175
C# Completions66
Total Stars161
% of votes with a positive feedback rating93% of 97
Total "Very Satisfied" Votes85
Total "Somewhat Satisfied" Votes11
Total "Not Satisfied" Votes1
Total Rank Assessments3
Average Assessed Rank
4 kyu
Highest Assessed Rank
2 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • Jomopipi Avatar
  • ecolban Avatar
  • KataSideKick Avatar
  • hobovsky Avatar
Ad