DEV Community

Discussion on: My ridiculously unreadable but concise solution to the Compare Tuples challenge on HackerRank

Collapse
crosseye profile image
Scott Sauyet

Interesting, as my solution to that was a few characters shorter, but I never thought about it as code-golfed. It's just how I think.

(a, b) => a.reduce(([x, y], a, i) => a > b[i] ? [x + 1, y] : a < b[i] ? [x, y + 1] : [x, y], [0, 0])
Enter fullscreen mode Exit fullscreen mode