Any Python Programmers Out There??

I showed this to my son and he said your code sucked. You need to learn good programming technique from the start, otherwise you'll just get into bad habits that will be very hard to break.

That's the whole idea. I'm trying to to learn good programming technique.
 
Well, my random number program DID work eventually. Took somewhere in the neighbor hood of one hundred hours. Here is the output:

10862750611
[2, 3, 4, 5, 7, 4, 3, 2] 30
[4, 4, 1, 6, 3, 1, 9, 2] 30
[4, 1, 3, 1, 7, 8, 2, 4] 30
[1, 5, 9, 2, 5, 5, 1, 2] 30
[6, 6, 1, 3, 2, 4, 2, 6] 30
[7, 3, 4, 3, 2, 5, 1, 5] 30
[5, 1, 6, 7, 1, 1, 7, 2] 30
[1, 7, 2, 3, 3, 2, 5, 7] 30
30 30 30 30 30 30 30 30

I agree this is not the best method of tackling the puzzle. What should I do?? Make a loop so the first zero gets replaced with every digit from one to nine, then check every possibility for the other digits?? Then make a loop to replace the second zero?? Not sure exactly what the best way to accomplish that goal is.

Well, however lame my code is, it eventually got to the right answer.

Oh, and it's not spaghetti code, at least as I understand the term. Excel VBA has `GoTo' which is provided for the sole purpose of writing spaghetti code. I never used it. And I'm pretty sure any experienced Python programmer can follow the program I posted with no problem.
 
Last edited:
Well, my random number program DID work eventually. Took somewhere in the neighbor hood of one hundred hours. Here is the output:

10862750611
[2, 3, 4, 5, 7, 4, 3, 2] 30
[4, 4, 1, 6, 3, 1, 9, 2] 30
[4, 1, 3, 1, 7, 8, 2, 4] 30
[1, 5, 9, 2, 5, 5, 1, 2] 30
[6, 6, 1, 3, 2, 4, 2, 6] 30
[7, 3, 4, 3, 2, 5, 1, 5] 30
[5, 1, 6, 7, 1, 1, 7, 2] 30
[1, 7, 2, 3, 3, 2, 5, 7] 30
30 30 30 30 30 30 30 30

I agree this is not the best method of tackling the puzzle. What should I do?? Make a loop so the first zero gets replace with every digit from one to nine, then check every possibility for the other digits?? Then make a loop to replace the second zero?? Not sure exactly what the best way to accomplish that goal is.

Well, however lame my code is, it eventually got to the right answer.

Oh, and it's not spaghetti code, at least as I understand the term. Excel VBA has `GoTo' which is provided for the sole purpose of writing spaghetti code. I never used it. And I'm pretty sure any experienced Python programmer can follow the program I posted with no problem.

Awesome. But still why use random numbers though? Of course doing that would take it a while to arrive at the goal.
 
Back
Top