This question is directly answered by the principles in the IPC.
Z's Guilt: Under Section 84 of the IPC, an act done by a person who, at the time of doing it, by reason of unsoundness of mind, is incapable of knowing the nature of the act, or that he is doing what is either wrong or contrary to law, is not an offence. So, Z is not guilty.
X's Right of Private Defence: Section 98 of the IPC is crucial here. It states that the right of private defence is available against an act which would otherwise be an offence, even if the person doing the act is not criminally liable due to youth, want of maturity, or unsoundness of mind.
Therefore, even though Z has not committed an offence due to insanity, X has the same right of private defence against Z's attack as he would have if Z were sane. The question's options are slightly misphrased, but (a) captures the correct legal outcome.