puzzleup2015_01::Same Sum

SAME SUM

You randomly select two different 2-digit numbers and calculate their sum. Your friend does the same operations. What is the probability of you and your friend having the same sum?

If the problem was asked for two different 1-digit numbers, the answer would be 29/405.

Enter your answer as a simplified fraction.

 

The code below is for 1-digit numbers, it should be changed according to the 2-digit numbers.

def Solve(sumi):
    count=0
    for i in range(sumi+1):
        t=sumi-i
        
       
        if t!=i and len(str(t))==1 and len(str(i))==1:
            #print("t=",t,i)
            count+=1
    
    return count**2

tot=0
for i in range(18):
    cnt=Solve(i)
    print(i,cnt)
    tot=tot+cnt
print(tot)

The last line prints “total”, which is 580. The probability is 580/8100 for 1-digit numbers as shown in the puzzle text.