So I have been trying to come up with the solution and only thing coming to my mind is using a lot of ifs but it will make the code unnecessarily long. How can ı automate it