Implement a function calculate_average_candies(n, operations) that computes the average number of candies distributed to a certain number of children based on a series of operations.
Functionality
The function should take two parameters:
An integer n, representing the total number of children.
A list of tuples operations, where each tuple contains three integers (a, b, k). The tuple represents an operation that indicates distributing k candies to each child from index a to index b, inclusive.
The function calculates the total number of candies distributed to all children based on the provided operations and returns the average number of candies each child receives.
Input Requirements
n (1 ≤ n ≤ 10^7): The total number of children.
operations: A list of tuples, where each tuple (a, b, k) satisfies the following constraints:
1 ≤ a ≤ b ≤ n
1 ≤ k ≤ 10^4
Output Requirements
The function should return an integer representing the average number of candies per child. The average should be computed using integer division.
Implementation
Write the solution in a file called /app/solution.py.
The file should include the function implementation according to the described functionality.
Example
python
n = 5
operations = [(1, 2, 1), (2, 5, 2)]
# The average candies per child should be calculated as follows:
# Total candies = (2-1+1)*1 + (5-2+1)*2 = 1 + 8 = 9
# Average = Total candies // n = 9 // 5 = 1
result = calculate_average_candies(n, operations) # Should return 1