exercise 1 answer #15

Open
simoneci wants to merge 1 commit from simoneci/2025-plovdiv-data:ex1 into main

View file

@ -27,7 +27,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 1,
"id": "cf05b9c4", "id": "cf05b9c4",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -36,9 +36,9 @@
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"-- Deck 1: --\n", "-- Deck 1: --\n",
" ['The Lovers', 'Temperance', 'The Emperor', 'The Sun', 'The Fool', 'The Chariot', 'Death', 'Strength', 'Justice', 'The Star', 'Judgement', 'The World', 'The Tower', 'The Hanged Man', 'The Empress', 'The Hermit', 'The Devil', 'The High Priestess', 'The Moon', 'The Hierophant', 'Wheel of Fortune', 'The Magician']\n", " ['The Lovers', 'Wheel of Fortune', 'Strength', 'The Moon', 'The Emperor', 'The Star', 'The High Priestess', 'The Hanged Man', 'The Sun', 'The Devil', 'The Empress', 'The Fool', 'The Chariot', 'The Magician', 'Judgement', 'The World', 'Temperance', 'The Hermit', 'The Hierophant', 'The Tower', 'Death', 'Justice']\n",
"-- Deck 2: --\n", "-- Deck 2: --\n",
" ['The Fool', 'Death', 'The Hermit', 'Strength', 'The Moon', 'Wheel of Fortune', 'Judgement', 'The Lovers', 'The Star', 'The Hanged Man', 'The Empress', 'The Emperor', 'The Magician', 'The Tower', 'The Hierophant', 'The Chariot', 'The High Priestess', 'Temperance', 'The World', 'The Devil', 'The Sun', 'Justice']\n" " ['Judgement', 'The High Priestess', 'The Moon', 'The World', 'The Hermit', 'The Star', 'The Hierophant', 'Death', 'The Hanged Man', 'The Devil', 'The Emperor', 'The Empress', 'The Tower', 'Temperance', 'Justice', 'The Fool', 'Strength', 'The Magician', 'The Lovers', 'Wheel of Fortune', 'The Sun', 'The Chariot']\n"
] ]
} }
], ],
@ -70,7 +70,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "48eb31e2", "id": "58d631bc-84ae-4715-8468-db6d01eb1539",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []
@ -78,9 +78,100 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "8674444d-47d2-4137-8d5c-4d31a20c8f33",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"id": "48eb31e2",
"metadata": {},
"outputs": [],
"source": [
"def make_dict_deck(deck):\n",
" dict_deck = {}\n",
" for i in range(len(deck)):\n",
" name = deck[i]\n",
" dict_deck[name] = i\n",
" return dict_deck"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "3f925be7-9cf3-40b7-9597-929729e62c42",
"metadata": {},
"outputs": [],
"source": [
"def compare_decks(dict1, dict2):\n",
" indeces = []\n",
" for name in dict1.keys():\n",
" if name in dict2.keys():\n",
" indeces.append((dict1[name], dict2[name]))\n",
" return indeces"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "509dda71", "id": "509dda71",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [
"dict1 = make_dict_deck(deck1)\n",
"dict2 = make_dict_deck(deck2)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "a54c0d47-609f-4860-92bc-96787514e293",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(0, 18),\n",
" (1, 19),\n",
" (2, 16),\n",
" (3, 2),\n",
" (4, 10),\n",
" (5, 5),\n",
" (6, 1),\n",
" (7, 8),\n",
" (8, 20),\n",
" (9, 9),\n",
" (10, 11),\n",
" (11, 15),\n",
" (12, 21),\n",
" (13, 17),\n",
" (14, 0),\n",
" (15, 3),\n",
" (16, 13),\n",
" (17, 4),\n",
" (18, 6),\n",
" (19, 12),\n",
" (20, 7),\n",
" (21, 14)]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"compare_decks(dict1, dict2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "81541f74-bf7a-4203-b3ab-67a3962ad72d",
"metadata": {},
"outputs": [],
"source": [] "source": []
} }
], ],
@ -100,7 +191,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.11.5" "version": "3.13.6"
} }
}, },
"nbformat": 4, "nbformat": 4,