An Algorithm to Generate Solutions to Hybrid Dynamical Systems with Inputs and Applications to Series Interconnections