in reply to Challenge: Letter Power Revisited
#!/usr/bin/perl use strict; use warnings; use List::Util 'shuffle'; my $num_cat = 20; my $max_len = 10; my $min_sol = 6; my $max_sol = 30; my @word; open(my $fh, '<', 'words.txt') or die "Unable to open 'words.txt' for +reading: $!"; while (<$fh>) { tr/a-z//cd; next if length($_) > $max_len; push @word, $_; } @word = shuffle(@word); for my $cat (1 .. $num_cat) { my $count = int(rand ($max_sol - ($min_sol - 1))) + $min_sol; my @cat = splice(@word, 0, $count); print "@cat\n"; }
Cheers - L~R
|
|---|