🎨 Add Blazor, BDD, crypto, java and kotlin tp

master
Antoine PEREDERII 1 year ago
parent 2d20fa5cf4
commit 19ecdf6238

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

@ -0,0 +1,330 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "a35eeb9f-df70-4ab1-a243-2d2025888eb0",
"metadata": {},
"source": [
"# Exercice 1\n",
"2) Écrire une fonction qui prend en entrée n et x et qui calcule si possible linverse modulo n dun nombre x. Vous pouvez pour cela utiliser la commande pow(a,b,c) de Python ou, si votre version de Python est trop vieille, la commande mod_inverse(a,b) de la librairie sympy.\n",
"Vous aurez peut-être aussi lusage de la commande gcd(a,b) de la librairie math."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "cfbd26eb-d3d4-48e2-afb0-b601390cc4d4",
"metadata": {},
"outputs": [],
"source": [
"import math"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "75966219-9371-4df9-ad40-a8100fca47c5",
"metadata": {},
"outputs": [],
"source": [
"def calcul_modulo(n, x) :\n",
" if math.gcd(x,n) != 1 :\n",
" return \"Le pgcd n'est pas égale à 1\"\n",
" else :\n",
" return pow(x, -1, mod=n)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "2803c754-77e2-4a23-b83d-5df43bf6d459",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5\n"
]
}
],
"source": [
"print(calcul_modulo(8,5))"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "54326ddc-7fdf-4d13-92f9-c75b9a71693d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2\n"
]
}
],
"source": [
"print(calcul_modulo(5,3))"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "c684d56b-9fab-45a8-a422-fd1392e6f280",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3\n"
]
}
],
"source": [
"print(calcul_modulo(11,4))"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "ccd9ff86-7bd4-430f-a032-256fc51b7a37",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Le pgcd n'est pas égale à 1\n"
]
}
],
"source": [
"print(calcul_modulo(8,4))"
]
},
{
"cell_type": "markdown",
"id": "c4aef01f-9b8e-46ec-b255-c611f9f64d21",
"metadata": {},
"source": [
"## Exercice 2"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "46534487-9c13-4d77-b362-10976f5eda01",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"8\n"
]
}
],
"source": [
"print(calcul_modulo(17,66))"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "2fc00a68-5c49-4e89-9558-a821f038eb2d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4\n"
]
}
],
"source": [
"print(calcul_modulo(11,102))"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "6355d03c-9fe0-4b19-b159-b77c81232218",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n"
]
}
],
"source": [
"print(calcul_modulo(6,187))"
]
},
{
"cell_type": "markdown",
"id": "8bf3422a-a84b-4c49-afe9-8c6e394ec263",
"metadata": {},
"source": [
"3) Écrivez une fonction permettant deffectuer ces calculs pour nimporte quelles équations modulaires satisfaisant les hypothèses du théorème des restes chinois, sur la donnée de la liste des restes et de la liste des modules. Vous aurez peut-être lusage des opérateurs // (division entière) et % (reste modulaire) de Python."
]
},
{
"cell_type": "code",
"execution_count": 53,
"id": "8b85c20c-0720-4c0a-81e8-33db4b5b055c",
"metadata": {},
"outputs": [],
"source": [
"def TRC(listRest, listMod) :\n",
" if len(listRest) != len(listMod):\n",
" return \"Erreur, les lists ne font pas la meme taille\"\n",
" \n",
" n = 1\n",
" somme = 0\n",
" \n",
" for i in range(0, len(listMod)) :\n",
" n = n * listMod[i]\n",
" if math.gcd(listMod[i-1],listMod[i]) != 1 :\n",
" return \"erreur PGCD de \" + listMod[i-1] + \" et \" + listMod[i] + \" différent de 1\"\n",
" for i in range(0, len(listMod)) :\n",
" ai = listRest[i]\n",
" ni = listMod[i]\n",
" ei = (n//ni) * (calcul_modulo(ni,n//ni))\n",
" somme = somme + ai * ei\n",
" return somme % n"
]
},
{
"cell_type": "code",
"execution_count": 54,
"id": "b6ffcc2c-dde0-4e27-8807-c6336f440e14",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"785\n"
]
}
],
"source": [
"lr = [3, 4, 5]\n",
"lm = [17, 11, 6]\n",
"print(TRC(lr, lm))"
]
},
{
"cell_type": "code",
"execution_count": 69,
"id": "8aaa5a8b-aa93-4a0b-8fbb-b351c908cb7f",
"metadata": {},
"outputs": [],
"source": [
"def TRC(listRest, listMod):\n",
" if len(listRest) != len(listMod):\n",
" return \"Erreur, les listes n'ont pas la même taille\"\n",
"\n",
" n = math.prod(listMod)\n",
" res = 0\n",
"\n",
" for ai, ni in zip(listRest, listMod): \n",
" res += ai * (n//ni) * calcul_modulo(ni, n // ni)\n",
"\n",
" return res % n"
]
},
{
"cell_type": "code",
"execution_count": 70,
"id": "e0d02ef7-9bda-474f-8137-3209da4df274",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"785\n"
]
}
],
"source": [
"print(TRC(lr, lm))"
]
},
{
"cell_type": "code",
"execution_count": 81,
"id": "6ce01aee-04b6-4dae-a7d0-a46094b331ed",
"metadata": {},
"outputs": [],
"source": [
"def verif(mods):\n",
" for i in range(0, len(mods)) :\n",
" if math.gcd(mods[i-1],mods[i]) != 1 :\n",
" return \"erreur PGCD de \" + str(mods[i-1]) + \" et \" + str(mods[i]) + \" différent de 1\"\n",
" return \"Les modolus satisfait les conditions du TRC\""
]
},
{
"cell_type": "code",
"execution_count": 82,
"id": "28906ad4-853f-4245-8671-10d5ec8e1c24",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Les modolus satisfait les conditions du TRC\n",
"erreur PGCD de 3 et 6 différent de 1\n"
]
}
],
"source": [
"listMods = [3,5,7]\n",
"listMods2 = [3,6,7]\n",
"\n",
"print(verif(listMods))\n",
"print(verif(listMods2))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "98e25038-6b84-42e0-87df-1c9f87793e70",
"metadata": {},
"outputs": [],
"source": []
}
],
"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.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

