It's hard
This video here should help you to complete the Sootopolis Gym puzzle.
(Skipped to 4:00 because he battles trainers and has a hard time completing it himself.)