Internet checksum

Write codeHard25 minCisco style

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]) -> int
Example 1
Inputinternet_checksum([0, 1, 242, 3])
Output3579