in reply to Math with Perl, equation combinations:
Here's the straight-ahead dumb way to do it:
Uhhh, this wasn't homework, was it? ;-)#!/usr/bin/perl -w use strict; my $target=shift; X: for my $x (1 .. 20) { for my $y (1..20) { my $z = $target - $x - $y; next X if $z<1 || $z>20; print "($x,$y,$z)$/"; } }
Update: Remove a bogosity from code. U 2: samtregar, there is Steal This Code.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Math with Perl, equation combinations:
by samtregar (Abbot) on May 11, 2002 at 03:07 UTC |