• Source
    1. #!/usr/bin/perl
    2.  
    3. # become over-sensitised to women
    4. # ooohhh become over-sensitised to women
    5.  
    6. use strict;
    7. use warnings;
    8.  
    9. my ($poptotal, $days, $type) = @ARGV;
    10. $poptotal ||= 1000;
    11. $days ||= 1000;
    12. $type ||= 1;
    13.  
    14. my $popref = createpop($poptotal, $type);
    15. printfullness($days, $popref);
    16.  
    17. sub printfullness {
    18. my ($days, $popref) = @_;
    19.  
    20. for my $day (0..$days-1) {
    21. my $bleedingtotal = 0;
    22.  
    23. for my $female (@$popref) {
    24. $bleedingtotal++ if isbleeding($female, $day);
    25. }
    26.  
    27. print "$day $bleedingtotal\n";
    28. }
    29.  
    30. }
    31.  
    32. sub createpop {
    33. my ($total, $type) = @_;
    34. my @pop = map {createdata($type)} 1..$total;
    35. return \@pop;
    36. }
    37.  
    38. sub createdata {
    39. my $type = shift;
    40. my @data;
    41. my @durations = (3, 4, 4, 4, 5, 5, 5, 6);
    42. my $duration = $durations[rand(@durations)];
    43. my @cycles = (25, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 29, 30, 30, 30, 30, 31, 31, 33, 35);
    44. my $cyclelength = $cycles[rand(@cycles)];
    45. push @data, $cyclelength;
    46. my $start = rand($cyclelength);
    47. my @bleedingdays = map {$_ % $cyclelength} $start..$start + $duration - 1;
    48. push @data, $type ? \@bleedingdays : calcbleedingdays($cyclelength, $start, $duration);
    49. return \@data;
    50. }
    51.  
    52. sub calcbleedingdays {
    53. my ($cyclelength, $start, $duration) = @_;
    54. my @bleedingdays = map {$_ % $cyclelength} $start..$start + $duration - 1;
    55. return \@bleedingdays;
    56. }
    57.  
    58. sub isbleeding {
    59. my ($self, $clock) = @_;
    60. my $res = 0;
    61.  
    62. for (@{$self->[1]}) {
    63. if ($_ == $clock % $self->[0]) {
    64. $res = 1;
    65. last;
    66. }
    67. }
    68.  
    69. return $res;
    70. }
    71.  
    72. sub mustbefedwithstick {
    73. return isbleeding(@_);
    74. }
    75.  
    76. sub maynevertalktomales {
    77. return isbleeding(@_);
    78. }