Skip to content
DeepForgeby svx
All problems
EasyAlgorithmsal-312

XOR Checksum

Problem

Compute the XOR checksum of a string by XOR-ing the numeric character codes of all its characters.

The empty string has checksum 0, and repeated characters cancel in pairs. This is a simple error-detection checksum, not a cryptographic hash.

Hint

Every character that appears an even number of times cancels out of the XOR.

Test cases

case 1
in: [""]
expected: 0
case 2
in: ["a"]
expected: 97
case 3
in: ["ab"]
expected: 3
case 4
in: ["hello"]
expected: 98
case 5
in: ["AAAA"]
expected: 0
Starter codePython
def xor_checksum(data):
    # Your code here
    pass

5 test cases · run your code against them in the editor