Quick encoding

Implements solution to 4b.