Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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";
n1: 81658500 n2: 81658500

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1035068]
[james28909]: i figured out a neet trick
[Lady_Aleena]: james28909, what neat trick?
[james28909]: now if i have packed a script into a PDK exe, and misplaced the source, i can print it.
[james28909]: but you have to prepare for it first by adding this to the source
[james28909]: seek DATA, 0, 0; while (<DATA>) { print; }
[Lady_Aleena]: Sounds interesting. Have you written a meditation or cool use for it?
[Lady_Aleena]: It might be something PerlMonks at large would be interested in.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2017-05-01 00:06 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (543 votes). Check out past polls.