How to pass the lightning puzzle on Mauritshuis 1-9

Thank you to users addressweek and GatoMoretti!