소스 검색

peking duck

master
Roderic Day 3 년 전
부모
커밋
6e6dc09a48
1개의 변경된 파일19개의 추가작업 그리고 0개의 파일을 삭제
  1. +19
    -0
      y2021/p03.py

+ 19
- 0
y2021/p03.py 파일 보기

@@ -0,0 +1,19 @@
from collections import Counter


app = eps = ''
for col in zip(*text.splitlines()):
n, *_, m = Counter(col).most_common()
app += n[0]
eps += m[0]
ans1 = int(app, 2) * int(eps, 2)

nums = text.splitlines()
xs = nums[:]
ys = nums[:]
for idx in range(len(nums[0])):
n, _ = Counter(sorted([x[idx] for x in xs])).most_common()[::-1][0]
xs = [x for x in xs if x[idx] == n]
m, _ = Counter(sorted([y[idx] for y in ys])).most_common()[::-1][-1]
ys = [y for y in ys if y[idx] == m]
ans2 = int(xs[0], 2) * int(ys[0], 2)

Loading…
취소
저장