aboutsummaryrefslogtreecommitdiff
path: root/challenge-159
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2022-04-07 18:31:05 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2022-04-07 18:31:05 +0100
commit92bee2e691cf2967a56fb8b58c85a07495cf6320 (patch)
tree794ec89cc60dada24549eb576fc255db874bf8d5 /challenge-159
parentf9e06f6d2ceadc086ced29020c81a855294a1fd3 (diff)
downloadperlweeklychallenge-club-92bee2e691cf2967a56fb8b58c85a07495cf6320.tar.gz
perlweeklychallenge-club-92bee2e691cf2967a56fb8b58c85a07495cf6320.tar.bz2
perlweeklychallenge-club-92bee2e691cf2967a56fb8b58c85a07495cf6320.zip
- Added solution by Robert DiCicco.
Diffstat (limited to 'challenge-159')
-rw-r--r--challenge-159/robert-dicicco/raku/ch-1.raku34
1 files changed, 34 insertions, 0 deletions
diff --git a/challenge-159/robert-dicicco/raku/ch-1.raku b/challenge-159/robert-dicicco/raku/ch-1.raku
new file mode 100644
index 0000000000..cd3b2f4e92
--- /dev/null
+++ b/challenge-159/robert-dicicco/raku/ch-1.raku
@@ -0,0 +1,34 @@
+use v6;
+
+use Lingua::EN::Numbers;
+
+# AUTHOR: Robert DiCicco
+# DATE: 7-APR-2022
+# Challenge 159 Farey Sequence ( Raku )
+
+my %equivs;
+
+sub MAIN(Int $num) {
+ my $d = $num;
+
+ while $d {
+ for (1..($d-1)) {
+ my $frac = pretty-rat($_/$d);
+ %equivs{$frac} = $_/$d;
+ #say $frac;
+ }
+
+ $d--;
+ }
+
+ print("Input: \$n = $num\n");
+ print '0/1 ';
+
+ for %equivs.sort(*.value) {
+ my $k = $_.key;
+ print("$k ");
+ }
+
+ print '1/1';
+ say "\n";
+}