in reply to biased random number picking

List::Util::shuffle will randomly shuffle a list of numbers, like 1 to 100. Use a slice to grab two of the numbers. These are guaranteed not to be the same.
use warnings; use strict; use List::Util qw(shuffle); for (1 .. 5) { my @nums = (shuffle(1 .. 100))[0 .. 1]; print "@nums\n"; }

Replies are listed 'Best First'.
Re^2: biased random number picking
by BillKSmith (Monsignor) on Jul 12, 2012 at 11:58 UTC
    There is no need to repeat the shuffle each time through the loop. Use the next two numbers.
      That is not the way I interpreted the OP's specification. If the OP had explicitly stated that no pair should contain any repeat number as another pair, then there is no need to have the shuffle in the loop.
      In fact the solution is incorrect unless you do this ... and correct if you do.