-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpythonboilerplate.py
More file actions
executable file
·69 lines (57 loc) · 1.95 KB
/
pythonboilerplate.py
File metadata and controls
executable file
·69 lines (57 loc) · 1.95 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/python3
import sys
red = []
blue = []
green = []
def print_pixel(arr, size):
# boring function to print a matrix
for i in range(0, size[0]):
for j in range(0, size[1]):
print(arr[i][j], end=' ')
print('')
def main(size):
global red, blue, green
"""
Inputs:
red[][] - stores red component of the image
green[][] - stores green component of the image
blue[][] - stores blue component of the image
size[0] - height of the image
size[1] - width of the image
Outputs:
Modify `red`, `green` and `blue` array itself.
Note: The default code leaves the image unchanged
"""
# =========================
# Write filter logic here
# =========================
for i in range(0, size[0]):
for j in range(0, size[1]):
red[i][j] = red[i][j]
blue[i][j] = blue[i][j]
green[i][j] = green[i][j]
# =========================
# Filter logic ends
# =========================
if __name__ == '__main__':
try:
# first line is height and width of the image
ht,width = list(map(int, input().strip().split(' ')))
# input in format red / green / blue
for i in range(0, ht):
red.append(list(map(int, input().strip().split(' '))))
for i in range(0, ht):
green.append(list(map(int, input().strip().split(' '))))
for i in range(0, ht):
blue.append(list(map(int, input().strip().split(' '))))
# call your magic filter function to do its magic !
main([ht,width])
# first line of output is height and width of the image
print(ht,width)
# Output in format red / green / blue
print_pixel(red, [ht,width])
print_pixel(green, [ht,width])
print_pixel(blue, [ht,width])
except Exception as e:
print(e, file=sys.stderr)
pass