Python Forum

Full Version: All possible products of 3 discrete numbers.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Sorry if this is not the appropriate place to post this.

The next Olympics will feature the sport of climbing for the first time, with a novel scoring system that takes into account your placement out of 20 in 3 disciplines and ranks you by multiplying your 3 placements (lowest score wins). So the best possible score is 1*1*1 = 1 and the worst possible score is 20*20*20 = 8000.

I am wanting a list of all possible scores (which I believe is 20 choose 3 = 1140), and beside each score the three factors of the product.

I am not much of a coder but I figured this would be easy for someone who knows even a little Python and I would be interested in what the code looks like.
We're not big on writing code for people here, but we would be happy to help you fix your code when you run into problems. When you do run into problems, please post your code in Python tags, and clearly explain the problem you are having, including the full text of any errors.

Note that it would not be 20 choose 3. That would ignore any scores where two or more of the categories had the same score. You could easily do this with three loops, and with the itertools package you wouldn't even need the loops.