aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-092/ash/raku/ch-1.raku39
1 files changed, 25 insertions, 14 deletions
diff --git a/challenge-092/ash/raku/ch-1.raku b/challenge-092/ash/raku/ch-1.raku
index be873658d2..80c1e8a541 100644
--- a/challenge-092/ash/raku/ch-1.raku
+++ b/challenge-092/ash/raku/ch-1.raku
@@ -5,20 +5,31 @@
# Comments: https://andrewshitov.com/2020/12/21/raku-challenge-week-92-issue-1/
-# unit sub MAIN(Str $a, Str $b);
+use Test;
-# say + [==] ($a.comb.map: *.ord) <<->> ($b.comb.map: *.ord);
-# say + [==] $a.ords <<->> $b.ords;
+unit sub MAIN(Str $a, Str $b);
-say + [==] [«-»] @*ARGS.map: *.ords;
+sub is-isomorphic($a, $b) {
+ +(([==] ($a, $b)>>.chars) && ([==] ($a.comb, $b.comb, ($a.comb Z~ $b.comb))>>.unique));
+}
-# Test cases:
-#
-# $ raku ch-1.raku abc def
-# 1
-#
-# $ raku ch-1.raku abb xyy
-# 1
-#
-# $ raku ch-1.raku sum add
-# 0
+is(is-isomorphic('abc', 'def'), 1);
+is(is-isomorphic('abb', 'xyy'), 1);
+is(is-isomorphic('sum', 'add'), 0);
+
+is(is-isomorphic('ACAB', 'XCXY'), 1);
+is(is-isomorphic('AAB', 'XYZ'), 0);
+is(is-isomorphic('AAB', 'XXZ'), 1);
+
+is(is-isomorphic('abc', 'abc'), 1);
+is(is-isomorphic('abc', 'ab'), 0);
+
+is(is-isomorphic('aeiou', 'bcdfg'), 1);
+is(is-isomorphic('aeiou', 'gxypq'), 1);
+is(is-isomorphic('aaeeiioouu', 'bbccddffgg'), 1);
+is(is-isomorphic('aeaieoiuo', 'gxgyxpyqp'), 1);
+
+is(is-isomorphic('aeiou', 'bcdtg'), 1);
+is(is-isomorphic('aeiou', 'qpyxg'), 1);
+is(is-isomorphic('aaeeiioouu', 'bbccdxffgg'), 0);
+is(is-isomorphic('aeaieoiuo', 'gxgyxpaejrkeruqp'), 0);