We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I'm not clear if you want the solution of the case: 3 coworkers with the following allocation of chocolates:
( 1 3 1123834 )
OR
the case 5 coworkes with the allocation (1 3 1 123 834).
Assume it's the first case. If it's the second just follow below steps closely.
First we find min { 1, 3, 1123834 } = 1. We have two cases and we need to try both and check which has less steps.
Case 1: target = (1 1 1)
delta = (1 3 1123834) - (1 1 1) = (0 2 1123833)
We next find min number of -5, -2 and -1 steps to get from (1 3 1123834) to (1 1 1)
0 = 0 * 5 + 0 * 2 + 0 * 1
2 = 0 * 5 + 1 * 2 + 0 * 1
1123833 = 224766 * 5 + 1 * 2 + 1 * 1
Total # of steps: (# of steps to make 0 -> 1) + (# of steps to make 2 -> 1) + (# of steps to make 1123833 -> 1) = (0 + 0 + 0) + (0 + 1 + 0) + (224766 + 1 + 1) = 224769
Case 2: target = (0 0 0)
delta = (1 3 1123834) - (0 0 0) = (1 3 1123834)
We next find min number of -5, -2 and -1 steps to get from (1 3 1123834) to (0 0 0)
1 = 0 * 5 + 0 * 2 + 1 * 1
3 = 0 * 5 + 1 * 2 + 1 * 1
1123834 = 224766 * 5 + 2 * 2 + 0 * 1
Total # of steps: (# of steps to make 1 -> 0) + (# of steps to make 3 -> 0) + (# of steps to make 1123834 -> 0) = (0 + 0 + 1) + (0 + 1 + 1) + (224766 + 2 + 0) = 224771
We see that case 1 requires fewer steps so min number of steps is 224769.
Equal
You are viewing a single comment's thread. Return to all comments →
I'm not clear if you want the solution of the case: 3 coworkers with the following allocation of chocolates:
( 1 3 1123834 )
OR
the case 5 coworkes with the allocation (1 3 1 123 834).
Assume it's the first case. If it's the second just follow below steps closely.
First we find min { 1, 3, 1123834 } = 1. We have two cases and we need to try both and check which has less steps.
Case 1: target = (1 1 1)
delta = (1 3 1123834) - (1 1 1) = (0 2 1123833)
We next find min number of -5, -2 and -1 steps to get from (1 3 1123834) to (1 1 1)
0 = 0 * 5 + 0 * 2 + 0 * 1
2 = 0 * 5 + 1 * 2 + 0 * 1
1123833 = 224766 * 5 + 1 * 2 + 1 * 1
Total # of steps: (# of steps to make 0 -> 1) + (# of steps to make 2 -> 1) + (# of steps to make 1123833 -> 1) = (0 + 0 + 0) + (0 + 1 + 0) + (224766 + 1 + 1) = 224769
Case 2: target = (0 0 0)
delta = (1 3 1123834) - (0 0 0) = (1 3 1123834)
We next find min number of -5, -2 and -1 steps to get from (1 3 1123834) to (0 0 0)
1 = 0 * 5 + 0 * 2 + 1 * 1
3 = 0 * 5 + 1 * 2 + 1 * 1
1123834 = 224766 * 5 + 2 * 2 + 0 * 1
Total # of steps: (# of steps to make 1 -> 0) + (# of steps to make 3 -> 0) + (# of steps to make 1123834 -> 0) = (0 + 0 + 1) + (0 + 1 + 1) + (224766 + 2 + 0) = 224771
We see that case 1 requires fewer steps so min number of steps is 224769.