Page 9 of 9 FirstFirst ... 56789
Results 121 to 131 of 131

Thread: Any Python Programmers Out There??

  1. #121 | Top
    Join Date
    Sep 2020
    Posts
    222
    Thanks
    2
    Thanked 68 Times in 58 Posts
    Groans
    0
    Groaned 2 Times in 2 Posts

    Default

    Quote Originally Posted by Primavera View Post
    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.

  2. #122 | Top
    Join Date
    Feb 2020
    Posts
    87,041
    Thanks
    35,070
    Thanked 21,784 Times in 17,103 Posts
    Groans
    985
    Groaned 2,343 Times in 2,262 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Bubba View Post
    That's the whole idea. I'm trying to to learn good programming technique.
    Well don't use random numbers in this problem.

  3. #123 | Top
    Join Date
    Apr 2009
    Posts
    108,120
    Thanks
    60,501
    Thanked 35,051 Times in 26,519 Posts
    Groans
    47,393
    Groaned 4,742 Times in 4,521 Posts
    Blog Entries
    61

    Default

    Quote Originally Posted by Bubba View Post
    That's the whole idea. I'm trying to to learn good programming technique.
    Ok, but he said it was a mess, you need to learn to annotate and structure your code.

  4. #124 | Top
    Join Date
    Feb 2020
    Posts
    87,041
    Thanks
    35,070
    Thanked 21,784 Times in 17,103 Posts
    Groans
    985
    Groaned 2,343 Times in 2,262 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Primavera View Post
    Ok, but he said it was a mess, you need to learn to annotate and structure your code.
    I gave him a partial code. A very minor code, but major for helping the rest.

  5. #125 | Top
    Join Date
    Sep 2020
    Posts
    222
    Thanks
    2
    Thanked 68 Times in 58 Posts
    Groans
    0
    Groaned 2 Times in 2 Posts

    Default

    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 by Bubba; 01-09-2021 at 01:49 AM.

  6. #126 | Top
    Join Date
    Feb 2020
    Posts
    87,041
    Thanks
    35,070
    Thanked 21,784 Times in 17,103 Posts
    Groans
    985
    Groaned 2,343 Times in 2,262 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Bubba View Post
    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.

  7. #127 | Top
    Join Date
    Dec 2016
    Posts
    27,505
    Thanks
    5,209
    Thanked 7,295 Times in 5,845 Posts
    Groans
    1,263
    Groaned 390 Times in 368 Posts

    Default

    Quote Originally Posted by AProudLefty View Post
    Awesome. But still why use random numbers though? Of course doing that would take it a while to arrive at the goal.
    He's a newb.
    Don't be afraid to see what you see

  8. #128 | Top
    Join Date
    Feb 2020
    Posts
    87,041
    Thanks
    35,070
    Thanked 21,784 Times in 17,103 Posts
    Groans
    985
    Groaned 2,343 Times in 2,262 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Guille View Post
    He's a newb.
    Imagine if it was a 16x16 matrix. Heh.

  9. #129 | Top
    Join Date
    Dec 2016
    Posts
    27,505
    Thanks
    5,209
    Thanked 7,295 Times in 5,845 Posts
    Groans
    1,263
    Groaned 390 Times in 368 Posts

    Default

    Quote Originally Posted by AProudLefty View Post
    Imagine if it was a 16x16 matrix. Heh.
    He ain't working on anything he can't pull from the library.
    Don't be afraid to see what you see

  10. #130 | Top
    Join Date
    Apr 2009
    Posts
    108,120
    Thanks
    60,501
    Thanked 35,051 Times in 26,519 Posts
    Groans
    47,393
    Groaned 4,742 Times in 4,521 Posts
    Blog Entries
    61

    Default

    Quote Originally Posted by Guille View Post
    He ain't working on anything he can't pull from the library.
    My son, who is a real Python programmer working for Softbank in Tokyo, said it was very badly written and annotated.
    Last edited by cancel2 2022; 01-10-2021 at 05:18 AM.

  11. #131 | Top
    Join Date
    Dec 2016
    Posts
    27,505
    Thanks
    5,209
    Thanked 7,295 Times in 5,845 Posts
    Groans
    1,263
    Groaned 390 Times in 368 Posts

    Default

    Quote Originally Posted by Primavera View Post
    My son who is a real Python programmer working for Softbank in Tokyo, said it was very badly written and annotated.
    Dude, just about everything you see that is open license is poorly written and annotated.
    Don't be afraid to see what you see

Similar Threads

  1. A Monty Python riddle for you......
    By Cancel 2020.2 in forum Off Topic Forum
    Replies: 0
    Last Post: 04-27-2020, 07:44 PM
  2. Replies: 2
    Last Post: 06-16-2018, 08:07 PM
  3. Monty Python meets Daesh
    By cancel2 2022 in forum Off Topic Forum
    Replies: 69
    Last Post: 01-13-2016, 06:00 PM
  4. 3 S.F. programmers build alternative to HealthCare.gov
    By StormX in forum Current Events Forum
    Replies: 17
    Last Post: 11-11-2013, 04:55 PM
  5. Pet Python Strangles Child, Officials Say
    By Demwit in forum Off Topic Forum
    Replies: 1
    Last Post: 07-01-2009, 07:39 PM

Bookmarks

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •