aboutsummaryrefslogtreecommitdiff
path: root/challenge-004
diff options
context:
space:
mode:
authorrir <rirans@comcast.net>2024-03-14 01:01:16 -0400
committerrir <rirans@comcast.net>2024-03-16 20:05:09 -0400
commit45e091aa22efc8eeebb63955553e46f90b9708c2 (patch)
treeb00172c69e1cb35749809f1f1737d9be7c2bf52e /challenge-004
parent62e7fc3bb85a74125663f4fbd0a5911f6f30c81f (diff)
downloadperlweeklychallenge-club-45e091aa22efc8eeebb63955553e46f90b9708c2.tar.gz
perlweeklychallenge-club-45e091aa22efc8eeebb63955553e46f90b9708c2.tar.bz2
perlweeklychallenge-club-45e091aa22efc8eeebb63955553e46f90b9708c2.zip
260, 001, 002, 003, 004-1
Diffstat (limited to 'challenge-004')
-rw-r--r--challenge-004/0rir/raku/Pi1000.rakumod5
-rw-r--r--challenge-004/0rir/raku/ch-1.raku23
2 files changed, 28 insertions, 0 deletions
diff --git a/challenge-004/0rir/raku/Pi1000.rakumod b/challenge-004/0rir/raku/Pi1000.rakumod
new file mode 100644
index 0000000000..fb47d5fb49
--- /dev/null
+++ b/challenge-004/0rir/raku/Pi1000.rakumod
@@ -0,0 +1,5 @@
+
+unit module Pi1000;
+
+sub Pi( --> RatStr) is export {
+ <3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989> }
diff --git a/challenge-004/0rir/raku/ch-1.raku b/challenge-004/0rir/raku/ch-1.raku
new file mode 100644
index 0000000000..83e706dda0
--- /dev/null
+++ b/challenge-004/0rir/raku/ch-1.raku
@@ -0,0 +1,23 @@
+#!/usr/bin/env raku
+INIT $*RAT-OVERFLOW = FatRat;
+use lib $?FILE.IO.cleanup.parent;
+use Pi1000;
+
+# 004-1 This script outputs PI w/ digit count == its file size.
+
+#________0_________0_________0_________0_________0_________0_________0_______80
+#________0_________0_________0_________0_________0_________0_________0______160
+#________0_________0_________0_________0_________0_________0_________0______240
+#________0_________0_________0_________0_________0_________0_________0______320
+#________0_________0_________0_________0_________0_________0_________0______400
+#________0_________0_________0_________0_________0_________0_________0______480
+#________0_________0_________0_________0_________0_________0_________0______560
+#________0_________0_________0_________0_________0_________0_____628
+#say $*PROGRAM.s;
+
+constant π = +Pi();
+my $scale = $*PROGRAM.s - 2;
+die 'Too precise' if $scale ≥ 1002;
+die 'Bad programmer' unless $scale + 2 == + π.round( 10**-$scale).chars;
+
+say π.round( 10**-$scale);