回答編集履歴
4
Update
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
print(sum(
|
10
10
|
|
11
|
-
|
11
|
+
[list_1[i:i+len(list_2)] == list_2 for i in range(len(list_1)-len(list_2)+1)]))
|
12
12
|
|
13
13
|
|
14
14
|
|
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
print(sum(
|
28
28
|
|
29
|
-
|
29
|
+
[list_1[i:i+len(list_2)] == list_2 for i in range(len(list_1)-len(list_2)+1)]))
|
30
30
|
|
31
31
|
|
32
32
|
|
3
Update
test
CHANGED
@@ -8,9 +8,7 @@
|
|
8
8
|
|
9
9
|
print(sum(
|
10
10
|
|
11
|
-
|
11
|
+
i == list_2 for i in [list_1[i:i+len(list_2)] for i in range(len(list_1)-len(list_2)+1)]))
|
12
|
-
|
13
|
-
if i == list_2))
|
14
12
|
|
15
13
|
|
16
14
|
|
@@ -28,9 +26,7 @@
|
|
28
26
|
|
29
27
|
print(sum(
|
30
28
|
|
31
|
-
|
29
|
+
i == list_2 for i in [list_1[i:i+len(list_2)] for i in range(len(list_1)-len(list_2)+1)]))
|
32
|
-
|
33
|
-
if i == list_2))
|
34
30
|
|
35
31
|
|
36
32
|
|
2
Update
test
CHANGED
@@ -1,8 +1,4 @@
|
|
1
1
|
```python
|
2
|
-
|
3
|
-
import re
|
4
|
-
|
5
|
-
|
6
2
|
|
7
3
|
list_1 = ['a','b','c','d','e','a','b','c']
|
8
4
|
|
@@ -10,9 +6,11 @@
|
|
10
6
|
|
11
7
|
|
12
8
|
|
13
|
-
|
9
|
+
print(sum(
|
14
10
|
|
15
|
-
|
11
|
+
1 for i in [list_1[i:i+len(list_2)] for i in range(len(list_1)-len(list_2)+1)]
|
12
|
+
|
13
|
+
if i == list_2))
|
16
14
|
|
17
15
|
|
18
16
|
|
@@ -28,9 +26,11 @@
|
|
28
26
|
|
29
27
|
|
30
28
|
|
31
|
-
|
29
|
+
print(sum(
|
32
30
|
|
33
|
-
|
31
|
+
1 for i in [list_1[i:i+len(list_2)] for i in range(len(list_1)-len(list_2)+1)]
|
32
|
+
|
33
|
+
if i == list_2))
|
34
34
|
|
35
35
|
|
36
36
|
|
@@ -39,3 +39,47 @@
|
|
39
39
|
2
|
40
40
|
|
41
41
|
```
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
~~~```python~~~
|
46
|
+
|
47
|
+
~~~import re
|
48
|
+
|
49
|
+
~~~
|
50
|
+
|
51
|
+
~~~list_1 = ['a','b','c','d','e','a','b','c']~~~
|
52
|
+
|
53
|
+
~~~list_2 = ['a','b','c']~~~
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
~~~str_1, str_2 = '\0'.join(list_1), '\0'.join(list_2)~~~
|
58
|
+
|
59
|
+
~~~print(len(re.findall(rf'(?={str_2})', str_1)))~~~
|
60
|
+
|
61
|
+
~~~
|
62
|
+
|
63
|
+
~~~#~~~
|
64
|
+
|
65
|
+
~~~2~~~
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
~~~list_1 = ['a','a','a']~~~
|
70
|
+
|
71
|
+
~~~list_2 = ['a','a']~~~
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
~~~str_1, str_2 = '\0'.join(list_1), '\0'.join(list_2)~~~
|
76
|
+
|
77
|
+
~~~print(len(re.findall(rf'(?={str_2})', str_1)))~~~
|
78
|
+
|
79
|
+
~~~
|
80
|
+
|
81
|
+
~~~#~~~
|
82
|
+
|
83
|
+
~~~2~~~
|
84
|
+
|
85
|
+
~~~```~~~
|
1
Update
test
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
str_1, str_2 = ''.join(list_1), ''.join(list_2)
|
13
|
+
str_1, str_2 = '\0'.join(list_1), '\0'.join(list_2)
|
14
14
|
|
15
15
|
print(len(re.findall(rf'(?={str_2})', str_1)))
|
16
16
|
|
@@ -28,7 +28,7 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
-
str_1, str_2 = ''.join(list_1), ''.join(list_2)
|
31
|
+
str_1, str_2 = '\0'.join(list_1), '\0'.join(list_2)
|
32
32
|
|
33
33
|
print(len(re.findall(rf'(?={str_2})', str_1)))
|
34
34
|
|