Sort by

recency

|

26 Discussions

|

  • + 0 comments

    Suppose we want person A and person B to sit together. The only way that the 2 people sit together is if person B either sits to either the right or left of person A (& vice versa, considering one situation is enough) Person B has 9 seats to choose but can only sit next to Person A if they choose the 2 seats right next to them so its 2/9

  • + 0 comments

    can someone say what is wrong in this:

    # Enter your code here. Read input from STDIN. Print output to STDOUT
    from fractions import Fraction
    
    table=['r','r']+['b' for i in range(8)]
    table2 = list(table)
    print(table)
    
    count=0
    total=0
    
    for i in table:
        table2 = list(table)    
        table2.remove(i)
        for j in table2:
            table3 = list(table)    
            table3.remove(i)
            table3.remove(j)
            for k in table3:
                draw=i+j+k
                #print(draw)
                if any([m in draw for m in ['rrb','brr']]):
                    print(draw,[m in draw for m in ['rrb','brr']])
                    count+=1
                total+=1
                
    print(Fraction(count, total))
    
  • + 0 comments
    from fractions import Fraction
    from math import comb
    
    print(Fraction(10, comb(10, 2)))
    
  • + 0 comments

    Python

    answer: 2/9

    from fractions import Fraction as F
    
    tot = 0
    tar = 0
    
    for i in range(10):
        for j in range(10):
            if i != j:
                tot += 1
                if abs(i-j) == 1 or abs(i-j) == 9:
                    tar += 1
    print(F(tar,tot))
    
  • + 0 comments

    Python

    Answer = 2/9

    from fractions import Fraction
    
    places = [i for i in range(0, 10, 1)]
    total = 0
    visited = []
    
    for e, i in enumerate(places):
        for j in places[0:e] + places[e+1:]:
            if i == 0:
                if j == 9:
                    visited.append([i, j])
                elif j == 1:
                    visited.append([i, j])
            elif i == 9:
                if j == 0:
                    visited.append([i, j])
                elif j == 8:
                    visited.append([i, j])
            else:
                if (i == (j - 1)) or (i == (j + 1)):
                    visited.append([i, j])
            
            total += 1
    
    print(Fraction(len(visited), total)) # 2/9