On Wed, Feb 09, 2011 at 10:52:24PM +0000, Rob Dixon wrote: > On 09/02/2011 17:05, Paul Johnson wrote: > > > >Of course you can redefine the problem this way, but it's more interesting to > >solve the original problem. > > > >To go with Rob's solution, here's something that's (more) correct:
> Hey Paul > > I'm not clear whether you meant your solution was 'more correct' than > mine or than Uri's? Of course it doesn't matter at all given the > triviality of the requirement, but my program produced N independent but > different minutes of the day, whereas yours results in times that are, > on average, spaced equally over the day. I don't think that can be said > to be more accurate than anything else that has been suggested. Hello Rob, Yes, sorry, that wasn't very clear. What I meant was that Uri's solution is simple, but clearly solving a slightly different problem. Your solution is elegant and obviously correct, with every minute having an equal probability of being selected. My solution is more difficult to reason about, and my brain is telling me that probability is hard, let's go shopping. (Hence the parenthetical "more".) Then again, why shouldn't two or more messages be sent out at the same minute? Perhaps all that's really needed is: perl -E 'say for sort map { sprintf "%02d:%02d", rand 24, rand 60 } 1 .. shift' 50 -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/