#!/usr/bin/env python3 ######################################################################## ## ## fletcher4.py ## ## Copyright (C) 2024 Herbert Poetzl ## ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License version 2 as ## published by the Free Software Foundation. ## ######################################################################## import sys import struct a = b = c = d = 0 # Read bytes directly from stdin while True: byte_block = sys.stdin.buffer.read(4) if not byte_block: break value = struct.unpack('I', byte_block)[0] a += value; b += a; c += b; d += c; a &= 0xFFFFFFFF b &= 0xFFFFFFFF c &= 0xFFFFFFFF d &= 0xFFFFFFFF r = ((a ^ c) << 32) ^ b ^ d # Print the final sum print(f"{r:016X}")