puzzles/is-isomorphic/README.md

33 lines
1.0 KiB
Markdown
Raw Permalink Normal View History

2024-04-02 21:01:09 +00: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:
>
> ```javascript
> > 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](https://buttondown.email/cassidoo/archive/no-matter-what-people-tell-you-words-and-ideas/) 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:
```console
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.