Original Post
Assume you have an array of 4 random floats. What is an elegant way to put the indices for the 3 smallest floats into a 3 integer array? You cannot change the values inside the float array. I ran into this problem during some work tonight. At first I just brute forced it, but was embarrassed at how much code there was to accomplish such a simple task. I spent about 15 minutes(!!!) coming up with a clean solution for fun. I've finally come up with what I think is the best solution, but I'm not positive. My current solution is still 6 lines of "simple" ( ie- single / unnested ) commands. It would be terribly embarrassing to get such a simple question on a programming test and not be able to instantly spit out a good answer. So what's your solution??