The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Marco Rovere (3) [Avatar] Offline
the code in listing 2.1, that is supposed to compute the inner product between 2 vectors is wrong, since it does more combinations that actually needed: it combines all indices, while the inner only combines identical ones.

revenue = 0
#maybe also a check on len(costs) == len(amounts)....
for i in range(len(costs)):
  revenue += costs[i]*amounts[i]

Nishant Shukla (52) [Avatar] Offline
Thanks Marco,

You're right. I was just testing if you were paying attention.

Just kidding - fatal mistake on my part. It will be fixed soon.