Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def circle(chars):
- test = """
- @@@@@@@@@@@@@
- @@ @@
- @@ @@
- @@ @@
- @ @
- @ @
- @ @
- @ @
- @ @
- @ @
- @ @
- @ @
- @ @
- @ @
- @ @
- @ @
- @ @
- @ @
- @ @
- @ @
- @ @
- @@ @@
- @@ @@
- @@ @@
- @@@@@@@@@@@@@
- """
- #chars = "abcdefghijklmnopqrstuvwxyzABDEFGHIJKLMOPQRSTUVWXYZ1234567890,.<>?;'#:~[]{}$%^&*)(£!|"
- chars = chars.replace(" ", "¬")
- def extract(chars, start, end):
- if end > len(chars):
- ext = chars[start:len(chars)]
- end -= len(chars)
- while end >= 0:
- ext += chars[:min(len(chars), end)]
- end -= len(chars)
- return ext
- else:
- return chars[start:end]
- ci = 0
- lines = [x for x in test.split("\n") if x.replace(" ", "") != ""]
- result = lines[:]
- for index in range(2):
- found_top = False
- reverse = index == 1
- for i, line in enumerate(lines):
- if index == 1:
- i = -(i+1)
- line = lines[i]
- front = ""
- while len(line) > 0 and line[0] == " ":
- front += " "
- line = line[1:]
- if len(front) == 1:
- reverse = (reverse == False)
- end = ""
- while len(line) > 0 and line[-1] == " ":
- end += " "
- line = line[:-1]
- if " " not in line: # top or bottom
- if not found_top: # bottom
- if index == 1: # going up
- result[i] = front + extract(chars, ci, ci+len(line))[::-1] + end
- ci = (ci + len(line)) % len(chars)
- elif index == 0: # going down
- result[i] = front + extract(chars, ci, ci+len(line)) + end
- ci = (ci + len(line)) % len(chars)
- found_top = True
- else:
- spl = [x for x in line.split(" ") if x != ""]
- right = spl[0]
- left = spl[1]
- middle = line[len(right):-len(left)]
- if index == 0: # going down
- block = extract(chars, ci, ci+len(right))
- if reverse:
- block = block[::-1]
- result[i] = middle + block + end
- ci = (ci + len(right)) % len(chars)
- else: # going up
- block = extract(chars, ci, ci + len(left))
- if reverse:
- block = block[::-1]
- result[i] = front + block + result[i]
- ci = (ci + len(left)) % len(chars)
- return "\n".join(result).replace("¬", " ")
- result(circle(" ".join(getargs())))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement