/plushcap/analysis/cloudflare/creating-serendipity-with-python

Creating serendipity with Python

What's this blog post about?

John Graham-Cumming has shared an interesting approach to dividing employees into random groups for virtual hangouts. He initially wrote a Python code to divide n elements into groups of at least size g, minimizing the size of each group. Later, he simplified the solution by using a formula that calculates how many elements should be in each group without looping. The final code is: `groups = [1+max(0,n-(i+1))//(n//g) for i in range(n//g)]`. This approach helps to ensure fair distribution of employees into groups and promotes interaction among them.

Company
Cloudflare

Date published
Feb. 25, 2021

Author(s)
John Graham-Cumming

Word count
785

Hacker News points
30

Language
English


By Matt Makai. 2021-2024.