JavaScript (Node.js), 78 bytes
This is a port of xnor's great answer.
s=>(t=118,u=10340,g=k=>Buffer(s).map(x=>(u+=t-=k&x-96)-531*t?x:x+t))(g(~0))+''
JavaScript (Node.js), (削除) 121 118 (削除ここまで) 116 bytes
s=>[...s+'jEIM'].some(c=>[...s].some(C=>Buffer(o=p+c+s.slice(++i)).map(c=>k=k*99^c,k=p+=C)|k==0x6B9400B8,i=p=''))&&o
Try 10 random test cases online!
##How?
How?
###Replacement letters
Replacement letters
All letters in the original paragraph appear at least twice, except j, E, I and M that appear only once and may disappear in the modified paragraph.
That's why we do:
[...s + 'jEIM'].some(c => ...)
This way, it is guaranteed that each possible replacement letter is tried.
###Hash
Hash
Using a built-in hash would be rather lengthy in Node:
require('crypto').createHash('md5').update(string).digest('hex')
Instead of that, we use the following custom 32-bit hash:
Buffer(string).map(c => k = k * 99 ^ c, k = 0)
This was (rather painfully) tested against all possible inputs.
JavaScript (Node.js), 78 bytes
This is a port of xnor's great answer.
s=>(t=118,u=10340,g=k=>Buffer(s).map(x=>(u+=t-=k&x-96)-531*t?x:x+t))(g(~0))+''
JavaScript (Node.js), (削除) 121 118 (削除ここまで) 116 bytes
s=>[...s+'jEIM'].some(c=>[...s].some(C=>Buffer(o=p+c+s.slice(++i)).map(c=>k=k*99^c,k=p+=C)|k==0x6B9400B8,i=p=''))&&o
Try 10 random test cases online!
##How?
###Replacement letters
All letters in the original paragraph appear at least twice, except j, E, I and M that appear only once and may disappear in the modified paragraph.
That's why we do:
[...s + 'jEIM'].some(c => ...)
This way, it is guaranteed that each possible replacement letter is tried.
###Hash
Using a built-in hash would be rather lengthy in Node:
require('crypto').createHash('md5').update(string).digest('hex')
Instead of that, we use the following custom 32-bit hash:
Buffer(string).map(c => k = k * 99 ^ c, k = 0)
This was (rather painfully) tested against all possible inputs.
JavaScript (Node.js), 78 bytes
This is a port of xnor's great answer.
s=>(t=118,u=10340,g=k=>Buffer(s).map(x=>(u+=t-=k&x-96)-531*t?x:x+t))(g(~0))+''
JavaScript (Node.js), (削除) 121 118 (削除ここまで) 116 bytes
s=>[...s+'jEIM'].some(c=>[...s].some(C=>Buffer(o=p+c+s.slice(++i)).map(c=>k=k*99^c,k=p+=C)|k==0x6B9400B8,i=p=''))&&o
Try 10 random test cases online!
How?
Replacement letters
All letters in the original paragraph appear at least twice, except j, E, I and M that appear only once and may disappear in the modified paragraph.
That's why we do:
[...s + 'jEIM'].some(c => ...)
This way, it is guaranteed that each possible replacement letter is tried.
Hash
Using a built-in hash would be rather lengthy in Node:
require('crypto').createHash('md5').update(string).digest('hex')
Instead of that, we use the following custom 32-bit hash:
Buffer(string).map(c => k = k * 99 ^ c, k = 0)
This was (rather painfully) tested against all possible inputs.
JavaScript (Node.js), 78 bytes
This is a port of xnor's great answer .
s=>(t=118,u=10340,g=k=>Buffer(s).map(x=>(u+=t-=k&x-96)-531*t?x:x+t))(g(~0))+''
JavaScript (Node.js) , (削除) 121 118 (削除ここまで) 116 bytes
s=>[...s+'jEIM'].some(c=>[...s].some(C=>Buffer(o=p+c+s.slice(++i)).map(c=>k=k*99^c,k=p+=C)|k==0x6B9400B8,i=p=''))&&o
Try 10 random test cases online!
##How?
###Replacement letters
All letters in the original paragraph appear at least twice, except j, E, I and M that appear only once and may disappear in the modified paragraph.
That's why we do:
[...s + 'jEIM'].some(c => ...)
This way, it is guaranteed that each possible replacement letter is tried.
###Hash
Using a built-in hash would be rather lengthy in Node:
require('crypto').createHash('md5').update(string).digest('hex')
Instead of that, we use the following custom 32-bit hash:
Buffer(string).map(c => k = k * 99 ^ c, k = 0)
This was (rather painfully) tested against all possible inputs.
JavaScript (Node.js), (削除) 121 118 (削除ここまで) 116 bytes
s=>[...s+'jEIM'].some(c=>[...s].some(C=>Buffer(o=p+c+s.slice(++i)).map(c=>k=k*99^c,k=p+=C)|k==0x6B9400B8,i=p=''))&&o
Try 10 random test cases online!
##How?
###Replacement letters
All letters in the original paragraph appear at least twice, except j, E, I and M that appear only once and may disappear in the modified paragraph.
That's why we do:
[...s + 'jEIM'].some(c => ...)
This way, it is guaranteed that each possible replacement letter is tried.
###Hash
Using a built-in hash would be rather lengthy in Node:
require('crypto').createHash('md5').update(string).digest('hex')
Instead of that, we use the following custom 32-bit hash:
Buffer(string).map(c => k = k * 99 ^ c, k = 0)
This was (rather painfully) tested against all possible inputs.
JavaScript (Node.js), 78 bytes
This is a port of xnor's great answer .
s=>(t=118,u=10340,g=k=>Buffer(s).map(x=>(u+=t-=k&x-96)-531*t?x:x+t))(g(~0))+''
JavaScript (Node.js) , (削除) 121 118 (削除ここまで) 116 bytes
s=>[...s+'jEIM'].some(c=>[...s].some(C=>Buffer(o=p+c+s.slice(++i)).map(c=>k=k*99^c,k=p+=C)|k==0x6B9400B8,i=p=''))&&o
Try 10 random test cases online!
##How?
###Replacement letters
All letters in the original paragraph appear at least twice, except j, E, I and M that appear only once and may disappear in the modified paragraph.
That's why we do:
[...s + 'jEIM'].some(c => ...)
This way, it is guaranteed that each possible replacement letter is tried.
###Hash
Using a built-in hash would be rather lengthy in Node:
require('crypto').createHash('md5').update(string).digest('hex')
Instead of that, we use the following custom 32-bit hash:
Buffer(string).map(c => k = k * 99 ^ c, k = 0)
This was (rather painfully) tested against all possible inputs.
JavaScript (Node.js), (削除) 121 118 (削除ここまで) 118116 bytes
s=>[...s+'jEIM'].some(c=>[...s].some(C=>Buffer(o=p+c+s.slice(++i)).map(c=>k=~k*97+cc=>k=k*99^c,k=p+=C)|k==0x8B9C2B0C2|k==0x6B9400B8,i=p=''))&&o
Try 10 random test cases online! Try 10 random test cases online!
##How?
###Replacement letters
All letters in the original paragraph appear at least twice, except j, E, I and M that appear only once and may disappear in the modified paragraph.
That's why we do:
[...s + 'jEIM'].some(c => ...)
This way, it is guaranteed that each possible replacement letter is tried.
###Hash
Using a built-in hash would be rather lengthy in Node:
require('crypto').createHash('md5').update(string).digest('hex')
Instead of that, we use the following custom 32-bit hash:
Buffer(string).map(c => k = ~kk * 9799 +^ c, k = 0)
The bitwise ~ ensures that the value from the previous iteration is turned into a 32-bit quantity to prevent an arithmetic overflow.
This was (rather painfully) tested against all possible inputs.
JavaScript (Node.js), (削除) 121 (削除ここまで) 118 bytes
s=>[...s+'jEIM'].some(c=>[...s].some(C=>Buffer(o=p+c+s.slice(++i)).map(c=>k=~k*97+c,k=p+=C)|k==0x8B9C2B0C2,i=p=''))&&o
Try 10 random test cases online!
##How?
###Replacement letters
All letters in the original paragraph appear at least twice, except j, E, I and M that appear only once and may disappear in the modified paragraph.
That's why we do:
[...s + 'jEIM'].some(c => ...)
This way, it is guaranteed that each possible replacement letter is tried.
###Hash
Using a built-in hash would be rather lengthy in Node:
require('crypto').createHash('md5').update(string).digest('hex')
Instead of that, we use the following custom hash:
Buffer(string).map(c => k = ~k * 97 + c, k = 0)
The bitwise ~ ensures that the value from the previous iteration is turned into a 32-bit quantity to prevent an arithmetic overflow.
This was (rather painfully) tested against all possible inputs.
JavaScript (Node.js), (削除) 121 118 (削除ここまで) 116 bytes
s=>[...s+'jEIM'].some(c=>[...s].some(C=>Buffer(o=p+c+s.slice(++i)).map(c=>k=k*99^c,k=p+=C)|k==0x6B9400B8,i=p=''))&&o
Try 10 random test cases online!
##How?
###Replacement letters
All letters in the original paragraph appear at least twice, except j, E, I and M that appear only once and may disappear in the modified paragraph.
That's why we do:
[...s + 'jEIM'].some(c => ...)
This way, it is guaranteed that each possible replacement letter is tried.
###Hash
Using a built-in hash would be rather lengthy in Node:
require('crypto').createHash('md5').update(string).digest('hex')
Instead of that, we use the following custom 32-bit hash:
Buffer(string).map(c => k = k * 99 ^ c, k = 0)
This was (rather painfully) tested against all possible inputs.