Submission c339cc56...

ChallengeHex decoder
Submitterricmoo.firefly.eth
Submitted at2018-07-31
Gas used1468653
contract HexDecoder {
    function decode(string input) pure public returns(bytes output) {
        bytes memory inp = bytes(input);
        uint length = inp.length; //uint((uint(msg.data[66]) << 8) | uint(msg.data[67]));

        output = new bytes(length >> 1);
        for (uint i = 0; i < output.length; i++) {
            //output[i] = msg.data[index++] & 1;

            uint a = uint(inp[i + i]);
            uint b = uint(inp[i + i + 1]);
            output[i] = byte(
                ((a + (((a & 0x40) + 1) / 7)) * 16) | ((b & 0x0f) + (((b & 0x40) + 1) / 7))
            );
        }
    }
}