Utilities shared by Hackfoldr implementations