Skip to content

Commit

Permalink
added day8
Browse files Browse the repository at this point in the history
  • Loading branch information
davydenk committed Feb 1, 2023
1 parent d6b884a commit ca661ba
Show file tree
Hide file tree
Showing 2 changed files with 5,048 additions and 0 deletions.
65 changes: 65 additions & 0 deletions Exercises8-gameoflife.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "567e2e56-b9fa-49ff-b672-a040cc537818",
"metadata": {},
"source": [
"### **Exercise: Game of Life (no xarray, just python practice)**\n",
"\n",
"Implement [Conway's game of life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) using numpy array to hold data.\n",
"Neighbours are defined as adjacent cells.\n",
"\n",
" - Any LIVING cell with 2 or 3 neighbours survives.\n",
" - Any DEAD cell with 3 neighbours comes alive.\n",
" - Any OTHER LIVING cell dies.\n",
" - All deaths and births occur simultaneously\n",
"\n",
"For plotting: Jupyter is very finicky with \"real-time\" plots and there is a high chance it will refuse to plot everything in one frame even if you try all the stackoverflow solutions, so I propose just using a script to run your program (type \"python FILE_NAME.py\" in console). Try the following code to produce \"animation\" to test that it works:\n",
"\n",
"```\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"plt.axis([0, 10, 0, 1])\n",
"\n",
"for i in range(10):\n",
" y = np.random.random()\n",
" plt.scatter(i, y)\n",
" plt.pause(0.5)\n",
"plt.show()\n",
"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "646ae670-4f06-4bef-a161-b2ad0d9a8089",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"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.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit ca661ba

Please sign in to comment.