Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. def solve(start,result,depth,arrTypeInput,arrJawaban):
  2.     return solveRecursive(float(start),float(result),int(depth),0,arrTypeInput,arrJawaban)
  3.  
  4.  
  5. def solveRecursive(start,result,depth,curDepth,arrTypeInput,arrJawaban):
  6.     found = False
  7.     if (depth>curDepth):
  8.         curDepth+=1
  9.         i = 0
  10.         while(i<len(arrTypeInput) and not(found)):
  11.             error = False
  12.             hasil = 0
  13.             if (arrTypeInput[i].getCmd() == "i" or arrTypeInput[i].getCmd() == "r"):
  14.                 temp = start
  15.                 while(temp>=1):
  16.                     temp-=1
  17.                 if (temp!=0):
  18.                     error = True
  19.                 else:
  20.                     hasil = arrTypeInput[i].calc(float(start))
  21.             else:
  22.                 hasil = arrTypeInput[i].calc(float(start))
  23.             arrJawaban[curDepth-1] = i
  24.             if ((hasil != result) and not(error)):
  25.                 found = solveRecursive(hasil,result,depth,curDepth,arrTypeInput,arrJawaban)
  26.             elif (hasil == result):
  27.                 found = True
  28.             i+=1
  29.     return found
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement