Proof of concept Python code, needs to be converted to C or C++.