puzzles/is-isomorphic
Zoé Cassiopée Gauthier 7e4f02547b Initial commit
2024-04-02 17:01:09 -04:00
..
is_isomorphic.c Initial commit 2024-04-02 17:01:09 -04:00
README.md Initial commit 2024-04-02 17:01:09 -04:00

Is Isomorphic?

Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if there is a one-to-one mapping possible for every character of the first string to every character of the second string.

Example:

> isIsomorphic('abb', 'cdd')
> true // 'a' maps to 'c' and 'b' maps to 'd'

> isIsomorphic('cassidy', '1234567')
> false // 's' cannot have a mapping to both '3' and '4'

> isIsomorphic('cass', '1233')
> true

Problem from rendezvous with cassidoo October 15th, 2023 newsletter.

Solution at https://strangeobject.space/@ooze/111245359154065762

How to run the solution

The C code needs to be compiled to an executable, so for example by running GCC:

gcc -Wall -o is-isomorphic is_isomorphic.c
./is-isomorphic abb cdd

If the arguments are not isomorphic, the program prints an explanation otherwise it returns with a success error code.