// for a = z, b = x + y, there are some solutions if and only if b > a/2, and the amount //can be (sneakily) calculate with some clever arithmatic to be (b - (a + 1) /2); private long CountShortestPathsBySplittingB(Pythagorean.Triple triple) { return(Math.Max(0, (triple.a - (triple.b + 1) / 2) + 1)); }
// If the Cube lengths are x,y,z then (x+y)^2 + z^2 being the shortest path ==> x <= z, y <= z // (To see why, map out all three shortest path candidates, assert one to be smaller than the other two, // and look at what this implies about x, y, and z. Algebra is very straightforward) // so given a triple of a,b,c, we are only interested in finding x,y,z // such that WLOG a = x + y, b = z OR a = z, b = x + y where our inequality holds (x, y <= z) // for a = x + y, b = z, then there are a/2 ways of finding x,y such that x+y = a and x,y < z private long CountShortestPathsBySplittingA(Pythagorean.Triple triple) { return(triple.a / 2); }