Skip to main content

Javascript -, 192 157 152 147 125 bytes

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

Thanks to Peter and David for squeezing more chars out!

for(a=[j=p=2];j<123;)a[j]?p%a[++j]<1&&p++&&(j=0):(a[j]=p,j=0);function b(c,i){return c[i=i||0]?a[c.charCodeAt(i)]*b(c,++i):1}

Then do:

alert(b("hello")==b("elloh"));

Expanded Code

The compressed has had lots of changes, but this is the basic theory:

// Define dictionary of primes
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];

// Returns the unique ID of the word (order irrelevant)
function b(c) {
    r = 1;
    for (i = 0; i < c.length; i++)
        r *= a[c[i].charCodeAt(0) - 97];
    return r
}

alert(b("hello") == b("hlleo"));

Javascript - 192 157 152 147 125

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

Thanks to Peter and David for squeezing more chars out!

for(a=[j=p=2];j<123;)a[j]?p%a[++j]<1&&p++&&(j=0):(a[j]=p,j=0);function b(c,i){return c[i=i||0]?a[c.charCodeAt(i)]*b(c,++i):1}

Then do:

alert(b("hello")==b("elloh"));

Expanded Code

The compressed has had lots of changes, but this is the basic theory:

// Define dictionary of primes
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];

// Returns the unique ID of the word (order irrelevant)
function b(c) {
    r = 1;
    for (i = 0; i < c.length; i++)
        r *= a[c[i].charCodeAt(0) - 97];
    return r
}

alert(b("hello") == b("hlleo"));

Javascript, 192 157 152 147 125 bytes

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

Thanks to Peter and David for squeezing more chars out!

for(a=[j=p=2];j<123;)a[j]?p%a[++j]<1&&p++&&(j=0):(a[j]=p,j=0);function b(c,i){return c[i=i||0]?a[c.charCodeAt(i)]*b(c,++i):1}

Then do:

alert(b("hello")==b("elloh"));

Expanded Code

The compressed has had lots of changes, but this is the basic theory:

// Define dictionary of primes
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];

// Returns the unique ID of the word (order irrelevant)
function b(c) {
    r = 1;
    for (i = 0; i < c.length; i++)
        r *= a[c[i].charCodeAt(0) - 97];
    return r
}

alert(b("hello") == b("hlleo"));
added 72 characters in body
Source Link
Tom Gullen
  • 1.3k
  • 1
  • 8
  • 12

Javascript - 192 157 152 147147 125

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

Thanks to Peter and David for squeezing more chars out!

a=[r=j=p=2];forfor(;j<28;a=[j=p=2];j<123;)if(a[j]?p%a[++j]<1&&p++&&(j=0){if:(p%a[j++]==0a[j]=p,j=0){p++;i=j=0}}else{a[j]=p;j=0}func­tion;function b(c,i){for(;i<c.length;i++)r*=a[c[i]return c[i=i||0]?a[c.charCodeAt(0i)-95];return r]*b(c,++i):1}

Then do:

alert(b("hello")==b("elloh"));

Expanded Code

The compressed has had lots of changes, but this is the basic theory:

// Define dictionary of primes
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];

// Returns the unique ID of the word (order irrelevant)
function b(c) {
    r = 1;
    for (i = 0; i < c.length; i++)
        r *= a[c[i].charCodeAt(0) - 97];
    return r
}

alert(b("hello") == b("hlleo"));

Javascript - 192 157 152 147

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

Thanks to Peter and David for squeezing more chars out!

a=[r=j=p=2];for(;j<28;)if(a[j]){if(p%a[j++]==0){p++;i=j=0}}else{a[j]=p;j=0}func­tion b(c){for(;i<c.length;i++)r*=a[c[i].charCodeAt(0)-95];return r}

Then do:

alert(b("hello")==b("elloh"));

Expanded Code

// Define dictionary of primes
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];

// Returns the unique ID of the word (order irrelevant)
function b(c) {
    r = 1;
    for (i = 0; i < c.length; i++)
        r *= a[c[i].charCodeAt(0) - 97];
    return r
}

