(point, { points } = this, score = 0)
| 18 | } |
| 19 | |
| 20 | count (point, { points } = this, score = 0) { |
| 21 | const [ x1, y1 ] = point; |
| 22 | |
| 23 | for (const [ x2, y2 ] of points) {/* Time O(N) */ |
| 24 | const isSame = (Math.abs(x2 - x1) === Math.abs(y2 - y1)); |
| 25 | const isEqual = ((x1 === x2) || (y1 === y2)); |
| 26 | const canSkip = (!isSame || isEqual); |
| 27 | if (canSkip) continue; |
| 28 | |
| 29 | score += this.getScore(x1, y1, x2, y2); |
| 30 | } |
| 31 | |
| 32 | return score; |
| 33 | }; |
| 34 | |
| 35 | getKey (x, y) { |
| 36 | return `${x},${y}`; |