This brought to light the apparent mislabelling of x as y and vice-versa that had confused me before. I'm confident in the naming of the inputs, but not as much in the naming of the local variables.
The good news is that, even if the variable names are incorrect, the procedure still passes all tests.