Roderic Day 2年前
コミット
22c6260355
1個のファイルの変更10行の追加0行の削除
  1. +10
    -0
      y2022/p03.py

+ 10
- 0
y2022/p03.py ファイルの表示

@@ -0,0 +1,10 @@
import string
import itertools


abc = ' ' + string.ascii_lowercase + string.ascii_uppercase
common = lambda ss: set.intersection(*map(set, ss))
tally = lambda sss: sum(abc.index(common(ss).pop()) for ss in sss)
lns = open(0).read().splitlines()
print(tally([[ln[:len(ln) // 2], ln[len(ln) // 2:]] for ln in lns]))
print(tally(zip(*[iter(lns)] * 3)))

読み込み中…
キャンセル
保存