Logan Capaldo
8/5/2006 7:21:00 PM
On Aug 5, 2006, at 3:07 PM, Meino Christian Cramer wrote:
> Oh...there is another issue:
>
> With encmap=Hash[*('A'..'Z').to_a.sort{rand(2)}] I only will get 13
> instead of 26 mappings! How can I fix /that/ ?
>
> Keep encoding! :)
> mcc
>
Actually its generally considered better to do sort_by{rand} that sort
{rand(2)}
If you only want to randomize key or value you can do
first = ("A".."Z").to_a
second = ("A".."Z").sort_by{rand}
encmap = Hash[ *first.zip(second).flatten ]