Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Redundant Iterations
#1
OrgH = [73.35,111.37,92.70,70.73,67.71,77.84]
BtmGap = 32
MinRH = 12
Div = 7
tH = 400

sH = sum(OrgH)
q = Div - len(OrgH)

def Optm(S, H, GH, q):

    s = H + GH

    L = [S,GH]

    if S >= s:
        K = S - s
    if S < s and GH > MinRH / 12:
        K = Optm(S, H, GH - 1, q)
    if S < s and GH <= MinRH / 12:
        K = Optm(S + 1, H, GH, q)


    if q < 0:
        print("Somethign wrong with the category!")
    if q == 0:
        return 0

    else:
        minGap = K / q

        if minGap < MinRH:
            print("b")
            return Optm(S + 1, H, GH, q)
        else:
            print("a")
            print(S)
            print(GH)
            print(minGap)
            return minGap
In the script above, my goal is to make the last "else" executes once and get only one result. But, now, it generates several iterations.

Can someone help? Thank you in advance!
Reply


Messages In This Thread
Redundant Iterations - by leoahum - Mar-13-2019, 06:29 PM
RE: Redundant Iterations - by ichabod801 - Mar-13-2019, 07:11 PM
RE: Redundant Iterations - by leoahum - Mar-13-2019, 07:15 PM
RE: Redundant Iterations - by ichabod801 - Mar-13-2019, 07:26 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020