Example #1
0
def runOneTest(name,p1,p2,resolution=0.01):
    print("\n"+name)    
    dc = DivideAndChoose(p1, p2, resolution)
    result = dc.run()
    print("   Answer is " + str(result))
    pi1, pi2 = result
    print("   P1 got " + str(pi1) + " with value " + str(p1.valueOfPiece(pi1)))
    print("   P2 got " + str(pi2) + " with value " + str(p2.valueOfPiece(pi2)))
'''
This is the file Kevin will call from the web page.
It is listed in the algs file at the top level of the repo,
  saying that it takes 2 prefs file names as input
'''
import sys
import os
if __name__ == '__main__':
    pass
'''
Make sure Kevin's web page can get to the python packages
'''
sys.path.insert(0,os.path.abspath(os.path.join(os.path.dirname(__file__),os.path.pardir)))

from DivideAndChoose import DivideAndChoose
from prefs.Prefs import Prefs

'''
Kevin supplies the filenames to us, chosen from the web page
'''
f1 = sys.argv[1]
f2 = sys.argv[2]

'''
Now do what you want
'''
dc = DivideAndChoose(Prefs.fromFile(f1), Prefs.fromFile(f2))
pi1, pi2 = dc.run()
print ("answer is pi1 = " + str(pi1) + " and pi2 = " + str(pi2))