# How to compare and subtract elements in nested list to generate a new list [closed]

I have list of lists like this one:
list={{1, 9, 4, 7, 2}, {1, 4, 7, 1, 8}, {0, 5, 7, 2, 9}}
where every nested list have 5 elements.

I want to compare the third, fourth and fifth elements of each nested list and do the subtraction: the largest number minus the smallest number. The result should create a new list.

In my example, it should work like this:
in the first nested list {1, 9, 4, 7, 2} the largest value between the third, fourth and fifth elements is 7 and the smallest 2, subtraction 7-2=5. So 5 will be the first element in the new list with results. I want to do it with every nested list in my list of list.
For my example, the result will be:
result={5,7,7}

The problem is that I don't know how to do it. It's not just comparing the elements between nested lists or extracting specific elements from the lists (because I want to compare and subtract them first, then get the result). Please help!

• Isn't the result supposed to be {5, 7, 7}? – Carl Woll Jun 11 at 22:38
• Does (Max[#[[3;;5]]] - Min[#[[3;;5]]] &) /@ list work for you? – thorimur Jun 11 at 22:45
• also I do think the result should be {5, 7, 7}, as 1 is the smallest element among the 3rd, 4th, and 5th elements of the second list, and 2 is the smallest among those elements in the last list – thorimur Jun 11 at 22:47
• omg you're right, my fault! i'll change it – smolar Jun 11 at 22:51
• now it turns out that I can't even count, all the more reason I need help – smolar Jun 11 at 22:54