I just put this page here so that I could have menu items “Posts” and “Rails”, because of the double pun afforded by (blog) Posts / (rants and) Rails versus (fence) Posts / (fence) Rails.

Post and Rail problems are a class of potential out-by-one issues that occur in software. The basic idea is that for a straight fence, the number of posts required is one more than the number of rails (really, gaps between the posts),

Straight fence:
P = 2
R = 1
P = R + 1

but on a circular track, the number of posts is equal to the number of rails.

Circular fence:
P = 18
R = 18
P = R

It’s not complicated – but then out-by-one issues are rarely complicated, they’re just surprisingly common.

Nothing whatsoever to do with these rails; although now that we’re here…

railway lines
Railway lines:
P ≈ ∞
R ≈ ∞
P ≈ R

…meaning that an infinitely long straight line is pretty much the same as an infinitely big circle.

End of post!