forked from gideo/CodeWars
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5kyu_OneLineTask_StringIsomorphism.js
More file actions
34 lines (24 loc) · 967 Bytes
/
Copy path5kyu_OneLineTask_StringIsomorphism.js
File metadata and controls
34 lines (24 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 5kyu - One Line Task - String Isomorphism
// This Kata is inspired by "Check if two words are isomorphic to each other"
// by rasmus_ri.
// Task
// Two strings a and b are called isomorphic if there is a one-to-one mapping possible
// for every character of a to every character of b and all occurrences of every
// character in a map to same character in b.
// In this Kata, you will create a function that returns true if two given strings are
// isomorphic to each other, and false otherwise. Remember that order is important.
// Your solution must be able to handle words with more than 100 characters.
// Example
// True examples:
// CBAABC DEFFED
// XXX YYY
// RAMBUNCTIOUSLY THERMODYNAMICS
// False examples:
// AB CC
// XXY XYY
// ABAB CD
// Code Limit
// Less than 70 chars.
// Advice
// If your code length is much longer than the limit, giving up is also a good choice :D
p=f=>[...f].map(a=>f.indexOf(a)).join(),isomorph=(a,b)=>p(a)==p(b);