{ "cells": [ { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "weeks = range(1,11)\n", "max_apperances = 5\n", "import numpy as np\n", "max_apperances_lib = 3\n", "JUDGES = [\"Hunter\", \"Lib\", \"Matthew\", \n", " \"Paul\", \"Freddy\", \"Taylor\",\n", " \"Griffin\", \"Regina\", \"Elizabeth\", 'Guest']" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ "cant_go = {'Hunter': [6],\n", " 'Regina': [1,3,4,5,6],\n", " 'Paul': [10],\n", " \"Lib\": [],\n", " 'Matthew': [2],\n", " 'Freddy': [1,2,3,4],\n", " 'Taylor': [],\n", " 'Griffin': [],\n", " 'Elizabeth': [1],\n", " 'Guest': [1,2] \n", " }" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import datetime\n", "def generate_tuesdays(start_date=datetime.date(2016,6,21)):\n", " \"\"\"Generates a list of tuesdays for 10 weeks starting with start date\"\"\"\n", " ret = {}\n", " for week in weeks:\n", " ret[week] = (start_date + datetime.timedelta(7 * week) - datetime.timedelta(7))\n", " return ret" ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "collapsed": false }, "outputs": [], "source": [ "def select_judge(judges, week):\n", " \"\"\"Returns a judge valid for the week\"\"\"\n", " judge = np.random.choice(judges)\n", " judge_can_go = week not in cant_go[judge]\n", " if judge_can_go:\n", " return judge\n", " else:\n", " copy = list(judges)\n", " copy.remove(judge)\n", " return select_judge(copy, week)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{1: datetime.date(2016, 6, 21),\n", " 2: datetime.date(2016, 6, 28),\n", " 3: datetime.date(2016, 7, 5),\n", " 4: datetime.date(2016, 7, 12),\n", " 5: datetime.date(2016, 7, 19),\n", " 6: datetime.date(2016, 7, 26),\n", " 7: datetime.date(2016, 8, 2),\n", " 8: datetime.date(2016, 8, 9),\n", " 9: datetime.date(2016, 8, 16),\n", " 10: datetime.date(2016, 8, 23)}" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "generate_tuesdays()" ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "collapsed": false }, "outputs": [], "source": [ "def generate_theme_round(judges, weeks):\n", " theme_round = {}\n", " for week in weeks:\n", " try:\n", " judge = select_judge(judges, week)\n", " theme_round[week] = judge\n", " judges.remove(judge)\n", " except ValueError:\n", " theme_round[week] = \"Andrew\"\n", " return theme_round" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{1: 'Lib',\n", " 2: 'Regina',\n", " 3: 'Griffin',\n", " 4: 'Matthew',\n", " 5: 'Paul',\n", " 6: 'Elizabeth',\n", " 7: 'Guest',\n", " 8: 'Taylor',\n", " 9: 'Hunter',\n", " 10: 'Andrew'}" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "judges_raw = [\"Hunter\", \"Lib\", \"Matthew\", \n", " \"Paul\", \"Freddy\", \"Taylor\",\n", " \"Griffin\", \"Regina\", \"Elizabeth\", 'Guest']\n", "theme_round = generate_theme_round(judges_raw, weeks) \n", "theme_round" ] }, { "cell_type": "code", "execution_count": 69, "metadata": { "collapsed": false }, "outputs": [], "source": [ "def pick_week(judges, week):\n", " \"\"\"Picks 4 judges for the week\"\"\"\n", " lineup = []\n", " while len(lineup) < 4:\n", " judge = select_judge(judges, week)\n", " # check if judge has theme, remove to list\n", " if theme_round[week] == 'judge':\n", " #print(\"judge has theme\")\n", " pass\n", " if judge in lineup:\n", " #print(\"judge in lineup\")\n", " pass\n", " else:\n", " lineup.append(judge)\n", " return lineup" ] }, { "cell_type": "code", "execution_count": 79, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "['Griffin', 'Taylor', 'Matthew', 'Paul']" ] }, "execution_count": 79, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pick_week(JUDGES, 1)" ] }, { "cell_type": "code", "execution_count": 80, "metadata": { "collapsed": false }, "outputs": [ { "ename": "SyntaxError", "evalue": "invalid syntax (, line 4)", "output_type": "error", "traceback": [ "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m4\u001b[0m\n\u001b[0;31m pick_week(judges, week))\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" ] } ], "source": [ "def make_schedule(judges, weeks, theme_round=theme_round):\n", " schedule = {}\n", " for week in weeks: \n", " pick_week(judges, week))\n", " " ] }, { "cell_type": "code", "execution_count": 84, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['Hunter', 'Matthew', 'Griffin', 'Paul']\n", "['Regina', 'Elizabeth', 'Lib', 'Paul']\n", "['Taylor', 'Elizabeth', 'Hunter', 'Matthew']\n", "['Matthew', 'Lib', 'Taylor', 'Paul']\n", "['Lib', 'Paul', 'Taylor', 'Guest']\n", "['Taylor', 'Griffin', 'Freddy', 'Paul']\n", "['Freddy', 'Regina', 'Elizabeth', 'Hunter']\n", "['Lib', 'Guest', 'Griffin', 'Hunter']\n", "['Freddy', 'Hunter', 'Regina', 'Taylor']\n", "['Elizabeth', 'Regina', 'Freddy', 'Guest']\n" ] } ], "source": [ "make_schedule(JUDGES, weeks)" ] }, { "cell_type": "code", "execution_count": 82, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "['Paul', 'Hunter', 'Regina', 'Taylor']" ] }, "execution_count": 82, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pick_week(JUDGES, 2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.1" } }, "nbformat": 4, "nbformat_minor": 0 }