-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboustroLOSS.py
53 lines (40 loc) · 1.69 KB
/
boustroLOSS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def boustrophedon_format(text, columns, corruption_side, tokens_to_corrupt, corrupt_every_line=False):
lines = []
reversed_lines = []
# Split the text into lines of the specified column width
for i in range(0, len(text), columns):
line = text[i:i + columns]
lines.append(line)
# Reverse every other line
for i, line in enumerate(lines):
if i % 2 == 1:
reversed_lines.append(line[::-1])
else:
reversed_lines.append(line)
# Apply corruption based on user choice
for i, line in enumerate(reversed_lines):
if corrupt_every_line or i % 2 == 1:
if corruption_side == "left":
line = "X" * tokens_to_corrupt + line[tokens_to_corrupt:]
elif corruption_side == "right":
line = line[:-tokens_to_corrupt] + "X" * tokens_to_corrupt
reversed_lines[i] = line
return '\n'.join(reversed_lines)
def main():
print("Boustrophedon Text Formatter")
print("Enter the text you want to format:")
input_text = input()
print("Enter the number of columns (tokens per line):")
columns = int(input())
print("Enter the corruption side ('left' or 'right'):")
corruption_side = input()
print("Enter the number of tokens to corrupt:")
tokens_to_corrupt = int(input())
print("Corrupt every line? (yes/no):")
corrupt_every_line_input = input().strip().lower()
corrupt_every_line = corrupt_every_line_input == 'yes'
formatted_text = boustrophedon_format(input_text, columns, corruption_side, tokens_to_corrupt, corrupt_every_line)
print("\nFormatted Text:")
print(formatted_text)
if __name__ == "__main__":
main()