I have a set of code that returns an array of two values. The next step in my code is to choose only one value based on a set of rules:
If both items are equal, return either one of the values.
If exactly one item is equal to 12, return the remaining value (12 could be in the first or second position)
Otherwise, always return the largest value.
I can map this out in my head and it seems fairly straightforward, but when I try to turn it into code, it becomes more complicated.
I have attached my attempt. Am I overthinking this?
Thanks for any help.
已解决! 转到解答。
c
First of all, use the Array Max & Min to get the largest value. Coincidentally, if they are equal, the Max and Min will be the same value. So finding the Max will suffice for cases 1 and 3. So really, we just need to figure out if one of them is 12. Compare the array to 12. This will give you a boolean array. Now use the Boolean Array to Number to get a number and wire that number to a case structure. If the number is 1, then the first value was 12 and you should return the second value. If the number is 2, then the second value was 12 and you should return the first value. If the number is anything else, return the max of the array.

For some reason I was thinking about this problem while washing the dishes and came up with another solution.
