Yes, in the sense that the corresponding C++ expression (p[1] == p[2] == p[3] == … == p[n]), where the p[k] are of type bool, has the same problem as Rosen’s notation; this “looks” like it might evaluate to true iff all of the p[k] are equal and false otherwise, but it doesn’t.

The *intended* meaning of this expression is essentially how Python treats chained comparisons, with an implicit AND stuck in between each consecutive binary comparison.

]]>You’re right that the fundamental matrix is a compact means of expressing the solution here as well; as noted in the article, the intent here was to explictly avoid the linear algebra and target a solution approachable by younger students.

]]>I took a slightly different approach by taking entry (100,1) of (I-Q)^(-2), which effectively calculates the expected number of turns, using the idea that entry (i,j) of Q^n is the probability of going from square j to square i in n turns.

]]>