Jelly, 28 bytes
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’Œ?"ðÑþQ’,ḥμÞ
How it works
μ turns everything to its left into a monadic chain, which Þ maps over the input array and sorts the input according to the generated values.
"1⁄2Ṗ©cƘʂẒẹMMỤẓHP’ sets the return value to 176073885534954276199526358143331.
Œ? generates the 176073885534954276199526358143331th permutation of the positive integers (without the sorted tail), yielding \$\small[20,28,15,3,5,26,18,16,8,30,4,25,2,21,22,11,24,1,23,10,29,12,17,27,14,9,6,13,7,19]\$.
"ðÑþQ’ yields 391695582; , prepends it to the permutation. Then, ḥc ompute Jelly's 391695582th hash function, mapping the
resulting buckets to the integers of the permutation.
The magic constant 391695582 was found by Jelly's utils.
dennis-home:utils$ time ./findhash 30 29 <<< '["red","yellow","green","brown","scarlet","black","ochre","peach","ruby","olive","violet","fawn","lilac","gold","chocolate","mauve","cream","crimson","silver","rose","azure","lemon","russet","grey","purple","white","pink","orange","blue"]'
391695582
real 0m2.058s
user 0m15.077s
sys 0m0.023s
- 211.7k
- 41
- 380
- 830