{ "cells": [ { "cell_type": "code", "id": "initial_id", "metadata": { "collapsed": true, "ExecuteTime": { "end_time": "2024-12-10T14:54:42.059468Z", "start_time": "2024-12-10T14:54:42.057421Z" } }, "source": [ "from src.keypad import Keypad\n", "from src.utils import total_shuffle_states, total_valid_nkode_states" ], "outputs": [], "execution_count": 3 }, { "metadata": { "ExecuteTime": { "end_time": "2024-12-10T14:54:43.388607Z", "start_time": "2024-12-10T14:54:43.373898Z" } }, "cell_type": "code", "source": [ "p = 4 # properties_per_key\n", "k = 3 # number_of_keys\n", "keypad = Keypad.new_keypad(k, p)\n", "print(keypad.keypad)\n", "keypad.partial_shuffle()\n", "print(keypad.keypad)\n", "keypad.partial_shuffle()\n", "print(keypad.keypad)\n" ], "id": "dd4b3cb6405a56e0", "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[ 8 1 2 3]\n", " [ 4 5 6 11]\n", " [ 0 9 10 7]]\n" ] }, { "ename": "UnboundLocalError", "evalue": "cannot access local variable 'shuffled_keypad' where it is not associated with a value", "output_type": "error", "traceback": [ "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", "\u001B[0;31mUnboundLocalError\u001B[0m Traceback (most recent call last)", "Cell \u001B[0;32mIn[4], line 5\u001B[0m\n\u001B[1;32m 3\u001B[0m keypad \u001B[38;5;241m=\u001B[39m Keypad\u001B[38;5;241m.\u001B[39mnew_keypad(k, p)\n\u001B[1;32m 4\u001B[0m \u001B[38;5;28mprint\u001B[39m(keypad\u001B[38;5;241m.\u001B[39mkeypad)\n\u001B[0;32m----> 5\u001B[0m keypad\u001B[38;5;241m.\u001B[39mpartial_shuffle()\n\u001B[1;32m 6\u001B[0m \u001B[38;5;28mprint\u001B[39m(keypad\u001B[38;5;241m.\u001B[39mkeypad)\n\u001B[1;32m 7\u001B[0m keypad\u001B[38;5;241m.\u001B[39mpartial_shuffle()\n", "File \u001B[0;32m~/repos/nkode-analysis/src/keypad.py:32\u001B[0m, in \u001B[0;36mKeypad.partial_shuffle\u001B[0;34m(self)\u001B[0m\n\u001B[1;32m 28\u001B[0m perm_indices \u001B[38;5;241m=\u001B[39m np\u001B[38;5;241m.\u001B[39mrandom\u001B[38;5;241m.\u001B[39mpermutation(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mk)\n\u001B[1;32m 30\u001B[0m shuffled_sets \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mkeypad[perm_indices, :][:, column_subset]\n\u001B[0;32m---> 32\u001B[0m \u001B[38;5;28;01mwhile\u001B[39;00m shuffled_keypad \u001B[38;5;129;01min\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mkeypad_cache:\n\u001B[1;32m 33\u001B[0m shuffled_keypad \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mkeypad[perm_indices, :][:, column_subset]\n\u001B[1;32m 35\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mkeypad_cache\u001B[38;5;241m.\u001B[39mappend(shuffled_keypad)\n", "\u001B[0;31mUnboundLocalError\u001B[0m: cannot access local variable 'shuffled_keypad' where it is not associated with a value" ] } ], "execution_count": 4 }, { "metadata": { "ExecuteTime": { "end_time": "2024-12-10T14:52:52.461529Z", "start_time": "2024-12-09T21:51:54.241796Z" } }, "cell_type": "code", "source": [ "print(total_shuffle_states(k,p))\n", "print(total_valid_nkode_states(k,p))" ], "id": "6e031aca38204895", "outputs": [ { "ename": "NameError", "evalue": "name 'k' is not defined", "output_type": "error", "traceback": [ "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", "\u001B[0;31mNameError\u001B[0m Traceback (most recent call last)", "Cell \u001B[0;32mIn[2], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[38;5;28mprint\u001B[39m(total_shuffle_states(k,p))\n\u001B[1;32m 2\u001B[0m \u001B[38;5;28mprint\u001B[39m(total_valid_nkode_states(k,p))\n", "\u001B[0;31mNameError\u001B[0m: name 'k' is not defined" ] } ], "execution_count": 2 }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": "", "id": "df3525c6e2bdaa8d" } ], "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": 5 }