Puzzle of the Week #365 - Twenty Coloured Balls

I asked my 10-year-old son Austin the question: if you had four balls in a bag and you wanted to colour them such that a randomly drawn pair of balls would have a 50% chance of matching in colour, how would you colour them? I was fully expecting him to go for the obvious but wrong answer of two of one colour, two of another. Instead, Austin, quick as a flash, came up with the correct answer of three of one colour and one of a second colour. I was intrigued as to how he did it so quickly; he explained that he visualised the four balls in a 2x2 grid. That way it was obvious to him that with a (3,1) colouring, half the rows half the columns and half the diagonals were matching in colour. Nice one Austin!

 

I now have 20 coloured balls of various colours in a bag, such that if you pick two balls at random the chance that the two chosen balls match is 50%. For this one there probably isn’t a neat visual shortcut, so arithmetic is likely needed.

 

What does the arrangement of the twenty coloured balls need to be?