4 ms·
I had to check 10! just to see how bad this could be. At 10 it's 3,628,800. Depending on how beefy the system is and how costly the operation is, pure brute f
by mjevans 7y ago
I had to check 10! just to see how bad this could be. At 10 it's 3,628,800. Depending on how beefy the system is and how costly the operation is, pure brute force but simple might be good enough.
- owenshen24 7y agoI think you could get by with ~50 checks if you just used selection sort. I'm not sure what brute-forcing means in this context. Do you mean hard-coding every way to order 10 unique elements?
- the8472 7y agoBrute force sorting would be generating permutations and checking if they're sorted. The non-deterministic version that uses random permutations is commonly called bogosort[0] [0] https://en.wikipedia.org/wiki/Bogosort https://en.wikipedia.org/wiki/Bogosort
- mjevans 7y agoThe thread switched problems and I didn't catch that. The 10 factorial was trying out all possible packing solutions and filtering for only the ones that were 'valid' (probably with an added step of also keeping the best valid configuration).
- rbonvall 7y agoA nice solution that is easy to implement in Excel is using a sorting network, that sorts an array by doing the same exchanges for any input. Here I did it just for fun: https://imgur.com/a/qPugrJ6 https://imgur.com/a/qPugrJ6
- istinetz 7y agowow that's pretty.