EANS = [ "4932413071222", "9215337181228", "4055572232713", "3177777536937", "5194353145886", "8022631001531", "2177559451930", "9375914288310", ] ISBNS = [ "0-024-00310-7", "0-238-30610-0", "3-505-52102-7", "0-022-11111-5", "6-052-75101-0", "8-323-17020-7", "6-422-29100-0", "5-112-73112-5", ] cards = [ "5217804766545209", "4885373827486781", "5839899598496843", "9587981988999895", "8837998849894933", "8986989999966281", "9999992947693935", "9999489398999945", ] def decode_ean(ean): digits = [int(c) for c in ean[:12]] total = 0 for i, d in enumerate(digits): if i % 2 != 0: total += d * 3 else: total += d return chr(total) def decode_isbn(isbn): digits = [int(c) for c in isbn.replace("-", "")[:9]] total = sum((i + 1) * d for i, d in enumerate(digits)) return chr(total) def decode_credit_card(cc): digits = [int(c) for c in cc[:15]] total = 0 for idx in range(14, -1, -1): d = digits[14 - idx] weight = 14 - idx if weight % 2 != 0: total += d else: doubled = 2 * d total += doubled - 9 if doubled > 9 else doubled return chr(total) part1 = "".join(decode_ean(i) for i in EANS) part2 = "".join(decode_isbn(i) for i in ISBNS) part3 = "".join(decode_credit_card(c) for c in cards) print(part1 + part2 + part3)