aboutsummaryrefslogtreecommitdiff
path: root/challenge-092/gugod
diff options
context:
space:
mode:
authorKang-min Liu <gugod@gugod.org>2020-12-23 08:37:07 +0900
committerKang-min Liu <gugod@gugod.org>2020-12-23 08:37:07 +0900
commitd8e1684b5a839403cffe589b123c8bd5937624ec (patch)
tree232e8f42dea8c36d207b4001fb6971a0d58bcca1 /challenge-092/gugod
parent5e60360e4902fe8537dd7eeef8f4627e27b889fa (diff)
downloadperlweeklychallenge-club-d8e1684b5a839403cffe589b123c8bd5937624ec.tar.gz
perlweeklychallenge-club-d8e1684b5a839403cffe589b123c8bd5937624ec.tar.bz2
perlweeklychallenge-club-d8e1684b5a839403cffe589b123c8bd5937624ec.zip
solution of pwc 092.1 in raku
Diffstat (limited to 'challenge-092/gugod')
-rw-r--r--challenge-092/gugod/raku/ch-1.raku34
1 files changed, 34 insertions, 0 deletions
diff --git a/challenge-092/gugod/raku/ch-1.raku b/challenge-092/gugod/raku/ch-1.raku
new file mode 100644
index 0000000000..22086ca16b
--- /dev/null
+++ b/challenge-092/gugod/raku/ch-1.raku
@@ -0,0 +1,34 @@
+
+sub MAIN {
+ tests;
+}
+
+sub isomorphic (Str $a, Str $b) {
+ return [eqv] ($a, $b).map(
+ -> $s {
+ $s.comb.keys.tail(*-1).map(
+ -> $i { $s.substr($i, 1) eq $s.substr($i-1, 1) }
+ )
+ }
+ );
+}
+
+sub tests {
+ my @cases := (
+ (True, "abc", "xyz"),
+ (True, "abb", "xyy"),
+ (True, "look", "moon"),
+
+ (False, "sum", "add"),
+ (False, "sun", "moon"),
+ (False, "Moose", "Mouse"),
+ );
+
+ for @cases -> ($expected, $a, $b) {
+ if $expected eqv isomorphic($a, $b) {
+ say "ok - $a vs $b";
+ } else {
+ say "not ok - $a vs $b"
+ }
+ }
+}