From 3cca01e097cfe16a8896b6d053a590d47cfa41d4 Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Wed, 24 Sep 2025 10:47:09 +0300 Subject: [PATCH] implemented matching --- exercises/match_tarots/match_tarots.ipynb | 73 ++++++++++++++++++++--- 1 file changed, 65 insertions(+), 8 deletions(-) diff --git a/exercises/match_tarots/match_tarots.ipynb b/exercises/match_tarots/match_tarots.ipynb index c35f220..b7292be 100644 --- a/exercises/match_tarots/match_tarots.ipynb +++ b/exercises/match_tarots/match_tarots.ipynb @@ -27,7 +27,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "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 Hierophant', 'Temperance', 'Wheel of Fortune', 'The Star', 'The Sun', 'The Tower', 'The Moon', 'Strength', 'The Hanged Man', 'The Hermit', 'The Devil', 'The Fool', 'The Magician', 'The Empress', 'Justice', 'The Lovers', 'The Emperor', 'The Chariot', 'The World', 'Judgement', 'Death', '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" + " ['Wheel of Fortune', 'Justice', 'The World', 'Temperance', 'The Fool', 'The Tower', 'The Sun', 'The Moon', 'The Chariot', 'The Devil', 'The Empress', 'The Hanged Man', 'Strength', 'Judgement', 'The Hierophant', 'The Lovers', 'The Emperor', 'The Magician', 'The Hermit', 'The Star', 'The High Priestess', 'Death']\n" ] } ], @@ -69,24 +69,81 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "48eb31e2", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "def match_cards(deck1_, deck2_):\n", + " res = []\n", + " for i,card in enumerate(deck1_):\n", + " idx2 = deck2_.index(card)\n", + " res.append((i,idx2))\n", + " return set(res)" + ] }, { "cell_type": "code", "execution_count": null, - "id": "509dda71", + "id": "01932720", "metadata": {}, "outputs": [], + "source": [ + "#O(n^2)??" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "6dc5dbcf", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{(0, 14),\n", + " (1, 3),\n", + " (2, 0),\n", + " (3, 19),\n", + " (4, 6),\n", + " (5, 5),\n", + " (6, 7),\n", + " (7, 12),\n", + " (8, 11),\n", + " (9, 18),\n", + " (10, 9),\n", + " (11, 4),\n", + " (12, 17),\n", + " (13, 10),\n", + " (14, 1),\n", + " (15, 15),\n", + " (16, 16),\n", + " (17, 8),\n", + " (18, 2),\n", + " (19, 13),\n", + " (20, 21),\n", + " (21, 20)}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "match_cards(deck1,deck2)" + ] + }, + { + "cell_type": "markdown", + "id": "509dda71", + "metadata": {}, "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -100,7 +157,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.13.6" } }, "nbformat": 4,