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 read to optimize



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

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

def _disabled_input(*args, **kwargs):
    raise RuntimeError("input() is disabled in callable mode")
builtins.input = _disabled_input

ns = {"__name__": "__judge__"}  # prevent if __name__ == "__main__" blocks
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '# SOLUTION:\n# Actually doing the reversals repeatedly is slow. Through observeration\n# we can find a mapping of single shifts which take the original string directly\n# to the target string while saving a lot of computation. The resulting "optimized"\n# manipulations will be different for strings of different lengths,\n# but the same for all strings of a given length.\n#\n# Over the course of multiple sets of reversals, each character necessarily goes through a loop.\n# For example, if the original string is \'1234\', then the character at index 0\n# will first move to index 1, then after another set of reversals to index 3,\n# and then back to index 0, thus completing a loop.\n# Index 2 may always stay in place.\n# For longer strings, the mapping often results in having multiple of these loops.\n#\n# Once the loops are mapped out, we can easily determine where each character will end up\n# after applying the reversal function x times.\n\ndef string_func(in_str, action_times):\n    \n    input_len = len(in_str)\n    input_mid_point = (input_len + 1) / 2 - 1\n\n    # First we\'ll map out the loops.\n    # Starting from index 0, figure out where each character will go after one set of reversals.\n\n    loops = [[0]]\n    index = 0\n\n    # Keep track of which loop each character starts in, so that when we want to place it in our new string we\'ll know where to look.\n    # Right now they\'re all set to 0, but that will change as we check each index.\n    loop_index_is_in = [0]*input_len\n\n    indices_not_checked = list(range(1, input_len))\n\n    while len(indices_not_checked) != 0:\n\n        # Next-step transitions can be easily calculated\n        if index < input_mid_point:\n            index = index * 2 + 1\n        elif index > input_mid_point:\n            index = (input_len - 1 - index)*2\n        elif index == input_mid_point:\n            index = input_len - 1\n\n        # Next, we\'ll need to find each of the next locations (the "loop") for that character.\n\n        # If we return to an index we\'ve already checked, it means that we\'ve completed a loop and we\'re done with that start index.\n        # In that case, we\'ll add a new empty loop to loops and switch to checking an index that hasn\'t been checked yet,\n        # until we\'ve mapped out all of the loops.\n        if index not in indices_not_checked:\n            loops.append([])\n            index = indices_not_checked[0]\n\n        # Adding the index to the loop it belongs in (the loop we are building is always the last one in loops,\n        # as any earlier loops we\'ve already completed.)\n        loops[-1].append(index)\n\n        indices_not_checked.remove(index)\n\n        # And we\'ll keep track of which loop each character starts in,\n        # so that when we want to place it in our final result string we\'ll know where to look.\n        loop_index_is_in[index] = len(loops) - 1\n\n\n    # Now that we mapped out the loops, we need to find which index each character will end up at.\n\n    # For now the final result string (new_string) is actually a list, so that we can use item assignment.\n    new_string = [0] * input_len\n\n    # For each character in the origional string:\n    for char_index in range(input_len):\n\n        # Find the loop that it is in:\n        loop = loops[loop_index_is_in[char_index]]\n\n        # Find where it is in that loop\n        place_in_loop = loop.index(char_index)\n\n        # Figure out where it will go (where it is in the loop, plus the amount of\n        # times we want to apply the reversal function, which is the amount of \'steps\' the character will take, mod the length of the loop)\n        new_index = loop[(place_in_loop + action_times)%len(loop)]\n\n        # Insert the character in its place in new_string\n        new_string[new_index] = in_str[char_index]\n\n    # After placing each character in the new_string list, convert the list to a string and return it. That\'s our final result string.\n    return \'\'.join(new_string)\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

_target = None
_fn_name = 'string_func'
if _fn_name:
    if "Solution" in ns:
        try:
            _obj = ns["Solution"]()
            if hasattr(_obj, _fn_name):
                _target = getattr(_obj, _fn_name)
        except Exception:
            _target = None
    if _target is None and _fn_name in ns and callable(ns[_fn_name]):
        _target = ns[_fn_name]
# Fallback: if there's exactly one user-defined function, use it
if _target is None:
    _cands = [v for k, v in ns.items() if callable(v) and getattr(v, "__module__", "") in ("__judge__", "__main__")]
    _user_funcs = [c for c in _cands if getattr(c, "__name__", "").startswith("_") is False]
    if len(_user_funcs) == 1:
        _target = _user_funcs[0]
if _target is None:
    raise RuntimeError(f"Could not resolve callable '{_fn_name}'")

_raw = sys.stdin.read().strip()
if _raw:
    _parsed = json.loads(_raw)
    if isinstance(_parsed, dict):
        _kwargs = _parsed.get("kwargs", {})
        _args = _parsed.get("args", [])
    else:
        _args, _kwargs = _parsed, {}
else:
    _args, _kwargs = [], {}
if not isinstance(_args, (list, tuple)):
    _args = [_args]
_res = _target(*_args, **_kwargs)
try:
    sys.stdout.write(repr(_res) + "\n")
except Exception:
    pass

```

Measured memory_bytes: 6882