Page 8 of 9 FirstFirst ... 456789 LastLast
Results 106 to 120 of 131

Thread: Any Python Programmers Out There??

  1. #106 | Top
    Join Date
    Dec 2020
    Posts
    93
    Thanks
    56
    Thanked 26 Times in 20 Posts
    Groans
    6
    Groaned 5 Times in 5 Posts

    Default

    Quote Originally Posted by Bubba View Post
    Seriously. Are any professional coders (Or even experienced amateurs) who use Python reading this forum??
    yes i use it for stock analysis

  2. #107 | 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 Niche Political Commentor View Post
    well im a fucking retard when it comes to math so i guess im out
    Well of course there's algorithm already on the Internet.

  3. #108 | Top
    Join Date
    Nov 2013
    Location
    internet
    Posts
    759
    Thanks
    127
    Thanked 366 Times in 247 Posts
    Groans
    5
    Groaned 24 Times in 23 Posts

    Default

    Quote Originally Posted by AProudLefty View Post
    Well of course there's algorithm already on the Internet.
    what would i look for?
    NPC is a beloved internet personality. Their pronouns are he/him. NPC fully recognizes the inherent privilege of being able to post on a message board, and as such NPC makes sure to avoid all social media where the trust and safety council flags something as dangerous to think about. He avoids all tweets that are disputed, and only supports mainstream news sources where former CIA, NSA and FBI serve as talking heads.The future is female, orange man bad, black lives matter, and wear a damn mask!

  4. #109 | 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

    My apologies. I spoke too soon. I kept getting Magic Square algorithm as search results.

  5. #110 | 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 Niche Political Commentor View Post
    what would i look for?
    Never heard of the stack overflow website, retard?

    https://stackoverflow.com/

  6. #111 | Top
    Join Date
    Nov 2013
    Location
    internet
    Posts
    759
    Thanks
    127
    Thanked 366 Times in 247 Posts
    Groans
    5
    Groaned 24 Times in 23 Posts

    Default

    Quote Originally Posted by Primavera View Post
    Never heard of the stack overflow website, retard?

    https://stackoverflow.com/
    lol yes tom i've never heard oof stack overflow, or google for that matter!

    those sites are meaningless if you don't know what you are looking for (with regards to linear algebra)
    NPC is a beloved internet personality. Their pronouns are he/him. NPC fully recognizes the inherent privilege of being able to post on a message board, and as such NPC makes sure to avoid all social media where the trust and safety council flags something as dangerous to think about. He avoids all tweets that are disputed, and only supports mainstream news sources where former CIA, NSA and FBI serve as talking heads.The future is female, orange man bad, black lives matter, and wear a damn mask!

  7. #112 | 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 Niche Political Commentor View Post
    lol yes tom i've never heard oof stack overflow, or google for that matter!

    those sites are meaningless if you don't know what you are looking for (with regards to linear algebra)
    So have you heard of scipy and numpy for linear algebra?

  8. #113 | 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

    Might not need linear algebra if it's done by brute force. It won't take long anyway. Go across first row and col, find possible values of the missing integers that will result in 30. Go to the next row and col and so on.

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

    Default Progress Report.

    While everybody else was ringing in 2021, I was trying to learn about Python Dictionaries.

    Excel VBA (And other languages of which I'm aware) have arrays. Python has lists. Dictionaries are (Or can be) arrays of arrays. Can't say I know everything about dictionaries, but I learned enough to use one in my code. Here's what I have so far:

    Sed = 3
    Ctr = 0
    import random
    random.seed(Sed)

    HDik = {0: [2, 0, 4, 5, 7, 0, 3, 2],
    --- 1: [0, 4, 1, 6, 0, 1, 9, 0],
    --- 2: [4, 0, 0, 1, 0, 8, 2, 4],
    --- 3: [1, 5, 0, 0, 5, 0, 0, 2],
    --- 4: [0, 6, 1, 3, 0, 4, 2, 6],
    --- 5: [7, 3, 4, 0, 2, 5, 1, 0],
    --- 6: [0, 1, 6, 7, 1, 0, 0, 2],
    --- 7: [1, 0, 2, 0, 3, 2, 5, 0] }

    def RShuf (HLst):
    --- for I, Value in enumerate (HLst):
    ------ if Value == 0:
    --------- HLst [I] = random.randint (1, 9)

    for Ctr, Value in enumerate (HDik):
    --- HLin = HDik [Ctr].copy ()

    --- while sum (HLin) != 30:
    ------ HLin = HDik [Ctr].copy ()
    ------ Sed += 1
    ------ random.seed (Sed)
    ------ RShuf (HLin)
    print (Ctr, HDik [Ctr], HLin)
    Ctr += 1

    And here is the output:

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

    As you can see, program changes the zeros in all eight lines until each adds to thirty. Obviously, I never coulda got this far without help from Niche Political Commentor and A Proud Lefty. Thanks to both of you. (Guille ... Nah. You were precious little help.)

    HOWEVER, what I have so far is not good enough. Remember, the goal in the original puzzle was to make all eight horizontal lines AND all eight vertical lines add to thirty.

    I strongly suspect getting all the vertical lines to add to thirty is going to be more of a challenge. If a vertical line doesn't add to thirty, that means one or more of the horizontal lines are wrong.

    Well, I'm happy I got as far as I did, and I'll dive into the vertical line challenge this weekend.

    Happy New Year.

  10. #115 | 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
    While everybody else was ringing in 2021, I was trying to learn about Python Dictionaries.

    Excel VBA (And other languages of which I'm aware) have arrays. Python has lists. Dictionaries are (Or can be) arrays of arrays. Can't say I know everything about dictionaries, but I learned enough to use one in my code. Here's what I have so far:

    Sed = 3
    Ctr = 0
    import random
    random.seed(Sed)

    HDik = {0: [2, 0, 4, 5, 7, 0, 3, 2],
    --- 1: [0, 4, 1, 6, 0, 1, 9, 0],
    --- 2: [4, 0, 0, 1, 0, 8, 2, 4],
    --- 3: [1, 5, 0, 0, 5, 0, 0, 2],
    --- 4: [0, 6, 1, 3, 0, 4, 2, 6],
    --- 5: [7, 3, 4, 0, 2, 5, 1, 0],
    --- 6: [0, 1, 6, 7, 1, 0, 0, 2],
    --- 7: [1, 0, 2, 0, 3, 2, 5, 0] }

    def RShuf (HLst):
    --- for I, Value in enumerate (HLst):
    ------ if Value == 0:
    --------- HLst [I] = random.randint (1, 9)

    for Ctr, Value in enumerate (HDik):
    --- HLin = HDik [Ctr].copy ()

    --- while sum (HLin) != 30:
    ------ HLin = HDik [Ctr].copy ()
    ------ Sed += 1
    ------ random.seed (Sed)
    ------ RShuf (HLin)
    print (Ctr, HDik [Ctr], HLin)
    Ctr += 1

    And here is the output:

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

    As you can see, program changes the zeros in all eight lines until each adds to thirty. Obviously, I never coulda got this far without help from Niche Political Commentor and A Proud Lefty. Thanks to both of you. (Guille ... Nah. You were precious little help.)

    HOWEVER, what I have so far is not good enough. Remember, the goal in the original puzzle was to make all eight horizontal lines AND all eight vertical lines add to thirty.

    I strongly suspect getting all the vertical lines to add to thirty is going to be more of a challenge. If a vertical line doesn't add to thirty, that means one or more of the horizontal lines are wrong.

    Well, I'm happy I got as far as I did, and I'll dive into the vertical line challenge this weekend.

    Happy New Year.
    Happy New Year to you too! I am glad to see you making a progress. Did you see my recommendation in post #113?

  11. #116 | 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 Bubba View Post
    While everybody else was ringing in 2021, I was trying to learn about Python Dictionaries.

    Excel VBA (And other languages of which I'm aware) have arrays. Python has lists. Dictionaries are (Or can be) arrays of arrays. Can't say I know everything about dictionaries, but I learned enough to use one in my code. Here's what I have so far:

    Sed = 3
    Ctr = 0
    import random
    random.seed(Sed)

    HDik = {0: [2, 0, 4, 5, 7, 0, 3, 2],
    --- 1: [0, 4, 1, 6, 0, 1, 9, 0],
    --- 2: [4, 0, 0, 1, 0, 8, 2, 4],
    --- 3: [1, 5, 0, 0, 5, 0, 0, 2],
    --- 4: [0, 6, 1, 3, 0, 4, 2, 6],
    --- 5: [7, 3, 4, 0, 2, 5, 1, 0],
    --- 6: [0, 1, 6, 7, 1, 0, 0, 2],
    --- 7: [1, 0, 2, 0, 3, 2, 5, 0] }

    def RShuf (HLst):
    --- for I, Value in enumerate (HLst):
    ------ if Value == 0:
    --------- HLst [I] = random.randint (1, 9)

    for Ctr, Value in enumerate (HDik):
    --- HLin = HDik [Ctr].copy ()

    --- while sum (HLin) != 30:
    ------ HLin = HDik [Ctr].copy ()
    ------ Sed += 1
    ------ random.seed (Sed)
    ------ RShuf (HLin)
    print (Ctr, HDik [Ctr], HLin)
    Ctr += 1

    And here is the output:

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

    As you can see, program changes the zeros in all eight lines until each adds to thirty. Obviously, I never coulda got this far without help from Niche Political Commentor and A Proud Lefty. Thanks to both of you. (Guille ... Nah. You were precious little help.)

    HOWEVER, what I have so far is not good enough. Remember, the goal in the original puzzle was to make all eight horizontal lines AND all eight vertical lines add to thirty.

    I strongly suspect getting all the vertical lines to add to thirty is going to be more of a challenge. If a vertical line doesn't add to thirty, that means one or more of the horizontal lines are wrong.

    Well, I'm happy I got as far as I did, and I'll dive into the vertical line challenge this weekend.

    Happy New Year.
    I don't recall trying to help.
    Don't be afraid to see what you see

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

    Default Progress Report.

    Afraid progress is nonexistent. I wrote code that I seriously expected to work. Replace all the zeros with random numbers. If all sixteen lines add to thirty, YAY. If not, get a new set of random numbers and try again. Unfortunately, I have to report failure. Program has been running now more than sixty hours. If it were going to work, it woulda done it by now. Well, here's the program:

    Sed = 3
    Ctr = 0
    import random
    random.seed(Sed)

    HDik = {0: [2, 0, 4, 5, 7, 0, 3, 2],
    --- 1: [0, 4, 1, 6, 0, 1, 9, 0],
    --- 2: [4, 0, 0, 1, 0, 8, 2, 4],
    --- 3: [1, 5, 0, 0, 5, 0, 0, 2],
    --- 4: [0, 6, 1, 3, 0, 4, 2, 6],
    --- 5: [7, 3, 4, 0, 2, 5, 1, 0],
    --- 6: [0, 1, 6, 7, 1, 0, 0, 2],
    --- 7: [1, 0, 2, 0, 3, 2, 5, 0] }

    NewHDik = {}
    VDik = {}
    AllThirty = False
    print ('Working ...')

    def RShuf (HLst):
    --- for I, Value in enumerate (HLst):
    ------ if Value == 0:
    --------- HLst [I] = random.randint (1, 9)

    while (AllThirty == False):

    --- for Ctr, Value in enumerate (HDik):
    ------ HLin = HDik [Ctr].copy ()

    ------ while sum (HLin) != 30:
    --------- HLin = HDik [Ctr].copy ()
    -------- Sed += 1
    -------- random.seed (Sed)
    -------- RShuf (HLin)

    ------ DCtr = str (Ctr)
    ------ NewHDik [DCtr] = HLin
    ------ Ctr += 1

    --- VLin0 = NewHDik ['0']
    --- VLin1 = NewHDik ['1']
    --- VLin2 = NewHDik ['2']
    --- VLin3 = NewHDik ['3']
    --- VLin4 = NewHDik ['4']
    --- VLin5 = NewHDik ['5']
    --- VLin6 = NewHDik ['6']
    --- VLin7 = NewHDik ['7']

    --- VTot0 = VLin0 [0] + VLin1 [0] + VLin2 [0] + VLin3 [0] + \
    ------ VLin4 [0] + VLin5 [0] + VLin6 [0] + VLin7 [0]
    --- VTot1 = VLin0 [1] + VLin1 [1] + VLin2 [1] + VLin3 [1] + \
    ------ VLin4 [1] + VLin5 [1] + VLin6 [1] + VLin7 [1]
    --- VTot2 = VLin0 [2] + VLin1 [2] + VLin2 [2] + VLin3 [2] + \
    ------ VLin4 [2] + VLin5 [2] + VLin6 [2] + VLin7 [2]
    --- VTot3 = VLin0 [3] + VLin1 [3] + VLin2 [3] + VLin3 [3] + \
    ------ VLin4 [3] + VLin5 [3] + VLin6 [3] + VLin7 [3]
    --- VTot4 = VLin0 [4] + VLin1 [4] + VLin2 [4] + VLin3 [4] + \
    ------ VLin4 [4] + VLin5 [4] + VLin6 [4] + VLin7 [4]
    --- VTot5 = VLin0 [5] + VLin1 [5] + VLin2 [5] + VLin3 [5] + \
    ------ VLin4 [5] + VLin5 [5] + VLin6 [5] + VLin7 [5]
    --- VTot6 = VLin0 [6] + VLin1 [6] + VLin2 [6] + VLin3 [6] + \
    ------ VLin4 [6] + VLin5 [6] + VLin6 [6] + VLin7 [6]
    --- VTot7 = VLin0 [7] + VLin1 [7] + VLin2 [7] + VLin3 [7] + \
    ------ VLin4 [7] + VLin5 [7] + VLin6 [7] + VLin7 [7]

    --- Ctr = 0
    --- if Sed / 10000000 == int (Sed / 10000000):
    ------ print (Sed)
    --- if (VTot0 == 30 and VTot1 == 30 and
    ------ VTot2 == 30 and VTot3 == 30 and
    ------ VTot4 == 30 and VTot5 == 30 and
    ------ VTot6 == 30 and VTot7 == 30):
    --------- AllThirty = True

    print () # Blank line.
    print (Sed)
    print (NewHDik ['0'], sum (NewHDik ['0']))
    print (NewHDik ['1'], sum (NewHDik ['1']))
    print (NewHDik ['2'], sum (NewHDik ['2']))
    print (NewHDik ['3'], sum (NewHDik ['3']))
    print (NewHDik ['4'], sum (NewHDik ['4']))
    print (NewHDik ['5'], sum (NewHDik ['5']))
    print (NewHDik ['6'], sum (NewHDik ['6']))
    print (NewHDik ['7'], sum (NewHDik ['7']))

    print (VTot0, VTot1, VTot2, VTot3, VTot4, VTot5, VTot6, VTot7)

  13. #118 | 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
    Afraid progress is nonexistent. I wrote code that I seriously expected to work. Replace all the zeros with random numbers. If all sixteen lines add to thirty, YAY. If not, get a new set of random numbers and try again. Unfortunately, I have to report failure. Program has been running now more than sixty hours. If it were going to work, it woulda done it by now. Well, here's the program:

    Sed = 3
    Ctr = 0
    import random
    random.seed(Sed)

    HDik = {0: [2, 0, 4, 5, 7, 0, 3, 2],
    --- 1: [0, 4, 1, 6, 0, 1, 9, 0],
    --- 2: [4, 0, 0, 1, 0, 8, 2, 4],
    --- 3: [1, 5, 0, 0, 5, 0, 0, 2],
    --- 4: [0, 6, 1, 3, 0, 4, 2, 6],
    --- 5: [7, 3, 4, 0, 2, 5, 1, 0],
    --- 6: [0, 1, 6, 7, 1, 0, 0, 2],
    --- 7: [1, 0, 2, 0, 3, 2, 5, 0] }

    NewHDik = {}
    VDik = {}
    AllThirty = False
    print ('Working ...')

    def RShuf (HLst):
    --- for I, Value in enumerate (HLst):
    ------ if Value == 0:
    --------- HLst [I] = random.randint (1, 9)

    while (AllThirty == False):

    --- for Ctr, Value in enumerate (HDik):
    ------ HLin = HDik [Ctr].copy ()

    ------ while sum (HLin) != 30:
    --------- HLin = HDik [Ctr].copy ()
    -------- Sed += 1
    -------- random.seed (Sed)
    -------- RShuf (HLin)

    ------ DCtr = str (Ctr)
    ------ NewHDik [DCtr] = HLin
    ------ Ctr += 1

    --- VLin0 = NewHDik ['0']
    --- VLin1 = NewHDik ['1']
    --- VLin2 = NewHDik ['2']
    --- VLin3 = NewHDik ['3']
    --- VLin4 = NewHDik ['4']
    --- VLin5 = NewHDik ['5']
    --- VLin6 = NewHDik ['6']
    --- VLin7 = NewHDik ['7']

    --- VTot0 = VLin0 [0] + VLin1 [0] + VLin2 [0] + VLin3 [0] + \
    ------ VLin4 [0] + VLin5 [0] + VLin6 [0] + VLin7 [0]
    --- VTot1 = VLin0 [1] + VLin1 [1] + VLin2 [1] + VLin3 [1] + \
    ------ VLin4 [1] + VLin5 [1] + VLin6 [1] + VLin7 [1]
    --- VTot2 = VLin0 [2] + VLin1 [2] + VLin2 [2] + VLin3 [2] + \
    ------ VLin4 [2] + VLin5 [2] + VLin6 [2] + VLin7 [2]
    --- VTot3 = VLin0 [3] + VLin1 [3] + VLin2 [3] + VLin3 [3] + \
    ------ VLin4 [3] + VLin5 [3] + VLin6 [3] + VLin7 [3]
    --- VTot4 = VLin0 [4] + VLin1 [4] + VLin2 [4] + VLin3 [4] + \
    ------ VLin4 [4] + VLin5 [4] + VLin6 [4] + VLin7 [4]
    --- VTot5 = VLin0 [5] + VLin1 [5] + VLin2 [5] + VLin3 [5] + \
    ------ VLin4 [5] + VLin5 [5] + VLin6 [5] + VLin7 [5]
    --- VTot6 = VLin0 [6] + VLin1 [6] + VLin2 [6] + VLin3 [6] + \
    ------ VLin4 [6] + VLin5 [6] + VLin6 [6] + VLin7 [6]
    --- VTot7 = VLin0 [7] + VLin1 [7] + VLin2 [7] + VLin3 [7] + \
    ------ VLin4 [7] + VLin5 [7] + VLin6 [7] + VLin7 [7]

    --- Ctr = 0
    --- if Sed / 10000000 == int (Sed / 10000000):
    ------ print (Sed)
    --- if (VTot0 == 30 and VTot1 == 30 and
    ------ VTot2 == 30 and VTot3 == 30 and
    ------ VTot4 == 30 and VTot5 == 30 and
    ------ VTot6 == 30 and VTot7 == 30):
    --------- AllThirty = True

    print () # Blank line.
    print (Sed)
    print (NewHDik ['0'], sum (NewHDik ['0']))
    print (NewHDik ['1'], sum (NewHDik ['1']))
    print (NewHDik ['2'], sum (NewHDik ['2']))
    print (NewHDik ['3'], sum (NewHDik ['3']))
    print (NewHDik ['4'], sum (NewHDik ['4']))
    print (NewHDik ['5'], sum (NewHDik ['5']))
    print (NewHDik ['6'], sum (NewHDik ['6']))
    print (NewHDik ['7'], sum (NewHDik ['7']))

    print (VTot0, VTot1, VTot2, VTot3, VTot4, VTot5, VTot6, VTot7)
    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.

  14. The Following User Says Thank You to cancel2 2022 For This Post:

    AProudLefty (01-06-2021)

  15. #119 | 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
    Afraid progress is nonexistent. I wrote code that I seriously expected to work. Replace all the zeros with random numbers. If all sixteen lines add to thirty, YAY. If not, get a new set of random numbers and try again. Unfortunately, I have to report failure. Program has been running now more than sixty hours. If it were going to work, it woulda done it by now. Well, here's the program:

    Sed = 3
    Ctr = 0
    import random
    random.seed(Sed)

    HDik = {0: [2, 0, 4, 5, 7, 0, 3, 2],
    --- 1: [0, 4, 1, 6, 0, 1, 9, 0],
    --- 2: [4, 0, 0, 1, 0, 8, 2, 4],
    --- 3: [1, 5, 0, 0, 5, 0, 0, 2],
    --- 4: [0, 6, 1, 3, 0, 4, 2, 6],
    --- 5: [7, 3, 4, 0, 2, 5, 1, 0],
    --- 6: [0, 1, 6, 7, 1, 0, 0, 2],
    --- 7: [1, 0, 2, 0, 3, 2, 5, 0] }

    NewHDik = {}
    VDik = {}
    AllThirty = False
    print ('Working ...')

    def RShuf (HLst):
    --- for I, Value in enumerate (HLst):
    ------ if Value == 0:
    --------- HLst [I] = random.randint (1, 9)

    while (AllThirty == False):

    --- for Ctr, Value in enumerate (HDik):
    ------ HLin = HDik [Ctr].copy ()

    ------ while sum (HLin) != 30:
    --------- HLin = HDik [Ctr].copy ()
    -------- Sed += 1
    -------- random.seed (Sed)
    -------- RShuf (HLin)

    ------ DCtr = str (Ctr)
    ------ NewHDik [DCtr] = HLin
    ------ Ctr += 1

    --- VLin0 = NewHDik ['0']
    --- VLin1 = NewHDik ['1']
    --- VLin2 = NewHDik ['2']
    --- VLin3 = NewHDik ['3']
    --- VLin4 = NewHDik ['4']
    --- VLin5 = NewHDik ['5']
    --- VLin6 = NewHDik ['6']
    --- VLin7 = NewHDik ['7']

    --- VTot0 = VLin0 [0] + VLin1 [0] + VLin2 [0] + VLin3 [0] + \
    ------ VLin4 [0] + VLin5 [0] + VLin6 [0] + VLin7 [0]
    --- VTot1 = VLin0 [1] + VLin1 [1] + VLin2 [1] + VLin3 [1] + \
    ------ VLin4 [1] + VLin5 [1] + VLin6 [1] + VLin7 [1]
    --- VTot2 = VLin0 [2] + VLin1 [2] + VLin2 [2] + VLin3 [2] + \
    ------ VLin4 [2] + VLin5 [2] + VLin6 [2] + VLin7 [2]
    --- VTot3 = VLin0 [3] + VLin1 [3] + VLin2 [3] + VLin3 [3] + \
    ------ VLin4 [3] + VLin5 [3] + VLin6 [3] + VLin7 [3]
    --- VTot4 = VLin0 [4] + VLin1 [4] + VLin2 [4] + VLin3 [4] + \
    ------ VLin4 [4] + VLin5 [4] + VLin6 [4] + VLin7 [4]
    --- VTot5 = VLin0 [5] + VLin1 [5] + VLin2 [5] + VLin3 [5] + \
    ------ VLin4 [5] + VLin5 [5] + VLin6 [5] + VLin7 [5]
    --- VTot6 = VLin0 [6] + VLin1 [6] + VLin2 [6] + VLin3 [6] + \
    ------ VLin4 [6] + VLin5 [6] + VLin6 [6] + VLin7 [6]
    --- VTot7 = VLin0 [7] + VLin1 [7] + VLin2 [7] + VLin3 [7] + \
    ------ VLin4 [7] + VLin5 [7] + VLin6 [7] + VLin7 [7]

    --- Ctr = 0
    --- if Sed / 10000000 == int (Sed / 10000000):
    ------ print (Sed)
    --- if (VTot0 == 30 and VTot1 == 30 and
    ------ VTot2 == 30 and VTot3 == 30 and
    ------ VTot4 == 30 and VTot5 == 30 and
    ------ VTot6 == 30 and VTot7 == 30):
    --------- AllThirty = True

    print () # Blank line.
    print (Sed)
    print (NewHDik ['0'], sum (NewHDik ['0']))
    print (NewHDik ['1'], sum (NewHDik ['1']))
    print (NewHDik ['2'], sum (NewHDik ['2']))
    print (NewHDik ['3'], sum (NewHDik ['3']))
    print (NewHDik ['4'], sum (NewHDik ['4']))
    print (NewHDik ['5'], sum (NewHDik ['5']))
    print (NewHDik ['6'], sum (NewHDik ['6']))
    print (NewHDik ['7'], sum (NewHDik ['7']))

    print (VTot0, VTot1, VTot2, VTot3, VTot4, VTot5, VTot6, VTot7)
    Question: why would you use random numbers? Why not just iterate numbers?

  16. The Following User Says Thank You to AProudLefty For This Post:

    cancel2 2022 (01-07-2021)

  17. #120 | 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
    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.
    It's what my computer professor used to say, "spaghetti code".

  18. The Following User Says Thank You to AProudLefty For This Post:

    cancel2 2022 (01-06-2021)

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
  •