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

Replies are listed 'Best First'.
Re: Lupus et Agnus
by tall_man (Parson) on Apr 16, 2003 at 05:45 UTC
    Here is a challenge response, probably not the one you intended. (It's a bit political).
    for my $p ( [529,199,442,183,393],[174,603,481,399,664],[483,139,314,5 +9] ) {
    Here is the code I used to probe for the 10-letter parts. The code for the 8-letter part is similar. Given an initial guess for the first 6 letters, it solves 5 equations in 5 unknowns and then uses the coefficients to generate the rest. The user has to pick through the junk to find a meaningful line.

    Update: Here are some alternate coordinates for the original moral.

    492, 258, 236, 558, 276: any excuse 226, 640, 286, 616, 465: any excuse 202, 487, 474, 15, 680: will serve 323, 527, 255, 84: a tyrant 501, 663, 511, 136: a tyrant 634, 447, 626, 165: a tyrant 107, 489, 228, 200: a tyrant 61, 535, 38, 216: a tyrant 625, 232, 416, 269: a tyrant 148, 199, 463, 303: a tyrant 380, 162, 314, 303: a tyrant 255, 535, 86, 326: a tyrant 610, 425, 390, 361: a tyrant 88, 470, 603, 458: a tyrant 645, 617, 159, 458: a tyrant 350, 669, 352, 514: a tyrant 242, 115, 22, 535: a tyrant 394, 46, 227, 535: a tyrant 307, 18, 392, 596: a tyrant
Re: Lupus et Agnus
by ant9000 (Monk) on Jun 19, 2003 at 12:32 UTC
    That's a really unexpected use of polinomials!
    Just a sidenote: the moral really should have been in latin :)