Determine a valid distribution of candies among three friends `A`, `B`, and `C` based on given math relations.
Write a function that is given several pieces of information about the number of candies held by three friends, `A`, `B`, and `C`. Specifically, you are given the difference between the number of candies held by `A` and `B`, the difference between those held by `B` and `C`, the total number of candies held by `A` and `B`, as well as the total number of candies held by `B` and `C`. The objective is to determine the exact amount of candies held by each friend. If no valid solution is found, the function should indicate this. ### Parameters - `sub_AB` (`int`): The difference in the number of candies between `A` and `B`. - `sub_BC` (`int`): The difference in the number of candies between `B` and `C`. - `sum_AB` (`int`): The total number of candies that `A` and `B` have. - `sum_BC` (`int`): The total number of candies that `B` and `C` have. ### Return value - If a valid solution can be found, the function should return a `tuple` representing the count of candies each friend `A`, `B`, and `C` has. If no solution can be found, it should return the string `"No"`. ### Examples ```python # We are given that (A - B) = 1, (B - C) = -2, (A + B) = 3, and (B + C) = 4, which suggest # that A, B, and C have 2, 1, and 3 candies respectively. solution(1,-2,3,4) # Expected output (2,1,3) # No valid solution can be found for these parameters solution(3,4,5,6) # Expected output "No" # We have (A - B) = 3, (B - C) = -1, (A + B) = 11, and (B + C) = 9, from which we can infer # that A, B, and C have 7, 4, and 5 candies respectively. solution(3,-1,11,9) # Expected output (7,4,5) ```