Hacker News new | ask | show | jobs
by Dylan16807 512 days ago
Using slice twice is pretty clever. That might work.

But my real point is they did have the digit sum insight. Their code was already doing your previous suggestion, and if there's a compact way to slice in typescript types it could be adapted to this new method by replacing SUM_TABLE and changing one other line.

The only difference is that they're doing a sum modulo 9 instead of modulo 3, but both of those work fine.

1 comments

I see what you mean now, you are right. My only intention was to demonstrate that a TS solution is possible - one that does not rely on the type system but one that still observes all the constraints listed. I think this was questioned by some in the thread (but not you).