I have the following code:
import random
usuarios = 2
APs = 2
distancias = random.sample(range(0, 100), usuarios*APs)
teste = [sum(distancias[x: x + usuarios]) for x in range(0, len(distancias), usuarios)]
print(teste)
This code creates a vector with the size of the multiplication of the APs with the users and then adds the sum of 2 in 2 and saves it in the test vector ..
For example:
-
Let's say the vector looks like this:
distances = [10, 20, 40, 60]
-
The result will look like this:
test = [30, 100]
However, what I want is for the sum to be made only of values smaller than 50, if it is greater, the value is assigned to the previous or subsequent sum.
For example:
In the values given above the answer should be:
teste = [90, 40]
- Notice that the value 60 was added to the previously added part because it is greater than 50.
Sorry if it was not very clear, I tried to be as much as possible.
Can anyone help me with this problem? I can not go on.