Suppose you had a list of numbers $[y_1, y_2,\ldots,y_n]$ that define the $y$-coordinates of $n$ points in space that are joined up to make a composite "slope" made of various line segments; the horizontal separation of each point is $x$ units.
Would it be possible to devise a method/algorithm to symbolically calculate the time taken for a block to frictionlessly slide down the ramp? I have considered using GPE/KE but am not too sure what to do at each change of direction.
Suppose a point-mass $m$ under the influence of gravity is constrained to slide without friction along a piecewise-linear path having no point higher than the starting point. Let there be $N$ segments joining $N+1$ end-points $P_i=(x_i,y_i) (i=0,\ldots,N).$
Let $t_i$ be the time at which the point-mass is at the point $(x_i,y_i) (i=0,\ldots,N$), taking $t_0=0$; thus, $0=t_0<t_1<\ldots<t_N,$ and we seek an algorithm for $t_N.$
By conservation of energy,
$${1\over 2}m{\dot s}^2 + mgy = mgy_0$$ where $s(t)$ is the total arc length along the path already traversed at time $t,$ and dot denotes the time-derivative; hence,
On the other hand, for $t\in[t_{k},t_{k+1}],$ we have the equation of motion $$\ddot{s}(t)=g_k$$ where $g_k$ is the component of the gravitational acceleration in the direction of motion along the segment $\overline{P_kP_{k+1}}$, i.e.,
$$g_k= g\,\text{sgn}(y_k-y_{k+1})\,\sin{\theta_k}=g\,{y_k-y_{k+1}\over\sqrt{(y_{k+1}-y_k)^2 + (x_{k+1}-x_k)^2}}$$ where $\theta_k$ is the acute angle between $\overline{P_kP_{k+1}}$ and the horizontal. (The sign of $g_k$ is such that $g_k>0$ when the mass is descending and $g_k<0$ when ascending.)
Integration then gives, for $t\in[t_{k},t_{k+1}],$ $$\dot s(t)=g_kt+A_k$$ where $A_k$ is a constant; therefore,
$$\begin{align} \dot s(t_{k+1})&=g_kt_{k+1}+A_k\\ \dot s(t_{k})&=g_kt_{k}+A_k \end{align}$$ Taking the difference of these and rearranging, we find that the travel-time on segment $\overline{P_kP_{k+1}}$ is $$t_{k+1}-t_k={\dot s(t_{k+1})-\dot s(t_{k})\over g_k} $$ hence the total travel-time is
Example (aligned segments):
If all the segments have the same slope, then all $\theta_k=\theta$ (say), and the segments constitute a single overall line segment. The sum then telescopes to $$t_N = \sqrt{2\over g}\ {\sqrt{y_0-y_N}\over\sin{\theta}}=\sqrt{2l\over g\sin{\theta}}$$ where $l$ is the combined length of all the segments. This is the correct result for a mass sliding a distance $l$ without friction down a plane inclined at angle $\theta$, as can be easily confirmed by twice integrating the equation of motion $\ddot s = g\,\sin{\theta}$ and applying the appropriate boundary conditions to get $s(t)={g\over 2}\,(\sin{\theta})\,t^2,$ hence $l={g\over 2}\,(\sin{\theta})\,t_N^2.$