in reply to Re: A little golfing challenge: replace digits by random letters
in thread A little golfing challenge: replace digits by random letters

half-blind-sort is a great idea (and so is {rand()<rand} ).

Couldn't resist sort{rand(2)-1} as it's shorter by 2 and truer blind.

Update/Correction: as vr rightly notes, int(rand(2)-1) is constantly 0!!! Because sort expects an integer back from the comparison BLOCK and int()'ing rand(2)-1 leaves just 0 :(. So, both these compensate for that bug and are uniformly random too: sort{rand(6)-4} and sort{1-rand(3)%3}

Replies are listed 'Best First'.
Re^3: A little golfing challenge: replace digits by random letters
by vr (Curate) on Feb 10, 2019 at 14:12 UTC

    Perhaps sort{rand(2)-1} (in effect, same as sort{0}) is somewhat too deterministic :). But

    $ perl -E 'say sort{rand 2}a..z'

    produces random enough strings, and is shorter.

      ai! indeed it is. got bitten by int. This is uniformly random sort{rand(6)-4} and so is this sort{1-rand(3)%3}