So, I have a function, that gets a call like this:
reversed("abc", "def", "ghi")
And has to return the reversed order like this (it is reversed by 90 degres - by this I mean if you stack them like this:
abc
def
ghi
And then reverse them for 90 degress, you would get:
gda
heb
ifc
And then to upgrade via another function, that would get the same argument and a number of reverses. Like this:
reversed_n(("abc", "def", "ghi"), 1)
And would then return the tuple of what I would get by reversing the same order n times.
For this it would return:
("gda", "heb", "ifc")
What I have tried:
So I made the functions like this:
def reversed(kos):
seznam = []
kos = [i[::-1] for i in kos]
i = 0
while i < len(kos[0]):
s = [beseda[i] for beseda in kos]
seznam.append("".join(s))
i += 1
return tuple(seznam)
def reversed_n(kos, n):
for i in range(0, n):
kos = reversed(kos)
return kos
So it works, but if I try something a lot larger, say a lot larger and put n = 10000001, it will run forever. What would I need to do, can it maybe be done with calculating if it is odd or even number of n?