Skip to content

Instantly share code, notes, and snippets.

@espadrine
Created February 12, 2021 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save espadrine/626ba7637c5edd76fe82f83ee2efa511 to your computer and use it in GitHub Desktop.
Save espadrine/626ba7637c5edd76fe82f83ee2efa511 to your computer and use it in GitHub Desktop.
Birthday paradox on Slack username colors.

You might know the birthday problem: “it only takes 23 people so that two have the same birthday”.

But do you know the Slack username color problem?

Slack gives random colors to each user in compact view. But there’s only 51 colors to choose from, so as soon as you are 9 in a channel, odds are that two share the same color.

function pcol(k, n)
1 - factorial(big(k)) * binomial(big(n), k) / big(n)^k
end
function mink(n)
k = 0
while pcol(k, n) < 0.5
k += 1
end
k
end
println(mink(51))
[
"235e5b",
"2b6836",
"385a86",
"3c8c69",
"3c989f",
"43761b",
"4bbe2e",
"4ec0d6",
"50a0cf",
"53b759",
"5870dd",
"5a4592",
"5b89d5",
"619a4f",
"674b1b",
"684b6c",
"73769d",
"827327",
"8469bc",
"84b22f",
"8d4b84",
"8f4a2b",
"902d59",
"965d1b",
"99a949",
"9b3b45",
"9d8eee",
"9e3997",
"9f69e7",
"a2a5dc",
"a63024",
"a72f79",
"aba727",
"b14cbc",
"bb86b7",
"bc3663",
"bd9336",
"d1707d",
"d55aef",
"d58247",
"db3150",
"dc7dbb",
"dd8527",
"de5f24",
"df3dc0",
"e06b56",
"e0a729",
"e475df",
"e7392d",
"e96699",
"ea2977"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment