-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtile_visualizer.py
More file actions
46 lines (36 loc) · 6.37 KB
/
tile_visualizer.py
File metadata and controls
46 lines (36 loc) · 6.37 KB
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
def display_array(string_list, elements_per_line):
"""
Display a list of strings with line breaks after a specified number of elements,
including line and column numbers.
Args:
string_list (list): List of strings to display
elements_per_line (int): Number of elements to display per line
"""
# Print column numbers header
print(" ", end="") # Space for line numbers
for col in range(elements_per_line):
print(f"{col:3}", end="")
print() # New line after column numbers
# Print a separator line
print(" " + "-" * (elements_per_line * 2))
# Print elements with line numbers
for line_num, i in enumerate(range(0, len(string_list), elements_per_line)):
# Print line number
print(f"{line_num:2}| ", end="")
# Get the slice of elements for current line
line_elements = string_list[i:i + elements_per_line]
# Print each element without spaces
for element in line_elements:
print(f"{element:3}", end="")
# Fill empty spaces if the last line is not complete
remaining_spaces = elements_per_line - len(line_elements)
if remaining_spaces > 0:
print(" " * remaining_spaces, end="")
print() # New line after elements
# Example usage
if __name__ == "__main__":
# Example list of strings
test_list = ["_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", "|", "|", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", "|", "|", ".", "|", "|", "|", "|", ".", "|", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", "|", ".", "|", "|", "|", "|", ".", "|", "|", "o", "|", "|", "|", "|", ".", "|", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", "|", ".", "|", "|", "|", "|", "o", "|", "|", ".", "|", "|", "|", "|", ".", "|", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", "|", ".", "|", "|", "|", "|", ".", "|", "|", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", "|", "|", ".", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", ".", "|", "|", ".", ".", ".", ".", ".", ".", "|", "|", ".", ".", ".", ".", "|", "|", ".", ".", ".", ".", "|", "|", ".", ".", ".", ".", ".", ".", "|", "|", "|", "|", "|", "|", "|", ".", "|", "|", "|", "|", "|", " ", "|", "|", " ", "|", "|", "|", "|", "|", ".", "|", "|", "|", "|", "|", "|", "_", "_", "_", "_", "_", "|", ".", "|", "|", "|", "|", "|", " ", "|", "|", " ", "|", "|", "|", "|", "|", ".", "|", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "|", ".", "|", "|", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "|", "|", ".", "|", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "|", ".", "|", "|", " ", "|", "|", "|", "-", "-", "|", "|", "|", " ", "|", "|", ".", "|", "_", "_", "_", "_", "_", "|", "|", "|", "|", "|", "|", ".", "|", "|", " ", "|", "_", "_", "_", "_", "_", "_", "|", " ", "|", "|", ".", "|", "|", "|", "|", "|", "|", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "|", "_", "_", "_", "_", "_", "_", "|", " ", " ", " ", ".", " ", " ", " ", " ", " ",
" ", "|", "|", "|", "|", "|", "|", " ", "|", "|", " ", "|", "_", "_", "_", "_", "_", "_", "|", " ", "|", "|", ".", "|", "|", "|", "|", "|", "|", "_", "_", "_", "_", "_", "|", " ", "|", "|", " ", "|", "|", "|", "|", "|", "|", "|", "|", " ", "|", "|", ".", "|", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "|", " ", "|", "|", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "|", "|", ".", "|", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "|", " ", "|", "|", " ", "|", "|", "|", "|", "|", "|", "|", "|", " ", "|", "|", ".", "|", "_", "_", "_", "_", "_", "|", "|", "|", "|", "|", "|", " ", "|", "|", " ", "|", "|", "|", "|", "|", "|", "|", "|", " ", "|", "|", ".", "|", "|", "|", "|", "|", "|", "|", ".", ".", ".", ".", ".", " ", " ", " ", " ", " ", " ", " ", "|", "|", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", "|", "|", ".", "|", "|", "|", "|", ".", "|", "|", "|", "|", "|", " ", "|", "|", ".", "|", "|", "|", "|", "|", ".", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", " ", "|", "|", "|", "|", "|", " ", "|", "|", ".", "|", "|", "|", "|", "|", ".", "|", "|", "|", "|", ".", "|", "|", "o", ".", ".", "|", "|", " ", " ", " ", " ", " ", " ", " ", " ", " ", ".", ".", ".", ".", ".", ".", ".", "|", "|", ".", ".", "o", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", ".", ".", ".", ".", ".", ".", "|", "|", ".", ".", ".", ".", "|", "|", ".", ".", ".", ".", "|", "|", ".", ".", ".", ".", ".", ".", "|", "|", ".", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", ".", "|", "|", ".", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", ".", "|", "|", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "|", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_"]
print("Displaying 28 elements per line:")
display_array(test_list, 28)