alert(b("hello") == b("hlleo"));

Javascript - 192 157 152 147 125

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

Thanks to Peter and David for squeezing more chars out!

for(a=[j=p=2];j<123;)a[j]?p%a[++j]<1&&p++&&(j=0):(a[j]=p,j=0);function b(c,i){return c[i=i||0]?a[c.charCodeAt(i)]*b(c,++i):1}

Then do:

alert(b("hello")==b("elloh"));

Expanded Code

The compressed has had lots of changes, but this is the basic theory:

// Define dictionary of primes
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];

// Returns the unique ID of the word (order irrelevant)
function b(c) {
    r = 1;
    for (i = 0; i < c.length; i++)
        r *= a[c[i].charCodeAt(0) - 97];
    return r
}

alert(b("hello") == b("hlleo"));
deleted 13 characters in body
Source Link
Tom Gullen
  • 1.3k
  • 1
  • 8
  • 12

Javascript - 192 157 152 (78 without dictionary)152 147

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 (Thanks

Thanks to Peter and David for code that builds the dictionarysqueezing more chars out! 5 char saving)

a=[2];fora=[r=j=p=2];for(p=3,j=0;j<26;;j<28;)if(a[j]){if(p%a[j++]==0){p++;j=0p++;i=j=0}}else{a[j]=p;j=0}functionfunc­tion b(c){r=1;forfor(i=0;i<c;i<c.length;i++)r*=a[c[i].charCodeAt(0)-97];return95];return r}

Then do:

alert(b("hello")==b("elloh"));

Expanded Code

// Define dictionary of primes
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];

// Returns the unique ID of the word (order irrelevant)
function b(c) {
    r = 1;
    for (i = 0; i < c.length; i++)
        r *= a[c[i].charCodeAt(0) - 97];
    return r
}

alert(b("hello") == b("hlleo"));

Javascript - 192 157 152 (78 without dictionary)

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 (Thanks Peter for code that builds the dictionary! 5 char saving)

a=[2];for(p=3,j=0;j<26;)if(a[j]){if(p%a[j++]==0){p++;j=0}}else{a[j]=p;j=0}function b(c){r=1;for(i=0;i<c.length;i++)r*=a[c[i].charCodeAt(0)-97];return r}

Then do:

alert(b("hello")==b("elloh"));

Expanded Code

// Define dictionary of primes
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];

// Returns the unique ID of the word (order irrelevant)
function b(c) {
    r = 1;
    for (i = 0; i < c.length; i++)
        r *= a[c[i].charCodeAt(0) - 97];
    return r
}

alert(b("hello") == b("hlleo"));

Javascript - 192 157 152 147

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

Thanks to Peter and David for squeezing more chars out!

a=[r=j=p=2];for(;j<28;)if(a[j]){if(p%a[j++]==0){p++;i=j=0}}else{a[j]=p;j=0}func­tion b(c){for(;i<c.length;i++)r*=a[c[i].charCodeAt(0)-95];return r}

Then do:

alert(b("hello")==b("elloh"));

Expanded Code

// Define dictionary of primes
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];

// Returns the unique ID of the word (order irrelevant)
function b(c) {
    r = 1;
    for (i = 0; i < c.length; i++)
        r *= a[c[i].charCodeAt(0) - 97];
    return r
}

alert(b("hello") == b("hlleo"));
added 14 characters in body
Source Link
Tom Gullen
  • 1.3k
  • 1
  • 8
  • 12
Loading
added 69 characters in body; deleted 1 characters in body
Source Link
Tom Gullen
  • 1.3k
  • 1
  • 8
  • 12
Loading
added 21 characters in body; added 5 characters in body
Source Link
Tom Gullen
  • 1.3k
  • 1
  • 8
  • 12
Loading
added 21 characters in body
Source Link
Tom Gullen
  • 1.3k
  • 1
  • 8
  • 12
Loading
added 15 characters in body; added 24 characters in body
Source Link
Tom Gullen
  • 1.3k
  • 1
  • 8
  • 12
Loading
Source Link
Tom Gullen
  • 1.3k
  • 1
  • 8
  • 12
Loading