My maths is quite poor and I need some help writing an algorithm/pseudo for a simple cost estimator: rules I have three inputs x, y and z. The inputs each have a separate max value that if breached return an error. These max values, X = 20, Y = 15, Z = 30. Now I need a function that compares the in-putted values and if possible swaps the values to keep them under the constraints. Also, Z should always contain the smallest value as long as the swapped value still meets the max value constraints. So for a few examples if the user entered X=15,Y=5,Z=10 the values for y and Z would be swapped to make z the lowest value. With X=5 Y=18 Z=2 X and Y would be swapped with x to fit under max values. With X=10 Y=8 Z=2 nothing would be swapped. X=31 Y=18 Z=10 nothing would be swapped and you would get an error. I have written this codepen so far: http://codepen.io/FredHair/pen/gpvoPR?editors=101[^] It finds the minVal, medVal and maxVal. I just need some help with the next logic steps for swapping the values. The values themself represent a bounding box, orientating an inputted box that would lead to a cost estimate. I have already had a go at writing this into a program but I made numerous logical errors. If anyone can offer any insight into the maths and best way to write this I can then write the code. Any help is greatly appriceted, I hope I have made myslef clear, feel free to look at codepen and ask any questions. Regards, F
U
User 11777723
@User 11777723