When studying numerology, you can say two words (strings consisting entirely of letters) are compatible if they produce the same number under the following operation (let's use the string
hello as an example):
Map each letter to a number according to the following, ignoring case:
1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z
The number at the top of the column a letter is in is its mapped value (e.g.
a -> 1,
x -> 6)
hello -> [8, 5, 3, 3, 6]
Take the sum of these numbers.
hello -> 25
Repeatedly take the digital sum until it reaches a single digit (i.e. it's digital root).
hello -> 2+5 = 7
world are not compatible (they yield
9 respectively), whereas
sandbox are (both
You are to write a program which will take two strings as input and output two distinct consistent values which indicate whether the strings are compatible or not
- The inputs will only consist of letters (
abcdefghijklmnopqrstuvwxyz) in a consistent case
- You may choose the case of the inputs, so long as it is consistent across inputs and runs
- You may take input as a delimited string (e.g. space separated), so long as the delimiter is non-empty and consists of entirely non-letter characters of your chosen case (i.e. if you input in uppercase, the delimiter may contain lowercase letters, but not uppercase letters)
- Otherwise, you may input and output in any convenient method
This is code-golf so the shortest code in bytes wins.
a, b -> out "hello", "world" -> 0 "raahyjc", "mvj" -> 0 "mpqtjmjd", "bwkhrh" -> 0 "VZZLCZTH", "DOJEIV" -> 0 "coding", "sandbox" -> 1 "vhw", "wl" -> 1 "HMCZQZZRC", "SIQYOBXK" -> 1 "a", "j" -> 1