Puzzle games H1

I am a beginner in programming, I am just want to solve this problem but I have no idea what approach I can follow and what I have to learn to solve this problem.
Please help me with solving the problem