Company: Mthree _6march
Difficulty: medium
Minimum Extra Chocolates Problem Description Alex and Drake have two boxes of chocolates. Alex's box holds A chocolates and Drake's box holds B chocolates. Drake is the younger child, and he will only be happy if the number of chocolates he receives is a multiple of the number Alex gets. You decide to buy some extra chocolates to make this happen. You may add X extra chocolates to Alex's box and Y extra chocolates to Drake's box. After buying, the boxes must satisfy k * (A + X) = B + Y for some non-negative integers X and Y and some positive integer k (so k = 1 , meaning both boxes end up equal, is allowed). The original chocolates cannot be moved from one box to the other, and no chocolate can be taken away from either box. Only extra chocolates can be added. Find the minimum total number of extra chocolates X + Y that you need to buy. Complete the function solution(A, B) , which returns this minimum. Input Format The first line contains an integer A , the number of chocolates initial