Skip to content
This repository was archived by the owner on Jul 18, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .ipynb_checkpoints/assignment-scratch-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
87 changes: 87 additions & 0 deletions .ipynb_checkpoints/lecture-notes-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Questions 1\n",
"Given an image represented by `NxN` matrix, where each pixel is an integer from 0-9, write a function `rotateImage` that rotates the image by 90 degrees in the counter-clockwise direction.\n",
"### Asking Questions\n",
"- How is the matrix represented\n",
"- How do I move matrix elements around\n",
"- How do I rotate a metrix in *any* direction?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Question 2\n",
"Write a function to return the `nth` term in the Fibonacci sequence.\n",
"\n",
"$F_n = F_{n-1} + F_{n-2}$\n",
"\n",
"\n",
"The Python solution:\n",
"```python\n",
"def nth_fib(n):\n",
" if n < 2:\n",
" return n\n",
" return nth_fib(n-1) + nth_fib(n-2)\n",
"```\n",
"\n",
"## Questions\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Write a `getFactorial()` function.\n",
"\n",
"```python\n",
"Base cases:\n",
"0! = 1\n",
"1! = 1\n",
"\n",
"Recusrive case:\n",
"n! = n + (n-1)!\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"def getFactorial(n):\n",
" if n < 2:\n",
" return 1\n",
" factored = n * getFactorial(n-1)\n",
" return factored"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading