The Tear Stained Prang

I'm in the midst of Prang and it's still not going well. I've retreated from trying to understand the algorithm, and am now trying to just translate it into Python. A bit like Searle's Chinese Room. I know there must be a mistake in my translation somewhere because my translation doesn't pass the tests. Therefore I'm breaking the translation down into individual steps and testing each of those. If that doesn't work I'll have to think again. I've said to myself that I'll give up if I haven't cracked it by midnight tonight.