Skip to main content
1 of 9
Tom Gullen
  • 1.3k
  • 1
  • 8
  • 12

Javascript (192)

Ok some of these languages are a lot more flexibile than I thought! Anyway this is the longer way I guess, but a different technique at least.

Compressed

a=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101];function b(c,d){return s(c)==s(d)}function s(c){r=1;for(i=0;i<c.length;i++)r*=a[c[i].charCodeAt(0)-97];return r};

Expanded Code

a = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101];
function b(c, d) {
    return s(c) == s(d);
}
function s(t) {
    r = 1;
    for (i = 0; i < t.length; i++) {
        r = r * a[t[i].charCodeAt(0) - 97];
    }
    return r;
}

alert(b("hello", "hlleo"));
Tom Gullen
  • 1.3k
  • 1
  • 8
  • 12