document most of operand and operator types

This commit is contained in:
2024-07-03 13:05:39 -05:00
parent 957d4a4953
commit e2b6ca014e

View File

@@ -12,7 +12,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 35, "execution_count": 82,
"outputs": [], "outputs": [],
"source": [ "source": [
"from src.models import OuterKey, InnerKey, SubstitutionKey" "from src.models import OuterKey, InnerKey, SubstitutionKey"
@@ -20,8 +20,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.906547Z", "end_time": "2024-07-03T17:15:30.365133Z",
"start_time": "2024-07-03T16:38:57.867931Z" "start_time": "2024-07-03T17:15:30.328857Z"
} }
} }
}, },
@@ -40,7 +40,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 36, "execution_count": 83,
"outputs": [], "outputs": [],
"source": [ "source": [
"height = 4\n", "height = 4\n",
@@ -49,8 +49,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.907029Z", "end_time": "2024-07-03T17:15:30.365712Z",
"start_time": "2024-07-03T16:38:57.872544Z" "start_time": "2024-07-03T17:15:30.332512Z"
} }
} }
}, },
@@ -67,13 +67,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 37, "execution_count": 84,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "[[2, 0, 1], [0, 2, 1], [0, 2, 1], [1, 2, 0]]" "text/plain": "[[1, 2, 0], [0, 1, 2], [2, 1, 0], [2, 0, 1]]"
}, },
"execution_count": 37, "execution_count": 84,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -88,8 +88,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.907507Z", "end_time": "2024-07-03T17:15:30.366169Z",
"start_time": "2024-07-03T16:38:57.876023Z" "start_time": "2024-07-03T17:15:30.335990Z"
} }
} }
}, },
@@ -105,13 +105,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 38, "execution_count": 85,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "[[3, 2, 1, 0]]" "text/plain": "[[1, 2, 3, 0]]"
}, },
"execution_count": 38, "execution_count": 85,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -126,8 +126,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.954081Z", "end_time": "2024-07-03T17:15:30.405313Z",
"start_time": "2024-07-03T16:38:57.880359Z" "start_time": "2024-07-03T17:15:30.341422Z"
} }
} }
}, },
@@ -143,13 +143,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 39, "execution_count": 106,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "[[21, 62, 42], [151, 171, 33], [31, 131, 141], [100, 202, 161]]" "text/plain": "[[237, 92, 1], [165, 114, 152], [38, 71, 114], [52, 116, 61]]"
}, },
"execution_count": 39, "execution_count": 106,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -157,13 +157,14 @@
"source": [ "source": [
"a0 = SubstitutionKey.init_matrix(width, height)\n", "a0 = SubstitutionKey.init_matrix(width, height)\n",
"a1 = SubstitutionKey.init_matrix(width, height)\n", "a1 = SubstitutionKey.init_matrix(width, height)\n",
"\n",
"a0.matrix" "a0.matrix"
], ],
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.954770Z", "end_time": "2024-07-03T17:26:59.359984Z",
"start_time": "2024-07-03T16:38:57.884556Z" "start_time": "2024-07-03T17:26:59.355497Z"
} }
} }
}, },
@@ -171,7 +172,8 @@
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"## Operators Types\n", "## Operators Types\n",
"### ***<<*** Inner Permutation" "### ***<*** Outer Permutation\n",
"#### Substitution Key < Outer Key"
], ],
"metadata": { "metadata": {
"collapsed": false "collapsed": false
@@ -179,21 +181,36 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 39, "execution_count": 107,
"outputs": [], "outputs": [
"source": [], {
"name": "stdout",
"output_type": "stream",
"text": [
"[[1, 2, 3, 0]]\n",
"[[237, 92, 1], [165, 114, 152], [38, 71, 114], [52, 116, 61]]\n",
"[[165, 114, 152], [38, 71, 114], [52, 116, 61], [237, 92, 1]]\n"
]
}
],
"source": [
"a0_o0 = a0 < o0\n",
"print(o0.matrix)\n",
"print(a0.matrix)\n",
"print(a0_o0.matrix)"
],
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.955162Z", "end_time": "2024-07-03T17:27:00.733689Z",
"start_time": "2024-07-03T16:38:57.887640Z" "start_time": "2024-07-03T17:27:00.729585Z"
} }
} }
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"### ***<*** Outer Permutation" "#### Inner Key < Outer Key"
], ],
"metadata": { "metadata": {
"collapsed": false "collapsed": false
@@ -201,21 +218,37 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 39, "execution_count": 108,
"outputs": [], "outputs": [
"source": [], {
"name": "stdout",
"output_type": "stream",
"text": [
"[[1, 2, 3, 0]]\n",
"[[1, 2, 0], [0, 1, 2], [2, 1, 0], [2, 0, 1]]\n",
"[[0, 1, 2], [2, 1, 0], [2, 0, 1], [1, 2, 0]]\n"
]
}
],
"source": [
"i0_o0 = i0 < o0\n",
"print(o0.matrix)\n",
"print(i0.matrix)\n",
"print(i0_o0.matrix)"
],
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.955526Z", "end_time": "2024-07-03T17:27:04.433733Z",
"start_time": "2024-07-03T16:38:57.890158Z" "start_time": "2024-07-03T17:27:04.429380Z"
} }
} }
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"### ***^*** Substitution" "### ***<<*** Inner Permutation\n",
"#### Outer Key << OuterKey"
], ],
"metadata": { "metadata": {
"collapsed": false "collapsed": false
@@ -223,14 +256,143 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 39, "execution_count": 109,
"outputs": [], "outputs": [
"source": [], {
"name": "stdout",
"output_type": "stream",
"text": [
"[[2, 1, 3, 0]]\n",
"[[1, 2, 3, 0]]\n",
"[[3, 2, 0, 1]]\n"
]
}
],
"source": [
"o0_o1 = o0 << o1\n",
"print(o1.matrix)\n",
"print(o0.matrix)\n",
"print(o0_o1.matrix)"
],
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.957721Z", "end_time": "2024-07-03T17:27:08.293098Z",
"start_time": "2024-07-03T16:38:57.892476Z" "start_time": "2024-07-03T17:27:08.288126Z"
}
}
},
{
"cell_type": "markdown",
"source": [
"#### Inner Key << Inner Key"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 110,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[0, 1, 2], [0, 2, 1], [0, 1, 2], [2, 1, 0]]\n",
"[[1, 2, 0], [0, 1, 2], [2, 1, 0], [2, 0, 1]]\n",
"[[1, 2, 0], [0, 2, 1], [2, 1, 0], [1, 0, 2]]\n"
]
}
],
"source": [
"i0_i1 = i0 << i1\n",
"print(i1.matrix)\n",
"print(i0.matrix)\n",
"print(i0_i1.matrix)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-03T17:27:11.574355Z",
"start_time": "2024-07-03T17:27:11.568652Z"
}
}
},
{
"cell_type": "markdown",
"source": [
"#### Substitution Key << Inner Key"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 111,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[1, 2, 0], [0, 1, 2], [2, 1, 0], [2, 0, 1]]\n",
"[[237, 92, 1], [165, 114, 152], [38, 71, 114], [52, 116, 61]]\n",
"[[92, 1, 237], [165, 114, 152], [114, 71, 38], [61, 52, 116]]\n"
]
}
],
"source": [
"a0_i0 = a0 << i0\n",
"print(i0.matrix)\n",
"print(a0.matrix)\n",
"print(a0_i0.matrix)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-03T17:27:14.277217Z",
"start_time": "2024-07-03T17:27:14.272132Z"
}
}
},
{
"cell_type": "markdown",
"source": [
"### ***^*** Substitution\n",
"#### Substitution Key ^ Substitution Key"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 114,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[237, 92, 1], [165, 114, 152], [38, 71, 114], [52, 116, 61]]\n",
"[[184, 159, 115], [199, 221, 35], [158, 70, 86], [74, 43, 129]]\n",
"[[85, 195, 114], [98, 175, 187], [184, 1, 36], [126, 95, 188]]\n",
"85\n"
]
}
],
"source": [
"a0_a1 = a0 ^ a1\n",
"print(a0.matrix)\n",
"print(a1.matrix)\n",
"print(a0_a1.matrix)\n",
"print(a0.matrix[0][0] ^ a1.matrix[0][0])"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-03T17:29:15.922958Z",
"start_time": "2024-07-03T17:29:15.915126Z"
} }
} }
}, },
@@ -245,13 +407,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 40, "execution_count": 88,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "True" "text/plain": "True"
}, },
"execution_count": 40, "execution_count": 88,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -265,20 +427,20 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.957791Z", "end_time": "2024-07-03T17:15:30.408639Z",
"start_time": "2024-07-03T16:38:57.896696Z" "start_time": "2024-07-03T17:15:30.361902Z"
} }
} }
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 41, "execution_count": 89,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "True" "text/plain": "True"
}, },
"execution_count": 41, "execution_count": 89,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -291,20 +453,20 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.958249Z", "end_time": "2024-07-03T17:15:30.408838Z",
"start_time": "2024-07-03T16:38:57.900751Z" "start_time": "2024-07-03T17:15:30.365269Z"
} }
} }
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 42, "execution_count": 90,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "True" "text/plain": "True"
}, },
"execution_count": 42, "execution_count": 90,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -317,20 +479,20 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.958404Z", "end_time": "2024-07-03T17:15:30.408892Z",
"start_time": "2024-07-03T16:38:57.903708Z" "start_time": "2024-07-03T17:15:30.368768Z"
} }
} }
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 50, "execution_count": 91,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "True" "text/plain": "True"
}, },
"execution_count": 50, "execution_count": 91,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -341,20 +503,20 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:42:45.756613Z", "end_time": "2024-07-03T17:15:30.408977Z",
"start_time": "2024-07-03T16:42:45.746766Z" "start_time": "2024-07-03T17:15:30.371377Z"
} }
} }
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 44, "execution_count": 92,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "True" "text/plain": "True"
}, },
"execution_count": 44, "execution_count": 92,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -368,20 +530,20 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.958613Z", "end_time": "2024-07-03T17:15:30.409076Z",
"start_time": "2024-07-03T16:38:57.910939Z" "start_time": "2024-07-03T17:15:30.375604Z"
} }
} }
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 49, "execution_count": 93,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "True" "text/plain": "True"
}, },
"execution_count": 49, "execution_count": 93,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -392,20 +554,20 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:41:01.725294Z", "end_time": "2024-07-03T17:15:30.409139Z",
"start_time": "2024-07-03T16:41:01.718345Z" "start_time": "2024-07-03T17:15:30.378496Z"
} }
} }
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 46, "execution_count": 94,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "True" "text/plain": "True"
}, },
"execution_count": 46, "execution_count": 94,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -421,8 +583,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.958859Z", "end_time": "2024-07-03T17:15:30.409210Z",
"start_time": "2024-07-03T16:38:57.915888Z" "start_time": "2024-07-03T17:15:30.381727Z"
} }
} }
}, },
@@ -438,13 +600,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 47, "execution_count": 95,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "True" "text/plain": "True"
}, },
"execution_count": 47, "execution_count": 95,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -455,8 +617,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-07-03T16:38:57.958925Z", "end_time": "2024-07-03T17:15:30.409260Z",
"start_time": "2024-07-03T16:38:57.920831Z" "start_time": "2024-07-03T17:15:30.384147Z"
} }
} }
} }