3 ms·
You can turn a sort into a shuffle by replacing the comparator with a random coin flip, and you already have defined a sort algorithm, so there's no added code
by jtolmar 5y ago
You can turn a sort into a shuffle by replacing the comparator with a random coin flip, and you already have defined a sort algorithm, so there's no added code complexity.
fn bogosort(a, comparator):
while not is_sorted(a, comparator) do
bogosort(a, rand)
- aidenn0 5y agoYou can't turn all sorts (not even all comparison sorts!) into a shuffle by replacing the comparator with a random coin flip. In fact your code post is a demonstration of that fact.