Failure is an essential part of success. Success that comes without failure was probably random chance.
Btw, you can't fail in math by failing to pay your taxes. In this case, your drug abuse are the taxes and math is your programming skills. The two doesn't hang together. Being an ex drug abuser is not a failure, that is success. If you continued to misuse drug, that would be a failure. So they basically kicked you out because of your success.
Some people punish other people for doing the right things.