From 9348255a21ddf6a142e72e30774df5a3fbdb07b1 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Mon, 28 Jan 2013 08:23:31 -0700 Subject: [PATCH] Add class registration script --- doc/2013-02-TF5/classes.py | 63 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 doc/2013-02-TF5/classes.py diff --git a/doc/2013-02-TF5/classes.py b/doc/2013-02-TF5/classes.py new file mode 100755 index 0000000..1692f59 --- /dev/null +++ b/doc/2013-02-TF5/classes.py @@ -0,0 +1,63 @@ +#! /usr/bin/python3 + +import sys + +limits = { + "net": 100, + "mal": 60, + "hst": 60, + "icc": 40, + "nil": 9000, + ":-(": 9000, +} + +# Read in allowed substring list +allowed = [] +for line in open("approved.txt"): + allowed.append(line.strip()) + +# Read in registration data +registrants = [] +regs = {} +for line in open("reg.txt"): + line = line.strip('\n') + ok = False + for a in allowed: + if a in line: + ok = True + break + name, email, org, c1, c2, _ = line.split('\t') + if not ok: + c1 = c2 = "nil" + + if email not in registrants: + registrants.append(email) + regs[email] = (name, org, c1, c2) + +# Divvy out classes +which = {} +counts = [0, 0, 0] +for email in registrants: + r = regs.get(email) + name, org, c1, c2 = regs[email] + c = [c1, c2, ":-("] + + for i in range(3): + w = c[i] + if limits[w] > 0: + which[email] = i + limits[w] -= 1 + counts[i] += 1 + break + + try: + oldreg = open(email).read() + except: + oldreg = None + + if oldreg != w: + print(w, email) + open(email, "w").write(w) + +print("%d got 1st choice, %d got 2nd choice, %d got screwed" % + (counts[0], counts[1], counts[2]))