@ -0,0 +1,330 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "a35eeb9f-df70-4ab1-a243-2d2025888eb0",
"metadata": {},
"source": [
"# Exercice 1\n",
"2) Écrire une fonction qui prend en entrée n et x et qui calcule si possible linverse modulo n dun nombre x. Vous pouvez pour cela utiliser la commande pow(a,b,c) de Python ou, si votre version de Python est trop vieille, la commande mod_inverse(a,b) de la librairie sympy.\n",
"Vous aurez peut-être aussi lusage de la commande gcd(a,b) de la librairie math."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "cfbd26eb-d3d4-48e2-afb0-b601390cc4d4",
"metadata": {},
"outputs": [],
"source": [
"import math"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "75966219-9371-4df9-ad40-a8100fca47c5",
"metadata": {},
"outputs": [],
"source": [
"def calcul_modulo(n, x) :\n",
" if math.gcd(x,n) != 1 :\n",
" return \"Le pgcd n'est pas égale à 1\"\n",
" else :\n",
" return pow(x, -1, mod=n)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "2803c754-77e2-4a23-b83d-5df43bf6d459",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5\n"
]
}
],
"source": [
"print(calcul_modulo(8,5))"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "54326ddc-7fdf-4d13-92f9-c75b9a71693d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2\n"
]
}
],
"source": [
"print(calcul_modulo(5,3))"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "c684d56b-9fab-45a8-a422-fd1392e6f280",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3\n"
]
}
],
"source": [
"print(calcul_modulo(11,4))"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "ccd9ff86-7bd4-430f-a032-256fc51b7a37",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Le pgcd n'est pas égale à 1\n"
]
}
],
"source": [
"print(calcul_modulo(8,4))"
]
},
{
"cell_type": "markdown",
"id": "c4aef01f-9b8e-46ec-b255-c611f9f64d21",
"metadata": {},
"source": [
"## Exercice 2"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "46534487-9c13-4d77-b362-10976f5eda01",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"8\n"
]
}
],
"source": [
"print(calcul_modulo(17,66))"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "2fc00a68-5c49-4e89-9558-a821f038eb2d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4\n"
]
}
],
"source": [
"print(calcul_modulo(11,102))"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "6355d03c-9fe0-4b19-b159-b77c81232218",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n"
]
}
],
"source": [
"print(calcul_modulo(6,187))"
]
},
{
"cell_type": "markdown",
"id": "8bf3422a-a84b-4c49-afe9-8c6e394ec263",
"metadata": {},
"source": [
"3) Écrivez une fonction permettant deffectuer ces calculs pour nimporte quelles équations modulaires satisfaisant les hypothèses du théorème des restes chinois, sur la donnée de la liste des restes et de la liste des modules. Vous aurez peut-être lusage des opérateurs // (division entière) et % (reste modulaire) de Python."
]
},
{
"cell_type": "code",
"execution_count": 53,
"id": "8b85c20c-0720-4c0a-81e8-33db4b5b055c",
"metadata": {},
"outputs": [],
"source": [
"def TRC(listRest, listMod) :\n",
" if len(listRest) != len(listMod):\n",
" return \"Erreur, les lists ne font pas la meme taille\"\n",
" \n",
" n = 1\n",
" somme = 0\n",
" \n",
" for i in range(0, len(listMod)) :\n",
" n = n * listMod[i]\n",
" if math.gcd(listMod[i-1],listMod[i]) != 1 :\n",
" return \"erreur PGCD de \" + listMod[i-1] + \" et \" + listMod[i] + \" différent de 1\"\n",
" for i in range(0, len(listMod)) :\n",
" ai = listRest[i]\n",
" ni = listMod[i]\n",
" ei = (n//ni) * (calcul_modulo(ni,n//ni))\n",
" somme = somme + ai * ei\n",
" return somme % n"
]
},
{
"cell_type": "code",
"execution_count": 54,
"id": "b6ffcc2c-dde0-4e27-8807-c6336f440e14",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"785\n"
]
}
],
"source": [
"lr = [3, 4, 5]\n",
"lm = [17, 11, 6]\n",
"print(TRC(lr, lm))"
]
},
{
"cell_type": "code",
"execution_count": 69,
"id": "8aaa5a8b-aa93-4a0b-8fbb-b351c908cb7f",
"metadata": {},
"outputs": [],
"source": [
"def TRC(listRest, listMod):\n",
" if len(listRest) != len(listMod):\n",
" return \"Erreur, les listes n'ont pas la même taille\"\n",
"\n",
" n = math.prod(listMod)\n",
" res = 0\n",
"\n",
" for ai, ni in zip(listRest, listMod): \n",
" res += ai * (n//ni) * calcul_modulo(ni, n // ni)\n",
"\n",
" return res % n"
]
},
{
"cell_type": "code",
"execution_count": 70,
"id": "e0d02ef7-9bda-474f-8137-3209da4df274",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"785\n"
]
}
],
"source": [
"print(TRC(lr, lm))"
]
},
{
"cell_type": "code",
"execution_count": 81,
"id": "6ce01aee-04b6-4dae-a7d0-a46094b331ed",
"metadata": {},
"outputs": [],
"source": [
"def verif(mods):\n",
" for i in range(0, len(mods)) :\n",
" if math.gcd(mods[i-1],mods[i]) != 1 :\n",
" return \"erreur PGCD de \" + str(mods[i-1]) + \" et \" + str(mods[i]) + \" différent de 1\"\n",
" return \"Les modolus satisfait les conditions du TRC\""
]
},
{
"cell_type": "code",
"execution_count": 82,
"id": "28906ad4-853f-4245-8671-10d5ec8e1c24",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Les modolus satisfait les conditions du TRC\n",
"erreur PGCD de 3 et 6 différent de 1\n"
]
}
],
"source": [
"listMods = [3,5,7]\n",
"listMods2 = [3,6,7]\n",
"\n",
"print(verif(listMods))\n",
"print(verif(listMods2))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "98e25038-6b84-42e0-87df-1c9f87793e70",
"metadata": {},
"outputs": [],
"source": []
}
],
"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.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

@ -0,0 +1,255 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "a35eeb9f-df70-4ab1-a243-2d2025888eb0",
"metadata": {},
"source": [
"# Exercice 1\n",
"1) Codez une fonction qui permet de chiffrer avec le chiffrement parfait (C = M ⊕ K). Cette\n",
"fonction prend en entrée une clé et un message, tous deux sous forme de chaîne de caractères,\n",
"et sa sortie est également une chaîne de caractères. Vous aurez peut-être lusage de lopérateur\n",
"∧."
]
},
{
"cell_type": "code",
"execution_count": 59,
"id": "57595af7-bd28-427e-b407-eb0bf49f483a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"72"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ord('H')"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "06c3d56f-6872-4179-a1f8-e2a44ba117f3",
"metadata": {},
"outputs": [],
"source": [
"def bit(nombre, n):\n",
" resBin = [0]*n\n",
" i = 0\n",
" while nombre > 0:\n",
" resBin[n-1-i] = nombre%2\n",
" nombre = nombre // 2\n",
" i += 1\n",
" return resBin\n",
"\n",
"def sToBit(s):\n",
" return bit(ord(s),8)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "277ebad9-936c-4e84-9f3c-b45bb69dd388",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0, 1, 0, 0, 1, 0, 0, 0]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sToBit(\"H\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c1376cfe-4eae-4323-8ec2-6fd5e3504f68",
"metadata": {},
"outputs": [],
"source": [
"def stringToBit(string):\n",
" resBin = []\n",
" for i in string:\n",
" resBin.append(sToBit(i))\n",
" return resBin"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "6f9311ce-b1d9-458a-bdb7-ce9cd2dc8f32",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[[0, 1, 0, 0, 1, 0, 0, 0],\n",
" [0, 1, 1, 0, 0, 1, 0, 1],\n",
" [0, 1, 1, 0, 1, 1, 0, 0],\n",
" [0, 1, 1, 0, 1, 1, 0, 0],\n",
" [0, 1, 1, 0, 1, 1, 1, 1]]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"stringToBit(\"Hello\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "7b1e1f48-45e8-4b60-94c2-f3fa2a1ac7e8",
"metadata": {},
"outputs": [],
"source": [
"def chiffrement(cle, message):\n",
" cleBin = stringToBit(cle)\n",
" messageBin = stringToBit(message)\n",
" print(cleBin[0][0])\n",
" print(message)\n",
" res = \"\"\n",
" for i in range(len(message)):\n",
" for j in range(8):\n",
" res = res + str(cleBin[i][j] ^ messageBin[i][j])\n",
" return res"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "8515d99f-d0e2-4da5-a186-3ed78e233b02",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"Hello\n"
]
},
{
"data": {
"text/plain": [
"'0000101100000000000111110000110100011101'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"chiffrement(\"Cesar\", \"Hello\")"
]
},
{
"cell_type": "markdown",
"id": "9211c83a-2fde-4614-b066-36a1b09d9ff3",
"metadata": {},
"source": [
"# Exercice 2"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "bfd0dfc8-0ebb-4103-a12d-0ccfcdcb15aa",
"metadata": {},
"outputs": [],
"source": [
"def LSFR(s, c, nbtours):\n",
" i = 0\n",
" resTot = s\n",
" t = len(s)\n",
" while i < nbtours:\n",
" res = s[t]\n",
" j = t\n",
" \n",
" for j in range(t):\n",
" print(c[j])\n",
" res = res ^ c[j]\n",
" for j in range(t):\n",
" if i == 1:\n",
" resTot[0] = res\n",
" break\n",
" resTot[t - 1] = resTot[t - 2]\n",
" return resTot"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "a2bbdc83-30f3-4aca-9026-b2a2aba64171",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4\n",
"4\n",
"4\n",
"4\n"
]
},
{
"ename": "IndexError",
"evalue": "list index out of range",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[9], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m s \u001b[38;5;241m=\u001b[39m [\u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 2\u001b[0m c \u001b[38;5;241m=\u001b[39m [\u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m0\u001b[39m]\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mLSFR\u001b[49m\u001b[43m(\u001b[49m\u001b[43ms\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m10\u001b[39;49m\u001b[43m)\u001b[49m)\n",
"Cell \u001b[0;32mIn[8], line 6\u001b[0m, in \u001b[0;36mLSFR\u001b[0;34m(s, c, nbtours)\u001b[0m\n\u001b[1;32m 4\u001b[0m t \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlen\u001b[39m(s)\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m i \u001b[38;5;241m<\u001b[39m nbtours:\n\u001b[0;32m----> 6\u001b[0m res \u001b[38;5;241m=\u001b[39m \u001b[43ms\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\n\u001b[1;32m 7\u001b[0m j \u001b[38;5;241m=\u001b[39m t\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28mprint\u001b[39m(j)\n",
"\u001b[0;31mIndexError\u001b[0m: list index out of range"
]
}
],
"source": [
"s = [0, 0, 1, 0]\n",
"c = [1, 0, 1, 0]\n",
"print(LSFR(s, c, 10))"
]
}
],
"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.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

@ -0,0 +1,255 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "a35eeb9f-df70-4ab1-a243-2d2025888eb0",
"metadata": {},
"source": [
"# Exercice 1\n",
"1) Codez une fonction qui permet de chiffrer avec le chiffrement parfait (C = M ⊕ K). Cette\n",
"fonction prend en entrée une clé et un message, tous deux sous forme de chaîne de caractères,\n",
"et sa sortie est également une chaîne de caractères. Vous aurez peut-être lusage de lopérateur\n",
"∧."
]
},
{
"cell_type": "code",
"execution_count": 59,
"id": "57595af7-bd28-427e-b407-eb0bf49f483a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"72"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ord('H')"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "06c3d56f-6872-4179-a1f8-e2a44ba117f3",
"metadata": {},
"outputs": [],
"source": [
"def bit(nombre, n):\n",
" resBin = [0]*n\n",
" i = 0\n",
" while nombre > 0:\n",
" resBin[n-1-i] = nombre%2\n",
" nombre = nombre // 2\n",
" i += 1\n",
" return resBin\n",
"\n",
"def sToBit(s):\n",
" return bit(ord(s),8)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "277ebad9-936c-4e84-9f3c-b45bb69dd388",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0, 1, 0, 0, 1, 0, 0, 0]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sToBit(\"H\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c1376cfe-4eae-4323-8ec2-6fd5e3504f68",
"metadata": {},
"outputs": [],
"source": [
"def stringToBit(string):\n",
" resBin = []\n",
" for i in string:\n",
" resBin.append(sToBit(i))\n",
" return resBin"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "6f9311ce-b1d9-458a-bdb7-ce9cd2dc8f32",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[[0, 1, 0, 0, 1, 0, 0, 0],\n",
" [0, 1, 1, 0, 0, 1, 0, 1],\n",
" [0, 1, 1, 0, 1, 1, 0, 0],\n",
" [0, 1, 1, 0, 1, 1, 0, 0],\n",
" [0, 1, 1, 0, 1, 1, 1, 1]]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"stringToBit(\"Hello\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "7b1e1f48-45e8-4b60-94c2-f3fa2a1ac7e8",
"metadata": {},
"outputs": [],
"source": [
"def chiffrement(cle, message):\n",
" cleBin = stringToBit(cle)\n",
" messageBin = stringToBit(message)\n",
" print(cleBin[0][0])\n",
" print(message)\n",
" res = \"\"\n",
" for i in range(len(message)):\n",
" for j in range(8):\n",
" res = res + str(cleBin[i][j] ^ messageBin[i][j])\n",
" return res"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "8515d99f-d0e2-4da5-a186-3ed78e233b02",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"Hello\n"
]
},
{
"data": {
"text/plain": [
"'0000101100000000000111110000110100011101'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"chiffrement(\"Cesar\", \"Hello\")"
]
},
{
"cell_type": "markdown",
"id": "9211c83a-2fde-4614-b066-36a1b09d9ff3",
"metadata": {},
"source": [
"# Exercice 2"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "bfd0dfc8-0ebb-4103-a12d-0ccfcdcb15aa",
"metadata": {},
"outputs": [],
"source": [
"def LSFR(s, c, nbtours):\n",
" i = 0\n",
" resTot = s\n",
" t = len(s)\n",
" while i < nbtours:\n",
" res = s[t]\n",
" j = t\n",
" \n",
" for j in range(t):\n",
" print(c[j])\n",
" res = res ^ c[j]\n",
" for j in range(t):\n",
" if j == 1:\n",
" resTot[0] = res\n",
" break\n",
" resTot[j] = resTot[j]\n",
" return resTot"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "a2bbdc83-30f3-4aca-9026-b2a2aba64171",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4\n",
"4\n",
"4\n",
"4\n"
]
},
{
"ename": "IndexError",
"evalue": "list index out of range",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[9], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m s \u001b[38;5;241m=\u001b[39m [\u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 2\u001b[0m c \u001b[38;5;241m=\u001b[39m [\u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m0\u001b[39m]\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mLSFR\u001b[49m\u001b[43m(\u001b[49m\u001b[43ms\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m10\u001b[39;49m\u001b[43m)\u001b[49m)\n",
"Cell \u001b[0;32mIn[8], line 6\u001b[0m, in \u001b[0;36mLSFR\u001b[0;34m(s, c, nbtours)\u001b[0m\n\u001b[1;32m 4\u001b[0m t \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlen\u001b[39m(s)\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m i \u001b[38;5;241m<\u001b[39m nbtours:\n\u001b[0;32m----> 6\u001b[0m res \u001b[38;5;241m=\u001b[39m \u001b[43ms\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\n\u001b[1;32m 7\u001b[0m j \u001b[38;5;241m=\u001b[39m t\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28mprint\u001b[39m(j)\n",
"\u001b[0;31mIndexError\u001b[0m: list index out of range"
]
}
],
"source": [
"s = [0, 0, 1, 0]\n",
"c = [1, 0, 1, 0]\n",
"print(LSFR(s, c, 10))"
]
}
],
"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.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

@ -0,0 +1,7 @@
import Answer.*
enum class Answer { a, b, c }
val answers = mapOf<Int, Answer?>(
1 to null, 2 to null, 3 to null, 4 to null
)

@ -0,0 +1,24 @@
type: edu
files:
- name: src/Task.kt
visible: true
placeholders:
- offset: 91
length: 42
placeholder_text: "1 to null, 2 to null, 3 to null, 4 to null"
initial_state:
length: 42
offset: 91
initialized_from_dependency: false
selected: false
status: Unchecked
encrypted_possible_answer: HZmpRQ1HH0etnSF1R1HRJ+Tw5PTrTIxMqO286ljYv0Q=
encrypted_text: TxBKO+zBdziRVfhRRQ1jkAfTwgK/9uCtrA7WKi44goHSMHWPofMmfafs236Jr+TYs4JzaGFBgKBbiqx7QFMf975/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7hurAcNO0g0tgKmIPkwtB4uEvjDAmZ+Hl7NW0NAvs1gWZuAw99g==
learner_created: false
feedback_link: https://docs.google.com/forms/d/e/1FAIpQLSeYool5qTz-p77fzn_9UKQVjO3u3Al6WjzEyW5cbjspRwtQig/viewform?usp=pp_url&entry.2103429047=Builders+/+Builders+how+it+works
status: Unchecked
record: -1

@ -0,0 +1,96 @@
## Builders: how they work
Answer the questions below
**1. In the Kotlin code**
```kotlin
tr {
td {
text("Product")
}
td {
text("Popularity")
}
}
```
**`td` is:**
a. a special built-in syntactic construct
b. a function declaration
c. a function invocation
***
**2. In the Kotlin code**
```kotlin
tr (color = "yellow") {
td {
text("Product")
}
td {
text("Popularity")
}
}
```
**`color` is:**
a. a new variable declaration
b. an argument name
c. an argument value
***
**3. The block**
```kotlin
{
text("Product")
}
```
**from the previous question is:**
a. a block inside built-in syntax construction `td`
b. a function literal (or "lambda")
c. something mysterious
***
**4. For the code**
```kotlin
tr (color = "yellow") {
this.td {
text("Product")
}
td {
text("Popularity")
}
}
```
**which of the following is true:**
a. this code doesn't compile
b. `this` refers to an instance of an outer class
c. `this` refers to a receiver parameter TR of the function literal:
```kotlin
tr (color = "yellow") {
this@tr.td {
text("Product")
}
}
```

@ -0,0 +1,41 @@
open class Tag(val name: String) {
protected val children = mutableListOf<Tag>()
override fun toString() =
"<$name>${children.joinToString("")}</$name>"
}
fun table(init: TABLE.() -> Unit): TABLE {
val table = TABLE()
table.init()
return table
}
class TABLE : Tag("table") {
fun tr(init: TR.() -> Unit) {
/* TODO */
}
}
class TR : Tag("tr") {
fun td(init: TD.() -> Unit) {
/* TODO */
}
}
class TD : Tag("td")
fun createTable() =
table {
tr {
repeat(2) {
td {
}
}
}
}
fun main() {
println(createTable())
//<table><tr><td></td><td></td></tr></table>
}

@ -0,0 +1,34 @@
type: edu
files:
- name: src/Task.kt
visible: true
placeholders:
- offset: 352
length: 10
placeholder_text: /* TODO */
initial_state:
length: 10
offset: 352
initialized_from_dependency: false
selected: false
status: Unchecked
encrypted_possible_answer: ZCdEEtdujCjy5Hfg8866UakTOAVyC+Ze7Qk75FM7sqAI9qAshcahmZsgGJXnwcHLwbhJgIf9PHcy5H1CJ13Llw==
- offset: 437
length: 10
placeholder_text: /* TODO */
initial_state:
length: 10
offset: 437
initialized_from_dependency: false
selected: false
status: Unchecked
encrypted_possible_answer: 79MgSUXjf8DSmVrp3xVP2LF7bkZkjqBwalLOLXTFs8o=
encrypted_text: /fTMCg0gg7sw0DyksvbNHIMujqZdMAve8ekNb39WqsqrYOjSjzY/KMQbVR5IuJFk+FTZysRz2VXnQZs6twa0Z42BuKvANN5FTdaq/iAMccgV+jOZ5PljdY2YimTJ0M2syv9jsKq7UKRi9w3CCzToiQudUP4moCGy4uSxVOoziqrEbVHZi1XHGc183i9JDrzjrJfGwZ9N9HlmxMzMjJqdV+of0rZMEEx/RKksfADcdljURPdAMrEfn2ihTfdo1Hf8J7jaZmVpYoar2V8bHrMxVaqY8XErxZbw1JOPJQ09IlkcUFzEVl0Y7ebL8uy002WxeFwFgW9+0Eg7+GOWOUnEFaNSJvvAEDl+VWLFRTPxx2LCRh8MB2/JN11in4W5wkVOBJmxndR0pDbSZjtY/gzbgX6cOsFqAfTAmYVjnOhuHJmAW624d3fsoPjtGABA2eczCLbz0oshHAuMTH/SZIOOVf9l/rO4DeYZ3UMvvoNxckCS0x/XuGqW6rhKCm3elbCXPpodzZPibBnk8HvaIR6u/iwVkhWQ0mVNFBg9BFj0XFR8Ex/2Hhjq2e8cPuy6epvmAfwiOkVIjzRuov2KdtIOsNqfDOjhMBl6qLcXqF2Et5Gomkkx9gR7tAf3NX66zMjCHXhZAyXNANtSb4S4IEPyAJYoIaXYS94UTH/1fw8v+egALSG/ZLvv1UhseRO0MXLgM5xwM/+Hrj5dr5hAu+tdkLf+mTvwPMaZI7SshCoOOJYyLV6xHoIIe9IGmWheTA9CcCjL4T7XdOkQpx760s6fg1EPhsWCkXX6r+gx+Mu2bK7Lrs1FkzQjRz1Gew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hN65t2fU3U9VRR57uIAyiLfOVBMxTaEkcod/OpiIrTzuxkl5hOVsW/oFsFUX/Jf6O0cK9nSRYUh4b6ASFOgPCqEBWntix2PLypQ4qISHO0EM84IW2z26VhjSNrpLT15RAXRXfiklJjuA2vqHmkjRF/IC4JWKH7xrYIIp9c4e6K7FJjWzyR2ETkb1w3jdPpMS52JBNtqx+TEc36UtOFeJ7kgsDDb//z2odFzoAsuDrkC6NvNgP4UiwPt3uTpWSmV5ZZfqXl15gohQQBk2YS56UGBqo4I9tm9lBq/rJZGQw6nXIoz0MMG9kAIXMa7K/5rRSKycQRzZg4rr3XYLONLUDVtwPvxNnHkW8WNv3dVRFQIsRNuNFPOei32fjuW7YApJd7yGmc/LK8ueg/OjXbH7RFao63KVi2i5VPHiZcF
learner_created: false
feedback_link: https://docs.google.com/forms/d/e/1FAIpQLSeYool5qTz-p77fzn_9UKQVjO3u3Al6WjzEyW5cbjspRwtQig/viewform?usp=pp_url&entry.2103429047=Builders+/+Builders+implementation
status: Unchecked
record: -1

@ -0,0 +1,6 @@
## Builders implementation
Complete the implementation of a simplified DSL for HTML.
Implement `tr` and `td` functions.
Learn more about [type-safe builders](https://kotlinlang.org/docs/type-safe-builders.html#type-safe-builders).

@ -0,0 +1,6 @@
fun task(): List<Boolean> {
val isEven: Int.() -> Boolean = { TODO() }
val isOdd: Int.() -> Boolean = { TODO() }
return listOf(42.isOdd(), 239.isOdd(), 294823098.isEven())
}

@ -0,0 +1,34 @@
type: edu
files:
- name: src/Task.kt
visible: true
placeholders:
- offset: 66
length: 6
placeholder_text: TODO()
initial_state:
length: 6
offset: 66
initialized_from_dependency: false
selected: false
status: Unchecked
encrypted_possible_answer: lHMCpiaCR4jq30yMpMuesw==
- offset: 112
length: 6
placeholder_text: TODO()
initial_state:
length: 6
offset: 112
initialized_from_dependency: false
selected: false
status: Unchecked
encrypted_possible_answer: VKCML8/qxOFVTAVGeCdUyQ==
encrypted_text: Ulcr7oA41A7Jclzc6y7irIbgJiuvz5ZuZ/mrTVY9UZ+Nq4Vt1KwWtty1dkya/XOjkL2QgT/TRkykf6vBMzgDg0gx9Nzk/Myz7QKbZfNpblZhgl8o5zXIWKZ4jxKfwzuZqpnPvEJ68uOPd7zPThnvzCxHYyVvknnK8mD1lvudFUM1QdeZTMA1owmODFNAOLrIVKZLF/Y2dph9gDDe7QUaq7qL2ApP1AVZJbnQy/DuNatCECibcIN3lAZui7b4/zaq
learner_created: false
- name: test/tests.kt
visible: false
encrypted_text: ITs8Nv8EH6QWJG5nufD7nCbrLPoZNTYAX8EbQHppKy+TR7uFhZF7JnSL5/nnFJtttspPQDDPNTQZe+3TX4/piBKJOs1v3rx8fpgS34b2bU+AFlcIn8GvDfeoAjWs8vF7VumyLfIL0abn4YgMRmHmJClfWkVUgUCqgdYKhH3InOXxi+U5UuDZ0CGmDm6UkK3VMr8LNYhS/44OwRcWSDeEsCxdPK5t471D65khgkTxTvhKgs85ZTlmvyKgeCAfgpanwrnbsfUWxw84IVpUMpvmn0iDY1sW2QkJkB1VJxg5PQPkd+2ySyO447rc40DECSounS1b2OYDNBlPl8rjPIGmi1ASuDlOFhpfq2nlCTffj4udsqctRzfK5HpUBYpDX/fp
learner_created: false
feedback_link: https://docs.google.com/forms/d/e/1FAIpQLSeYool5qTz-p77fzn_9UKQVjO3u3Al6WjzEyW5cbjspRwtQig/viewform?usp=pp_url&entry.2103429047=Builders+/+Function+Literals+with+Receiver
status: Unchecked
record: -1

@ -0,0 +1,6 @@
## Function literals with receiver
Learn about [function literals with receiver](https://kotlinlang.org/docs/lambdas.html#function-literals-with-receiver).
You can declare `isEven` and `isOdd` as values that can be called as extension functions.
Complete the declarations in the code.

@ -0,0 +1,22 @@
fun renderProductTable(): String {
return html {
table {
tr/* TODO */ {
td {
text("Product")
}
td {
text("Price")
}
td {
text("Popularity")
}
}
val products = getProducts()
TODO()
}
}.toString()
}
fun getTitleColor() = "#b9c9fe"
fun getCellColor(index: Int, column: Int) = if ((index + column) % 2 == 0) "#dce4ff" else "#eff2ff"

@ -0,0 +1,21 @@
data class Product(val description: String, val price: Double, val popularity: Int)
val cactus = Product("cactus", 11.2, 13)
val cake = Product("cake", 3.2, 111)
val camera = Product("camera", 134.5, 2)
val car = Product("car", 30000.0, 0)
val carrot = Product("carrot", 1.34, 5)
val cellPhone = Product("cell phone", 129.9, 99)
val chimney = Product("chimney", 190.0, 2)
val certificate = Product("certificate", 99.9, 1)
val cigar = Product("cigar", 8.0, 51)
val coffee = Product("coffee", 8.0, 67)
val coffeeMaker = Product("coffee maker", 201.2, 1)
val cola = Product("cola", 4.0, 67)
val cranberry = Product("cranberry", 4.1, 39)
val crocs = Product("crocs", 18.7, 10)
val crocodile = Product("crocodile", 20000.2, 1)
val cushion = Product("cushion", 131.0, 0)
fun getProducts() = listOf(cactus, cake, camera, car, carrot, cellPhone, chimney, certificate, cigar, coffee, coffeeMaker,
cola, cranberry, crocs, crocodile, cushion)

@ -0,0 +1,13 @@
import javax.swing.JFrame
import javax.swing.JLabel
import javax.swing.JScrollPane
import javax.swing.SwingConstants.CENTER
fun main() {
with(JFrame("Product popularity")) {
setSize(600, 600)
defaultCloseOperation = JFrame.EXIT_ON_CLOSE
add(JScrollPane(JLabel(renderProductTable(), CENTER)))
isVisible = true
}
}

@ -0,0 +1,6 @@
import kotlin.browser.document
fun main(args: Array<String>){
document.body!!.style.overflowY = ""
document.body!!.innerHTML = renderProductTable()
}

@ -0,0 +1,49 @@
open class Tag(val name: String) {
val children = mutableListOf<Tag>()
val attributes = mutableListOf<Attribute>()
override fun toString(): String {
return "<$name" +
(if (attributes.isEmpty()) "" else attributes.joinToString(separator = "", prefix = " ")) + ">" +
(if (children.isEmpty()) "" else children.joinToString(separator = "")) +
"</$name>"
}
}
class Attribute(val name: String, val value: String) {
override fun toString() = """$name="$value" """
}
fun <T : Tag> T.set(name: String, value: String?): T {
if (value != null) {
attributes.add(Attribute(name, value))
}
return this
}
fun <T : Tag> Tag.doInit(tag: T, init: T.() -> Unit): T {
tag.init()
children.add(tag)
return tag
}
class Html : Tag("html")
class Table : Tag("table")
class Center : Tag("center")
class TR : Tag("tr")
class TD : Tag("td")
class Text(val text: String) : Tag("b") {
override fun toString() = text
}
fun html(init: Html.() -> Unit): Html = Html().apply(init)
fun Html.table(init: Table.() -> Unit) = doInit(Table(), init)
fun Html.center(init: Center.() -> Unit) = doInit(Center(), init)
fun Table.tr(color: String? = null, init: TR.() -> Unit) = doInit(TR(), init).set("bgcolor", color)
fun TR.td(color: String? = null, align: String = "left", init: TD.() -> Unit) = doInit(TD(), init).set("align", align).set("bgcolor", color)
fun Tag.text(s: Any?) = doInit(Text(s.toString()), {})

@ -0,0 +1,54 @@
type: edu
files:
- name: src/html.kt
visible: true
encrypted_text: /fTMCg0gg7sw0DyksvbNHIMujqZdMAve8ekNb39WqsqlptiTFhLErXAmkoi/CI4aMgiyDYgn77a7YR/PZ0gF2g7MwuO2McDQfH8W1p/UKuNrDOMESVc4Zl/8/6ysKhWIM0Tk09XcWm6Pq5sJJYOrtmNyEFNEBs7YdFhdqqS/HFys3VkBNMM8P8bawkIKr9lWuW10Y9RBWYuREeCvhDeBaK8xJZ6iLmRN7LO0LEQkLdRsgqcwL+9DaXikF7Hzt8gcHWJEeMXXR905rWHjo9BpGz0zCZVfvQUg703e0Er3ecEIdfqepW1GWm2P9LHVkqn2Eoq8Ikt9aoN2Cc2Ov86u7cW8Xknbw6v6UaYA3UGh+Us9enpjjMKdfU3RwCM0aHSflV0u/DQpGqTwzfgprqEd4m5/8Jsvbr3+n94RV8k9r6Jh2pBflLKM39GkzUMBPtPGobGI8F95pf+9YtxECievt8nYTOTttktrshOT6QnL1l0MiW8fpLPobThBYCcLXgx5LFa5PlQIwOd4iKZtnK439QuRq5QYMQFpm/feg8CMwIeb7te+W+cqELt9N1aaq45Js2C8ZX8LOKN2vQWx7iTziqAZupEbbUx4uq2LNQMVxf4fr5mvzhNmuiTTMQd3DWJFrjWUadZc0balSXeWvAn4+13ag+KtUXMjp1DU7+Y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2UwrlKs66ePV0WLRRHeNzbWP1ZbvPLeA4/93Qgl8t3JjfeR/kaGXKbFgI9Jdsfvt/eR+RxxuckNYARRTIXvI19Ck8qx3EX34BRkpfQJ0GThUG7g5yTEykGBKBpW9TjVL92nKz4n8MZYgRVLNjwpvsx2hWxuu0a4O959LVSNyCXGyPgDiMlj/BBVu0CxNqOjcWLWkDuGPAvQQRw+P6eJZ2gfK7L6pYTGKGmbQzmXiINZjQ==
learner_created: false
- name: src/Task.kt
visible: true
placeholders:
- offset: 83
length: 10
placeholder_text: /* TODO */
initial_state:
length: 10
offset: 83
initialized_from_dependency: false
selected: false
status: Unchecked
encrypted_possible_answer: RsOJqel91ytF+ayPlADPOvhOy4/WSSw7zF5lAvZwFS8=
- offset: 389
length: 6
placeholder_text: TODO()
initial_state:
length: 6
offset: 389
initialized_from_dependency: false
selected: false
status: Unchecked
encrypted_possible_answer: ox+RjiDizH76htkWKPOdM1DnImfrfzKeBvje46quDwxkzBk0rdnPFpSOwW/dvZqbDck8j94sXrZ1MeYXOWMl8ANmLla73MNIZM0CWXoSiO1w5tWqgxHkKh0i5VZ5oXCcUbjZqqGHgCOTx+Sa/twHomIUYzotU67US2S6jov2COlFTepHl+YRtbalPqmcHHbK2doSyR4lr0KwaJ3kEQjIEMY7iK4EjVCFpvzr5f+Qz6tRluK7VmtfIShsfjptsxcbxrETkeHTMp9zNy+8RWuWgGrE7pj4EBDJX8fFExUJi7ROk9cQLZyQ6aEq7BxED5QEGoP93cNJWdSdfUVNjeEumhsepTtaLydBUFihbNO0TLbxjR0khcrWArWbIwVFmMtMtikYP4Py4cn0IQs7K7djtwvlBLMpbdQyYJ8TmZVRKwVEHqQtC7M+amstOQmFc5721b/ywyBC02kkft2ABRhyupzwYdU3uQlvrz5XiDU60yNwv0U50o8J33ffDjnILE5s47Z33x5EXub9QKFhlCg9JcQ+MA4dbHn+080Oj0au+Nj1ndJI3lHwOd5JAZfgnizy6ief/RW09hM/2P+7ZBrJc1HtMGLWvZ/bmZJbo1OIf0jh7CqqDR/4SFGP/8EVd/8eWU2pJFsmLwQC7g1rHw9B5A==
encrypted_text: mMFwJKTThLYfAaIOF17xLoJC3gsd/R9T+mPZHx49ToQSKj/PqRK491N6C7avkeohjJlhqwLNoRaOL+gjn6ZrXl8tV45xyzchU6PEvOsYZtbnmr2rztBGzNuH5/eOnL+WBYRSJ2ySLhI61HPK3tZRuv4REtm5VKJMZwW6KkeMX5xJO8PyR17Z9ZMLdCXColxlputOU3z/k8jxWoUiD5Lbb0s4nah++ztqc92TWUZS1FmjC7teAwx8/bYDgw71er78XmnPp+zShX5Kw7N0x2/kIa8xPEk1dN4irKIjJv55tiIaCNO8zxnmiYBllHeG5eLdl1iJxCHRVdTmr5T938+g4EFm6Koz+xCzdPXkAhX8rG6dcqEL0TllF0skOYUCxG5DXTwT3MzpotChrp7MwqQniSYgV7R8BOo3Tut531pKEDU+/2ptr/D1plCHfJHGr7OzNmXLhxOB//11p9xuuCjbEN5H3FGNM6HVoTB5KQFvAjjJ3XOtJiX8q0CCkjoxCNIim++CV2NVpfBPbU/88rBUXPM4nJ2mgpmGfItxOK/doyTjRJ0MJU3NRyuTBSmWCXtpib5N8WNTVRNrLjRpUDZqwn1xGrBUNoDJTlrae/RdNShKHqOpwy6jjz273t2WaY7/RMhs+K97OmgxsH8xbU49tMChpvektlxJFwj25pbi1cVbpidF/e1mkVp6SMoyj9DGvSFGCNqEflmYyeAkr1HXAXDu8MxUBNzaIMnuT6Jv4io=
learner_created: false
- name: src/data.kt
visible: true
encrypted_text: dE9hHThjwWxk0uqOFlVS5HPcefkGWvyMfNA2gjTSSc6UAN65HwNEyk60yOBaVTHdEkzry9YeTiAw8uwcfeUlYIQjaoROFnvxJfJ1RxXNfwXpypK9H0Cam+j6dS8CbLgEFHaedXGKNSHK1IINqPANOc7xnG9gLalZuBesf8dKU0PWOgqts/WdGnG3D0KgyJnuunp2xXrRrXdduko8zRtpI/ZG8zjJsKEnc+0VgoTQWywoTMFQBYPm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iQ6fpiuPZrWvj9oCDJDiOpTTbiLsvWo7Hni4ISnSj1p5TGDx89otkpG+QFXIVasLLk6Fmz3nLxGc7Y3kA==
learner_created: false
- name: src/demo.kt.wb
visible: false
encrypted_text: 1B+4bYXp0Fkxt/ek3c4icTod/OQTcxTvX9L2mge6oEynr4CGqLb+2nV7OBb8HUrRAeiymgRwIRpv4cpd20i9CWSaLsIjsdYNzZA78lYZVQTDAxUZ/+GgHcTHrKY7aUS/qcNYEf4MuUHgUrPbjaJppOR7ufux7uKU1lwiHskvMDUn61cAWIKvmNHAybnVoksIEqedQ9ANs8cqodj3uE4gGg==
learner_created: false
- name: task.md.wb
visible: false
encrypted_text: x8efRHEn6mtpcBlEA1h0fE7+If60lYp0eoOkDvh1SBb8brLSlVeq+z5mnvRUPPHnwQjlihx0oR6q5ImURN17IXFONQqxOkStM61xbAv41I3YA+fbff/Sz+/U5JYxR/MUAfc4E1AEoWwZ2kWYzI9C4/O4QT2BA38Kww12f0Jp+OpaGzUP1OdGhOh9oeootjDtPFJ0LYBqK1WkSBiTj9PWrsAvv93mfXhhokeHtL5myorevL3CcpdlrTz6ARKCb0BD/taJ/NdfwbOwF1eK8pwqstYZ00WVJLNTrtEuIQY++GvBH7sqbIQsZ9yY2+TS0++sKTowav/854uSlf2LnqK3OqmyiW9Ui4ara1Awjm0ZT55ru/iycCdWQbTHQvv+zJX3f7Ee5Xk+w97CDKoJhGl29PRtKbe31MtlJG0emiHBVVrM5WlfRtsUDQf4avDEkpnVZylr5+7JBT2FKGlv9k/d2fHbzFzekqVrMNLlAiNuqr0=
learner_created: false
feedback_link: https://docs.google.com/forms/d/e/1FAIpQLSeYool5qTz-p77fzn_9UKQVjO3u3Al6WjzEyW5cbjspRwtQig/viewform?usp=pp_url&entry.2103429047=Builders+/+Html+builders
status: Unchecked
record: -1

@ -0,0 +1,10 @@
## HTML builder
1. Fill the table with proper values from the product list.
The products are declared in `data.kt`.
2. Color the table like a chessboard.
Use the `getTitleColor()` and `getCellColor()` functions.
Pass a color as an argument to the functions `tr`, `td`.
Run the main function defined in the file `demo.kt` to see the rendered table.

@ -0,0 +1,9 @@
## Html builder
_1._ Fill the table with the proper values from the product list.
The products are declared in `data.kt`.
_2._ Color the table like a chess board (using getTitleColor() and getCellColor() functions above).
Pass a color as an argument to the functions `tr`, `td`.
You can run 'JavaScript(Canvas)' configuration to see the rendered table.

@ -0,0 +1,12 @@
import java.util.HashMap
/* TODO */
fun usage(): Map<Int, String> {
return buildMutableMap {
put(0, "0")
for (i in 1..10) {
put(i, "$i")
}
}
}

@ -0,0 +1,24 @@
type: edu
files:
- name: src/Task.kt
visible: true
placeholders:
- offset: 26
length: 10
placeholder_text: /* TODO */
initial_state:
length: 10
offset: 26
initialized_from_dependency: false
selected: false
status: Unchecked
encrypted_possible_answer: hqAg774QUxkCIQsPstuMQA55z4XVASNwv50AHZqeBdotz5qZPJkTAPssQpPYCh7+4cv3qvd9bhxgcz3NLO6g3Jd7XP2/Lw4j5k0ylQ4QDJsTTqPVZElCh33dK+CvNyS+Lsvwa3o6NG0qXg60L5C0lFCUak3trY48QvJY3N79ITydceqyFB1xtBgAb9S63+FO
encrypted_text: NYgHoNruO3t7vIi6YFhoH54cJSowayhlYalrWHBzPk0O7qoy/qVS5eFW6baQXBeaUXviV8sDOj4HUDNcAliuAY+InQYcR6OU7S+FYc/Kf3WxkkR5Ymsp2K23FFW9X9M6WxyIrHnCchBD0stBCQFVITg8v3r2Ocbdvsvi++vxBVY/rTi5qlXng5UaoEMScbUdmq3PdC6eU+mwM2/4GqIJ0N7EZqUujspi/T297Eb8Bdv6nWeXkMQ3LHSxszta33TT
learner_created: false
- name: test/tests.kt
visible: false
encrypted_text: ITs8Nv8EH6QWJG5nufD7nCbrLPoZNTYAX8EbQHppKy+TR7uFhZF7JnSL5/nnFJttkyEltD8hb4JuHqitjqPdzdABkf4C3ixUHsx9rAvyl6fXOuAlxgb/6eD7HuhlLGci4TLWHjvT85N2FLNTq/81xn8poeuc416VYxAaDyi9lIRCCd/N2tCu4e6blmOK8/iuwx3+B8UZq4XB6r9rtO+5GRPTVTpG/bvO+DUl/CA/iFHB99fjBHza+xwZEc5YzjEs4jfqSBMdW0ewnFirLfZhbD6+GN7euIakkWhfMtPpSR06SkEJwRZQXIXAGDezeDsAYZeyJICFRKHJRg9tC6H67GFKFHd/gNmIaWFU76HeUQ9nlXyUsLaQED5qvwxAxaupUf2mx05Drcfo21k0gY+iMvpGUBg64PAOECyb4odoH0j9nPLZdN8pKl8RCbMn3wgtCpRCdn/2uuhWmlN9PvYMMw==
learner_created: false
feedback_link: https://docs.google.com/forms/d/e/1FAIpQLSeYool5qTz-p77fzn_9UKQVjO3u3Al6WjzEyW5cbjspRwtQig/viewform?usp=pp_url&entry.2103429047=Builders+/+String+and+Map+Builders
status: Unchecked
record: -1

@ -0,0 +1,25 @@
## String and map builders
Function literals with receiver are very useful for creating builders, for example:
```kotlin
fun buildString(build: StringBuilder.() -> Unit): String {
val stringBuilder = StringBuilder()
stringBuilder.build()
return stringBuilder.toString()
}
val s = buildString {
this.append("Numbers: ")
for (i in 1..3) {
// 'this' can be omitted
append(i)
}
}
s == "Numbers: 123"
```
Implement the function `buildMutableMap` that takes a parameter (of extension function type), creates a new `HashMap`,
builds it, and returns it as a result. Note that starting from 1.3.70, the standard library has a similiar `buildMap`
function.

@ -0,0 +1,21 @@
fun <T> T.myApply(f: T.() -> Unit): T {
TODO()
}
fun createString(): String {
return StringBuilder().myApply {
append("Numbers: ")
for (i in 1..10) {
append(i)
}
}.toString()
}
fun createMap(): Map<Int, String> {
return hashMapOf<Int, String>().myApply {
put(0, "0")
for (i in 1..10) {
put(i, "$i")
}
}
}

@ -0,0 +1,24 @@
type: edu
files:
- name: src/Task.kt
visible: true
placeholders:
- offset: 44
length: 6
placeholder_text: TODO()
initial_state:
length: 6
offset: 44
initialized_from_dependency: false
selected: false
status: Unchecked
encrypted_possible_answer: e6q73DJafCDwTJxGT6+LXfajF1ye17rMLiU0XeSqvLI=
encrypted_text: fuFmsdrW/z332+GC09waYWNxalPHbCyunZk7BYKO5I4mM1r5aJHbCQ+ESaPnzrFiOQnx4yBwrw07y+CKWCNONgWnsAzb72zxxtZYc9guUGlsu0hqZqv0UNcyWZJilCycX8Mlq8Vt/ZlWNIUDuPmSLhbmnArsnQTlpiH6g/N/VL2v03L8StMoWIeJSMMZbdWBFhpyLzeNCNZkFw4Cg3Ii/pV04yx4wDRYdTff3+iJlJJJD+EOT0QRHfGUzZ0H0/X0JjU93zbrQDCwYlcxtGMs9P59wGHU3dkiikrnfDlP5YlV7lCgAZFURauZAReCUzk8iKbAtIm3IRiLdxc32aQeJPihHLjdsbbPv1uwL9O27JSh+KZQqr1xxL7TK+xgZApEVw98xDA0APYUG23jLJV6d2afBlpaZuaQG15KtGdgEDt1gl1mOzNtIM1uO0ehx+ENFIgWccIDd7CNiguIanadmIOJ6G5O3ypwGXCbm1DE8e0el9MEUZioURHppDkAYw1cDcFPwxgerNaRPe3dlZ4kfA==
learner_created: false
- name: test/tests.kt
visible: false
encrypted_text: ITs8Nv8EH6QWJG5nufD7nCbrLPoZNTYAX8EbQHppKy8S+0d6SUuSBLOWeXdkV1kqhwWxUQZYeS3GXBNoMnDbnoYDsY/hvZFXsTMm1IxP/vQX0JnhCXcS4Jn8dN2AVQAxuL2RoGxOYqLIcG5EdS3AKVB/Yrt0KcFd9RrPneXcvGDe0YJSab0auR5E7V9TRYxDkcK5NyjjuOUTzPinjOIk6cnDK8n8VCa7CNhOgKnOzOWjfF9gLUSgPCZsiHm1lEvHvzsgEGKlE1M/wDCH6gGAv7+kp55GO37Bstq3GBcTHOfLiTxuQgx8lup7j1dtzXIm7FKzKyQn5yCO2XcAkTTum8J3XdLT70crIa8GYSEXGMRmKxQyQ7SXyJNc77I52FKxbpJ7RgI4AtjfDSNzyzODychV6xsybhBSyiBSWGGewYHfuwjgUl274HI7qztevcCOV0olKhV1o9kD/zU3TCC6hJkQe+QKbo+gnc1XxLFEHEeTpdpO+uDNR4DAvE8tv5NQDjsydtP8YKCtewCGVyXtFWkuLHV9i/jmLdYcj1NisVnBcZZp7DqhjjpVzpFIWtJd2EMKGyIHEX0LRoKHeTFVWaftvOg0TVldfWBrHV+oym+Qeb66JCov0OypzzVETy81qEEe1wp08sZod/umJcn28egz4Ig2ALD+Jm3Oni1m+X7Gpds29e3oPjf5i6Ro6WVL5RKPw8EUJel0YUPQd2+mV24M1NxmMfKUOxhPGWG6pOqlQ57qwssp1pbL8o95JRhaWQwMD9uO2XESGT1RuSacdZ57hyagmTC84/THJIhZKOXuvu16CpYiW/UuIxM7fcz0V1JvdyM5YkCxy0DhWJXxR+pf6C3jNALWbc3uwv9ui/A+zLTiXsl4DxvwFoGz7IFZKuvmPa+fe3sGs5IN6cjTsQ==
learner_created: false
feedback_link: https://docs.google.com/forms/d/e/1FAIpQLSeYool5qTz-p77fzn_9UKQVjO3u3Al6WjzEyW5cbjspRwtQig/viewform?usp=pp_url&entry.2103429047=Builders+/+The+function+Apply
status: Unchecked
record: -1

@ -0,0 +1,8 @@
## The function apply
The previous examples can be rewritten using the library function
[`apply`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/apply.html).
Write your implementation of this function named `myApply`.
Learn about the other [scope functions](https://kotlinlang.org/docs/scope-functions.html)
and how to use them.

@ -0,0 +1,7 @@
content:
- Function literals with receiver
- String and map builders
- The function apply
- Html builders
- Builders how it works
- Builders implementation

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save