Mercurial > hg > problem6
changeset 16:4c23cfdeaa5f draft
main: enable some debug output
Also fix the default plan for brute_force() so that it is always
iterable, even when it's not set.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Wed, 11 Mar 2015 16:48:15 -0400 |
parents | d9aa5e25859c |
children | da2d5f75774f |
files | optim.py |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/optim.py +++ b/optim.py @@ -125,7 +125,7 @@ plans = [] maxcapital = case.capital - maxplan = None + maxplan = [] for plan in plans: try: plancapital = final_capital(case, machines, plan) @@ -174,6 +174,11 @@ solver = brute_force maxcapital, plan = solver(case) print "Case %d: %d" % (number + 1, maxcapital) + if args.debug: + for (action, machine) in zip(plan, case.machines): + if action: + print "Buy ", machine + print if __name__ == "__main__": main()