Solution for binary converter problem