The one-liners are never quite as performant as the more standard code, but I do love one-line solutions!
Suggestions: You can simplify/speed up the solution a bit by condensing the .split() and .map(), while converting to a faster 16-bit typed array with Uint16Array.from(). Then, you can also simplify the .reduce() a bit as well.
The one-liners are never quite as performant as the more standard code, but I do love one-line solutions!
Suggestions: You can simplify/speed up the solution a bit by condensing the .split() and .map(), while converting to a faster 16-bit typed array with Uint16Array.from(). Then, you can also simplify the .reduce() a bit as well.