Process of elimination is a powerful tool, especially when you can't use the variable input due to an arbitrary restriction that you're supposed to test to determine what the output is. Could this be done better? Yes. Will this be done better? Probably not. Over 1000 instructions and a repeat ain't one.