SageMath, 260 255 253 247 246 241 236 234 233 231 bytes
m=map
f=lambda w:sum(vector(m(w.count,m(chr,(65..90))))*(matrix(26,m([sum(ZZ([*m(ord,'v8^x$ 2??&:#Jd;2Nv&=4-wB/yY$4I"o^_bufTTZ fn"U(J1W:ZRYG=/p,ZTRn[RHJA$jbGn-ul2zeVJ')],92).digits(27)[:i])for i in(0..111)].count,(0..675)))+1)^100)
This constructs the transition matrix
[2 1 1 1 0 0 0 0 1 0 0 1 0 0 1 2 0 0 1 1 0 0 0 1 1 0]
[0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0]
[0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0]
[0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 1 1 1 0 0 1 0 1 0 0 1 2 0 0 2 1 1 0 0 0 1 0 2 0]
[1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0]
[0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0]
[0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]
[0 0 1 0 0 0 0 0 2 1 1 1 1 0 0 0 0 0 1 0 1 1 1 0 0 0]
[0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0]
[1 0 1 1 0 0 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1]
[0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 0 0 1 0 0 0 0 0]
[0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0]
[0 1 0 0 1 2 1 1 0 0 1 0 0 1 1 0 0 2 0 1 1 1 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]
[0 1 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 2 0 1 1 0 1 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0]
[0 0 0 1 0 2 0 1 0 2 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0]
[0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 2]
[0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]
[0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]
and raises it to the 100th power, then multiplies the matrix by the column vector representing the letter-frequencies of the input word, and finally computes the 1-norm.
It’s not the shortest entry, but it is fairly efficient: it takes about 4 ms to compute f("MOUSE")
on my computer:
sage: %time f("MOUSE")
CPU times: user 4.11 ms, sys: 25 µs, total: 4.13 ms
Wall time: 4.14 ms
11668858751132191916987463577721689732389027026909488644164954259977441
This can almost certainly be shortened further. I bet there’s a more concise way to represent the matrix. (See the third and fifth edits below…)
edit (255): It’s shorter to use sum(v)
than v.norm(1)
to compute the 1-norm of a vector.
edit (253): We can pass a generator object to the vector()
constructor, rather than a list, saving a []
pair.
edit (247): Use a more efficient string representation of the data, grouping the codewords into threes and representing each of the three with a different section of the ascii range: so the three words in a group are represented by characters from the ranges 33–58, 59–84, and 85–110 respectively.
edit (246): Changing the start of the ascii range we’re using from 33 to 39 means that none of the characters in the string need to be escaped, which saves one character since previously there was an escaped backslash \\
. This has the pleasing side-effect that one codeword in three is now in plain text.
edit (241): Represent the matrix with a string in a completely different way: using a base-95 encoding of the lengths of the gaps between consecutive 1's, when the matrix is read by columns. In order to make the column-first order work without extra code, I’ve transposed everything, so now it’s multiplying a row vector by the 100th power of the transposed transition matrix.
The encoded list of numbers is:
[5, 6, 15, 14, 3, 4, 5, 4, 3, 1, 3, 6, 9, 4, 7, 8, 9, 5, 7, 26, 0, 3, 2, 0, 4, 8, 6, 3, 16, 7, 3, 5, 7, 3, 5, 5, 17, 4, 3, 8, 0, 1, 14, 3, 3, 12, 8, 4, 18, 4, 2, 17, 3, 0, 8, 2, 3, 4, 5, 2, 15, 1, 8, 0, 15, 12, 1, 2, 0, 16, 10, 8, 2, 0, 12, 4, 4, 9, 0, 9, 6, 7, 1, 17, 3, 4, 1, 1, 3, 11, 6, 6, 3, 2, 11, 3, 1, 2, 8, 6, 2, 17, 7, 2, 4, 0, 6, 3, 24, 9, 0]
This list is treated as a sequence of digits in base 27, for encoding purposes.
Where there is a 2
in the (transition matrix minus the identity), we represent that by a 0
in this list. After all, what is a two but a pair of ones at zero distance from each other?
Sadly this version is a few milliseconds slower – but we are playing golf, after all, not racing.
edit (236): Use a slightly different base-95 encoding that allows for a terser decoder, taking advantage of the fact that the integer constructor ZZ(digits, base)
doesn’t mind if some of the digits are ≥ base. So we use digits in the printable range (32–126), even though the base is 95. The final (most significant) digit is 5, which therefore cannot be subject to this treatment, so we add it separately.
One could save an additional character by inserting a literal ^E
character at the end of the string and removing the ,5
following it, but surely one must maintain some decorum.
edit (234): It turns out that using base 92, rather than 95, means the encoded string consists entirely of printable ascii characters that do not need to be escaped.
edit (233): map(w.count,map(chr,(65..90)))
is one character shorter than w.count(chr(c))for c in(65..90)
.
edit (231): Now we’re using the map
function four times, it’s worth abbreviating.
CAT
orCHARLIE ALFA TANGO
? \$\endgroup\$