# ВОТ ЭТО ДОЛЖНО РАБОТАТЬ, но в validated_data нет files :-(
def checksum(code, awards={'A': 15, 'B': 20, 'C': 30, '': 40}, joker='D'):
return sum(
awards.get(''.join(set(triplet)-{joker}), 0) for triplet in zip(*[iter(code)]*3)
)
checksum('ABCAABDCA') # 0
checksum('ADAAABDCA') # 15
def checksum2(code, awards={'A': 15, 'B': 20, 'C': 30, '': 40}, joker='D'):
return reduce(
lambda xsum, triplet: xsum + awards.get(
''.join(set(triplet).difference(joker)), 0
),
(code[0:3], code[3:6], code[6:9]), 0
)