diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-08-03 13:05:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-03 13:05:16 +0100 |
| commit | 941a22997655fae6b98fe3d79c1fe2bc8947f274 (patch) | |
| tree | 686315743ad485846687540531697520aa1176bb | |
| parent | 127292b83c85d31ed4b9b11dd8f38de146cde40e (diff) | |
| parent | 5087c097540d325f73c97a3678c550e69948afea (diff) | |
| download | perlweeklychallenge-club-941a22997655fae6b98fe3d79c1fe2bc8947f274.tar.gz perlweeklychallenge-club-941a22997655fae6b98fe3d79c1fe2bc8947f274.tar.bz2 perlweeklychallenge-club-941a22997655fae6b98fe3d79c1fe2bc8947f274.zip | |
Merge pull request #460 from Firedrake/rogerbw-challenge-019-perl6
Adding Perl6, because I can.
| -rwxr-xr-x | challenge-019/roger-bell-west/perl6/ch-1.p6 | 12 | ||||
| -rwxr-xr-x | challenge-019/roger-bell-west/perl6/ch-2.p6 | 35 |
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"; +} |
