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

Re^6: Split range 0 to M into N non-overlapping (roughly equal) ranges.

by repellent (Priest)
on Mar 13, 2011 at 07:32 UTC ( #892936=note: print w/replies, xml ) Need Help??


in reply to Re^5: Split range 0 to M into N non-overlapping (roughly equal) ranges.
in thread Split range 0 to M into N non-overlapping (roughly equal) ranges.

But this isn't 0 .. 14 inclusive:
[ 6:16:11.35] C:\test>ranges -M=14 -N=11 0 : from 0 to 0 ( 1) 1 : from 1 to 1 ( 1) 2 : from 2 to 3 ( 2) 3 : from 4 to 4 ( 1) 4 : from 5 to 5 ( 1) 5 : from 6 to 7 ( 2) 6 : from 8 to 8 ( 1) 7 : from 9 to 9 ( 1) 8 : from 10 to 11 ( 2) 9 : from 12 to 12 ( 1) 10 : from 13 to 13 ( 1) ======================================== 14

Based on your previous results, I expect non-inclusive every time. If my expectation is wrong, then why is the result above non-inclusive (i.e. does not end with index 14)?

(I'm not adamant on my expectation of non-inclusiveness. I just expect consistent behavior. :-)
  • Comment on Re^6: Split range 0 to M into N non-overlapping (roughly equal) ranges.
  • Download Code

Replies are listed 'Best First'.
Re^7: Split range 0 to M into N non-overlapping (roughly equal) ranges.
by BrowserUk (Pope) on Mar 13, 2011 at 07:51 UTC

    Ah! Now I see the problem. (Phraseology lacking).

    Preliminary response:

    my $STEP = ( $M + 1.5 ) / $N;

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2021-10-21 05:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (82 votes). Check out past polls.

    Notices?