Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 chilling in the Monastery: (14)
As of 2015-07-02 21:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (45 votes), past polls