in blog | Matthias Kestenholz: Posts about Django |
---|---|
original entry | Workbench: Coffee time! |
I have written about the Workbench agency software a few weeks back.
Back when we were using Slack at Feinheit we used a Donut bot to generate randomized invites for a coffee break. We lost that bot when we switched to Discord. I searched some time for an equivalent bot for Discord but couldn’t find any, so like any self-respecting nerd, break lover and NIH-sufferer I reimplemented the functionality as a part of our agency software.
The first version generated totally random pairings without any history; I thought that maybe this would be good enough, but of course I received an invite for a coffee with the exact same person in the first two invitations. Even though I did enjoy the break both times this motivated me to put some effort into a better solution :-)
The result of this work is the coffee_invites()
function
There are two main parts to the generator:
So, it’s not mathematically perfect, but all imbalances will cancel out over a long time. I experimented with the discounting factor and the number of random pairings it generates upfront. The values in the code seem to work fine.
Sometimes it’s simple stuff like this which gets me going and reignites the love for programming. Like a small puzzle.