aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-019/roger-bell-west/perl6/ch-1.p612
-rwxr-xr-xchallenge-019/roger-bell-west/perl6/ch-2.p635
2 files changed, 47 insertions, 0 deletions
diff --git a/challenge-019/roger-bell-west/perl6/ch-1.p6 b/challenge-019/roger-bell-west/perl6/ch-1.p6
new file mode 100755
index 0000000000..386a114c26
--- /dev/null
+++ b/challenge-019/roger-bell-west/perl6/ch-1.p6
@@ -0,0 +1,12 @@
+#! /usr/bin/perl6
+
+# Write a script to display months from the year 1900 to 2019 where
+# you find 5 weekends i.e. 5 Friday, 5 Saturday and 5 Sunday.
+
+for 1990..2019 -> $y {
+ for 1,3,5,7,8,10,12 -> $m {
+ if Date.new($y,$m,1).day-of-week == 5 {
+ say "$m $y";
+ }
+ }
+}
diff --git a/challenge-019/roger-bell-west/perl6/ch-2.p6 b/challenge-019/roger-bell-west/perl6/ch-2.p6
new file mode 100755
index 0000000000..6207d9b213
--- /dev/null
+++ b/challenge-019/roger-bell-west/perl6/ch-2.p6
@@ -0,0 +1,35 @@
+#! /usr/bin/perl6
+
+# Write a script that can wrap the given paragraph at a specified
+# column using the greedy algorithm.
+
+my $width=72;
+
+my $s=$width;
+my @w;
+for lines() {
+ .chomp;
+ if ($_ eq '') {
+ if (@w) {
+ print join(' ',@w),"\n";
+ @w=();
+ $s=$width;
+ }
+ print "\n";
+ } else {
+ for split ' ',$_ -> $w {
+ my $lw=chars($w);
+ if ($lw+1 > $s) {
+ print join(' ',@w),"\n";
+ @w=($w);
+ $s=$width-$lw;
+ } else {
+ push @w,$w;
+ $s-=($lw+1);
+ }
+ }
+ }
+}
+if (@w) {
+ print join(' ',@w),"\n";
+}