teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

修正

2020/08/03 13:51

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -5,7 +5,7 @@
5
5
  import pandas as pd
6
6
 
7
7
  with open("sample.txt") as f:
8
- text = f.read().replace("\n", "")
8
+ text = f.read().replace("\n", "").replace(" ", "")
9
9
 
10
10
  n = 3
11
11
  s = pd.Series(map(int, text))

2

修正

2020/08/03 13:51

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -6,7 +6,8 @@
6
6
 
7
7
  with open("sample.txt") as f:
8
8
  text = f.read().replace("\n", "")
9
+
9
-
10
+ n = 3
10
11
  s = pd.Series(map(int, text))
11
12
  max_val = s.rolling(n).apply(lambda x: x.prod()).max()
12
13
  print(max_val) # 648.0

1

修正

2020/08/03 13:50

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -5,13 +5,15 @@
5
5
  import pandas as pd
6
6
 
7
7
  with open("sample.txt") as f:
8
- text = f.read()
8
+ text = f.read().replace("\n", "")
9
9
 
10
10
  s = pd.Series(map(int, text))
11
11
  max_val = s.rolling(n).apply(lambda x: x.prod()).max()
12
12
  print(max_val) # 648.0
13
13
  ```
14
14
 
15
+ ----
16
+
15
17
  例えば、`7316717653` で窓の大きさを n = 3 としたとき、各位置での対象の値とその総乗は以下になります。
16
18
 
17
19
  [7.0, 3.0, 1.0] -> 21