How to optimize this code for printing pattern?

In this lecture a pattern problem is suggested at last

for N = 5
ooooo
oxxxo
oxoxo
oxxxo
ooooo

after lot’s of mehnat :joy: I did this please tell me how can I optimize the code.

  • I am handling odd and even cases separately
  • have several special cases in my logic
  • still failing at handling n=1( that is a special case too for me :sweat_smile:)
    Thanks,