PY
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
# Created by JaScript
def MR(record,ofl,ofr):
w = len(record)
rc = record.copy()
Tr=Tl= -float('inf')
for j in range(w+ofl):
i=j-ofr
if i<w-ofr: Tr=record[i+ofr]
if i>=ofl: Tl=record[i-ofl]
if (record[i]<=Tr and i-ofl<0) or (record[i]<=Tl and i+ofl>=w): rc[i]=0
if (record[i]<=Tr and i<w-ofr) or (record[i]<=Tl and i>=ofl): rc[i]=0
return rc
record = [1, 2, 0, 5, 0, 2, 4, 3, 3, 3]
print(MR(record,3,4))
'''
Your company is analyzing malware which targets numerical record files.
The malware uses a sliding window over the array of numbers in a file, and tries to match the following pattern:
Tl, -, -, X, -, -, -, Tr
The entire window is moved so that 'X' passes through all the values and is compared to the numbers at the 'Tl' and 'Tr' locations, which are positioned at a constant offset to 'X'.
The malware has the following rules:
If the value at the 'Tl' or 'Tr' position of the pattern is bigger or equal to the value at the 'X’ position, the malware replaces the value at 'X' with 0.
OUTPUT
Run