Any other approaches to Quest 3: sides_make_triangles()?

You could make use of the sort algorithm provided by #include <algorithm> to sort an unsorted array of integers. Then you can simply return true if (arr[0] + arr[1]) >= arr[2]

You'll want to take a look at how to use std::sort, std::begin and std::end. You could also use a vector which have methods for begin() and end() as well, but since we're working with an array that doesn't grow, you can just use algorithm

I tried to do it without using the sort algorithm and did it similar to your approach, but without loops. You can check whether an integer is between two other integers using a <= b & b <= c for example; this means b is between a and c (or equal to either/both). Then check to see if (a + b) >= c and return true—repeat this for when a is the middle value and when c is the middle value. The resulting code is much longer than using sort though.

/r/cs2a Thread