Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
The stupid question is the question not asked
 
PerlMonks  

converter's scratchpad

by converter (Priest)
on Jun 02, 2004 at 03:29 UTC ( #359104=scratchpad: print w/ replies, xml ) Need Help??

#!/usr/bin/perl use warnings; use strict; # given skew factor and sectors/track, # return a list of skewed sector numbers. # skew: skew factor # sectors: number of sectors (per track) sub skewlist { my ($skew, $sectors) = @_; my @a = 1; my %seen = (1 => 1); for (2..$sectors) { my $s = $a[-1] + $skew; $s = $skew - ($sectors - $a[-1]) if $s > $sectors; $s++ while $seen{$s}; $seen{$s}++; push @a, $s; } return @a; } sub main { unless (2 == @ARGV) { die "usage: skewgen <skew factor> <number of sectors>"; } my @a = skewlist(@ARGV); print "skewlist: @a\n"; } exit(main()); __END__ $ ./skewgen 4 15 skewlist: 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 $ ./skewgen 6 26 skewlist: 1 7 13 19 25 5 11 17 23 3 9 15 21 2 8 14 20 26 6 12 18 24 4 +10 16 22
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2014-04-20 13:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls