-
Notifications
You must be signed in to change notification settings - Fork 7
/
4.py
32 lines (26 loc) · 807 Bytes
/
4.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
from typing import (
List,
Set,
)
def find_pattern_indexes(
measurements: List[int],
pattern: List[int],
) -> List[int]:
indexes: List[int] = []
for i in range(len(pattern) - 1, len(measurements)):
offset: int = i - (len(pattern) - 1)
measurements_slice: List[int] = measurements[offset : i + 1]
diff: Set[int] = set(
(x - y for x, y in zip(measurements_slice, pattern))
)
if len(diff) == 1:
indexes.append(offset + 1)
return indexes
def main() -> None:
_ = int(input())
measurements: List[int] = list(map(int, input().split()))
_ = int(input())
pattern: List[int] = list(map(int, input().split()))
print(*find_pattern_indexes(measurements, pattern))
if __name__ == "__main__":
main()