Updated descriptions

This commit is contained in:
Edward Donner
2024-12-24 17:59:48 +00:00
parent f5a66d264a
commit cb0b8a8d45
7 changed files with 96 additions and 70 deletions

View File

@@ -282,7 +282,8 @@
"metadata": {},
"outputs": [],
"source": [
"python_hard = \"\"\"\n",
"python_hard = \"\"\"# Be careful to support large number sizes\n",
"\n",
"def lcg(seed, a=1664525, c=1013904223, m=2**32):\n",
" value = seed\n",
" while True:\n",
@@ -461,31 +462,31 @@
"outputs": [],
"source": [
"def execute_python(code):\n",
" try:\n",
" output = io.StringIO()\n",
" sys.stdout = output\n",
" exec(code)\n",
" finally:\n",
" sys.stdout = sys.__stdout__\n",
" return output.getvalue()"
" try:\n",
" output = io.StringIO()\n",
" sys.stdout = output\n",
" exec(code)\n",
" finally:\n",
" sys.stdout = sys.__stdout__\n",
" return output.getvalue()"
]
},
{
"cell_type": "code",
"execution_count": 107,
"execution_count": null,
"id": "77f3ab5d-fcfb-4d3f-8728-9cacbf833ea6",
"metadata": {},
"outputs": [],
"source": [
"def execute_cpp(code):\n",
" write_output(code)\n",
" try:\n",
" compile_result = subprocess.run(compiler_cmd[2], check=True, text=True, capture_output=True)\n",
" run_cmd = [\"./optimized\"]\n",
" run_result = subprocess.run(run_cmd, check=True, text=True, capture_output=True)\n",
" return run_result.stdout\n",
" except subprocess.CalledProcessError as e:\n",
" return f\"An error occurred:\\n{e.stderr}\""
" write_output(code)\n",
" try:\n",
" compile_result = subprocess.run(compiler_cmd[2], check=True, text=True, capture_output=True)\n",
" run_cmd = [\"./optimized\"]\n",
" run_result = subprocess.run(run_cmd, check=True, text=True, capture_output=True)\n",
" return run_result.stdout\n",
" except subprocess.CalledProcessError as e:\n",
" return f\"An error occurred:\\n{e.stderr}\""
]
},
{
@@ -640,6 +641,27 @@
" yield stream_so_far "
]
},
{
"cell_type": "markdown",
"id": "4b0a6a97-5b8a-4a9b-8ee0-7561e0ced673",
"metadata": {},
"source": [
"<table style=\"margin: 0; text-align: left;\">\n",
" <tr>\n",
" <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
" <img src=\"../thankyou.jpg\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
" </td>\n",
" <td>\n",
" <h2 style=\"color:#090;\">Thank you to @CloudLlama for an amazing contribution</h2>\n",
" <span style=\"color:#090;\">\n",
" A student has contributed a chunk of code to improve this, in the next 2 cells. You can now select which Python porgram to run,\n",
" and a compiler is automatically selected that will work on PC, Windows and Mac. Massive thank you @CloudLlama!\n",
" </span>\n",
" </td>\n",
" </tr>\n",
"</table>"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -658,7 +680,7 @@
},
{
"cell_type": "code",
"execution_count": 115,
"execution_count": null,
"id": "e42286bc-085c-45dc-b101-234308e58269",
"metadata": {},
"outputs": [],
@@ -795,7 +817,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f12bfe23-135b-45a7-8c6d-0c27d68b0a82",
"id": "9d0ad093-425b-488e-8c3f-67f729dd9c06",
"metadata": {},
"outputs": [],
"source": []
@@ -817,7 +839,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.10"
"version": "3.11.11"
}
},
"nbformat": 4,