Internet checksum
Your task
Compute the 16-bit Internet checksum (RFC 1071) over a list of byte values. Treat the data as a sequence of 16-bit big-endian words; if the byte count is odd, pad with a single trailing zero byte. Sum the words in ones-complement arithmetic (fold any carry out of bit 15 back into the low bits), then return the bitwise complement of the final sum, masked to 16 bits. An empty input yields 0xFFFF.
Examples
internet_checksum(data: list[int]) -> intExample 1
Input
internet_checksum([0, 1, 242, 3])Output
3579