Implement a function that counts the number of valid equilateral triangles that can be formed given a maximum side length, ( L ), and a minimum side length, ( K ). An equilateral triangle has all three sides of equal length, so the valid lengths are the integers within the range from ( K ) to ( L ) inclusive.
Functionality:
The function count_valid_equilateral_triangles(L, K) should take two integer parameters, ( L ) (the maximum length of the sides of the triangle) and ( K ) (the minimum length of the sides).
If ( K ) is greater than ( L ), the function should return ( 0 ) since no valid equilateral triangle can be formed.
If ( K ) is less than or equal to ( L ), the function should calculate the number of different valid side lengths from ( K ) to ( L ) and return the number of ways to choose two different lengths out of these available lengths, which is computed using the formula for the sum of an arithmetic series.
Input/Output Requirements:
Input:
Two integers: ( L ) (1 ≤ ( L ) ≤ 10^9), ( K ) (1 ≤ ( K ) ≤ ( L )).
Output:
An integer representing the number of valid equilateral triangles that can be formed.
Implementation:
Write the function in a Python file located at /app/solution.py with the same function signature provided. Ensure that the function adheres to the input/output specifications outlined above.
Please make sure to include appropriate error handling to manage any inputs that do not adhere to the specified constraints.