-
테이블 해시 함수코딩 테스트/Level 2 2022. 12. 24. 13:04반응형
https://school.programmers.co.kr/learn/courses/30/lessons/147354
from functools import reduce solution = lambda data, col, row_begin, row_end: reduce(lambda x, y: x ^ y, (sum(each % (i + 1) for each in sorted(data, key=lambda x: (x[col - 1], -x[0]))[i]) for i in range(row_begin - 1, row_end)))
def solution(data, col, row_begin, row_end): data.sort(key=lambda x: (x[col - 1], -x[0])) answer = None for i in range(row_begin - 1, row_end): si = sum(each % (i + 1) for each in data[i]) answer = si if answer is None else answer ^ si return answer
반응형