The function should check if the weight w can be measured exactly using the weights x, y, and z. The measurement can be done in the following ways:
Using any one of the weights alone.
Using any combination of two weights.
Using all three weights together.
If the weight w can be measured by any of the above methods, the function should return 'YES'. If it cannot be measured using any of the weights, return 'NO'.
Input/Output Requirements:
Input:
Four integers: w (the target weight), x, y, z (the available weights). The input weights can be any non-negative integer.
Output:
A string - either 'YES' or 'NO'.
Example Cases:
If can_measure_weight(5, 3, 2, 1), the output should be 'YES' because 3 + 2 = 5.
If can_measure_weight(7, 2, 1, 5), the output should be 'YES' because 2 + 5 = 7.
If can_measure_weight(6, 1, 2, 3), the output should be 'NO' as 6 cannot be formed with the given weights.
Implementation Instructions:
Write the solution in a file called /app/solution.py.
Ensure that the function performs the checks in an efficient manner, considering all possible combinations of the weights.