solution for finding pairs of cards #13

Open
julioro wants to merge 1 commit from julioro/2025-plovdiv-data:match_tarot into main
Showing only changes of commit 701a6cdb9e - Show all commits

View file

@ -27,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"id": "cf05b9c4",
"metadata": {},
"outputs": [
@ -36,9 +36,9 @@
"output_type": "stream",
"text": [
"-- 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 Hanged Man', 'The Emperor', 'Death', 'The Hierophant', 'The Magician', 'Strength', 'The Sun', 'Temperance', 'The World', 'The Lovers', 'The Moon', 'The Devil', 'The Hermit', 'Judgement', 'Justice', 'Wheel of Fortune', 'The Empress', 'The Fool', 'The Chariot', 'The Tower', 'The Star', 'The High Priestess']\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"
" ['The Hermit', 'The High Priestess', 'The Magician', 'The Hanged Man', 'Judgement', 'The Lovers', 'The Emperor', 'The Sun', 'The Tower', 'The Chariot', 'The Moon', 'Wheel of Fortune', 'The World', 'Temperance', 'The Empress', 'The Devil', 'Strength', 'Death', 'The Hierophant', 'The Star', 'Justice', 'The Fool']\n"
]
}
],
@ -69,19 +69,101 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "48eb31e2",
"metadata": {},
"outputs": [],
"source": []
"source": [
"def find_idx(card_name, deck1, deck2): \n",
" \n",
" idx1 = 0\n",
" for i,card in enumerate(deck1):\n",
" if card_name == card:\n",
" idx1 = i\n",
" break\n",
" idx2 = 0\n",
" for i, card in enumerate(deck2):\n",
" if card_name == card:\n",
" idx2 = i\n",
" break\n",
" \n",
" return (idx1,idx2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "c854c656-b41e-43ca-9fa1-e06b04b33944",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(0, 3),\n",
" (1, 6),\n",
" (2, 17),\n",
" (3, 18),\n",
" (4, 2),\n",
" (5, 16),\n",
" (6, 7),\n",
" (7, 13),\n",
" (8, 12),\n",
" (9, 5),\n",
" (10, 10),\n",
" (11, 15),\n",
" (12, 0),\n",
" (13, 4),\n",
" (14, 20),\n",
" (15, 11),\n",
" (16, 14),\n",
" (17, 21),\n",
" (18, 9),\n",
" (19, 8),\n",
" (20, 19),\n",
" (21, 1)]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"deck1_dict = {card: i for i,card in enumerate(deck1)}\n",
"deck2_dict = {card: i for i,card in enumerate(deck2)}\n",
"\n",
"idx_pairs = []\n",
"for card,idx1 in deck1_dict.items():\n",
" idx2 = deck2_dict[card]\n",
"\n",
" idx_pairs.append((idx1,idx2))\n",
"\n",
"idx_pairs\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "509dda71",
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/plain": [
"(17, 21)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"card_name = \"The Fool\"\n",
"\n",
"find_idx(card_name, deck1, deck2)"
]
}
],
"metadata": {
@ -100,7 +182,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.13.7"
}
},
"nbformat": 4,