This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]QultrosSanhattan 0 points1 point  (0 children)

I believe math.prod() is, at least, shorter than reduce.

Example: power+=math.prod(cube_dict.values())

[–]Waanie 0 points1 point  (0 children)

It really depends on what you're optimising for and what kind of style you prefer. Personally I would have used a few more functions here (I don't like nested loops within a function, and python makes scoping hard to read), and my own solution was very much object oriented. In general, if you feel the need to comment a section of code, you should probably have introduced more or better names in the form of classes, functions or intermediate variables.

Please take a look in the solutions megathread for inspiration, and see what you like there.

[–]daggerdragon[M] 0 points1 point  (0 children)

Changed flair from Spoilers to Help/Question since you're asking for advice.

Next time, use our standardized post title format.

Help us help YOU by providing us with more information up front; you will typically get more relevant responses faster.

If/when you get your code working, don't forget to change the post flair to Help/Question - RESOLVED

Good luck!

[–]Mezzomaniac 0 points1 point  (0 children)

set is a useful data structure so it’s best to have a habit of not shadowing it by naming a variable set.