Skip to content

Instantly share code, notes, and snippets.

@mgechev
Created July 5, 2013 10:59
Show Gist options
  • Select an option

  • Save mgechev/5933783 to your computer and use it in GitHub Desktop.

Select an option

Save mgechev/5933783 to your computer and use it in GitHub Desktop.
Random generator for the topics to re-study...
#!/usr/bin/perl
use warnings;
use strict;
use constant NUM_PER_DAY => 5;
use constant TOTAL_TOPICS => 24;
my @topics = (1..TOTAL_TOPICS);
my ($rand, $temp);
for (my $i = 0; $i < @topics; $i += 1) {
$rand = int(rand($#topics) + 0.5);
$temp = $topics[$rand];
$topics[$rand] = $topics[$i];
$topics[$i] = $temp;
}
$temp = 0;
for (@topics) {
print "---\n" unless $temp % NUM_PER_DAY;
print "$_\n";
$temp++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment