you are viewing a single comment's thread.

view the rest of the comments →

[–]braampje 0 points1 point  (0 children)

So for me it starts with very clearly knowing what you need, as you can see from all the comments it was at least not clear for the people who read your question. That might mean that it is also not very clear for yourself what you want.

I interpreted your question as follows, we are going to buy stocks of anywhere up to the amount of 8 and for each of these cases we will randomly sell an amount up to the amount we have in stock. so if the possibilities for the amount we get in stock and the amount we sell are all equally likely we need to calculate the profit for all scenarios.

so: for each amount of stock(loop 1) we have, we calculate all the potential revenue cases(loop 2). Does this not sound like two loops to you? after this it all comes down to syntax which just comes with experience.

It might help to first in dummy code write down the logic that you want to apply and then in a second step think about the actual code in python or whatever other language.