Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: help with simplifying program

by snoopy (Deacon)
on May 24, 2013 at 05:50 UTC ( #1035068=note: print w/ replies, xml ) Need Help??


in reply to help with simplifying program

Hi There, I'm not sure, if the unless condition is actually filtering anything:

use strict; my $n1; my $n2; foreach my $w (3..100) { foreach my $x (2..$w-1) { foreach my $y (1..$x-1) { foreach my $z (0..$y-1) { foreach my $s (1..20) { $n1++; unless ( $x == $w + $s && $y == $x + $s && $z == $y + $s ) { $n2++; } } } } } } print "n1: $n1\n"; print "n2: $n2\n";
Output:
n1: 81658500 n2: 81658500


Comment on Re: help with simplifying program
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1035068]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-09-19 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (143 votes), past polls