回答編集履歴

3

コード修正 int("1" + "0"*6) -> 10**6

2020/03/29 13:00

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -22,9 +22,9 @@
22
22
 
23
23
  UNIT_TABLE = {
24
24
 
25
- "M": int("1" + "0"*6),
25
+ "M": 10**6,
26
26
 
27
- "B": int("1" + "0"*9),
27
+ "B": 10**9,
28
28
 
29
29
  }
30
30
 

2

意図しないデータに対しての注釈を追加

2020/03/29 13:00

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -64,6 +64,8 @@
64
64
 
65
65
 
66
66
 
67
+ 出力
68
+
67
69
  ```
68
70
 
69
71
  4170000000.00
@@ -77,3 +79,11 @@
77
79
  -388.679
78
80
 
79
81
  ```
82
+
83
+
84
+
85
+
86
+
87
+ ※ 追記: エラー処理は省いてます、"((" がプラスになる等。
88
+
89
+ 正規表現で 数値・記号 に分割した方がよかったかもしれない。

1

コメント修正

2020/03/29 12:33

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -34,15 +34,15 @@
34
34
 
35
35
  for info in tokenize.generate_tokens(io.StringIO(token).readline):
36
36
 
37
- if info.type == NUMBER: # NUMBER
37
+ if info.type == NUMBER:
38
38
 
39
39
  result *= Decimal(info.string)
40
40
 
41
- elif info.type == NAME: # NAME (Unit)
41
+ elif info.type == NAME: # Unit
42
42
 
43
43
  result *= UNIT_TABLE[info.string]
44
44
 
45
- elif info.type == OP and info.string == "(": # OP
45
+ elif info.type == OP and info.string == "(": # Nagative
46
46
 
47
47
  result *= -1
48
48