The simplest thing to do is to treat this as a series of constant slope segments. We know that, at t= 0, p= 2 and its rate of change is -1. Okay, p= 2- t is a line with slope -1 such that p(0)= 2. At t= 1, p(1)= 2- 1= 1. Now we know that p(1)= 1 and its rate of change is -1. A line through (1, 1) with slope -1 is p= 1+ (-1)(t- 1)= 2- t again. (Since the slope at t= 0 and t= 1 are the same, we can use the same line for both.)

p(2)= 2- 2= 0 and we now have rate -1 again. We could find the line with slope -1 through (2, 0) but since that is again the same slope as at 0 and 1, we know the line is still p(t)= 2- t.

p(3)= 2- 3= -1 and now the slope is 0. That's a horizontal line. p(t)= -1 for all t between 3 and 4.

p(4)= -1 and now the slope is 1: p(t)=-1+ (1)(t- 4)= -1+ t- 4= t- 5.

p(5)= 5- 5= 0.