Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Embargo algorithm

by Not_a_Number (Prior)
on Oct 29, 2013 at 21:15 UTC ( #1060221=note: print w/replies, xml ) Need Help??

in reply to Embargo algorithm

This is how I'd do it (albeit without using OO Perl):

use List::Util 'shuffle'; my @bag = shuffle qw( A B C D E ); my @embargoed = pop @bag; while ( 1 ) { my $time = ( localtime )[ 0 ]; # seconds sleep 1; if ( $time >= 55 ) { push @embargoed, pop @bag; push @bag, shift @embargoed if @embargoed > 2; @bag = shuffle @bag; sleep 5; } print "$time @embargoed\n"; }

NB: For testing porpoises, I've substituted seconds for minutes and minutes for hours. Adjusting this (including sleep times) is left as an excercise...

Update: Simplified code (and explanation). Minutes don't matter!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1060221]
[marto]: yes, trying to do anything other than sideload to android via windows has always been more effort than linux
[Corion]: The inconvenient thing is that my Linux machine is in another room than my desktop, so I have to walk up to it while some device is hooked up to it, just to press "allow" for install tasks etc :-)

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2018-05-23 09:09 GMT
Find Nodes?
    Voting Booth?