The unexpected hanging is described in the Wikipedia article Unexpected hanging paradox.

A hanging is said to be a surprise of on the morning that the prisoner is hanged, he cannot deduce that he will be hanged that day. I don't see the ability to derive a contradiction. If you assume that the judge is telling the truth, then you can deduce that the prisoner won't be hanged any of the days of the week. However, he gets hanged on Wednesday. Since he deduced that he won't get hanged on Wednesday, that must mean he cannot deduce that he will get hanged on Wednesday. Therefore, his hanging on Wednesday was a surprize. However, he also deduced that if he gets hanged on Wednesday, that won't be a surprize. The solution then is to break the assumption that the judge was telling the truth. Since the judge's statement was contradictory, it's totally possible that the prisoner can deduce that he won't be hanged on Wednesday but can also deduce that he will be hanged on Wendesday. Since he can also deduce that he will be hanged on Wednesday, the hanging wasn't a surprize. The judge did not tell the truth that the hanging would be a surprize. That seems like a perfectly good solution to the problem. I see no paradox in that solution.

• Maybe this would have been more suitable as an answer than a question. However, once, I wrote something like this as answer and it wasn't accepted and got deleted then a year later, I wrote another slightly different answer and then it got deleted as well and that's why asked the question. May 27, 2019 at 5:56