dshahin has asked for the wisdom of the Perl Monks concerning the following question:
I suppose I should just build every possible combination and then discard the teams over $maxpoints, but I thought there might be a more elegant solution. I'm going to sleep on it and see if that, and your insights help.#!/usr/bin/perl use strict; print "how many points?:"; my $maxpoints = <STDIN>; chomp $maxpoints; my %roster; my $total_figs = 0; while(<DATA>){ chomp; my ($name, $rank, $value) = split /:/; $roster{"$name($rank)"} = $value; $total_figs++; }; my @groups; foreach my $key (keys(%roster)){ print "$key: $roster{$key}\n"; #build armies here! } __DATA__ blastaar:v:138 mr fixit:u:104 daredevil:r:30 blob:v:51 boomerang:e:34 wolverine:e:61 skrull commando:v:18
dan shahin
hijinx comics
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: army building
by Zaxo (Archbishop) on Mar 03, 2003 at 08:50 UTC | |
|
Re: army building
by zengargoyle (Deacon) on Mar 03, 2003 at 09:43 UTC | |
|
Re: army building
by abell (Chaplain) on Mar 03, 2003 at 14:05 UTC | |
|
Re: army building
by pg (Canon) on Mar 03, 2003 at 16:18 UTC | |
|
Re: army building
by BrowserUk (Patriarch) on Mar 03, 2003 at 19:05 UTC | |
|
Re: army building
by hv (Prior) on Mar 03, 2003 at 15:51 UTC | |
by dshahin (Pilgrim) on Mar 03, 2003 at 19:29 UTC |