Format integers Sergey Svistunov

Compute a checksum over the decimal representations of binary integers as fast as possible.

Input: 250 000 000 uint32 values in little-endian binary on STDIN (4 bytes each).

Output: A uint64 checksum computed as:

CRC = sum of number_crc(n) for each n

where number_crc(n) converts n to its decimal string and sums ascii(digit) * position over each digit (0-indexed from the left).

Example: For n = 42, the decimal string is "42", so number_crc(42) = ascii('4') * 0 + ascii('2') * 1 = 52 * 0 + 50 * 1 = 50.

Back to listMay 12, 2021 11:05Andrei GrazhdankovAndrei GrazhdankovError
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 12, 2021 11:0500000Wrong answer: expected: 1010142161 got: s: 10 c: 10 k 0 49 0 k 1 48 0 s: 5 c: 5 k 0 53 48 s: 4 c: 4 k 0 52 48 s: 2 c: 2 k 0 50 48 s: 4 c: 4 k 0 52 48 s: 2 c: 2 k 0 50 48 s: 13 c: 13 k 0 49 48 k 1 51 48 s: 9 c: 9 k 0 57 99 s: 9 c: 9 ...