Sort by

recency

|

27 Discussions

|

  • + 0 comments
    different_sum6 = 0
    total_rolls = 0
    
    for p in range(1,6+1):
        for q in range(1,6+1):
            if (p+q) == 6 and (p != q):
                different_sum6 += 1
            total_rolls += 1
    
    print(str((different_sum6//different_sum6))+"/"+str((total_rolls//different_sum6)))
    
  • + 0 comments

    Python3:

    import fractions
    
    if __name__ == "__main__":
      count_all, count_sum6 = 0, 0
      for i in range(1,6+1):
        for j in range(1,6+1):
          count_all += 1
          if i != j and i + j == 6:
             count_sum6 += 1
            
      print(fractions.Fraction(count_sum6, count_all))
    
  • + 0 comments

    Python code

    from fractions import Fraction
    
    count = 0
    
    def func(count):
        for i in range(1, 7, 1):
            for j in range(1, 7, 1):
                if (i != j) and (i + j) == 6:
                    count += 1
        
        return Fraction(count, 6*6)
    
    
    print(func(count))
    
  • + 0 comments

    The instructions kind of cheat. It says "put your answer in the editor" below. There is no editor "below" (there's on to the side). So I figured they must have meant the "custom input", since the program refused to accept an aswer when I tried doing a printf. But when I put an input into the custom input, it said I was wrong (I didn't see that you can't use 3/3 and 3/3 as valid outcomes). So I picked the correct answer, and still got an error. Finally decided to use both a custom input and a printf... and now it works.

    So put your answer in the custom input and a printf.

  • + 0 comments

    Python 3

    dice=[1,2,3,4,5,6]
    comb=[(a,b) for a in dice for b in dice]       
    favourable=[(a+b)==6 for a,b in comb if a!=b]       
    
    sum(favourable)/len(comb)