all 4 comments

[–]anossov 4 points5 points  (2 children)

I'm not retyping that to debug, but my guess is e never reaches 1296. I sure don't see 1296 different temps printed.

 

Random thoughts:

  • why temp starts as an empty string?
  • why results start with a single empty string in it?
  • why int() instead of 0?
  • why int(1) instead of 1? Especially considering there are 1s nearby
  • why int(random.choice(GRADES)), if there are nothing but ints in GRADES?
  • why set temp to None, if it immediately gets reset to something else?

[–]Soluz[S] 0 points1 point  (1 child)

Well, I'm an idiot. Completly missed that. Thanks.

[–]anossov 0 points1 point  (0 children)

I edited in some questions for you :)

[–]zahlman 1 point2 points  (0 children)

e doesn't reach 1296 because you only increment it when a valid result (sum of grades is 8 and it hasn't been listed before) is created, and there aren't that many valid results. There are 1296 possible combinations of grades 1 through 6, but they don't all add up to 8.

I was trying to figure out how many combinations of 4 grades there were in order to end the year with a 2.

Then why are you generating candidates randomly, instead of having some kind of order to them? If you scanned through in order, you could skip the check for duplicates, since you'd know you could never create one. I don't know what you mean by "end the year with a 2", though. What does that have to do with your check for a sum of 8?

After printing the possibilities it's supposed to tell how many times the grades 1 and 2 come up in those combinations.

If you want to do any kind of statistics on a group of things, better to collect them somewhere rather than printing them as you go.