Merely an unscientific toy that tries to tell if you're a risk-taker or not. Run the script and answer a few questions at the prompt.
use strict; use warnings; my $input = input(); print $input->(0); while(<STDIN>){ my $output = $input->($_); last unless $output; print $output; } sub input { my @policy; my @damage = qw/ 0 33.21 57.36 72.45 138.87 253.59 298.88 /; my($text,@prompt,@result); while (<DATA>) { if(/TEXT1/../TEXT2/){$text .= $_ unless /[A-Z]+[12]/} if(/PROMPT1/../PROMPT2/){chomp; push @prompt, $_ unless /[A-Z] ++[12]/} if(/RESULT1/../RESULT2/){chomp; push @result, $_ unless /[A-Z] ++[12]/} } print $text; return sub { push @policy, shift; return $#policy < 6 ? $prompt[$#policy] : $#policy == 6 ? predict(\@damage,\@policy,\@result) : unde +f; }; } sub predict { my $slope = slope(shift, shift); my @r = @{$_[0]}; if ($slope < 0.625) { return "\n " . $r[0] . percent($slope); } elsif ($slope < 0.8) { return "\n " . $r[1] . percent($slope); } elsif ($slope < 1.25) { return "\n " . $r[2] . percent($slope); } elsif ($slope < 1.6) { return "\n " . $r[3] . percent($slope); } else { return "\n " . $r[4] . percent($slope); } } sub percent { if ($_[0] < 0.8) { return "\n You're paying " . int(100*(1-$_[0])) . "% less +than you should.\n"; } elsif ($_[0] > 1.25) { return "\n You're paying " . int(100*($_[0]-1)) . "% more +than you should.\n"; } else { return "\n You're paying " . int(100*$_[0]) . "% of the \" +right\" price.\n"; } } sub sum {my $sum = 0; $sum += $_ for @_; $sum} sub mean {sum(@_)/scalar(@_)} sub sumn { my($n, $mean) = (shift, mean(@_)); sum(map{($_ - $mean)**$n} @_); } sub sumxy { my @x = @{$_[0]}; my @y = @{$_[1]}; return unless $#x == $#y; my ($xmean, $ymean) = (mean(@x), mean(@y)); my $sumxy = 0; $sumxy += ($x[$_] - $xmean)*($y[$_] - $ymean) for 0..$#x; return $sumxy; } sub slope { my($x, $y) = @_; sumxy($x, $y) / sumn(2, @{$x}); } __DATA__ TEXT1 By Federal Law, as a sysadmin, you're required to purchase Bug Insurance. The insurance policy will pay the plaintiff the damage incurred by each bug your system causes. Let $54.99 be the max possible damage claimable per bug, 5.49% the chances for each bug to independently occur. Using your "instinct" only, how much are you willing to pay for a policy that protect you against... TEXT2 PROMPT1 ... 11 bugs: ... 19 bugs: ... 24 bugs: ... 46 bugs: ... 84 bugs: ... 99 bugs: Press any key to quit. PROMPT2 RESULT1 You're a Gambler--code w/o your monitor on. You're a Risk-taker--code & pray, & never debug. You're a Stone-Cold Human Calculator--code in assembly. You're a Risk-Averser--even debug a plain text. You're a Wuss--even afraid of electrocution by your mouse. RESULT2

In reply to Are you a risk-taker? by chunlou

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.