aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Proctor <simon.proctor@zoopla.co.uk>2020-07-21 09:16:47 +0100
committerSimon Proctor <simon.proctor@zoopla.co.uk>2020-07-21 09:16:47 +0100
commitae71ff22a71c3718321f708b656dc9b6730e42f6 (patch)
treec24311747df6f5c5d90d15d132352a890aa4bd53
parent00dddf1071853ee82cb8a3751d6db2d1711f7514 (diff)
downloadperlweeklychallenge-club-ae71ff22a71c3718321f708b656dc9b6730e42f6.tar.gz
perlweeklychallenge-club-ae71ff22a71c3718321f708b656dc9b6730e42f6.tar.bz2
perlweeklychallenge-club-ae71ff22a71c3718321f708b656dc9b6730e42f6.zip
Week 70 Challenge 1 and late submission for lest week
-rw-r--r--challenge-069/simon-proctor/raku/ch-2.raku15
-rw-r--r--challenge-070/simon-proctor/raku/ch-1.raku20
2 files changed, 35 insertions, 0 deletions
diff --git a/challenge-069/simon-proctor/raku/ch-2.raku b/challenge-069/simon-proctor/raku/ch-2.raku
new file mode 100644
index 0000000000..1023bf20c8
--- /dev/null
+++ b/challenge-069/simon-proctor/raku/ch-2.raku
@@ -0,0 +1,15 @@
+#!/usr/bin/env raku
+
+#| Calculate S1000 where see https://perlweeklychallenge.org/blog/perl-weekly-challenge-069/
+multi sub MAIN ( UInt $S = 30 ) {
+ my @ret = [];
+ my $count = 0;
+ while $S > $count {
+ @ret .= push( "0", @ret.hyper.reverse.map(*.trans(<0 1> => <1 0>)).Slip );
+ $count++;
+ }
+ say @ret.join("");
+}
+
+
+
diff --git a/challenge-070/simon-proctor/raku/ch-1.raku b/challenge-070/simon-proctor/raku/ch-1.raku
new file mode 100644
index 0000000000..4ce551bfc6
--- /dev/null
+++ b/challenge-070/simon-proctor/raku/ch-1.raku
@@ -0,0 +1,20 @@
+#!/usr/bin/env raku
+
+use v6
+
+#| Given a string, swap count and offset swap characters in the string
+sub MAIN (
+ Str $S, #= String to manipulate
+ UInt $C, #= Swap count
+ UInt $O where { $C <= $O && $C + $O <= $S.codes }, #= Offset
+) {
+ my @swaps = $S.comb;
+ my $N = $S.codes;
+ for 1..$C -> $i {
+ my $x = $i % $N;
+ my $y = ($i+$O) % $N;
+ @swaps[$x,$y] = @swaps[$y,$x];
+ }
+
+ @swaps.join("").say;
+}