Rakuten interview question

Online coding task with negabinary arithmetics.