Skip to content

Instantly share code, notes, and snippets.

@miketwo
miketwo / pairwise.py
Last active May 9, 2022 14:05
Streaming pairwise implementation
import random
import time
def counts_to_pairs(counts, target):
pairs, incomplete = {}, {}
for a in range(int(target/2)+1):
b = target-a
matching_pair = counts.get(a,0) >= 1 and counts.get(b, 0) >= 1
if matching_pair:
if a == b:
#!/usr/bin/env ruby
require 'set'
# I have a group of 65 people that is divided into 10 subgroups. From the group of 65 I want to generate 17 teams. 14 teams of 4 people, 3 teams of 3.
# - First restriction: Each team must contain no more than 1 person from one of the subgroups. For example, a correct team would be {1, 2, 3, 4}, {2, 5, 6, 3}, and an incorrect team {2, 2, 5, 8} or {10, 2, 5, 2}. (the numbers 1-10 standing for the 10 subgroups)
# - Second restriction: I have to generate team combinations for multiple weeks, whereby people cannot be matched to a person they have been on a team with in the past. So if person A and B where in the same team in week 1, they cannot be matched up in any of the following weeks
# - Third (optional) restriction: The group contains of 22 males and 43 females. Besides the first two restrictions, it would be ideal to keep the male/female ration the same across all the teams. However, this might be hard to sustain after a few rounds, so it's not a priority. It would just
@miketwo
miketwo / keybase.md
Last active September 21, 2019 22:53
Keybase proof

Keybase proof

I hereby claim:

  • I am miketwo on github.
  • I am miketwo (https://keybase.io/miketwo) on keybase.
  • I have a public key ASD11r0dn6Hh-fEa8iIuyFDjgdqXqoBLlh_nwCw9OxiZ7wo

To claim this, I am signing this object: