-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (40 loc) · 1.24 KB
/
main.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
from typing import List
#
# list1 = ["Shogun", "Piatti", "Tapioca Express", "Burger King", "KFC"]
#
# list2 = ["Piatti", "The Grill at Torrey Pines", "Hungry Hunter Steakhouse", "Shogun"]
#
#
# def findRestaurant(list1: List[str], list2: List[str]) -> List[str]:
# l1 = {v: i for i, v in enumerate(list1)}
# d = {}
# l = []
# for i, v in enumerate(list2):
# if v in l1.keys():
# d[v] = sum((l1[v], i))
# min_ = min(d.values())
# for i, v in d.items():
# if v == min_:
# l.append(i)
# return l
#
#
# print(findRestaurant(list1, list2))
# a = [
# [9, 9, 8, 1],
# [5, 6, 11, 6],
# [8, 2, 6, 4],
# [6, 2, 2, 2]
# ]
#
# result = [[max(a[i - 1][j - 1:j + 2] + a[i][j - 1:j + 2] + a[i + 1][j - 1:j + 2]) for j in range(1, len(a) - 1)] for i in range(1, len(a) - 1)]
# print(result)
# https://leetcode.com/problems/flipping-an-image/submissions/
# image = [[1, 1, 0], [1, 0, 1], [0, 0, 0]]
# print(list([1 if j == 0 else 0 for j in i[::-1]] for i in image))
matrix = [[1, 2, 3, 4], [5, 1, 2, 3], [9, 5, 1, 2]]
for i in range(1, len(matrix)):
for j in range(1, len(matrix[i])):
if matrix[i][j] == matrix[i - 1][j - 1]:
print(matrix[i][j], end=' ')
print()