When I worked for a company writing education software many moons ago on the BBC micro we had a product that would work out the polynonial function for a sequence of number. We actually used this in some crude protection schemes.
Excel offers a smaller version of this in trending so I thought I could use the principle to generate a JAPH. Limitations in Excel mean accuracy is limited to 6 characters at a time.
I dare say those with a more maths bent can get this even better.
Note I'm not a mathematician so if this is named wrongly and someone else already has this then I appologise.#!/usr/local/bin/perl -w use strict; map{ eval} ('map{printf "%c" ,3.55*$_**5-57.583*$_**4+347.75*$_**3-972.92*$_**2+1 +249.2*$_-463.5}(1..6)', 'map{printf "%c", -0.55*$_**5+10.208*$_**4-69.833*$_**3+215.29*$_**2-2 +92.12*$_+247.5}(1..6)', 'map{printf "%c", 1.25*$_**5-25.333*$_**4+191.25*$_**3-672.17*$_**2+10 +99*$_-561.5}(1..6)', 'map{printf "%c", 0.5833*$_**5-9.4583*$_**4+56.167*$_**3-148.54*$_**2+ +169.25*$_+36.5}(1..6)'); print "\n"
Update
With some playing I have this down to
Update 2 This is now at 306 chars.for('3.55*$i**5-57.583*$i**4+347.75*$i**3-972.92*$i**2+1249.2*$i-463.5 +','-0.55*$i**5+10.208*$i**4-69.833*$i**3+215.29*$i**2-292.12*$i+247.5 +','1.25*$i**5-25.333*$i**4+191.25*$i**3-672.17*$i**2+1099*$i-561.5',' +0.5833*$i**5-9.4583*$i**4+56.167*$i**3-148.54*$i**2+169.25*$i+36.5'){ +{for$i(1..6){printf"%c",eval$_}}};
Update 3 Shaved another char off (305)map{$i=$_%6+1;print chr${[3.55*$i**5-57.583*$i**4+347.75*$i**3-972.92* +$i**2+1249.2*$i-463.5,-0.55*$i**5+10.208*$i**4-69.833*$i**3+215.29*$i +**2-292.12*$i+247.5,1.25*$i**5-25.333*$i**4+191.25*$i**3-672.17*$i**2 ++1099*$i-561.5,0.5833*$i**5-9.4583*$i**4+56.167*$i**3-148.54*$i**2+16 +9.25*$i+36.5]}[$_/6]}(0..23)
map{print chr${[3.55*++($i=$_%6)**5-57.583*$i**4+347.75*$i**3-972.92*$ +i**2+1249.2*$i-463.5,-0.55*$i**5+10.208*$i**4-69.833*$i**3+215.29*$i* +*2-292.12*$i+247.5,1.25*$i**5-25.333*$i**4+191.25*$i**3-672.17*$i**2+ +1099*$i-561.5,0.5833*$i**5-9.4583*$i**4+56.167*$i**3-148.54*$i**2+169 +.25*$i+36.5]}[$_/6]}(0..23)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Polynomial JAPH
by ambrus (Abbot) on Oct 12, 2006 at 10:19 UTC | |
by dewey (Pilgrim) on Oct 12, 2006 at 21:20 UTC | |
Re: Polynomial JAPH (golf?)
by dewey (Pilgrim) on Oct 12, 2006 at 06:05 UTC | |
by ambrus (Abbot) on Oct 12, 2006 at 15:27 UTC | |
by tweetiepooh (Hermit) on Oct 12, 2006 at 10:01 UTC | |
Re: Polynomial JAPH
by jdporter (Paladin) on Apr 18, 2008 at 13:22 UTC |