Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Embargo algorithm

by Not_a_Number (Parson)
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]
[Discipulus]: good morning monks! town holiday here.. but super busy
Discipulus time is not comarable with money.. when you have a roof and something to eat
[Corion]: Hi Discipulus! Busy making the town better? ;)
[Discipulus]: the house I hope.. now i'm going on the roof putting some protection for the sun. afternoon 150 km for a water polo training (son, obviously..)
[Corion]: Discipulus: Ah - lazy roof-sitting ;)
[Corion]: (well, after you've put on the sun protection ;) )
[Corion]: But I should be moving into town as well, do some chores and get my hair cut...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2017-06-29 08:39 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (655 votes). Check out past polls.