-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlecture.py
More file actions
32 lines (25 loc) · 737 Bytes
/
lecture.py
File metadata and controls
32 lines (25 loc) · 737 Bytes
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
import numpy
import matplotlib.pyplot as plt
def read1():
file = open("a_example.in", "r")
lines = file.readlines()
mappedLines = list(map(lambda line: line.replace("\n", ""), lines))
print(mappedLines)
return mappedLines
def read2():
file = open("a_example.in", "r")
lines = file.read().split("\n")[:-1]
return lines
def ingredientToColor(ingredient):
return 1 if ingredient == "T" else 0
def ingredientsToColor(ingredients):
return list(map(ingredientToColor, ingredients))
def arrayToColor(array):
return list(map(ingredientsToColor, array))
lines = read2()
print(lines)
coloredLines = arrayToColor(lines[1:])
fig, ax = plt.subplots()
ax.grid(True)
ax.imshow(coloredLines)
plt.show()