Working solution to "All your Base"