回答編集履歴
4
リファクタ
test
CHANGED
@@ -28,15 +28,15 @@
|
|
28
28
|
|
29
29
|
standard_hour = (base_hour - timezone_table[base_city]) % 24
|
30
30
|
|
31
|
-
for
|
31
|
+
for diff in timezone_table.values():
|
32
32
|
|
33
|
-
print(f'{(standard_hour +
|
33
|
+
print(f'{(standard_hour + diff) % 24:02d}:{base_minute:02d}')
|
34
34
|
|
35
35
|
```
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
[Wandbox](https://wandbox.org/permlink/
|
39
|
+
[Wandbox](https://wandbox.org/permlink/fvC7likOXLyuWNpt)
|
40
40
|
|
41
41
|
|
42
42
|
|
3
リファクタ
test
CHANGED
@@ -20,23 +20,23 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
base_city, time = input().split()
|
23
|
+
base_city, base_time = input().split()
|
24
24
|
|
25
|
-
hour, minute = map(int, time.split(':'))
|
25
|
+
base_hour, base_minute = map(int, base_time.split(':'))
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
|
29
|
+
standard_hour = (base_hour - timezone_table[base_city]) % 24
|
30
30
|
|
31
31
|
for city, diff in timezone_table.items():
|
32
32
|
|
33
|
-
print(f'{(
|
33
|
+
print(f'{(standard_hour + timezone_table[city]) % 24:02d}:{base_minute:02d}')
|
34
34
|
|
35
35
|
```
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
[Wandbox](https://wandbox.org/permlink/
|
39
|
+
[Wandbox](https://wandbox.org/permlink/Jw06bs2RkidFyqjd)
|
40
40
|
|
41
41
|
|
42
42
|
|
2
追記
test
CHANGED
@@ -42,4 +42,44 @@
|
|
42
42
|
|
43
43
|
---
|
44
44
|
|
45
|
-
|
45
|
+
[datetimeモジュール](https://docs.python.jp/3/library/datetime.html)を使ってみた例。どっちもどっちですね。
|
46
|
+
|
47
|
+
```Python
|
48
|
+
|
49
|
+
from collections import OrderedDict
|
50
|
+
|
51
|
+
from datetime import datetime, timedelta
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
n = int(input())
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
timezone_table = OrderedDict()
|
60
|
+
|
61
|
+
for _ in range(n):
|
62
|
+
|
63
|
+
city, diff = input().split()
|
64
|
+
|
65
|
+
timezone_table[city] = timedelta(hours=int(diff))
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
base_city, base_time = input().split()
|
70
|
+
|
71
|
+
base_time = datetime.strptime(base_time, '%H:%M')
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
standard_time = (base_time - timezone_table[base_city])
|
76
|
+
|
77
|
+
for diff in timezone_table.values():
|
78
|
+
|
79
|
+
print(datetime.strftime(standard_time + diff, '%H:%M'))
|
80
|
+
|
81
|
+
```
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
[Wandbox](https://wandbox.org/permlink/9A2bnhuRXjccu6M0)
|
1
修正
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ちょっとだけ
|
1
|
+
ちょっとだけスマートにできた...かも。あんまり変わってないようにも見えます。
|
2
2
|
|
3
3
|
```Python
|
4
4
|
|