Created
November 20, 2022 17:06
-
-
Save bogovicj/35ad1c8c4dc66054bb77240bc158528d 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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 138, | |
"id": "d502b27e", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"teams = {\n", | |
" \"ec\" : \"ecuador\",\n", | |
" \"qa\" : \"qatar\",\n", | |
" \"en\": \"england\",\n", | |
" \"ir\": \"iran\",\n", | |
" \"se\": \"senegal\",\n", | |
" \"ne\": \"netherlands\",\n", | |
" \"us\": \"usa\",\n", | |
" \"wa\": \"wales\",\n", | |
" \"ar\": \"argentina\",\n", | |
" \"sa\": \"saudiarabia\",\n", | |
" \"de\": \"denmark\",\n", | |
" \"tu\": \"tunisia\",\n", | |
" \"me\": \"mexico\",\n", | |
" \"po\": \"poland\",\n", | |
" \"fr\": \"france\",\n", | |
" \"au\": \"australia\",\n", | |
" \"mo\": \"morocco\",\n", | |
" \"cr\": \"croatia\",\n", | |
" \"ge\": \"germany\",\n", | |
" \"ja\": \"japan\",\n", | |
" \"sp\": \"spain\",\n", | |
" \"cr\": \"costarica\",\n", | |
" \"be\": \"belgium\",\n", | |
" \"ca\": \"canada\",\n", | |
" \"sw\": \"switzerland\",\n", | |
" \"cm\": \"cameroon\",\n", | |
" \"ur\": \"uruguay\",\n", | |
" \"ko\": \"korearepublic\",\n", | |
" \"po\": \"portugal\",\n", | |
" \"gh\": \"ghana\",\n", | |
" \"br\": \"brazil\",\n", | |
" \"sr\": \"serbia\"\n", | |
"}" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 139, | |
"id": "693b0336", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import random\n", | |
"random.seed(2022)\n", | |
"\n", | |
"def match( away, home ):\n", | |
" home = teams[home] if (home in teams) else home\n", | |
" away = teams[away] if (away in teams) else away\n", | |
" h = list(home)\n", | |
" a = list(away)\n", | |
" random.shuffle(h)\n", | |
" random.shuffle(a)\n", | |
" tie = abs( ord(h[0]) - ord(a[0]) ) > 12\n", | |
" print(\"tie\" if tie else (home if h < a else away))\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 140, | |
"id": "c1a40736", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"ecuador\n" | |
] | |
} | |
], | |
"source": [ | |
"# Sunday\n", | |
"match(\"ec\", \"qa\")" | |
] | |
} | |
], | |
"metadata": { | |
"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.9.13" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment