As I read and reread this question, I find myself fixated on the idea that this must be unethical, somehow. I suppose my knee-jerk reaction could be described like this: Every professor is operating from the position that any assignment she makes is exclusive to that particular class, even if she doesn’t expressly say so at the onset (in other words, it’s simply assumed that work done for a specific class will be used only for that specific class). It’s as if you were breaking a rule that was so over-the-top obvious it may not have been overtly outlined. But you know what? The more I think this over, the more I find myself agreeing with your position. I don’t think this is cheating. I wouldn’t say it qualifies as “genius,” and it might get you expelled from some universities. Yet I can’t isolate anything about this practice that harms other people, provides you with an unfair advantage or engenders an unjustified reward.

I look at it like this: You were essentially asked two questions that shared a common answer. The fact that you could see commonalities between unrelated intellectual disciplines is a point in your favor. Some might call your actions self-plagiarism, but the very premise of stealing your own creative property is absurd. You’re not betraying the public’s trust. It seems strange only because the assignments involve a degree of creativity. If this had been a multiple-choice physics test you failed to study for — yet were still able to pass, based on knowledge you acquired from an applied-math class taken the previous semester — no one would question your veracity.