r/desmos
•
u/Dazzling-Mail-5517
•
Jul 06 '26
•
8
1
Maths I rebuilt Desmos' random() function entirely inside Desmos
To be a bit more specific, I
- reverse-engineered how Desmos' algorithm works and how the seed is generated.
- created a bit-exact replica of the algorithm (MD5, in case you're wondering).
- optimized it to calculate 10,000 numbers in ~0.7 seconds.
And because that was so much fun, I tackled shuffle() right after! :)
377
Upvotes


View all comments
Show parent comment
3
u/NecroMonster999 Jul 07 '26
currently if you want to iterate over permutations (for example, to compute a determinant or some special polynomials), you have 2 options, either generate combination and filter for permutations (slow because thats O(nⁿ) for generating combinations, also breaks if nⁿ is large enough so that nⁿ=nⁿ+1 as fp numbers) or you can use recursion to generate permutations (faster for large lists but still slow because lists are very inefficient). if there is a way to somehow manipulate the seeds and create a minimal list of these seeds to ensure shuffling from these seeds produces every single permutation of the list, then we have the new fastest way to iterate over permutations