x86-64 machine code, 27 bytes
Hexdump:
6b 01 35 c1 e8 06 6b c8 d3 d1 c1 48 ba 4e 88 00
02 c3 45 88 8b 48 d3 e2 1a c0 c3
A function which receives a pointer to the string in rcx, and returns the result in al.
−1 means true, and 0 means false.
Assembly source code, using ml64 (MASM) syntax:
.CODE
my PROC
imul eax, dword ptr[rcx], 53
shr eax, 6
imul ecx, eax, -45
rol ecx, 1;
mov rdx, 8b8845c30200884eh;
shl rdx, cl;
sbb al, al;
ret;
my ENDP
end
Disassembly, while stopped on a breakpoint at the start of the function:
00007FF73978F4A0 6B 01 35 imul eax,dword ptr [rcx],35h
00007FF73978F4A3 C1 E8 06 shr eax,6
00007FF73978F4A6 6B C8 D3 imul ecx,eax,0FFFFFFD3h
00007FF73978F4A9 D1 C1 rol ecx,1
00007FF73978F4AB 48 BA 4E 88 00 02 C3 45 88 8B mov rdx,8B8845C30200884Eh
00007FF73978F4B5 48 D3 E2 shl rdx,cl
00007FF73978F4B8 1A C0 sbb al,al
00007FF73978F4BA C3 ret
It uses hashing, like many other answers. The hash function uses the first 4 bytes of the string - by luck, all strings are at least 4 bytes long (including terminating zero byte). It does the following:
- Multiply by 53, ignoring overflow
- Shift right by 6 bits
- Multiply by -45, ignoring overflow
- Rotate left by 1 bit
- Access the 64-bit hash table, using 6 LSB of the result
Found by brute-force search. The search space was 8 +たす 5 +たす 8 +たす 5 =わ 26 bits. The "rotate left" bit count is 1 by luck, which reduces code size by 1 byte, compared to the general "rotate left" case.
- 14.1k
- 3
- 43
- 114