Files
pydarc/permutation_algebra_examples.ipynb

285 lines
5.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-07-03T14:43:00.143871Z",
"start_time": "2024-07-03T14:43:00.105294Z"
}
},
"outputs": [],
"source": [
"from src.models import OuterKey, InnerKey, AlphabetKey"
]
},
{
"cell_type": "code",
"execution_count": 2,
"outputs": [],
"source": [
"height = 10\n",
"width = 7\n",
"\n",
"a0 = AlphabetKey.init_matrix(width, height, 255)\n",
"\n",
"o0 = OuterKey.init_matrix(height)\n",
"o1 = OuterKey.init_matrix(height)\n",
"o2 = OuterKey.init_matrix(height)\n",
"o3 = OuterKey.init_matrix(height)\n",
"\n",
"i0 = InnerKey.init_matrix(width, height)\n",
"i1 = InnerKey.init_matrix(width, height)\n",
"i2 = InnerKey.init_matrix(width, height)\n"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-03T14:43:11.536945Z",
"start_time": "2024-07-03T14:43:11.532046Z"
}
}
},
{
"cell_type": "code",
"execution_count": 3,
"outputs": [
{
"data": {
"text/plain": "True"
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a0_i0_o0_v0 = a0 << (i0 < o0)\n",
"a0_i0_o0_v1 = ((a0 < ~o0) << i0) < o0\n",
"\n",
"a0_i0_o0_v0 == a0_i0_o0_v1"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-03T14:43:36.810538Z",
"start_time": "2024-07-03T14:43:36.805348Z"
}
}
},
{
"cell_type": "code",
"execution_count": 4,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n"
]
}
],
"source": [
"a0_o0_i0_v0 = (a0 < o0) << i0\n",
"a0_o0_i0_v1 = (a0 << (i0 < ~o0)) < o0\n",
"a0_i0_o0_v0 == a0_i0_o0_v1"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-03T14:44:07.321778Z",
"start_time": "2024-07-03T14:44:07.318402Z"
}
}
},
{
"cell_type": "code",
"execution_count": 5,
"outputs": [
{
"data": {
"text/plain": "True"
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a0_o0_i0_v0 = (a0 < o0) << i0\n",
"a0_o0_i0_v1 = (a0 << (i0 < ~o0)) < o0\n",
"a0_o0_i0_v0 == a0_o0_i0_v1"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-03T14:44:48.380940Z",
"start_time": "2024-07-03T14:44:48.377032Z"
}
}
},
{
"cell_type": "code",
"execution_count": 6,
"outputs": [
{
"data": {
"text/plain": "True"
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"n_i0_i1 = ~(i0 << i1)\n",
"ni1_ni0 = ~i1 << ~i0\n",
"ni1_ni0 == n_i0_i1"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-03T14:45:01.588349Z",
"start_time": "2024-07-03T14:45:01.584641Z"
}
}
},
{
"cell_type": "code",
"execution_count": 7,
"outputs": [
{
"data": {
"text/plain": "True"
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"i0_i1_i2_v0 = i0 << i1 << i2\n",
"i0_i1_i2_v1 = i0 << (i1 << i2)\n",
"i0_i1_i2_v2 = (i0 << i1) << i2\n",
"i0_i1_i2_v0 == i0_i1_i2_v1 == i0_i1_i2_v2"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-03T14:45:41.860153Z",
"start_time": "2024-07-03T14:45:41.855897Z"
}
}
},
{
"cell_type": "code",
"execution_count": 8,
"outputs": [
{
"data": {
"text/plain": "True"
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"i0_i2_i1 = i0 << i2 << i1\n",
"i0 == i0_i2_i1 << ~(i2 << i1) == i0_i2_i1 << ~i1 << ~i2"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-03T14:47:02.948800Z",
"start_time": "2024-07-03T14:47:02.944314Z"
}
}
},
{
"cell_type": "code",
"execution_count": 11,
"outputs": [
{
"data": {
"text/plain": "True"
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"i0_o0_o1_o2_v1 = ((i0 < o0) < o1) < o2\n",
"i0_o0_o1_o2_v2 = (i0 < (o0 << o1)) < o2\n",
"i0_o0_o1_o2_v3 = ((i0 < o0) < (o1 << o2))\n",
"\n",
"i0_o0_o1_o2_v1 == i0_o0_o1_o2_v2 == i0_o0_o1_o2_v3"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-03T14:48:17.489611Z",
"start_time": "2024-07-03T14:48:17.485650Z"
}
}
},
{
"cell_type": "code",
"execution_count": 12,
"outputs": [
{
"data": {
"text/plain": "True"
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"i0 < (o0 << o1 << o2) != i0_o0_o1_o2_v1 # not equal"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-07-03T14:48:18.120561Z",
"start_time": "2024-07-03T14:48:18.116436Z"
}
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}