Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solve(start,result,depth,arrTypeInput,arrJawaban):
- return solveRecursive(float(start),float(result),int(depth),0,arrTypeInput,arrJawaban)
- def solveRecursive(start,result,depth,curDepth,arrTypeInput,arrJawaban):
- found = False
- if (depth>curDepth):
- curDepth+=1
- i = 0
- while(i<len(arrTypeInput) and not(found)):
- error = False
- hasil = 0
- if (arrTypeInput[i].getCmd() == "i" or arrTypeInput[i].getCmd() == "r"):
- temp = start
- while(temp>=1):
- temp-=1
- if (temp!=0):
- error = True
- else:
- hasil = arrTypeInput[i].calc(float(start))
- else:
- hasil = arrTypeInput[i].calc(float(start))
- arrJawaban[curDepth-1] = i
- if ((hasil != result) and not(error)):
- found = solveRecursive(hasil,result,depth,curDepth,arrTypeInput,arrJawaban)
- elif (hasil == result):
- found = True
- i+=1
- return found
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement