diff options
| author | Andrew Shitov <andy@shitov.ru> | 2020-12-22 09:40:25 +0100 |
|---|---|---|
| committer | Andrew Shitov <andy@shitov.ru> | 2020-12-22 09:40:25 +0100 |
| commit | 0d5f465cd194d043cca5d99e7d1d0bbe21b7ef05 (patch) | |
| tree | f3d5bafe53302176c27732c55365a999f6c380bc | |
| parent | 3e3304ddef1bb9362026f555c58a58bf3bd74cc9 (diff) | |
| download | perlweeklychallenge-club-0d5f465cd194d043cca5d99e7d1d0bbe21b7ef05.tar.gz perlweeklychallenge-club-0d5f465cd194d043cca5d99e7d1d0bbe21b7ef05.tar.bz2 perlweeklychallenge-club-0d5f465cd194d043cca5d99e7d1d0bbe21b7ef05.zip | |
Update
| -rw-r--r-- | challenge-092/ash/raku/ch-1.raku | 39 |
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); |
