PParityOchre
Product

Product features · Hamming single-bit correction

01

Keep the single-error assumption visible in ParityOchre while tracing how parity checks identify a bit to flip.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Hamming single-bit correction

● ● ●ParityOchre●
A concrete starting point · Hamming single-bit correction ×
def correct_hamming(word):
    word = list(word)
    if len(word) != 7 or any(type(b) is not int or b not in (0, 1) for b in word):
        raise ValueError("hamming.word")
    syndrome = 0
    for parity in (1, 2, 4):
        value = 0
        for position in range(1, 8):
            if position & parity:
                value ^= word[position-1]
        if value:
            syndrome |= parity
    if syndrome:
        word[syndrome-1] ^= 1
    data = (word[2] << 3) | (word[4] << 2) | (word[5] << 1) | word[6]
    return data, syndrome
✳Decode a seven-bit Hamming word under an explicit assumption of at most one flipped bit.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