Coding challenge

Attached: Screenshot_2019-05-17_13-39-47.png (523x649, 54K)

Other urls found in this thread:

hastebin.com/ucanineweg.go
oeis.org/A003714
twitter.com/SFWRedditVideos

do your own homework retard

user, why do you study computer science if you aren't even going to try.

>(1, 2) is considered the same as (2, 1)
what?

Oh, that's the pair of bishops, not the (row, column) tuple

Ok, so what's the challenge? Doing it in better time than n^2?

"""challenge"""

I guess for each bishop (r,c) you can calculate c-r, and c+r, then match it up to other bishops with equal values for the same computation and it would just be O(n)

Wait, actually you can it in n.

For \ leaning diagonals if (ri+ci) == (rj+cj) then they match
For / leaning diagonals if (ri+(M-ci)) == (rj+(M-cj)) then they match
Count all matches and divide final result by 2 to get all pairs
Alternatively you could use a stack and pop a bishop every time you finish looking into its matches