• Seeking guidance on solving a simple(?) problem


I am a middle school gifted support teacher. I am a programming hobbyist and I have no formal education/training in programming. That being said, one of my students was given an extra math challenge today, and since he's been working his way through Hacking Secret Ciphers with Python, I told him we should try to model this program in Python. I'll list the gist of the problem below. I'm looking for any input as to how a middle schooler and his novice teacher can use Python to solve the problem. I'm pretty sure we solved it correctly on paper, but I thought this was still a teachable moment, and we want to use Python to confirm our answer.

We want to buy all of the three-digit lottery tickets that meet these conditions: 1. The winning digits are all different and in decreasing order. 2. One digit is the perfect square of one of the other digits. 3. At least two of the digits are consecutive.

How many tickets will we buy?

Thanks in advance!


[Condition 2 means that we need 2 & 4 or 3 & 9 in our solution, filling in the third blank with a unique consecutive digit...]