changeset 6:d4be13772b01 draft

final_capital: consider as invalid plans that buy more than one machine per day
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Tue, 10 Mar 2015 22:20:59 -0400
parents cd24a8027d5f
children af2598b58791
files optim.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/optim.py
+++ b/optim.py
@@ -66,6 +66,10 @@
 
             capital -= machine.buy
             if slot:
+                if machine.day == slot.day:
+                    raise InvalidPlan("Cannot buy two machines on the same day: %d"
+                                      % (machine.day))
+
                 # Subtract 1, because the machine in the slot cannot
                 # be used the day it's sold.
                 days_used = machine.day - slot.day - 1