Text this: A pseudo-linear time algorithm for the optimal discrete speed minimizing energy consumption.