Advertisement
Guest User

Untitled

a guest
Feb 16th, 2012
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.45 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use List::Util qw(shuffle);
  5. use Data::Dumper;
  6. $Data::Dumper::Indent = 0;
  7.  
  8. unless (defined $ARGV[0]) {
  9.         $ARGV[0] = 5;
  10. }
  11. for (1 .. factorial($ARGV[0])) {
  12.         my @array = (0 .. ($ARGV[0] - 1));
  13.         @array = shuffle(@array);
  14.         print Dumper( \@array ) . "\n";
  15. }
  16.  
  17. sub factorial {
  18.         my $n = shift;
  19.         my $f = 1;
  20.         $f *= $n-- while $n > 0;
  21.         return $f;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement