Transfer Matrix Method Python Code For Snake