Created
March 21, 2015 12:39
-
-
Save 10nin/73243f1cbcbe372f7cf5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*-coding:utf-8-*- | |
from datetime import datetime as dt | |
def make_time_table(raw_time_table): | |
"""入力された文字から、時間のリストを使って返します""" | |
ret = list() | |
# 1文字目は無意味なので読み捨てます | |
lst = raw_time_table.split(' ')[1:] | |
# 2要素ずつ取り出して、時間データとして確保します | |
for h, m in zip(*[iter(lst)]*2): | |
ret.append(dt.strptime('%s:%s'%(h,m), '%H:%M')) | |
return ret | |
def join_time_table(time_table): | |
"""時間データをソートして、スペース区切りの文字列にして返します""" | |
ret = list() | |
# 重複した時間はひとつだけ出力します | |
for i in sorted(list(set(time_table))): | |
ret.append(i.strftime('%k:%M').strip()) | |
return ' '.join(ret) | |
if __name__ == '__main__': | |
n = input() | |
m = input() | |
n_time = make_time_table(n) | |
m_time = make_time_table(m) | |
print(join_time_table(n_time+m_time)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment