Made from summed inversions and a basic kaleidoscopic ifs.

Code in comments.