*Translations appreciated*

## Background information

The Hamming Code is used to correct errors, so-called bit flips, in data transmissions. Later in the description follows a detailed explanation of how it works.
In this Kata we will implement the Hamming Code with bit length 3, this has some advantages and disadvantages:
- ✓ Compared to other versions of hamming code, we can correct more mistakes
- ✓ It's simple to implement
- x  The size of the input triples



## Task 1: Encode function:

First of all we have to implement the encode function, which is pretty easy, just follow the steps below.

Steps:
1. convert every letter of our text to ASCII value
2. convert ASCII value to 8-bit binary string
3. replace every "0" with "000" and every "1" with "111"

Let's do an example:

We have to convert the string ```hey``` to hamming code sequence.

1. First convert it to ASCII values:

```104``` for ```h```, ```101``` for ```e``` and ```121``` for ```y```.


2. Now we convert the ASCII values to a 8-bit binary string:

```104``` -> ```01101000```, ```101``` -> ```01100101``` and ```121``` -> ```01111001```

if we concat the binarys we get ```011010000110010101111001```


3. Now we replace every "0" with "000" and every "1" with "111":

```011010000110010101111001``` -> ```000111111000111000000000000111111000000111000111000111111111111000000111```

That's it good job!


## Task 2: Decode function:

Now we have to check if there happened any mistakes and correct them.
Errors will only be a bit flip and not a loose of bits, so the length of the input string is always divisible by 3.

example: 
- 111 --> 101  this can and will happen
- 111 --> 11   this won't happen

The length of the input string is also always divsible by 24 so that you can convert it to an ASCII value.

Steps:
1. Split the string of 0 and 1 in groups of three characters example: "000", "111"
2. Check if an error occured:
 If no error occured the group is "000" or "111", then replace "000" with "0" and "111" with 1
 If an error occured the group is for example "001" or "100" or "101" and so on...
 Replace this group with the character that occurs most often. example: "010" -> "0" , "110" -> "1" 

3. Now take a group of 8 characters and convert that binary number to decimal ASCII value
4. Convert the ASCII value to a char and well done you made it :)



Look at this example carefully to understand it better:

We got a bit sequence:

```100111111000111001000010000111111000000111001111000111110110111000010111``` 

First we split the bit sequence into groups of three:

```100```, ```111```, ```111```, ```000```, ```111```, ```001``` ....

Every group with the most "0" becomes "0" and every group with the most "1" becomes "1":

```100``` -> ```0``` Because there are two ```0``` and only one ```1```

```111``` -> ```1``` Because there are zero ```0``` and three ```1```

```111``` -> ```1``` Because there are zero ```0``` and three ```1```

```000``` -> ```0``` Because there are three ```0``` and zero ```1```

```111``` -> ```1``` Because there are zero ```0``` and three ```1```

```001``` -> ```0``` Because there are two ```0``` and one ```1```

Now concat all 0 and 1 to get ```011010000110010101111001```

We split this string into groups of eight:
```01101000```, ```01100101``` and ```01111001```.

And now convert it back to letters:

```01101000``` is binary representation of 104, which is ASCII value of ```h```

```01100101``` is binary representation of 101, which is ASCII value of ```e```

```01111001``` is binary representation of 121, which is ASCII value of ```y```

Now we got our word ```hey``` !

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

def _disabled_input(*args, **kwargs):
    raise RuntimeError("input() is disabled in callable mode")
builtins.input = _disabled_input

ns = {"__name__": "__judge__"}  # prevent if __name__ == "__main__" blocks
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'def encode(string):\n    bits = ""\n    for i in string:\n        bits += \'{0:08b}\'.format(ord(i))\n        \n    return bits.replace(\'1\', \'111\').replace(\'0\', \'000\')\n\ndef decode(bits):\n    x = 3\n    res=[bits[y-x:y] for y in range(x, len(bits)+x,x)]\n    \n    decoded = ""\n    for i in res:\n        sorti = sorted(i)\n        decoded += sorti[1]\n            \n    x = 8\n    bin=[decoded[y-x:y] for y in range(x, len(decoded)+x,x)]\n    \n    return "".join([chr(int(x, 2)) for x in bin])'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

_target = None
_fn_name = 'encode'
if _fn_name:
    if "Solution" in ns:
        try:
            _obj = ns["Solution"]()
            if hasattr(_obj, _fn_name):
                _target = getattr(_obj, _fn_name)
        except Exception:
            _target = None
    if _target is None and _fn_name in ns and callable(ns[_fn_name]):
        _target = ns[_fn_name]
# Fallback: if there's exactly one user-defined function, use it
if _target is None:
    _cands = [v for k, v in ns.items() if callable(v) and getattr(v, "__module__", "") in ("__judge__", "__main__")]
    _user_funcs = [c for c in _cands if getattr(c, "__name__", "").startswith("_") is False]
    if len(_user_funcs) == 1:
        _target = _user_funcs[0]
if _target is None:
    raise RuntimeError(f"Could not resolve callable '{_fn_name}'")

_raw = sys.stdin.read().strip()
if _raw:
    _parsed = json.loads(_raw)
    if isinstance(_parsed, dict):
        _kwargs = _parsed.get("kwargs", {})
        _args = _parsed.get("args", [])
    else:
        _args, _kwargs = _parsed, {}
else:
    _args, _kwargs = [], {}
if not isinstance(_args, (list, tuple)):
    _args = [_args]
_res = _target(*_args, **_kwargs)
try:
    sys.stdout.write(repr(_res) + "\n")
except Exception:
    pass

```

Measured memory_bytes: 5555