I used a solution that I happened to already have on my laptop on an exam. Did I cheat?
I would say no, unless this was explicitly prohibited beforehand. Look, what's the purpose of a test?  To gauge the extent to which one has comprehended the material. The fact that you did the work indicates you do. Hell, the fact you did it on your own for fun deserves recognition. 

What's the point of re-doing the work while sitting in class during a test?  Worse yet, suppose you did and made a mistake due to nerves/time pressure.  You still did and comprehended the material, thus you pass.  

Others will disagree, but in my mind, I just want to know if you do or do not understand the material.