Polynomials and modular arithmetic to get the moral out of this classic Aesop's fable.

If you haven't practiced your Latin recently, an English version is available at Project Gutenberg (search "The Wolf and the Lamb").

#!/usr/bin/perl -w use strict; undef $/; our $data = lc <DATA> . "jkwy" x 10; $data =~ s/(\015|\012)+/ /g; # Needed to solve newline mismatches our @letter = split //, $data; sub poleval { my ($x, $r) = (shift, 0); $r = ( $r * $x + $_ ) % 683 for @_; $r; } for my $p ( [504,354,142,50,9],[155,9,370,394,644],[48,38,324,84] ) { for my $x ( 0 .. 2 * @$p - 1 ) { print $letter[ poleval( $x, @$p) ]; } print "\n"; } __DATA__ Lupus et agnus Ad rivum eundem lupus et agnus venerant, siti compulsi. Superior stabat lupus, longeque inferior agnus. Tunc fauce improba latro incitatus iurgii causam intulit; 'Cur' inquit 'turbulentam fecisti mihi aquam bibenti?' Laniger contra timens 'Qui possum, quaeso, facere quod quereris, lupe? A te decurrit ad meos haustus liquor'. Repulsus ille veritatis viribus 'Ante hos sex menses male' ait 'dixisti mihi'. Respondit agnus 'Equidem natus non eram'. 'Pater hercle tuus' ille inquit 'male dixit mihi'; atque ita correptum lacerat iniusta nece. Haec propter illos scripta est homines fabula qui fictis causis innocentes opprimunt.

Challenge

If you have some time to waste: are you able to get another moral by only changing the polynomial coefficients in the line starting with "for my $p"?

Antonio

The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket

In reply to Lupus et Agnus by abell

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.