Reimplementation of the funny_hash algorithm, output-compatible with the version used in the Crystal language.