Last active
April 16, 2017 02:47
-
-
Save moratorium08/57d823ddb87db2be5de9bb3ad15852ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| from itertools import permutations | |
| filename = "data.tsv" | |
| signames = ["CTF分科会", "競技プログラミング分科会", | |
| "インフラ(Go/Docker他)分科会", "機械学習分科会"] | |
| daynames = "火水木金" | |
| sigs_d = dict([(x, i) for i, x in enumerate(signames)]) | |
| days_d = dict([(x, i) for i, x in enumerate(daynames)]) | |
| mentors = [[3, 4, 5], [1, 3], [0, 1, 2], [1, 2, 3, 4]] | |
| mentors = [[x-1 for x in y] for y in mentors] | |
| with open(filename, "r") as f: | |
| l = f.read().strip("\n").split("\n") | |
| l = [x.split("\t") for x in l[1:]] | |
| persons = [] | |
| for p in l: | |
| sigs = p[2].split(", ") | |
| sigs = [sigs_d[x] for x in sigs if x != "初心者分科会"] | |
| days = p[3].split(", ") | |
| days = [days_d[x] for x in days if x != "月"] | |
| persons.append((days, sigs)) | |
| mn = 987654321 | |
| mx = 0 | |
| best_pattern = None | |
| best_pattern_detail = [[], [], [], []] | |
| for pattern in permutations(range(len(signames))): | |
| flag = False | |
| for day, sig in enumerate(pattern): | |
| mentor = mentors[sig] | |
| if day not in mentor: | |
| flag = True | |
| break | |
| if flag: | |
| continue | |
| cnt = 0 | |
| tmp = [[], [], [], []] | |
| for day, sig in enumerate(pattern): | |
| for idx, person in enumerate(persons): | |
| if sig in person[1] and day in person[0]: | |
| tmp[sig].append(idx) | |
| cnt += 1 | |
| if mx < cnt: | |
| mn = cnt | |
| best_pattern = pattern[:] | |
| best_pattern_detail = tmp | |
| print("score", mn) | |
| for day, x in zip(daynames, best_pattern): | |
| print(day, signames[x]) | |
| print(best_pattern_detail[x]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment