About Block: From each number from...to...by

I have a question.
With the above blocks, I get the result in Label 1 which is 4.
But I want the result to be 2.
I mean:
7,8,13,16 are all > 1x3(3)
7,8,13,16 are all > 2x3(6)
But 7,8 is not greater than 3x3(9).
I want all the numbers in "list_number" to be greater than the number in "number2_" when multiplied by 3, so the result must be 2.
I understand why the result is 4 (16>4x3) but have no idea how to get the result 2.
Can anyone help me?
Thank you so much

So this is what you want:
You have a list with numbers, you want get x, that all the numbers in the list is greater than 3*x,
what is the maximal x?

1 Like

Maybe you want to count how many items in the list are greater than 3*x ?

1 Like

Thanks for replying. I've tried applying it and editing it to suit what I want to do but I'm still having trouble.

What I want to do is:
I will reach level 1 if 1 number in the list is greater than 1x3(3), level 2 if 2 numbers are greater than 2x3(6), level 3 if 3 numbers are greater than 3x3(9), and so on.

I tried following this photo and some other changes but it didn't work. I want the result to be level 3 (3 numbers greater than 9). I thought when I had level=4 and x=5 I would have 12 < 3x5 but nothing happened.

Thank you very much.

This is similar to calculating a histogram, which would be a new list of buckets containing counts of how many original list items fall into different categories.

Sorting the input list then reversing the sorted list helps here, because each item's index in the sorted list tells you how many other items are almost bigger than that item .

(End of hint)

1 Like

This is astonishing.

Look at what the AI2 list sort block is doing here:

It's sorting what should be a list of numbers in text order, not math order.

Will have to use a more robust sort block.

Bug is in screen Histogram
math.aia (61.8 KB)

1 Like

hmmm, yes, the csv returns strings to the list

image

1 Like

This should work:



Blocks are draggable.

1 Like

I have turned on my Show Lists as JSON flag in that old math project, to avoid falling for this again.

1 Like

Thank you all very much.
I finally did it.

Wish you all the best!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.