{ "cells": [ { "cell_type": "markdown", "metadata": { "button": false, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "slide" } }, "source": [ "# Control Flow Graph\n", "\n", "The code in this notebook helps with obtaining the control flow graph of python functions." ] }, { "cell_type": "markdown", "metadata": { "button": false, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "source": [ "**Prerequisites**\n", "\n", "* This notebook needs some understanding on advanced concepts in Python, notably \n", " * classes" ] }, { "cell_type": "markdown", "metadata": { "button": false, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "slide" } }, "source": [ "## Control Flow Graph\n", "\n", "The class `PyCFG` allows one to obtain the control flow graph.\n", "\n", "```Python\n", "from ControlFlow import gen_cfg, to_graph\n", "cfg = gen_cfg(inspect.getsource(my_function))\n", "to_graph(cfg)\n", "```" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.098386Z", "iopub.status.busy": "2023-01-07T14:25:46.086060Z", "iopub.status.idle": "2023-01-07T14:25:46.130463Z", "shell.execute_reply": "2023-01-07T14:25:46.130710Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "skip" } }, "outputs": [], "source": [ "import bookutils" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.132671Z", "iopub.status.busy": "2023-01-07T14:25:46.132358Z", "iopub.status.idle": "2023-01-07T14:25:46.133582Z", "shell.execute_reply": "2023-01-07T14:25:46.133791Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "skip" } }, "outputs": [], "source": [ "from bookutils import print_content" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.135296Z", "iopub.status.busy": "2023-01-07T14:25:46.135005Z", "iopub.status.idle": "2023-01-07T14:25:46.136471Z", "shell.execute_reply": "2023-01-07T14:25:46.136670Z" }, "slideshow": { "slide_type": "skip" } }, "outputs": [], "source": [ "import ast\n", "import re" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.138722Z", "iopub.status.busy": "2023-01-07T14:25:46.138369Z", "iopub.status.idle": "2023-01-07T14:25:46.145782Z", "shell.execute_reply": "2023-01-07T14:25:46.145529Z" }, "slideshow": { "slide_type": "skip" } }, "outputs": [], "source": [ "from graphviz import Source, Digraph" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Registry" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.148055Z", "iopub.status.busy": "2023-01-07T14:25:46.147560Z", "iopub.status.idle": "2023-01-07T14:25:46.149119Z", "shell.execute_reply": "2023-01-07T14:25:46.149323Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "REGISTRY_IDX = 0" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.151299Z", "iopub.status.busy": "2023-01-07T14:25:46.150903Z", "iopub.status.idle": "2023-01-07T14:25:46.152336Z", "shell.execute_reply": "2023-01-07T14:25:46.152635Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "REGISTRY = {}" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.154780Z", "iopub.status.busy": "2023-01-07T14:25:46.154468Z", "iopub.status.idle": "2023-01-07T14:25:46.155661Z", "shell.execute_reply": "2023-01-07T14:25:46.155853Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "def get_registry_idx():\n", " global REGISTRY_IDX\n", " v = REGISTRY_IDX\n", " REGISTRY_IDX += 1\n", " return v" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.158009Z", "iopub.status.busy": "2023-01-07T14:25:46.157701Z", "iopub.status.idle": "2023-01-07T14:25:46.159232Z", "shell.execute_reply": "2023-01-07T14:25:46.159033Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "def reset_registry():\n", " global REGISTRY_IDX\n", " global REGISTRY\n", " REGISTRY_IDX = 0\n", " REGISTRY = {}" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.161228Z", "iopub.status.busy": "2023-01-07T14:25:46.160917Z", "iopub.status.idle": "2023-01-07T14:25:46.162126Z", "shell.execute_reply": "2023-01-07T14:25:46.162305Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def register_node(node):\n", " node.rid = get_registry_idx()\n", " REGISTRY[node.rid] = node" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.164068Z", "iopub.status.busy": "2023-01-07T14:25:46.163727Z", "iopub.status.idle": "2023-01-07T14:25:46.165074Z", "shell.execute_reply": "2023-01-07T14:25:46.165277Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "def get_registry():\n", " return dict(REGISTRY)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### CFGNode\n", "We start with the `CFGNode` representing each node in the control flow graph.\n", "\\todo{Augmented and annotated assignments (`a += 1`), (`a:int = 1`)}." ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.170927Z", "iopub.status.busy": "2023-01-07T14:25:46.170559Z", "iopub.status.idle": "2023-01-07T14:25:46.171776Z", "shell.execute_reply": "2023-01-07T14:25:46.171969Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class CFGNode(dict):\n", " def __init__(self, parents=[], ast=None):\n", " assert type(parents) is list\n", " register_node(self)\n", " self.parents = parents\n", " self.ast_node = ast\n", " self.update_children(parents) # requires self.rid\n", " self.children = []\n", " self.calls = []\n", "\n", " def i(self):\n", " return str(self.rid)\n", "\n", " def update_children(self, parents):\n", " for p in parents:\n", " p.add_child(self)\n", "\n", " def add_child(self, c):\n", " if c not in self.children:\n", " self.children.append(c)\n", "\n", " def lineno(self):\n", " return self.ast_node.lineno if hasattr(self.ast_node, 'lineno') else 0\n", "\n", " def __str__(self):\n", " return \"id:%d line[%d] parents: %s : %s\" % (\n", " self.rid, self.lineno(), str([p.rid for p in self.parents]),\n", " self.source())\n", "\n", " def __repr__(self):\n", " return str(self)\n", "\n", " def __eq__(self, other):\n", " return self.rid == other.rid\n", "\n", " def __neq__(self, other):\n", " return self.rid != other.rid\n", "\n", " def set_parents(self, p):\n", " self.parents = p\n", "\n", " def add_parent(self, p):\n", " if p not in self.parents:\n", " self.parents.append(p)\n", "\n", " def add_parents(self, ps):\n", " for p in ps:\n", " self.add_parent(p)\n", "\n", " def add_calls(self, func):\n", " self.calls.append(func)\n", "\n", " def source(self):\n", " return ast.unparse(self.ast_node).strip()\n", "\n", " def to_json(self):\n", " return {\n", " 'id': self.rid,\n", " 'parents': [p.rid for p in self.parents],\n", " 'children': [c.rid for c in self.children],\n", " 'calls': self.calls,\n", " 'at': self.lineno(),\n", " 'ast': self.source()\n", " }" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### PyCFG\n", "\n", "Next, the `PyCFG` class which is responsible for parsing, and holding the graph." ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.174204Z", "iopub.status.busy": "2023-01-07T14:25:46.173901Z", "iopub.status.idle": "2023-01-07T14:25:46.175199Z", "shell.execute_reply": "2023-01-07T14:25:46.175457Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "class PyCFG:\n", " def __init__(self):\n", " self.founder = CFGNode(\n", " parents=[], ast=ast.parse('start').body[0]) # sentinel\n", " self.founder.ast_node.lineno = 0\n", " self.functions = {}\n", " self.functions_node = {}" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.177254Z", "iopub.status.busy": "2023-01-07T14:25:46.176939Z", "iopub.status.idle": "2023-01-07T14:25:46.178370Z", "shell.execute_reply": "2023-01-07T14:25:46.178569Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def parse(self, src):\n", " return ast.parse(src)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.180807Z", "iopub.status.busy": "2023-01-07T14:25:46.180503Z", "iopub.status.idle": "2023-01-07T14:25:46.181971Z", "shell.execute_reply": "2023-01-07T14:25:46.182196Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def walk(self, node, myparents):\n", " fname = \"on_%s\" % node.__class__.__name__.lower()\n", " if hasattr(self, fname):\n", " fn = getattr(self, fname)\n", " v = fn(node, myparents)\n", " return v\n", " else:\n", " return myparents" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.184795Z", "iopub.status.busy": "2023-01-07T14:25:46.184493Z", "iopub.status.idle": "2023-01-07T14:25:46.185855Z", "shell.execute_reply": "2023-01-07T14:25:46.186147Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_module(self, node, myparents):\n", " \"\"\"\n", " Module(stmt* body)\n", " \"\"\"\n", " # each time a statement is executed unconditionally, make a link from\n", " # the result to next statement\n", " p = myparents\n", " for n in node.body:\n", " p = self.walk(n, p)\n", " return p" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.188240Z", "iopub.status.busy": "2023-01-07T14:25:46.187938Z", "iopub.status.idle": "2023-01-07T14:25:46.189185Z", "shell.execute_reply": "2023-01-07T14:25:46.189419Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_augassign(self, node, myparents):\n", " \"\"\"\n", " AugAssign(expr target, operator op, expr value)\n", " \"\"\"\n", " p = [CFGNode(parents=myparents, ast=node)]\n", " p = self.walk(node.value, p)\n", "\n", " return p" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.191395Z", "iopub.status.busy": "2023-01-07T14:25:46.191109Z", "iopub.status.idle": "2023-01-07T14:25:46.192366Z", "shell.execute_reply": "2023-01-07T14:25:46.192555Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_annassign(self, node, myparents):\n", " \"\"\"\n", " AnnAssign(expr target, expr annotation, expr? value, int simple)\n", " \"\"\"\n", " p = [CFGNode(parents=myparents, ast=node)]\n", " p = self.walk(node.value, p)\n", "\n", " return p" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.194780Z", "iopub.status.busy": "2023-01-07T14:25:46.194436Z", "iopub.status.idle": "2023-01-07T14:25:46.195671Z", "shell.execute_reply": "2023-01-07T14:25:46.195995Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_assign(self, node, myparents):\n", " \"\"\"\n", " Assign(expr* targets, expr value)\n", " \"\"\"\n", " if len(node.targets) > 1:\n", " raise NotImplemented('Parallel assignments')\n", "\n", " p = [CFGNode(parents=myparents, ast=node)]\n", " p = self.walk(node.value, p)\n", "\n", " return p" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.198022Z", "iopub.status.busy": "2023-01-07T14:25:46.197712Z", "iopub.status.idle": "2023-01-07T14:25:46.199494Z", "shell.execute_reply": "2023-01-07T14:25:46.199856Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_pass(self, node, myparents):\n", " return [CFGNode(parents=myparents, ast=node)]" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.202983Z", "iopub.status.busy": "2023-01-07T14:25:46.202611Z", "iopub.status.idle": "2023-01-07T14:25:46.204084Z", "shell.execute_reply": "2023-01-07T14:25:46.204326Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_break(self, node, myparents):\n", " parent = myparents[0]\n", " while not hasattr(parent, 'exit_nodes'):\n", " # we have ordered parents\n", " parent = parent.parents[0]\n", "\n", " assert hasattr(parent, 'exit_nodes')\n", " p = CFGNode(parents=myparents, ast=node)\n", "\n", " # make the break one of the parents of label node.\n", " parent.exit_nodes.append(p)\n", "\n", " # break doesn't have immediate children\n", " return []" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.207039Z", "iopub.status.busy": "2023-01-07T14:25:46.206699Z", "iopub.status.idle": "2023-01-07T14:25:46.207972Z", "shell.execute_reply": "2023-01-07T14:25:46.208175Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_continue(self, node, myparents):\n", " parent = myparents[0]\n", " while not hasattr(parent, 'exit_nodes'):\n", " # we have ordered parents\n", " parent = parent.parents[0]\n", " assert hasattr(parent, 'exit_nodes')\n", " p = CFGNode(parents=myparents, ast=node)\n", "\n", " # make continue one of the parents of the original test node.\n", " parent.add_parent(p)\n", "\n", " # return the parent because a continue is not the parent\n", " # for the just next node\n", " return []" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.211750Z", "iopub.status.busy": "2023-01-07T14:25:46.211406Z", "iopub.status.idle": "2023-01-07T14:25:46.212697Z", "shell.execute_reply": "2023-01-07T14:25:46.212948Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_for(self, node, myparents):\n", " # node.target in node.iter: node.body\n", " # The For loop in python (no else) can be translated\n", " # as follows:\n", " # \n", " # for a in iterator:\n", " # mystatements\n", " #\n", " # __iv = iter(iterator)\n", " # while __iv.__length_hint() > 0:\n", " # a = next(__iv)\n", " # mystatements\n", "\n", " init_node = CFGNode(parents=myparents,\n", " ast=ast.parse('__iv = iter(%s)' % ast.unparse(node.iter).strip()).body[0])\n", " ast.copy_location(init_node.ast_node, node.iter)\n", "\n", " _test_node = CFGNode(\n", " parents=[init_node],\n", " ast=ast.parse('_for: __iv.__length__hint__() > 0').body[0])\n", " ast.copy_location(_test_node.ast_node, node)\n", "\n", " # we attach the label node here so that break can find it.\n", " _test_node.exit_nodes = []\n", " test_node = self.walk(node.iter, [_test_node])\n", "\n", " extract_node = CFGNode(parents=test_node,\n", " ast=ast.parse('%s = next(__iv)' % ast.unparse(node.target).strip()).body[0])\n", " ast.copy_location(extract_node.ast_node, node.iter)\n", "\n", " # now we evaluate the body, one at a time.\n", " p1 = [extract_node]\n", " for n in node.body:\n", " p1 = self.walk(n, p1)\n", "\n", " # the test node is looped back at the end of processing.\n", " _test_node.add_parents(p1)\n", "\n", " return _test_node.exit_nodes + test_node" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.215828Z", "iopub.status.busy": "2023-01-07T14:25:46.215451Z", "iopub.status.idle": "2023-01-07T14:25:46.216760Z", "shell.execute_reply": "2023-01-07T14:25:46.216997Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_while(self, node, myparents):\n", " # For a while, the earliest parent is the node.test\n", " _test_node = CFGNode(\n", " parents=myparents,\n", " ast=ast.parse(\n", " '_while: %s' % ast.unparse(node.test).strip()).body[0])\n", " ast.copy_location(_test_node.ast_node, node.test)\n", " _test_node.exit_nodes = []\n", " test_node = self.walk(node.test, [_test_node])\n", "\n", " # we attach the label node here so that break can find it.\n", "\n", " # now we evaluate the body, one at a time.\n", " assert len(test_node) == 1\n", " p1 = test_node\n", " for n in node.body:\n", " p1 = self.walk(n, p1)\n", "\n", " # the test node is looped back at the end of processing.\n", " _test_node.add_parents(p1)\n", "\n", " # link label node back to the condition.\n", " return _test_node.exit_nodes + test_node" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.220083Z", "iopub.status.busy": "2023-01-07T14:25:46.219731Z", "iopub.status.idle": "2023-01-07T14:25:46.221008Z", "shell.execute_reply": "2023-01-07T14:25:46.221347Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_if(self, node, myparents):\n", " _test_node = CFGNode(\n", " parents=myparents,\n", " ast=ast.parse(\n", " '_if: %s' % ast.unparse(node.test).strip()).body[0])\n", " ast.copy_location(_test_node.ast_node, node.test)\n", " test_node = self.walk(node.test, [ _test_node])\n", " assert len(test_node) == 1\n", " g1 = test_node\n", " for n in node.body:\n", " g1 = self.walk(n, g1)\n", " g2 = test_node\n", " for n in node.orelse:\n", " g2 = self.walk(n, g2)\n", " return g1 + g2" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.223517Z", "iopub.status.busy": "2023-01-07T14:25:46.223215Z", "iopub.status.idle": "2023-01-07T14:25:46.224913Z", "shell.execute_reply": "2023-01-07T14:25:46.225283Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_binop(self, node, myparents):\n", " left = self.walk(node.left, myparents)\n", " right = self.walk(node.right, left)\n", " return right" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.227932Z", "iopub.status.busy": "2023-01-07T14:25:46.227452Z", "iopub.status.idle": "2023-01-07T14:25:46.228730Z", "shell.execute_reply": "2023-01-07T14:25:46.228980Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_compare(self, node, myparents):\n", " left = self.walk(node.left, myparents)\n", " right = self.walk(node.comparators[0], left)\n", " return right" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.230990Z", "iopub.status.busy": "2023-01-07T14:25:46.230701Z", "iopub.status.idle": "2023-01-07T14:25:46.232016Z", "shell.execute_reply": "2023-01-07T14:25:46.232223Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_unaryop(self, node, myparents):\n", " return self.walk(node.operand, myparents)" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.235492Z", "iopub.status.busy": "2023-01-07T14:25:46.235133Z", "iopub.status.idle": "2023-01-07T14:25:46.236463Z", "shell.execute_reply": "2023-01-07T14:25:46.236693Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_call(self, node, myparents):\n", " def get_func(node):\n", " if type(node.func) is ast.Name:\n", " mid = node.func.id\n", " elif type(node.func) is ast.Attribute:\n", " mid = node.func.attr\n", " elif type(node.func) is ast.Call:\n", " mid = get_func(node.func)\n", " else:\n", " raise Exception(str(type(node.func)))\n", " return mid\n", " #mid = node.func.value.id\n", "\n", " p = myparents\n", " for a in node.args:\n", " p = self.walk(a, p)\n", " mid = get_func(node)\n", " myparents[0].add_calls(mid)\n", "\n", " # these need to be unlinked later if our module actually defines these\n", " # functions. Otherwsise we may leave them around.\n", " # during a call, the direct child is not the next\n", " # statement in text.\n", " for c in p:\n", " c.calllink = 0\n", " return p" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.238929Z", "iopub.status.busy": "2023-01-07T14:25:46.238634Z", "iopub.status.idle": "2023-01-07T14:25:46.239804Z", "shell.execute_reply": "2023-01-07T14:25:46.240070Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_expr(self, node, myparents):\n", " p = [CFGNode(parents=myparents, ast=node)]\n", " return self.walk(node.value, p)" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.242905Z", "iopub.status.busy": "2023-01-07T14:25:46.242570Z", "iopub.status.idle": "2023-01-07T14:25:46.243692Z", "shell.execute_reply": "2023-01-07T14:25:46.244034Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_return(self, node, myparents):\n", " if type(myparents) is tuple:\n", " parent = myparents[0][0]\n", " else:\n", " parent = myparents[0]\n", "\n", " val_node = self.walk(node.value, myparents)\n", " # on return look back to the function definition.\n", " while not hasattr(parent, 'return_nodes'):\n", " parent = parent.parents[0]\n", " assert hasattr(parent, 'return_nodes')\n", "\n", " p = CFGNode(parents=val_node, ast=node)\n", "\n", " # make the break one of the parents of label node.\n", " parent.return_nodes.append(p)\n", "\n", " # return doesnt have immediate children\n", " return []" ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.247808Z", "iopub.status.busy": "2023-01-07T14:25:46.247467Z", "iopub.status.idle": "2023-01-07T14:25:46.248956Z", "shell.execute_reply": "2023-01-07T14:25:46.249218Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def on_functiondef(self, node, myparents):\n", " # a function definition does not actually continue the thread of\n", " # control flow\n", " # name, args, body, decorator_list, returns\n", " fname = node.name\n", " args = node.args\n", " returns = node.returns\n", "\n", " enter_node = CFGNode(\n", " parents=[],\n", " ast=ast.parse('enter: %s(%s)' % (node.name, ', '.join(\n", " [a.arg for a in node.args.args]))).body[0]) # sentinel\n", " enter_node.calleelink = True\n", " ast.copy_location(enter_node.ast_node, node)\n", " exit_node = CFGNode(\n", " parents=[],\n", " ast=ast.parse('exit: %s(%s)' % (node.name, ', '.join(\n", " [a.arg for a in node.args.args]))).body[0]) # sentinel\n", " exit_node.fn_exit_node = True\n", " ast.copy_location(exit_node.ast_node, node)\n", " enter_node.return_nodes = [] # sentinel\n", "\n", " p = [enter_node]\n", " for n in node.body:\n", " p = self.walk(n, p)\n", "\n", " for n in p:\n", " if n not in enter_node.return_nodes:\n", " enter_node.return_nodes.append(n)\n", "\n", " for n in enter_node.return_nodes:\n", " exit_node.add_parent(n)\n", "\n", " self.functions[fname] = [enter_node, exit_node]\n", " self.functions_node[enter_node.lineno()] = fname\n", "\n", " return myparents" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.251807Z", "iopub.status.busy": "2023-01-07T14:25:46.251508Z", "iopub.status.idle": "2023-01-07T14:25:46.252980Z", "shell.execute_reply": "2023-01-07T14:25:46.253291Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def get_defining_function(self, node):\n", " if node.lineno() in self.functions_node:\n", " return self.functions_node[node.lineno()]\n", " if not node.parents:\n", " self.functions_node[node.lineno()] = ''\n", " return ''\n", " val = self.get_defining_function(node.parents[0])\n", " self.functions_node[node.lineno()] = val\n", " return val" ] }, { "cell_type": "code", "execution_count": 33, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.255995Z", "iopub.status.busy": "2023-01-07T14:25:46.255684Z", "iopub.status.idle": "2023-01-07T14:25:46.256902Z", "shell.execute_reply": "2023-01-07T14:25:46.257151Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def link_functions(self):\n", " for nid, node in REGISTRY.items():\n", " if node.calls:\n", " for calls in node.calls:\n", " if calls in self.functions:\n", " enter, exit = self.functions[calls]\n", " enter.add_parent(node)\n", " if node.children:\n", " # # until we link the functions up, the node\n", " # # should only have succeeding node in text as\n", " # # children.\n", " # assert(len(node.children) == 1)\n", " # passn = node.children[0]\n", " # # We require a single pass statement after every\n", " # # call (which means no complex expressions)\n", " # assert(type(passn.ast_node) == ast.Pass)\n", "\n", " # # unlink the call statement\n", " assert node.calllink > -1\n", " node.calllink += 1\n", " for i in node.children:\n", " i.add_parent(exit)\n", " # passn.set_parents([exit])\n", " # ast.copy_location(exit.ast_node, passn.ast_node)\n", "\n", " # #for c in passn.children: c.add_parent(exit)\n", " # #passn.ast_node = exit.ast_node" ] }, { "cell_type": "code", "execution_count": 34, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.259086Z", "iopub.status.busy": "2023-01-07T14:25:46.258805Z", "iopub.status.idle": "2023-01-07T14:25:46.260082Z", "shell.execute_reply": "2023-01-07T14:25:46.260319Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def update_functions(self):\n", " for nid, node in REGISTRY.items():\n", " _n = self.get_defining_function(node)" ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.262521Z", "iopub.status.busy": "2023-01-07T14:25:46.262159Z", "iopub.status.idle": "2023-01-07T14:25:46.263592Z", "shell.execute_reply": "2023-01-07T14:25:46.263794Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def update_children(self):\n", " for nid, node in REGISTRY.items():\n", " for p in node.parents:\n", " p.add_child(node)" ] }, { "cell_type": "code", "execution_count": 36, "metadata": { "button": false, "execution": { "iopub.execute_input": "2023-01-07T14:25:46.266586Z", "iopub.status.busy": "2023-01-07T14:25:46.266255Z", "iopub.status.idle": "2023-01-07T14:25:46.267560Z", "shell.execute_reply": "2023-01-07T14:25:46.267894Z" }, "new_sheet": false, "run_control": { "read_only": false }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class PyCFG(PyCFG):\n", " def gen_cfg(self, src):\n", " \"\"\"\n", " >>> i = PyCFG()\n", " >>> i.walk(\"100\")\n", " 5\n", " \"\"\"\n", " node = self.parse(src)\n", " nodes = self.walk(node, [self.founder])\n", " self.last_node = CFGNode(parents=nodes, ast=ast.parse('stop').body[0])\n", " ast.copy_location(self.last_node.ast_node, self.founder.ast_node)\n", " self.update_children()\n", " self.update_functions()\n", " self.link_functions()" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Supporting Functions" ] }, { "cell_type": "code", "execution_count": 37, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.271117Z", "iopub.status.busy": "2023-01-07T14:25:46.270744Z", "iopub.status.idle": "2023-01-07T14:25:46.271920Z", "shell.execute_reply": "2023-01-07T14:25:46.272163Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def compute_dominator(cfg, start=0, key='parents'):\n", " dominator = {}\n", " dominator[start] = {start}\n", " all_nodes = set(cfg.keys())\n", " rem_nodes = all_nodes - {start}\n", " for n in rem_nodes:\n", " dominator[n] = all_nodes\n", "\n", " c = True\n", " while c:\n", " c = False\n", " for n in rem_nodes:\n", " pred_n = cfg[n][key]\n", " doms = [dominator[p] for p in pred_n]\n", " i = set.intersection(*doms) if doms else set()\n", " v = {n} | i\n", " if dominator[n] != v:\n", " c = True\n", " dominator[n] = v\n", " return dominator" ] }, { "cell_type": "code", "execution_count": 38, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.274512Z", "iopub.status.busy": "2023-01-07T14:25:46.274091Z", "iopub.status.idle": "2023-01-07T14:25:46.275156Z", "shell.execute_reply": "2023-01-07T14:25:46.275399Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def compute_flow(pythonfile):\n", " cfg, first, last = get_cfg(pythonfile)\n", " return cfg, compute_dominator(\n", " cfg, start=first), compute_dominator(\n", " cfg, start=last, key='children')" ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.277759Z", "iopub.status.busy": "2023-01-07T14:25:46.277410Z", "iopub.status.idle": "2023-01-07T14:25:46.278552Z", "shell.execute_reply": "2023-01-07T14:25:46.278794Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def gen_cfg(fnsrc, remove_start_stop=True):\n", " reset_registry()\n", " cfg = PyCFG()\n", " cfg.gen_cfg(fnsrc)\n", " cache = dict(REGISTRY)\n", " if remove_start_stop:\n", " return {\n", " k: cache[k]\n", " for k in cache if cache[k].source() not in {'start', 'stop'}\n", " }\n", " else:\n", " return cache" ] }, { "cell_type": "code", "execution_count": 40, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.281793Z", "iopub.status.busy": "2023-01-07T14:25:46.279760Z", "iopub.status.idle": "2023-01-07T14:25:46.283064Z", "shell.execute_reply": "2023-01-07T14:25:46.283419Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def get_cfg(src):\n", " reset_registry()\n", " cfg = PyCFG()\n", " cfg.gen_cfg(src)\n", " cache = dict(REGISTRY)\n", " g = {}\n", " for k, v in cache.items():\n", " j = v.to_json()\n", " at = j['at']\n", " parents_at = [cache[p].to_json()['at'] for p in j['parents']]\n", " children_at = [cache[c].to_json()['at'] for c in j['children']]\n", " if at not in g:\n", " g[at] = {'parents': set(), 'children': set()}\n", " # remove dummy nodes\n", " ps = set([p for p in parents_at if p != at])\n", " cs = set([c for c in children_at if c != at])\n", " g[at]['parents'] |= ps\n", " g[at]['children'] |= cs\n", " if v.calls:\n", " g[at]['calls'] = v.calls\n", " g[at]['function'] = cfg.functions_node[v.lineno()]\n", " return (g, cfg.founder.ast_node.lineno, cfg.last_node.ast_node.lineno)" ] }, { "cell_type": "code", "execution_count": 41, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.289426Z", "iopub.status.busy": "2023-01-07T14:25:46.289101Z", "iopub.status.idle": "2023-01-07T14:25:46.290561Z", "shell.execute_reply": "2023-01-07T14:25:46.290772Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def to_graph(cache, arcs=[]):\n", " graph = Digraph(comment='Control Flow Graph')\n", " colors = {0: 'blue', 1: 'red'}\n", " kind = {0: 'T', 1: 'F'}\n", " cov_lines = set(i for i, j in arcs)\n", " for nid, cnode in cache.items():\n", " lineno = cnode.lineno()\n", " shape, peripheries = 'oval', '1'\n", " if isinstance(cnode.ast_node, ast.AnnAssign):\n", " if cnode.ast_node.target.id in {'_if', '_for', '_while'}:\n", " shape = 'diamond'\n", " elif cnode.ast_node.target.id in {'enter', 'exit'}:\n", " shape, peripheries = 'oval', '2'\n", " else:\n", " shape = 'rectangle'\n", " graph.node(cnode.i(), \"%d: %s\" % (lineno, unhack(cnode.source())),\n", " shape=shape, peripheries=peripheries)\n", " for pn in cnode.parents:\n", " plineno = pn.lineno()\n", " if hasattr(pn, 'calllink') and pn.calllink > 0 and not hasattr(\n", " cnode, 'calleelink'):\n", " graph.edge(pn.i(), cnode.i(), style='dotted', weight=100)\n", " continue\n", "\n", " if arcs:\n", " if (plineno, lineno) in arcs:\n", " graph.edge(pn.i(), cnode.i(), color='green')\n", " elif plineno == lineno and lineno in cov_lines:\n", " graph.edge(pn.i(), cnode.i(), color='green')\n", " # child is exit and parent is covered\n", " elif hasattr(cnode, 'fn_exit_node') and plineno in cov_lines:\n", " graph.edge(pn.i(), cnode.i(), color='green')\n", " # parent is exit and one of its parents is covered.\n", " elif hasattr(pn, 'fn_exit_node') and len(\n", " set(n.lineno() for n in pn.parents) | cov_lines) > 0:\n", " graph.edge(pn.i(), cnode.i(), color='green')\n", " # child is a callee (has calleelink) and one of the parents is covered.\n", " elif plineno in cov_lines and hasattr(cnode, 'calleelink'):\n", " graph.edge(pn.i(), cnode.i(), color='green')\n", " else:\n", " graph.edge(pn.i(), cnode.i(), color='red')\n", " else:\n", " order = {c.i(): i for i, c in enumerate(pn.children)}\n", " if len(order) < 2:\n", " graph.edge(pn.i(), cnode.i())\n", " else:\n", " o = order[cnode.i()]\n", " graph.edge(pn.i(), cnode.i(), color=colors[o], label=kind[o])\n", " return graph" ] }, { "cell_type": "code", "execution_count": 42, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.292889Z", "iopub.status.busy": "2023-01-07T14:25:46.292575Z", "iopub.status.idle": "2023-01-07T14:25:46.293962Z", "shell.execute_reply": "2023-01-07T14:25:46.294359Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def unhack(v):\n", " for i in ['if', 'while', 'for', 'elif']:\n", " v = re.sub(r'^_%s:' % i, '%s:' % i, v)\n", " return v" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Examples" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "#### check_triangle" ] }, { "cell_type": "code", "execution_count": 43, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.296928Z", "iopub.status.busy": "2023-01-07T14:25:46.296602Z", "iopub.status.idle": "2023-01-07T14:25:46.297767Z", "shell.execute_reply": "2023-01-07T14:25:46.298068Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def check_triangle(a, b, c):\n", " if a == b:\n", " if a == c:\n", " if b == c:\n", " return \"Equilateral\"\n", " else:\n", " return \"Isosceles\"\n", " else:\n", " return \"Isosceles\"\n", " else:\n", " if b != c:\n", " if a == c:\n", " return \"Isosceles\"\n", " else:\n", " return \"Scalene\"\n", " else:\n", " return \"Isosceles\"" ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.300221Z", "iopub.status.busy": "2023-01-07T14:25:46.299882Z", "iopub.status.idle": "2023-01-07T14:25:46.301339Z", "shell.execute_reply": "2023-01-07T14:25:46.301756Z" }, "slideshow": { "slide_type": "skip" } }, "outputs": [], "source": [ "import inspect" ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.305545Z", "iopub.status.busy": "2023-01-07T14:25:46.303827Z", "iopub.status.idle": "2023-01-07T14:25:46.587562Z", "shell.execute_reply": "2023-01-07T14:25:46.587769Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "1\n", "\n", "\n", "1: enter: check_triangle(a, b, c)\n", "\n", "\n", "\n", "3\n", "\n", "2: if: a == b\n", "\n", "\n", "\n", "1->3\n", "\n", "\n", "\n", "\n", "\n", "2\n", "\n", "\n", "1: exit: check_triangle(a, b, c)\n", "\n", "\n", "\n", "6\n", "\n", "5: return 'Equilateral'\n", "\n", "\n", "\n", "6->2\n", "\n", "\n", "\n", "\n", "\n", "7\n", "\n", "7: return 'Isosceles'\n", "\n", "\n", "\n", "7->2\n", "\n", "\n", "\n", "\n", "\n", "8\n", "\n", "9: return 'Isosceles'\n", "\n", "\n", "\n", "8->2\n", "\n", "\n", "\n", "\n", "\n", "11\n", "\n", "13: return 'Isosceles'\n", "\n", "\n", "\n", "11->2\n", "\n", "\n", "\n", "\n", "\n", "12\n", "\n", "15: return 'Scalene'\n", "\n", "\n", "\n", "12->2\n", "\n", "\n", "\n", "\n", "\n", "13\n", "\n", "17: return 'Isosceles'\n", "\n", "\n", "\n", "13->2\n", "\n", "\n", "\n", "\n", "\n", "4\n", "\n", "3: if: a == c\n", "\n", "\n", "\n", "3->4\n", "\n", "\n", "T\n", "\n", "\n", "\n", "9\n", "\n", "11: if: b != c\n", "\n", "\n", "\n", "3->9\n", "\n", "\n", "F\n", "\n", "\n", "\n", "4->8\n", "\n", "\n", "F\n", "\n", "\n", "\n", "5\n", "\n", "4: if: b == c\n", "\n", "\n", "\n", "4->5\n", "\n", "\n", "T\n", "\n", "\n", "\n", "5->6\n", "\n", "\n", "T\n", "\n", "\n", "\n", "5->7\n", "\n", "\n", "F\n", "\n", "\n", "\n", "9->13\n", "\n", "\n", "F\n", "\n", "\n", "\n", "10\n", "\n", "12: if: a == c\n", "\n", "\n", "\n", "9->10\n", "\n", "\n", "T\n", "\n", "\n", "\n", "10->11\n", "\n", "\n", "T\n", "\n", "\n", "\n", "10->12\n", "\n", "\n", "F\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "to_graph(gen_cfg(inspect.getsource(check_triangle)))" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "#### cgi_decode\n", "\n", "Note that we do not yet support _augmented assignments_: i.e assignments such as `+=`" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.592434Z", "iopub.status.busy": "2023-01-07T14:25:46.592123Z", "iopub.status.idle": "2023-01-07T14:25:46.593327Z", "shell.execute_reply": "2023-01-07T14:25:46.593524Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def cgi_decode(s):\n", " hex_values = {\n", " '0': 0, '1': 1, '2': 2, '3': 3, '4': 4,\n", " '5': 5, '6': 6, '7': 7, '8': 8, '9': 9,\n", " 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15,\n", " 'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15,\n", " }\n", "\n", " t = \"\"\n", " i = 0\n", " while i < len(s):\n", " c = s[i]\n", " if c == '+':\n", " t += ' '\n", " elif c == '%':\n", " digit_high, digit_low = s[i + 1], s[i + 2]\n", " i += 2\n", " if digit_high in hex_values and digit_low in hex_values:\n", " v = hex_values[digit_high] * 16 + hex_values[digit_low]\n", " t += chr(v)\n", " else:\n", " raise ValueError(\"Invalid encoding\")\n", " else:\n", " t += c\n", " i += 1\n", " return t" ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.615774Z", "iopub.status.busy": "2023-01-07T14:25:46.615364Z", "iopub.status.idle": "2023-01-07T14:25:46.871831Z", "shell.execute_reply": "2023-01-07T14:25:46.872127Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "1\n", "\n", "\n", "1: enter: cgi_decode(s)\n", "\n", "\n", "\n", "3\n", "\n", "2: hex_values = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15, 'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15}\n", "\n", "\n", "\n", "1->3\n", "\n", "\n", "\n", "\n", "\n", "2\n", "\n", "\n", "1: exit: cgi_decode(s)\n", "\n", "\n", "\n", "18\n", "\n", "26: return t\n", "\n", "\n", "\n", "18->2\n", "\n", "\n", "\n", "\n", "\n", "4\n", "\n", "9: t = ''\n", "\n", "\n", "\n", "3->4\n", "\n", "\n", "\n", "\n", "\n", "5\n", "\n", "10: i = 0\n", "\n", "\n", "\n", "4->5\n", "\n", "\n", "\n", "\n", "\n", "6\n", "\n", "11: while: i < len(s)\n", "\n", "\n", "\n", "5->6\n", "\n", "\n", "\n", "\n", "\n", "6->18\n", "\n", "\n", "F\n", "\n", "\n", "\n", "7\n", "\n", "12: c = s[i]\n", "\n", "\n", "\n", "6->7\n", "\n", "\n", "T\n", "\n", "\n", "\n", "17\n", "\n", "25: i += 1\n", "\n", "\n", "\n", "17->6\n", "\n", "\n", "\n", "\n", "\n", "8\n", "\n", "13: if: c == '+'\n", "\n", "\n", "\n", "7->8\n", "\n", "\n", "\n", "\n", "\n", "9\n", "\n", "14: t += ' '\n", "\n", "\n", "\n", "8->9\n", "\n", "\n", "T\n", "\n", "\n", "\n", "10\n", "\n", "15: if: c == '%'\n", "\n", "\n", "\n", "8->10\n", "\n", "\n", "F\n", "\n", "\n", "\n", "9->17\n", "\n", "\n", "\n", "\n", "\n", "11\n", "\n", "16: (digit_high, digit_low) = (s[i + 1], s[i + 2])\n", "\n", "\n", "\n", "10->11\n", "\n", "\n", "T\n", "\n", "\n", "\n", "16\n", "\n", "24: t += c\n", "\n", "\n", "\n", "10->16\n", "\n", "\n", "F\n", "\n", "\n", "\n", "12\n", "\n", "17: i += 2\n", "\n", "\n", "\n", "11->12\n", "\n", "\n", "\n", "\n", "\n", "13\n", "\n", "18: if: digit_high in hex_values and digit_low in hex_values\n", "\n", "\n", "\n", "12->13\n", "\n", "\n", "\n", "\n", "\n", "13->17\n", "\n", "\n", "F\n", "\n", "\n", "\n", "14\n", "\n", "19: v = hex_values[digit_high] * 16 + hex_values[digit_low]\n", "\n", "\n", "\n", "13->14\n", "\n", "\n", "T\n", "\n", "\n", "\n", "15\n", "\n", "20: t += chr(v)\n", "\n", "\n", "\n", "14->15\n", "\n", "\n", "\n", "\n", "\n", "15->17\n", "\n", "\n", "\n", "\n", "\n", "16->17\n", "\n", "\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "to_graph(gen_cfg(inspect.getsource(cgi_decode)))" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "#### gcd" ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:46.874556Z", "iopub.status.busy": "2023-01-07T14:25:46.873319Z", "iopub.status.idle": "2023-01-07T14:25:46.875715Z", "shell.execute_reply": "2023-01-07T14:25:46.875928Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "def gcd(a, b):\n", " if a\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "1\n", "\n", "\n", "1: enter: gcd(a, b)\n", "\n", "\n", "\n", "3\n", "\n", "2: if: a < b\n", "\n", "\n", "\n", "1->3\n", "\n", "\n", "\n", "\n", "\n", "2\n", "\n", "\n", "1: exit: gcd(a, b)\n", "\n", "\n", "\n", "11\n", "\n", "11: return a\n", "\n", "\n", "\n", "11->2\n", "\n", "\n", "\n", "\n", "\n", "4\n", "\n", "3: c: int = a\n", "\n", "\n", "\n", "3->4\n", "\n", "\n", "T\n", "\n", "\n", "\n", "7\n", "\n", "7: while: b != 0\n", "\n", "\n", "\n", "3->7\n", "\n", "\n", "F\n", "\n", "\n", "\n", "5\n", "\n", "4: a: int = b\n", "\n", "\n", "\n", "4->5\n", "\n", "\n", "\n", "\n", "\n", "6\n", "\n", "5: b: int = c\n", "\n", "\n", "\n", "5->6\n", "\n", "\n", "\n", "\n", "\n", "6->7\n", "\n", "\n", "\n", "\n", "\n", "7->11\n", "\n", "\n", "F\n", "\n", "\n", "\n", "8\n", "\n", "8: c: int = a\n", "\n", "\n", "\n", "7->8\n", "\n", "\n", "T\n", "\n", "\n", "\n", "10\n", "\n", "10: b: int = c % b\n", "\n", "\n", "\n", "10->7\n", "\n", "\n", "\n", "\n", "\n", "9\n", "\n", "9: a: int = b\n", "\n", "\n", "\n", "8->9\n", "\n", "\n", "\n", "\n", "\n", "9->10\n", "\n", "\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "to_graph(gen_cfg(inspect.getsource(gcd)))" ] }, { "cell_type": "code", "execution_count": 50, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.130888Z", "iopub.status.busy": "2023-01-07T14:25:47.130584Z", "iopub.status.idle": "2023-01-07T14:25:47.131790Z", "shell.execute_reply": "2023-01-07T14:25:47.132032Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def compute_gcd(x, y):\n", " if x > y:\n", " small = y\n", " else:\n", " small = x\n", " for i in range(1, small+1):\n", " if((x % i == 0) and (y % i == 0)):\n", " gcd = i\n", "\n", " return gcd" ] }, { "cell_type": "code", "execution_count": 51, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.137611Z", "iopub.status.busy": "2023-01-07T14:25:47.137044Z", "iopub.status.idle": "2023-01-07T14:25:47.382243Z", "shell.execute_reply": "2023-01-07T14:25:47.382505Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "1\n", "\n", "\n", "1: enter: compute_gcd(x, y)\n", "\n", "\n", "\n", "3\n", "\n", "2: if: x > y\n", "\n", "\n", "\n", "1->3\n", "\n", "\n", "\n", "\n", "\n", "2\n", "\n", "\n", "1: exit: compute_gcd(x, y)\n", "\n", "\n", "\n", "11\n", "\n", "10: return gcd\n", "\n", "\n", "\n", "11->2\n", "\n", "\n", "\n", "\n", "\n", "4\n", "\n", "3: small = y\n", "\n", "\n", "\n", "3->4\n", "\n", "\n", "T\n", "\n", "\n", "\n", "5\n", "\n", "5: small = x\n", "\n", "\n", "\n", "3->5\n", "\n", "\n", "F\n", "\n", "\n", "\n", "6\n", "\n", "6: __iv = iter(range(1, small + 1))\n", "\n", "\n", "\n", "4->6\n", "\n", "\n", "\n", "\n", "\n", "5->6\n", "\n", "\n", "\n", "\n", "\n", "7\n", "\n", "6: for: __iv.__length__hint__() > 0\n", "\n", "\n", "\n", "6->7\n", "\n", "\n", "\n", "\n", "\n", "7->11\n", "\n", "\n", "F\n", "\n", "\n", "\n", "8\n", "\n", "6: i = next(__iv)\n", "\n", "\n", "\n", "7->8\n", "\n", "\n", "T\n", "\n", "\n", "\n", "10\n", "\n", "8: gcd = i\n", "\n", "\n", "\n", "10->7\n", "\n", "\n", "\n", "\n", "\n", "9\n", "\n", "7: if: x % i == 0 and y % i == 0\n", "\n", "\n", "\n", "9->7\n", "\n", "\n", "F\n", "\n", "\n", "\n", "9->10\n", "\n", "\n", "T\n", "\n", "\n", "\n", "8->9\n", "\n", "\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "to_graph(gen_cfg(inspect.getsource(compute_gcd)))" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "#### fib\n", "\n", "Note that the *for-loop* requires additional massaging. While we show the labels correctly, the *comparison node* needs to be extracted. Hence, the representation is not accurate." ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.385247Z", "iopub.status.busy": "2023-01-07T14:25:47.384888Z", "iopub.status.idle": "2023-01-07T14:25:47.385964Z", "shell.execute_reply": "2023-01-07T14:25:47.386202Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "def fib(n,):\n", " ls = [0, 1]\n", " for i in range(n-2):\n", " ls.append(ls[-1] + ls[-2])\n", " return ls" ] }, { "cell_type": "code", "execution_count": 53, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.390690Z", "iopub.status.busy": "2023-01-07T14:25:47.387778Z", "iopub.status.idle": "2023-01-07T14:25:47.637677Z", "shell.execute_reply": "2023-01-07T14:25:47.637927Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "1\n", "\n", "\n", "1: enter: fib(n)\n", "\n", "\n", "\n", "3\n", "\n", "2: ls = [0, 1]\n", "\n", "\n", "\n", "1->3\n", "\n", "\n", "\n", "\n", "\n", "2\n", "\n", "\n", "1: exit: fib(n)\n", "\n", "\n", "\n", "8\n", "\n", "5: return ls\n", "\n", "\n", "\n", "8->2\n", "\n", "\n", "\n", "\n", "\n", "4\n", "\n", "3: __iv = iter(range(n - 2))\n", "\n", "\n", "\n", "3->4\n", "\n", "\n", "\n", "\n", "\n", "5\n", "\n", "3: for: __iv.__length__hint__() > 0\n", "\n", "\n", "\n", "4->5\n", "\n", "\n", "\n", "\n", "\n", "5->8\n", "\n", "\n", "F\n", "\n", "\n", "\n", "6\n", "\n", "3: i = next(__iv)\n", "\n", "\n", "\n", "5->6\n", "\n", "\n", "T\n", "\n", "\n", "\n", "7\n", "\n", "4: ls.append(ls[-1] + ls[-2])\n", "\n", "\n", "\n", "7->5\n", "\n", "\n", "\n", "\n", "\n", "6->7\n", "\n", "\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "to_graph(gen_cfg(inspect.getsource(fib)))" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "#### quad_solver" ] }, { "cell_type": "code", "execution_count": 54, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.641450Z", "iopub.status.busy": "2023-01-07T14:25:47.641156Z", "iopub.status.idle": "2023-01-07T14:25:47.642389Z", "shell.execute_reply": "2023-01-07T14:25:47.642673Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def quad_solver(a, b, c):\n", " discriminant = b^2 - 4*a*c\n", " r1, r2 = 0, 0\n", " i1, i2 = 0, 0\n", " if discriminant >= 0:\n", " droot = math.sqrt(discriminant)\n", " r1 = (-b + droot) / (2*a)\n", " r2 = (-b - droot) / (2*a)\n", " else:\n", " droot = math.sqrt(-1 * discriminant)\n", " droot_ = droot/(2*a)\n", " r1, i1 = -b/(2*a), droot_\n", " r2, i2 = -b/(2*a), -droot_\n", " if i1 == 0 and i2 == 0:\n", " return (r1, r2)\n", " return ((r1,i1), (r2,i2))" ] }, { "cell_type": "code", "execution_count": 55, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.646414Z", "iopub.status.busy": "2023-01-07T14:25:47.645989Z", "iopub.status.idle": "2023-01-07T14:25:47.909830Z", "shell.execute_reply": "2023-01-07T14:25:47.910182Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "1\n", "\n", "\n", "1: enter: quad_solver(a, b, c)\n", "\n", "\n", "\n", "3\n", "\n", "2: discriminant = b ^ 2 - 4 * a * c\n", "\n", "\n", "\n", "1->3\n", "\n", "\n", "\n", "\n", "\n", "2\n", "\n", "\n", "1: exit: quad_solver(a, b, c)\n", "\n", "\n", "\n", "15\n", "\n", "15: return (r1, r2)\n", "\n", "\n", "\n", "15->2\n", "\n", "\n", "\n", "\n", "\n", "16\n", "\n", "16: return ((r1, i1), (r2, i2))\n", "\n", "\n", "\n", "16->2\n", "\n", "\n", "\n", "\n", "\n", "4\n", "\n", "3: (r1, r2) = (0, 0)\n", "\n", "\n", "\n", "3->4\n", "\n", "\n", "\n", "\n", "\n", "5\n", "\n", "4: (i1, i2) = (0, 0)\n", "\n", "\n", "\n", "4->5\n", "\n", "\n", "\n", "\n", "\n", "6\n", "\n", "5: if: discriminant >= 0\n", "\n", "\n", "\n", "5->6\n", "\n", "\n", "\n", "\n", "\n", "7\n", "\n", "6: droot = math.sqrt(discriminant)\n", "\n", "\n", "\n", "6->7\n", "\n", "\n", "T\n", "\n", "\n", "\n", "10\n", "\n", "10: droot = math.sqrt(-1 * discriminant)\n", "\n", "\n", "\n", "6->10\n", "\n", "\n", "F\n", "\n", "\n", "\n", "8\n", "\n", "7: r1 = (-b + droot) / (2 * a)\n", "\n", "\n", "\n", "7->8\n", "\n", "\n", "\n", "\n", "\n", "9\n", "\n", "8: r2 = (-b - droot) / (2 * a)\n", "\n", "\n", "\n", "8->9\n", "\n", "\n", "\n", "\n", "\n", "14\n", "\n", "14: if: i1 == 0 and i2 == 0\n", "\n", "\n", "\n", "9->14\n", "\n", "\n", "\n", "\n", "\n", "11\n", "\n", "11: droot_ = droot / (2 * a)\n", "\n", "\n", "\n", "10->11\n", "\n", "\n", "\n", "\n", "\n", "12\n", "\n", "12: (r1, i1) = (-b / (2 * a), droot_)\n", "\n", "\n", "\n", "11->12\n", "\n", "\n", "\n", "\n", "\n", "13\n", "\n", "13: (r2, i2) = (-b / (2 * a), -droot_)\n", "\n", "\n", "\n", "12->13\n", "\n", "\n", "\n", "\n", "\n", "13->14\n", "\n", "\n", "\n", "\n", "\n", "14->15\n", "\n", "\n", "T\n", "\n", "\n", "\n", "14->16\n", "\n", "\n", "F\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "to_graph(gen_cfg(inspect.getsource(quad_solver)))" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Call Graph\n", "### Install: Pyan Static Call Graph Lifter" ] }, { "cell_type": "code", "execution_count": 56, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.912459Z", "iopub.status.busy": "2023-01-07T14:25:47.912106Z", "iopub.status.idle": "2023-01-07T14:25:47.913358Z", "shell.execute_reply": "2023-01-07T14:25:47.913634Z" }, "slideshow": { "slide_type": "skip" } }, "outputs": [], "source": [ "import os" ] }, { "cell_type": "code", "execution_count": 57, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.915596Z", "iopub.status.busy": "2023-01-07T14:25:47.915286Z", "iopub.status.idle": "2023-01-07T14:25:47.947050Z", "shell.execute_reply": "2023-01-07T14:25:47.947240Z" }, "slideshow": { "slide_type": "skip" } }, "outputs": [], "source": [ "import networkx as nx # type: ignore" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Call Graph Helpers" ] }, { "cell_type": "code", "execution_count": 58, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.948946Z", "iopub.status.busy": "2023-01-07T14:25:47.948661Z", "iopub.status.idle": "2023-01-07T14:25:47.949996Z", "shell.execute_reply": "2023-01-07T14:25:47.950202Z" }, "slideshow": { "slide_type": "skip" } }, "outputs": [], "source": [ "import shutil" ] }, { "cell_type": "code", "execution_count": 59, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.952259Z", "iopub.status.busy": "2023-01-07T14:25:47.951929Z", "iopub.status.idle": "2023-01-07T14:25:47.953921Z", "shell.execute_reply": "2023-01-07T14:25:47.953666Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "PYAN = 'pyan3' if shutil.which('pyan3') is not None else 'pyan'\n", "\n", "if shutil.which(PYAN) is None:\n", " # If installed from pypi, pyan may still be missing\n", " os.system('pip install \"git+https://github.com/uds-se/pyan#egg=pyan\"')\n", " PYAN = 'pyan3' if shutil.which('pyan3') is not None else 'pyan'\n", "\n", "assert shutil.which(PYAN) is not None" ] }, { "cell_type": "code", "execution_count": 60, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.956009Z", "iopub.status.busy": "2023-01-07T14:25:47.955701Z", "iopub.status.idle": "2023-01-07T14:25:47.957023Z", "shell.execute_reply": "2023-01-07T14:25:47.957212Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "def construct_callgraph(code, name=\"callgraph\"):\n", " file_name = name + \".py\"\n", " with open(file_name, 'w') as f:\n", " f.write(code)\n", " cg_file = name + '.dot'\n", " os.system(f'{PYAN} {file_name} --uses --defines --colored --grouped --annotated --dot > {cg_file}')" ] }, { "cell_type": "code", "execution_count": 61, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.959180Z", "iopub.status.busy": "2023-01-07T14:25:47.958867Z", "iopub.status.idle": "2023-01-07T14:25:47.960539Z", "shell.execute_reply": "2023-01-07T14:25:47.960862Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def callgraph(code, name=\"callgraph\"):\n", " if not os.path.isfile(name + '.dot'):\n", " construct_callgraph(code, name)\n", " return Source.from_file(name + '.dot')" ] }, { "cell_type": "code", "execution_count": 62, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.963746Z", "iopub.status.busy": "2023-01-07T14:25:47.963394Z", "iopub.status.idle": "2023-01-07T14:25:47.964461Z", "shell.execute_reply": "2023-01-07T14:25:47.964665Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "def get_callgraph(code, name=\"callgraph\"):\n", " if not os.path.isfile(name + '.dot'):\n", " construct_callgraph(code, name)\n", "\n", " # This is deprecated:\n", " # return nx.drawing.nx_pydot.read_dot(name + '.dot')\n", " \n", " return nx.nx_agraph.read_dot(name + '.dot')" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Example: Maze\n", "\n", "To provide a meaningful example where you can easily change the code complexity and target location, we generate the maze source code from the maze provided as string. This example is loosely based on an old [blog post](https://feliam.wordpress.com/2010/10/07/the-symbolic-maze/) on symbolic execution by Felipe Andres Manzano (Quick shout-out!).\n", "\n", "You simply specify the maze as a string. Like so." ] }, { "cell_type": "code", "execution_count": 63, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.966546Z", "iopub.status.busy": "2023-01-07T14:25:47.966214Z", "iopub.status.idle": "2023-01-07T14:25:47.967435Z", "shell.execute_reply": "2023-01-07T14:25:47.967637Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "maze_string = \"\"\"\n", "+-+-----+\n", "|X| |\n", "| | --+ |\n", "| | | |\n", "| +-- | |\n", "| |#|\n", "+-----+-+\n", "\"\"\"" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "Each character in `maze_string` represents a tile. For each tile, a tile-function is generated. \n", "* If the current tile is \"benign\" (` `), the tile-function corresponding to the next input character (D, U, L, R) is called. Unexpected input characters are ignored. If no more input characters are left, it returns \"VALID\" and the current maze state.\n", "* If the current tile is a \"trap\" (`+`,`|`,`-`), it returns \"INVALID\" and the current maze state.\n", "* If the current tile is the \"target\" (`#`), it returns \"SOLVED\" and the current maze state.\n", "\n", "The code is generated using the function `generate_maze_code`. " ] }, { "cell_type": "code", "execution_count": 64, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.969370Z", "iopub.status.busy": "2023-01-07T14:25:47.969079Z", "iopub.status.idle": "2023-01-07T14:25:47.970415Z", "shell.execute_reply": "2023-01-07T14:25:47.970603Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "# ignore\n", "def maze(s: str) -> str:\n", " return \"\" # Will be overwritten by exec()" ] }, { "cell_type": "code", "execution_count": 65, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.972219Z", "iopub.status.busy": "2023-01-07T14:25:47.971932Z", "iopub.status.idle": "2023-01-07T14:25:47.973530Z", "shell.execute_reply": "2023-01-07T14:25:47.973281Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "# ignore\n", "def target_tile() -> str:\n", " return ' ' # Will be overwritten by exec()" ] }, { "cell_type": "code", "execution_count": 66, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.975432Z", "iopub.status.busy": "2023-01-07T14:25:47.975108Z", "iopub.status.idle": "2023-01-07T14:25:47.976436Z", "shell.execute_reply": "2023-01-07T14:25:47.976624Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def generate_print_maze(maze_string):\n", " return \"\"\"\n", "def print_maze(out, row, col):\n", " output = out +\"\\\\n\"\n", " c_row = 0\n", " c_col = 0\n", " for c in list(\\\"\\\"\\\"%s\\\"\\\"\\\"):\n", " if c == '\\\\n':\n", " c_row += 1\n", " c_col = 0\n", " output += \"\\\\n\"\n", " else:\n", " if c_row == row and c_col == col: output += \"X\"\n", " elif c == \"X\": output += \" \"\n", " else: output += c\n", " c_col += 1\n", " return output\n", "\"\"\" % maze_string" ] }, { "cell_type": "code", "execution_count": 67, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.978591Z", "iopub.status.busy": "2023-01-07T14:25:47.978144Z", "iopub.status.idle": "2023-01-07T14:25:47.979439Z", "shell.execute_reply": "2023-01-07T14:25:47.979621Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def generate_trap_tile(row, col):\n", " return \"\"\"\n", "def tile_%d_%d(input, index):\n", " try: HTMLParser().feed(input)\n", " except: pass\n", " return print_maze(\"INVALID\", %d, %d)\n", "\"\"\" % (row, col, row, col)" ] }, { "cell_type": "code", "execution_count": 68, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.981826Z", "iopub.status.busy": "2023-01-07T14:25:47.981526Z", "iopub.status.idle": "2023-01-07T14:25:47.982920Z", "shell.execute_reply": "2023-01-07T14:25:47.983111Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def generate_good_tile(c, row, col):\n", " code = \"\"\"\n", "def tile_%d_%d(input, index):\n", " if (index == len(input)): return print_maze(\"VALID\", %d, %d)\n", " elif input[index] == 'L': return tile_%d_%d(input, index + 1)\n", " elif input[index] == 'R': return tile_%d_%d(input, index + 1)\n", " elif input[index] == 'U': return tile_%d_%d(input, index + 1)\n", " elif input[index] == 'D': return tile_%d_%d(input, index + 1)\n", " else : return tile_%d_%d(input, index + 1)\n", "\"\"\" % (row, col, row, col,\n", " row, col - 1, \n", " row, col + 1, \n", " row - 1, col, \n", " row + 1, col,\n", " row, col)\n", "\n", " if c == \"X\":\n", " code += \"\"\"\n", "def maze(input):\n", " return tile_%d_%d(list(input), 0)\n", "\"\"\" % (row, col)\n", "\n", " return code" ] }, { "cell_type": "code", "execution_count": 69, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.985512Z", "iopub.status.busy": "2023-01-07T14:25:47.984971Z", "iopub.status.idle": "2023-01-07T14:25:47.986989Z", "shell.execute_reply": "2023-01-07T14:25:47.987244Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def generate_target_tile(row, col):\n", " return \"\"\"\n", "def tile_%d_%d(input, index):\n", " return print_maze(\"SOLVED\", %d, %d)\n", "\n", "def target_tile():\n", " return \"tile_%d_%d\"\n", "\"\"\" % (row, col, row, col, row, col)" ] }, { "cell_type": "code", "execution_count": 70, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.990193Z", "iopub.status.busy": "2023-01-07T14:25:47.989878Z", "iopub.status.idle": "2023-01-07T14:25:47.991012Z", "shell.execute_reply": "2023-01-07T14:25:47.991281Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def generate_maze_code(maze, name=\"maze\"):\n", " row = 0\n", " col = 0\n", " code = generate_print_maze(maze)\n", "\n", " for c in list(maze):\n", " if c == '\\n':\n", " row += 1\n", " col = 0\n", " else:\n", " if c == \"-\" or c == \"+\" or c == \"|\":\n", " code += generate_trap_tile(row, col)\n", " elif c == \" \" or c == \"X\":\n", " code += generate_good_tile(c, row, col)\n", " elif c == \"#\":\n", " code += generate_target_tile(row, col)\n", " else:\n", " print(\"Invalid maze! Try another one.\")\n", " col += 1\n", "\n", " return code" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "Now you can generate the maze code for an arbitrary maze." ] }, { "cell_type": "code", "execution_count": 71, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:47.993128Z", "iopub.status.busy": "2023-01-07T14:25:47.992800Z", "iopub.status.idle": "2023-01-07T14:25:47.994299Z", "shell.execute_reply": "2023-01-07T14:25:47.994103Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "maze_code = generate_maze_code(maze_string)" ] }, { "cell_type": "code", "execution_count": 72, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:48.019196Z", "iopub.status.busy": "2023-01-07T14:25:48.018842Z", "iopub.status.idle": "2023-01-07T14:25:48.092042Z", "shell.execute_reply": "2023-01-07T14:25:48.092339Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[34mdef\u001b[39;49;00m \u001b[32mprint_maze\u001b[39;49;00m(out, row, col):\u001b[37m\u001b[39;49;00m\n", " output = out +\u001b[33m\"\u001b[39;49;00m\u001b[33m\\n\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " c_row = \u001b[34m0\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " c_col = \u001b[34m0\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mfor\u001b[39;49;00m c \u001b[35min\u001b[39;49;00m \u001b[36mlist\u001b[39;49;00m(\u001b[33m\"\"\"\u001b[39;49;00m\u001b[33m\u001b[39;49;00m\n", "\u001b[33m+-+-----+\u001b[39;49;00m\u001b[33m\u001b[39;49;00m\n", "\u001b[33m|X| |\u001b[39;49;00m\u001b[33m\u001b[39;49;00m\n", "\u001b[33m| | --+ |\u001b[39;49;00m\u001b[33m\u001b[39;49;00m\n", "\u001b[33m| | | |\u001b[39;49;00m\u001b[33m\u001b[39;49;00m\n", "\u001b[33m| +-- | |\u001b[39;49;00m\u001b[33m\u001b[39;49;00m\n", "\u001b[33m| |#|\u001b[39;49;00m\u001b[33m\u001b[39;49;00m\n", "\u001b[33m+-----+-+\u001b[39;49;00m\u001b[33m\u001b[39;49;00m\n", "\u001b[33m\"\"\"\u001b[39;49;00m):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m c == \u001b[33m'\u001b[39;49;00m\u001b[33m\\n\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m:\u001b[37m\u001b[39;49;00m\n", " c_row += \u001b[34m1\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " c_col = \u001b[34m0\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " output += \u001b[33m\"\u001b[39;49;00m\u001b[33m\\n\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m:\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m c_row == row \u001b[35mand\u001b[39;49;00m c_col == col: output += \u001b[33m\"\u001b[39;49;00m\u001b[33mX\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m c == \u001b[33m\"\u001b[39;49;00m\u001b[33mX\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m: output += \u001b[33m\"\u001b[39;49;00m\u001b[33m \u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m: output += c\u001b[37m\u001b[39;49;00m\n", " c_col += \u001b[34m1\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m output\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_1_0\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m, \u001b[34m0\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_1_1\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_1_2\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_1_3\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_1_4\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_1_5\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_1_6\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_1_7\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_1_8\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m, \u001b[34m8\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_2_0\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m, \u001b[34m0\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_2_1\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_0(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_2(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_1_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_2_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mmaze\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m tile_2_1(\u001b[36mlist\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m), \u001b[34m0\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_2_2\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_2_3\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_2(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_1_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_2_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_2_4\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_1_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_2_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_2_5\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_6(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_1_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_2_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_2_6\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_1_6(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_6(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_2_6(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_2_7\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_6(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_8(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_1_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_2_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_2_8\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m, \u001b[34m8\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_3_0\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m, \u001b[34m0\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_3_1\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_0(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_2(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_3_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_3_2\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_3_3\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_2(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_3_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_3_4\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_3_5\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_3_6\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_3_7\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_6(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_8(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_2_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_3_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_3_8\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m, \u001b[34m8\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_4_0\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m, \u001b[34m0\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_4_1\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_0(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_2(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_4_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_4_2\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_4_3\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_2(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_4_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_4_4\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_4_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_4_5\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_6(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_4_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_4_6\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_4_7\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_6(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_8(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_3_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_4_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_4_8\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m, \u001b[34m8\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_5_0\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m, \u001b[34m0\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_5_1\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_0(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_2(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_5_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_5_2\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_5_3\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_5_4\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_5_5\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_6(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_5_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_5_6\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_5_7\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_6(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_8(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_4_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_5_7(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_5_8\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m, \u001b[34m8\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_6_0\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m, \u001b[34m0\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_6_1\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_0(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_2(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_7_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_6_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_6_2\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_1(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_2(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_7_2(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_6_2(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_6_3\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_2(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_7_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_6_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_6_4\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_3(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_7_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_6_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_6_5\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mif\u001b[39;49;00m (index == \u001b[36mlen\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m)): \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mL\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_4(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mR\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_6_6(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mU\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_5_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melif\u001b[39;49;00m \u001b[36minput\u001b[39;49;00m[index] == \u001b[33m'\u001b[39;49;00m\u001b[33mD\u001b[39;49;00m\u001b[33m'\u001b[39;49;00m: \u001b[34mreturn\u001b[39;49;00m tile_7_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34melse\u001b[39;49;00m : \u001b[34mreturn\u001b[39;49;00m tile_6_5(\u001b[36minput\u001b[39;49;00m, index + \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_6_6\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_6_7\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mSOLVED\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtarget_tile\u001b[39;49;00m():\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m \u001b[33m\"\u001b[39;49;00m\u001b[33mtile_6_7\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_6_8\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m, \u001b[34m8\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_7_0\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m, \u001b[34m0\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_7_1\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m, \u001b[34m1\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_7_2\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m, \u001b[34m2\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_7_3\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m, \u001b[34m3\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_7_4\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m, \u001b[34m4\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_7_5\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m, \u001b[34m5\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_7_6\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m, \u001b[34m6\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_7_7\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", "\u001b[37m\u001b[39;49;00m\n", "\u001b[34mdef\u001b[39;49;00m \u001b[32mtile_7_8\u001b[39;49;00m(\u001b[36minput\u001b[39;49;00m, index):\u001b[37m\u001b[39;49;00m\n", " \u001b[34mtry\u001b[39;49;00m: HTMLParser().feed(\u001b[36minput\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m\n", " \u001b[34mexcept\u001b[39;49;00m: \u001b[34mpass\u001b[39;49;00m\u001b[37m\u001b[39;49;00m\n", " \u001b[34mreturn\u001b[39;49;00m print_maze(\u001b[33m\"\u001b[39;49;00m\u001b[33mINVALID\u001b[39;49;00m\u001b[33m\"\u001b[39;49;00m, \u001b[34m7\u001b[39;49;00m, \u001b[34m8\u001b[39;49;00m)\u001b[37m\u001b[39;49;00m" ] } ], "source": [ "print_content(maze_code, filename='.py')" ] }, { "cell_type": "code", "execution_count": 73, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:48.096661Z", "iopub.status.busy": "2023-01-07T14:25:48.096339Z", "iopub.status.idle": "2023-01-07T14:25:48.097742Z", "shell.execute_reply": "2023-01-07T14:25:48.097934Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "exec(maze_code)" ] }, { "cell_type": "code", "execution_count": 74, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:48.099673Z", "iopub.status.busy": "2023-01-07T14:25:48.099302Z", "iopub.status.idle": "2023-01-07T14:25:48.100813Z", "shell.execute_reply": "2023-01-07T14:25:48.100636Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "VALID\n", "\n", "+-+-----+\n", "| | |\n", "| | --+ |\n", "| | | |\n", "| +-- |X|\n", "| |#|\n", "+-----+-+\n", "\n" ] } ], "source": [ "# Appending one more 'D', you have reached the target.\n", "print(maze(\"DDDDRRRRUULLUURRRRDDD\"))" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "This is the corresponding call graph." ] }, { "cell_type": "code", "execution_count": 75, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:48.102509Z", "iopub.status.busy": "2023-01-07T14:25:48.102211Z", "iopub.status.idle": "2023-01-07T14:25:48.509006Z", "shell.execute_reply": "2023-01-07T14:25:48.509200Z" }, "slideshow": { "slide_type": "subslide" } }, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "G\n", "\n", "\n", "cluster_G\n", "\n", "\n", "\n", "cluster_callgraphX\n", "\n", "callgraph\n", "\n", "\n", "\n", "callgraphX\n", "\n", "callgraph\n", "\n", "\n", "\n", "callgraphX__maze\n", "\n", "maze\n", "(callgraph.py:84)\n", "\n", "\n", "\n", "callgraphX->callgraphX__maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__print_maze\n", "\n", "print_maze\n", "(callgraph.py:2)\n", "\n", "\n", "\n", "callgraphX->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__target_tile\n", "\n", "target_tile\n", "(callgraph.py:358)\n", "\n", "\n", "\n", "callgraphX->callgraphX__target_tile\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_0\n", "\n", "tile_1_0\n", "(callgraph.py:26)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_1_0\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_1\n", "\n", "tile_1_1\n", "(callgraph.py:31)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_1_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_2\n", "\n", "tile_1_2\n", "(callgraph.py:36)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_1_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_3\n", "\n", "tile_1_3\n", "(callgraph.py:41)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_1_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_4\n", "\n", "tile_1_4\n", "(callgraph.py:46)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_1_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_5\n", "\n", "tile_1_5\n", "(callgraph.py:51)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_1_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_6\n", "\n", "tile_1_6\n", "(callgraph.py:56)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_1_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_7\n", "\n", "tile_1_7\n", "(callgraph.py:61)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_1_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_8\n", "\n", "tile_1_8\n", "(callgraph.py:66)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_1_8\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_0\n", "\n", "tile_2_0\n", "(callgraph.py:71)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_2_0\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_1\n", "\n", "tile_2_1\n", "(callgraph.py:76)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_2_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_2\n", "\n", "tile_2_2\n", "(callgraph.py:87)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_2_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_3\n", "\n", "tile_2_3\n", "(callgraph.py:92)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_2_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_4\n", "\n", "tile_2_4\n", "(callgraph.py:100)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_2_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_5\n", "\n", "tile_2_5\n", "(callgraph.py:108)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_2_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_6\n", "\n", "tile_2_6\n", "(callgraph.py:116)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_2_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_7\n", "\n", "tile_2_7\n", "(callgraph.py:124)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_2_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_8\n", "\n", "tile_2_8\n", "(callgraph.py:132)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_2_8\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_0\n", "\n", "tile_3_0\n", "(callgraph.py:137)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_3_0\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_1\n", "\n", "tile_3_1\n", "(callgraph.py:142)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_3_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_2\n", "\n", "tile_3_2\n", "(callgraph.py:150)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_3_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_3\n", "\n", "tile_3_3\n", "(callgraph.py:155)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_3_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_4\n", "\n", "tile_3_4\n", "(callgraph.py:163)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_3_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_5\n", "\n", "tile_3_5\n", "(callgraph.py:168)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_3_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_6\n", "\n", "tile_3_6\n", "(callgraph.py:173)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_3_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_7\n", "\n", "tile_3_7\n", "(callgraph.py:178)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_3_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_8\n", "\n", "tile_3_8\n", "(callgraph.py:186)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_3_8\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_0\n", "\n", "tile_4_0\n", "(callgraph.py:191)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_4_0\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_1\n", "\n", "tile_4_1\n", "(callgraph.py:196)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_4_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_2\n", "\n", "tile_4_2\n", "(callgraph.py:204)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_4_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_3\n", "\n", "tile_4_3\n", "(callgraph.py:209)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_4_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_4\n", "\n", "tile_4_4\n", "(callgraph.py:217)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_4_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_5\n", "\n", "tile_4_5\n", "(callgraph.py:225)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_4_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_6\n", "\n", "tile_4_6\n", "(callgraph.py:233)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_4_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_7\n", "\n", "tile_4_7\n", "(callgraph.py:238)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_4_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_8\n", "\n", "tile_4_8\n", "(callgraph.py:246)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_4_8\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_0\n", "\n", "tile_5_0\n", "(callgraph.py:251)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_5_0\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_1\n", "\n", "tile_5_1\n", "(callgraph.py:256)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_5_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_2\n", "\n", "tile_5_2\n", "(callgraph.py:264)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_5_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_3\n", "\n", "tile_5_3\n", "(callgraph.py:269)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_5_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_4\n", "\n", "tile_5_4\n", "(callgraph.py:274)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_5_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_5\n", "\n", "tile_5_5\n", "(callgraph.py:279)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_5_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_6\n", "\n", "tile_5_6\n", "(callgraph.py:287)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_5_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_7\n", "\n", "tile_5_7\n", "(callgraph.py:292)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_5_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_8\n", "\n", "tile_5_8\n", "(callgraph.py:300)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_5_8\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_0\n", "\n", "tile_6_0\n", "(callgraph.py:305)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_6_0\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_1\n", "\n", "tile_6_1\n", "(callgraph.py:310)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_6_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_2\n", "\n", "tile_6_2\n", "(callgraph.py:318)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_6_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_3\n", "\n", "tile_6_3\n", "(callgraph.py:326)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_6_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_4\n", "\n", "tile_6_4\n", "(callgraph.py:334)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_6_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_5\n", "\n", "tile_6_5\n", "(callgraph.py:342)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_6_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_6\n", "\n", "tile_6_6\n", "(callgraph.py:350)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_6_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_7\n", "\n", "tile_6_7\n", "(callgraph.py:355)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_6_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_8\n", "\n", "tile_6_8\n", "(callgraph.py:361)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_6_8\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_0\n", "\n", "tile_7_0\n", "(callgraph.py:366)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_7_0\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_1\n", "\n", "tile_7_1\n", "(callgraph.py:371)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_7_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_2\n", "\n", "tile_7_2\n", "(callgraph.py:376)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_7_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_3\n", "\n", "tile_7_3\n", "(callgraph.py:381)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_7_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_4\n", "\n", "tile_7_4\n", "(callgraph.py:386)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_7_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_5\n", "\n", "tile_7_5\n", "(callgraph.py:391)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_7_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_6\n", "\n", "tile_7_6\n", "(callgraph.py:396)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_7_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_7\n", "\n", "tile_7_7\n", "(callgraph.py:401)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_7_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_8\n", "\n", "tile_7_8\n", "(callgraph.py:406)\n", "\n", "\n", "\n", "callgraphX->callgraphX__tile_7_8\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__maze->callgraphX__tile_2_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_0->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_1->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_2->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_3->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_4->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_5->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_6->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_7->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_1_8->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_0->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_1->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_1->callgraphX__tile_1_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_1->callgraphX__tile_2_0\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_1->callgraphX__tile_2_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_1->callgraphX__tile_2_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_1->callgraphX__tile_3_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_2->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_3->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_3->callgraphX__tile_1_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_3->callgraphX__tile_2_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_3->callgraphX__tile_2_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_3->callgraphX__tile_2_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_3->callgraphX__tile_3_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_4->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_4->callgraphX__tile_1_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_4->callgraphX__tile_2_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_4->callgraphX__tile_2_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_4->callgraphX__tile_2_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_4->callgraphX__tile_3_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_5->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_5->callgraphX__tile_1_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_5->callgraphX__tile_2_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_5->callgraphX__tile_2_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_5->callgraphX__tile_2_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_5->callgraphX__tile_3_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_6->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_6->callgraphX__tile_1_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_6->callgraphX__tile_2_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_6->callgraphX__tile_2_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_6->callgraphX__tile_2_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_6->callgraphX__tile_3_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_7->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_7->callgraphX__tile_1_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_7->callgraphX__tile_2_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_7->callgraphX__tile_2_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_7->callgraphX__tile_2_8\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_7->callgraphX__tile_3_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_2_8->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_0->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_1->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_1->callgraphX__tile_2_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_1->callgraphX__tile_3_0\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_1->callgraphX__tile_3_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_1->callgraphX__tile_3_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_1->callgraphX__tile_4_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_2->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_3->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_3->callgraphX__tile_2_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_3->callgraphX__tile_3_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_3->callgraphX__tile_3_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_3->callgraphX__tile_3_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_3->callgraphX__tile_4_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_4->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_5->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_6->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_7->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_7->callgraphX__tile_2_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_7->callgraphX__tile_3_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_7->callgraphX__tile_3_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_7->callgraphX__tile_3_8\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_7->callgraphX__tile_4_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_3_8->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_0->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_1->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_1->callgraphX__tile_3_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_1->callgraphX__tile_4_0\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_1->callgraphX__tile_4_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_1->callgraphX__tile_4_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_1->callgraphX__tile_5_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_2->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_3->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_3->callgraphX__tile_3_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_3->callgraphX__tile_4_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_3->callgraphX__tile_4_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_3->callgraphX__tile_4_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_3->callgraphX__tile_5_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_4->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_4->callgraphX__tile_3_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_4->callgraphX__tile_4_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_4->callgraphX__tile_4_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_4->callgraphX__tile_4_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_4->callgraphX__tile_5_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_5->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_5->callgraphX__tile_3_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_5->callgraphX__tile_4_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_5->callgraphX__tile_4_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_5->callgraphX__tile_4_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_5->callgraphX__tile_5_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_6->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_7->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_7->callgraphX__tile_3_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_7->callgraphX__tile_4_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_7->callgraphX__tile_4_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_7->callgraphX__tile_4_8\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_7->callgraphX__tile_5_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_4_8->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_0->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_1->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_1->callgraphX__tile_4_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_1->callgraphX__tile_5_0\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_1->callgraphX__tile_5_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_1->callgraphX__tile_5_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_1->callgraphX__tile_6_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_2->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_3->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_4->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_5->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_5->callgraphX__tile_4_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_5->callgraphX__tile_5_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_5->callgraphX__tile_5_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_5->callgraphX__tile_5_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_5->callgraphX__tile_6_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_6->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_7->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_7->callgraphX__tile_4_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_7->callgraphX__tile_5_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_7->callgraphX__tile_5_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_7->callgraphX__tile_5_8\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_7->callgraphX__tile_6_7\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_5_8->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_0->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_1->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_1->callgraphX__tile_5_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_1->callgraphX__tile_6_0\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_1->callgraphX__tile_6_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_1->callgraphX__tile_6_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_1->callgraphX__tile_7_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_2->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_2->callgraphX__tile_5_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_2->callgraphX__tile_6_1\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_2->callgraphX__tile_6_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_2->callgraphX__tile_6_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_2->callgraphX__tile_7_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_3->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_3->callgraphX__tile_5_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_3->callgraphX__tile_6_2\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_3->callgraphX__tile_6_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_3->callgraphX__tile_6_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_3->callgraphX__tile_7_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_4->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_4->callgraphX__tile_5_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_4->callgraphX__tile_6_3\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_4->callgraphX__tile_6_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_4->callgraphX__tile_6_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_4->callgraphX__tile_7_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_5->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_5->callgraphX__tile_5_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_5->callgraphX__tile_6_4\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_5->callgraphX__tile_6_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_5->callgraphX__tile_6_6\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_5->callgraphX__tile_7_5\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_6->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_7->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_6_8->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_0->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_1->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_2->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_3->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_4->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_5->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_6->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_7->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n", "callgraphX__tile_7_8->callgraphX__print_maze\n", "\n", "\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 75, "metadata": {}, "output_type": "execute_result" } ], "source": [ "callgraph(maze_code)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Cleanup\n", "\n", "We're done, so we clean up:" ] }, { "cell_type": "code", "execution_count": 76, "metadata": { "execution": { "iopub.execute_input": "2023-01-07T14:25:48.511555Z", "iopub.status.busy": "2023-01-07T14:25:48.511141Z", "iopub.status.idle": "2023-01-07T14:25:48.512650Z", "shell.execute_reply": "2023-01-07T14:25:48.512980Z" }, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "if os.path.exists('callgraph.dot'):\n", " os.remove('callgraph.dot')\n", "\n", "if os.path.exists('callgraph.py'):\n", " os.remove('callgraph.py')" ] } ], "metadata": { "ipub": { "bibliography": "fuzzingbook.bib", "toc": true }, "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.10.2" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": true, "title_cell": "", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": true }, "toc-autonumbering": false, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }