solution for exercise 6
This commit is contained in:
parent
385ba8961d
commit
4b04fd1ac0
206
exercises/source/exercise-06/1__SSH_CLI_Schnitzeljagd.ipynb
Normal file
206
exercises/source/exercise-06/1__SSH_CLI_Schnitzeljagd.ipynb
Normal file
|
@ -0,0 +1,206 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "abe9babf",
|
||||
"metadata": {
|
||||
"nbgrader": {
|
||||
"grade": false,
|
||||
"grade_id": "cell-05142c09f787bba0",
|
||||
"locked": true,
|
||||
"schema_version": 3,
|
||||
"solution": false,
|
||||
"task": false
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# You must run this cell, but you can ignore its contents.\n",
|
||||
"\n",
|
||||
"import hashlib\n",
|
||||
"\n",
|
||||
"def ads_hash(ty):\n",
|
||||
" \"\"\"Return a unique string for input\"\"\"\n",
|
||||
" ty_str = str(ty).encode()\n",
|
||||
" m = hashlib.sha256()\n",
|
||||
" m.update(ty_str)\n",
|
||||
" return m.hexdigest()[:10]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4be5f20b-f850-4267-b57c-0cc8aee0d30a",
|
||||
"metadata": {
|
||||
"nbgrader": {
|
||||
"grade": false,
|
||||
"grade_id": "cell-5d906cfc256b7dc5",
|
||||
"locked": true,
|
||||
"schema_version": 3,
|
||||
"solution": false,
|
||||
"task": false
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"# Q1 SSH, command line, exit codes, etc "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "31eb869a",
|
||||
"metadata": {
|
||||
"nbgrader": {
|
||||
"grade": false,
|
||||
"grade_id": "cell-8b9d3e971dac9415",
|
||||
"locked": true,
|
||||
"schema_version": 3,
|
||||
"solution": false,
|
||||
"task": false
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"SSH to your account at `python-course` (e.g. `ssh your-user-name@python-course`) and follow the puzzle starting in the directory `/schnitzeljagd`.\n",
|
||||
"\n",
|
||||
"You must be in the University of Freiburg network in order to be able to SSH correctly.\n",
|
||||
"\n",
|
||||
"Your username is your the lowercase version of your lastname (e.g. Cem Özdemir would have a username of `oezdemir`). Your password is your matriculation number followed by \"x\" (e.g. `12345678x`).\n",
|
||||
"\n",
|
||||
"Place the final answer in the variable `final_answer`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "e7575efb",
|
||||
"metadata": {
|
||||
"nbgrader": {
|
||||
"grade": false,
|
||||
"grade_id": "cell-d6b141313f4f3a09",
|
||||
"locked": false,
|
||||
"schema_version": 3,
|
||||
"solution": true,
|
||||
"task": false
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"final_answer = \"lada0df89ksdjf8alkds9339akklafk93\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "a3ef21b2",
|
||||
"metadata": {
|
||||
"nbgrader": {
|
||||
"grade": true,
|
||||
"grade_id": "cell-3d5b7fe600c4c6ba",
|
||||
"locked": true,
|
||||
"points": 1,
|
||||
"schema_version": 3,
|
||||
"solution": false,
|
||||
"task": false
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert ads_hash(final_answer) == 'dfb81c4fac'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "357ffd1f-d0ce-4992-a0d8-411adadfe332",
|
||||
"metadata": {
|
||||
"nbgrader": {
|
||||
"grade": false,
|
||||
"grade_id": "cell-3004f9869fd73843",
|
||||
"locked": true,
|
||||
"schema_version": 3,
|
||||
"solution": false,
|
||||
"task": false
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"# Q2 Starting conda environment from command line\n",
|
||||
"\n",
|
||||
"On the above server, we have Anaconda installed at `/anaconda3` so from the command line, you can start the anaconda `base` environment like this:\n",
|
||||
"\n",
|
||||
" eval \"$(/anaconda3/bin/conda shell.bash hook)\"\n",
|
||||
" \n",
|
||||
"If you do this, your command-line prompt will start with `(base)`.\n",
|
||||
" \n",
|
||||
"Steps:\n",
|
||||
"\n",
|
||||
"0) Login to `10.4.66.100` as described above.\n",
|
||||
"1) Start the anaconda `base` environment.\n",
|
||||
"2) Change to the directory `/course`.\n",
|
||||
"3) Run the python program `program1.py`\n",
|
||||
"4) Put the program console output into the variable `program1_output` below"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "8e6b720b-91a6-4ffb-a93b-44e8288c8d86",
|
||||
"metadata": {
|
||||
"nbgrader": {
|
||||
"grade": false,
|
||||
"grade_id": "cell-6d9ed8460134bae3",
|
||||
"locked": false,
|
||||
"schema_version": 3,
|
||||
"solution": true,
|
||||
"task": false
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"program1_output=300"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "4ee8b2c9-8fd0-4d47-86a2-3c52dc352ddd",
|
||||
"metadata": {
|
||||
"nbgrader": {
|
||||
"grade": true,
|
||||
"grade_id": "cell-bc67d9f37b59741d",
|
||||
"locked": true,
|
||||
"points": 1,
|
||||
"schema_version": 3,
|
||||
"solution": false,
|
||||
"task": false
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert ads_hash(program1_output) == '983bd614bb'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"celltoolbar": "Create Assignment",
|
||||
"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.11.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
Loading…
Reference in a new issue