Skip to content

Instantly share code, notes, and snippets.

@MikeTrizna
Last active February 13, 2022 18:31
Show Gist options
  • Save MikeTrizna/353e9d0b7e67f869983e01d68143bd8a to your computer and use it in GitHub Desktop.
Save MikeTrizna/353e9d0b7e67f869983e01d68143bd8a to your computer and use it in GitHub Desktop.
0 1 2 3 4 5 6 7 8 9
0 Elliott Mom Natalie Bill Carla Carla Sam Christopher Sule Elliott
1 Michael Jessica Sam Andrew Sule Bill Natalie Christopher EVERYONE Andrew
2 Bill Elliott Andrew Katie Mom Wynn Mom Mom Dad EVERYONE
3 Wynn Carla Lauren Sarah Bill Jessica Sam Jessica Wynn Katie
4 Wynn Sule Jessica Dad Mom Michael Bill Lauren Natalie Dad
5 Mom Michael Lauren Michael Natalie Wynn Sarah Sarah Wynn Katie
6 Michael Natalie Jessica Michael Carla Lauren Bill EVERYONE Katie Sam
7 Carla Sam EVERYONE Jessica Dad Natalie Dad Katie Sarah Christopher
8 Andrew Sule Sule Sarah Andrew Dad Elliott Sule Lauren Sam
9 Sarah Lauren Christopher Carla Katie Elliott Christopher Andrew Elliott Christopher
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Super Bowl 2022 Squares"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-07T15:58:52.298163Z",
"start_time": "2021-02-07T15:58:51.465217Z"
}
},
"outputs": [],
"source": [
"import random\n",
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First, creating the list of players"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-07T15:58:52.302552Z",
"start_time": "2021-02-07T15:58:52.299798Z"
}
},
"outputs": [],
"source": [
"player_list = ['Dad','Carla',\n",
" 'Mom', 'Bill',\n",
" 'Michael', 'Natalie','Elliott',\n",
" 'Jessica', 'Sam',\n",
" 'Andrew', 'Wynn',\n",
" 'Christopher',\n",
" 'Katie', 'Sule',\n",
" 'Lauren', 'Sarah']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are 16 names in the list. 100 divided by 16 is 6 and a little change. So now we'll make a list with each name duplicated 6 times."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-07T15:58:52.308682Z",
"start_time": "2021-02-07T15:58:52.305065Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Dad', 'Dad', 'Dad', 'Dad', 'Dad', 'Dad', 'Carla', 'Carla', 'Carla', 'Carla', 'Carla', 'Carla', 'Mom', 'Mom', 'Mom', 'Mom', 'Mom', 'Mom', 'Bill', 'Bill']\n"
]
}
],
"source": [
"squares_list = [name for name in player_list for _ in range(0,6)]\n",
"print(squares_list[:20])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"After doing this, we've got 98 squares."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-07T15:58:52.318709Z",
"start_time": "2021-02-07T15:58:52.310359Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"96"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(squares_list)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"98 squares means that 2 will be left blank, so let's just fill those with EVERYONE. Not sure how we'll handle that if one of these squares wins, but we'll deal with that later."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"fill_in = ['EVERYONE' for i in range(4)]"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-07T15:58:52.327100Z",
"start_time": "2021-02-07T15:58:52.321520Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"100"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"squares_list += fill_in\n",
"len(squares_list)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Since we're about to randomize the order of the list, we need to set a seed so that it will give the same random order every time."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-07T15:58:52.333078Z",
"start_time": "2021-02-07T15:58:52.329432Z"
}
},
"outputs": [],
"source": [
"random.seed(2022)\n",
"random.shuffle(squares_list)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Printing the first 20 items in the list looks like it worked..."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-07T15:58:52.338354Z",
"start_time": "2021-02-07T15:58:52.334855Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Elliott', 'Mom', 'Natalie', 'Bill', 'Carla', 'Carla', 'Sam', 'Christopher', 'Sule', 'Elliott', 'Michael', 'Jessica', 'Sam', 'Andrew', 'Sule', 'Bill', 'Natalie', 'Christopher', 'EVERYONE', 'Andrew']\n"
]
}
],
"source": [
"print(squares_list[:20])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here's the hard part. I had to reshape the list into a 10x10 numpy array with *reshape*, and then turn that into a Pandas dataframe for nice display and output."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-07T15:58:52.369610Z",
"start_time": "2021-02-07T15:58:52.343123Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" <th>6</th>\n",
" <th>7</th>\n",
" <th>8</th>\n",
" <th>9</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Jessica</td>\n",
" <td>Mom</td>\n",
" <td>Natalie</td>\n",
" <td>Bill</td>\n",
" <td>Carla</td>\n",
" <td>Carla</td>\n",
" <td>Andrew</td>\n",
" <td>Katie</td>\n",
" <td>Lauren</td>\n",
" <td>Jessica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Michael</td>\n",
" <td>Sam</td>\n",
" <td>Andrew</td>\n",
" <td>Wynn</td>\n",
" <td>Lauren</td>\n",
" <td>Bill</td>\n",
" <td>Natalie</td>\n",
" <td>Katie</td>\n",
" <td>EVERYONE</td>\n",
" <td>Wynn</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Bill</td>\n",
" <td>Jessica</td>\n",
" <td>Wynn</td>\n",
" <td>Sule</td>\n",
" <td>Mom</td>\n",
" <td>Christopher</td>\n",
" <td>Mom</td>\n",
" <td>Mom</td>\n",
" <td>Dad</td>\n",
" <td>EVERYONE</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Christopher</td>\n",
" <td>Carla</td>\n",
" <td>Sarah</td>\n",
" <td>EVERYONE</td>\n",
" <td>Bill</td>\n",
" <td>Sam</td>\n",
" <td>Andrew</td>\n",
" <td>Sam</td>\n",
" <td>Christopher</td>\n",
" <td>Sule</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Christopher</td>\n",
" <td>Lauren</td>\n",
" <td>Sam</td>\n",
" <td>Dad</td>\n",
" <td>Mom</td>\n",
" <td>Michael</td>\n",
" <td>Bill</td>\n",
" <td>Sarah</td>\n",
" <td>Natalie</td>\n",
" <td>Dad</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Mom</td>\n",
" <td>Michael</td>\n",
" <td>Sarah</td>\n",
" <td>Michael</td>\n",
" <td>Natalie</td>\n",
" <td>Christopher</td>\n",
" <td>EVERYONE</td>\n",
" <td>EVERYONE</td>\n",
" <td>Christopher</td>\n",
" <td>Sule</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Michael</td>\n",
" <td>Natalie</td>\n",
" <td>Sam</td>\n",
" <td>Michael</td>\n",
" <td>Carla</td>\n",
" <td>Sarah</td>\n",
" <td>Bill</td>\n",
" <td>EVERYONE</td>\n",
" <td>Sule</td>\n",
" <td>Andrew</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Carla</td>\n",
" <td>Andrew</td>\n",
" <td>EVERYONE</td>\n",
" <td>Sam</td>\n",
" <td>Dad</td>\n",
" <td>Natalie</td>\n",
" <td>Dad</td>\n",
" <td>Sule</td>\n",
" <td>EVERYONE</td>\n",
" <td>Katie</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Wynn</td>\n",
" <td>Lauren</td>\n",
" <td>Lauren</td>\n",
" <td>EVERYONE</td>\n",
" <td>Wynn</td>\n",
" <td>Dad</td>\n",
" <td>Jessica</td>\n",
" <td>Lauren</td>\n",
" <td>Sarah</td>\n",
" <td>Andrew</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>EVERYONE</td>\n",
" <td>Sarah</td>\n",
" <td>Katie</td>\n",
" <td>Carla</td>\n",
" <td>Sule</td>\n",
" <td>Jessica</td>\n",
" <td>Katie</td>\n",
" <td>Wynn</td>\n",
" <td>Jessica</td>\n",
" <td>Katie</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2 3 4 5 6 \\\n",
"0 Jessica Mom Natalie Bill Carla Carla Andrew \n",
"1 Michael Sam Andrew Wynn Lauren Bill Natalie \n",
"2 Bill Jessica Wynn Sule Mom Christopher Mom \n",
"3 Christopher Carla Sarah EVERYONE Bill Sam Andrew \n",
"4 Christopher Lauren Sam Dad Mom Michael Bill \n",
"5 Mom Michael Sarah Michael Natalie Christopher EVERYONE \n",
"6 Michael Natalie Sam Michael Carla Sarah Bill \n",
"7 Carla Andrew EVERYONE Sam Dad Natalie Dad \n",
"8 Wynn Lauren Lauren EVERYONE Wynn Dad Jessica \n",
"9 EVERYONE Sarah Katie Carla Sule Jessica Katie \n",
"\n",
" 7 8 9 \n",
"0 Katie Lauren Jessica \n",
"1 Katie EVERYONE Wynn \n",
"2 Mom Dad EVERYONE \n",
"3 Sam Christopher Sule \n",
"4 Sarah Natalie Dad \n",
"5 EVERYONE Christopher Sule \n",
"6 EVERYONE Sule Andrew \n",
"7 Sule EVERYONE Katie \n",
"8 Lauren Sarah Andrew \n",
"9 Wynn Jessica Katie "
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"squares_df = pd.DataFrame(np.array(squares_list).reshape(10,10))\n",
"squares_df"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"squares_df.to_csv('squares.csv')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"gist": {
"data": {
"description": "Super Bowl 2021 Squares",
"public": true
},
"id": ""
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment