From c70d884ad89e553b5c6c7d26c8d2cbeae87b26ea Mon Sep 17 00:00:00 2001 From: mefrem Date: Wed, 18 Mar 2020 18:43:48 -0400 Subject: [PATCH 1/6] stock prices assignment --- .../assignment-scratch-checkpoint.ipynb | 6 + .../lecture-notes-checkpoint.ipynb | 87 ++++++ assignment-scratch.ipynb | 97 +++++++ lecture-notes.ipynb | 273 ++++++++++++++++++ stock_prices/stock_prices.py | 11 +- 5 files changed, 473 insertions(+), 1 deletion(-) create mode 100644 .ipynb_checkpoints/assignment-scratch-checkpoint.ipynb create mode 100644 .ipynb_checkpoints/lecture-notes-checkpoint.ipynb create mode 100644 assignment-scratch.ipynb create mode 100644 lecture-notes.ipynb diff --git a/.ipynb_checkpoints/assignment-scratch-checkpoint.ipynb b/.ipynb_checkpoints/assignment-scratch-checkpoint.ipynb new file mode 100644 index 000000000..2fd64429b --- /dev/null +++ b/.ipynb_checkpoints/assignment-scratch-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/.ipynb_checkpoints/lecture-notes-checkpoint.ipynb b/.ipynb_checkpoints/lecture-notes-checkpoint.ipynb new file mode 100644 index 000000000..a56c434ef --- /dev/null +++ b/.ipynb_checkpoints/lecture-notes-checkpoint.ipynb @@ -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 +} diff --git a/assignment-scratch.ipynb b/assignment-scratch.ipynb new file mode 100644 index 000000000..9db915743 --- /dev/null +++ b/assignment-scratch.ipynb @@ -0,0 +1,97 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "prices = [2,3,1,4,5,0] " + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[0, 5, 4, 1, 3, 2]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "prices[::-1]" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "def find_max_profit(prices):\n", + " differentials = []\n", + " cursor = 1\n", + " for pricepoint in prices:\n", + " for next_pricepoint in prices[cursor:]:\n", + " differentials.append(next_pricepoint - pricepoint)\n", + " cursor += 1\n", + " return max(differentials)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "94" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "find_max_profit([100, 55, 4, 98, 10, 18, 90, 95, 43, 11, 47, 67, 89, 42, 49, 79])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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 +} diff --git a/lecture-notes.ipynb b/lecture-notes.ipynb new file mode 100644 index 000000000..2ad496b23 --- /dev/null +++ b/lecture-notes.ipynb @@ -0,0 +1,273 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Question 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", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Question 3\n", + "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": 5, + "metadata": {}, + "outputs": [], + "source": [ + "def getFactorial(n):\n", + " if n < 2:\n", + " return 1\n", + " factored = n * getFactorial(n-1)\n", + " return factored" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "120" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "getFactorial(5)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Question 4\n", + "Implement quicksort algorithm" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def quicksort(data):\n", + " # base case: if array length 0 or 1\n", + " if len(data) < 2:\n", + " # return array\n", + " return data\n", + " \n", + " else:\n", + " # pick pivot (first element will do)\n", + " pivot = data[0]\n", + " left = []\n", + " right = []\n", + " # put anything smaller into left array\n", + " # put anything bigger into right array\n", + " for value in data[1:]:\n", + " if value <= pivot:\n", + " left.append(value)\n", + " if value > pivot:\n", + " right.append(value)\n", + " \n", + " # return quicksort(left) + pivot + quicksort(right)\n", + " return quicksort(left) + [pivot] + quicksort(right)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 3, 4, 5]" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "quicksort([5,4,3,2,1])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Question 5 (last night's assignment)\n", + "Implement merge sort.\n", + "```python\n", + " [5 9 3 7 2 8 1 6]\n", + " [5 9 3 7] [2 8 1 6]\n", + " [5 9] [3 7] [2 8] [1 6]\n", + " [5] [9] [3] [7] [2] [8] [1] [6] # Viola! Each (sub)array is individually sorted\n", + " ↑ ↑\n", + "# Now let's compare each subarray pairwise, keeping track with two cursors\n", + "\n", + " # Here one of our cursors hit the end of its subarray,\n", + " # so we can append the remainder of the other array since we know its sorted\n", + " ↓\n", + "i i i\n", + "[5] [ ] [ ]\n", + "[ ] -->[5] -->[5 9] \n", + "[9] [9] [ ]\n", + "j j j\n", + "\n", + "# Repeat for every other one recursively\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [], + "source": [ + "# Implementation\n", + "def merge(arrA, arrB):\n", + " elements = len(arrA) + len(arrB)\n", + " merged_arr = [0] * elements\n", + " # put back together here\n", + " # SORTING happens here\n", + " \n", + " # our cursors\n", + " a = 0\n", + " b = 0\n", + "\n", + " for k in range(0, elements):\n", + " # compare a and b\n", + " # if a is out of range, push b and iterate\n", + " # if b is out of range, push a and iterate\n", + " if a >= len(arrA): # we're done with arrA, push remaining arrB\n", + " merged_arr[k] = arrB[b]\n", + " b += 1\n", + " elif b >= len(arrB): # we're done with arrB, push remaining arrA\n", + " merged_arr[k] = arrA[a]\n", + " a += 1\n", + " # if a is smaller, put in array and iterate\n", + " # if b is smaller, put in array and iterate\n", + " elif arrA[a] < arrB[b]:\n", + " merged_arr[k] = arrA[a]\n", + " a += 1\n", + " else:\n", + " merged_arr[k] = arrB[b]\n", + " b += 1\n", + " return merged_arr\n", + "\n", + "def merge_sort(arr):\n", + " # split here\n", + " # find the middle of arr\n", + " mid = len(arr)//2\n", + " # base case:\n", + " # if array size > 1:\n", + " if len(arr) > 1:\n", + " # sort stuff in left and put it to the left\n", + " left = merge_sort(arr[:mid])\n", + " \n", + " # sort stuff in right and put it to the right\n", + " right = merge_sort(arr[mid:])\n", + " \n", + " # merge left and right\n", + " arr = merge(left, right)\n", + " return arr" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 3, 5, 6, 7, 8, 9]" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "merge_sort([5,9,3,7,2,8,1,6])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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 +} diff --git a/stock_prices/stock_prices.py b/stock_prices/stock_prices.py index 9de20bc94..379478f27 100644 --- a/stock_prices/stock_prices.py +++ b/stock_prices/stock_prices.py @@ -3,7 +3,16 @@ import argparse def find_max_profit(prices): - pass + differentials = [] + cursor = 1 + for pricepoint in prices: + for next_pricepoint in prices[cursor:]: + differentials.append(next_pricepoint - pricepoint) + cursor += 1 + return max(differentials) + + + if __name__ == '__main__': From 45f92aa2aa8409b3ac43bec8ff16382c039c3b34 Mon Sep 17 00:00:00 2001 From: mefrem Date: Wed, 18 Mar 2020 19:09:51 -0400 Subject: [PATCH 2/6] recipe assignment --- assignment-scratch.ipynb | 177 +++++++++++++++++++++++++++++++ recipe_batches/recipe_batches.py | 17 ++- 2 files changed, 193 insertions(+), 1 deletion(-) diff --git a/assignment-scratch.ipynb b/assignment-scratch.ipynb index 9db915743..f3a2bba5e 100644 --- a/assignment-scratch.ipynb +++ b/assignment-scratch.ipynb @@ -1,5 +1,12 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Stock Prices" + ] + }, { "cell_type": "code", "execution_count": 1, @@ -65,6 +72,176 @@ "find_max_profit([100, 55, 4, 98, 10, 18, 90, 95, 43, 11, 47, 67, 89, 42, 49, 79])" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Recipe Batches" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Write a function that receives a recipe in the form of a dictionary, as well as all of the ingredients you have available to you, also in the form of a dictionary. Your function should output the maximum number of whole batches that can be made for the supplied recipe using the ingredients available to you, as indicated by the second dictionary.\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "metadata": {}, + "outputs": [], + "source": [ + "def recipe_batches(recipe, ingredients):\n", + " need = []\n", + " have = []\n", + " for i in recipe.keys():\n", + " need.append(i)\n", + " for i in ingredients.keys():\n", + " have.append(i)\n", + " for i in need:\n", + " if i not in have:\n", + " return 0\n", + " ratios = []\n", + " for i in recipe:\n", + " ratio = ingredients[i] // recipe[i]\n", + " if ratio < 1:\n", + " return 0\n", + " ratios.append(ratio)\n", + " return min(ratios)" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [], + "source": [ + "recipe = {\n", + " 'eggs': 5,\n", + " 'butter': 10,\n", + " 'sugar': 8,\n", + " 'flour': 15\n", + "}\n", + "ingredients = {}" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['eggs', 'butter', 'sugar', 'flour'])" + ] + }, + "execution_count": 80, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ingredients.keys()" + ] + }, + { + "cell_type": "code", + "execution_count": 70, + "metadata": {}, + "outputs": [], + "source": [ + "for i in recipe:\n", + " ingredients[i] = recipe[i]*2" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "eggs\n", + "butter\n", + "sugar\n", + "flour\n", + "[2, 2, 2, 2]\n" + ] + } + ], + "source": [ + "ratios = []\n", + "for i in recipe:\n", + " print(i)\n", + " ratio = ingredients[i] // recipe[i]\n", + " ratios.append(ratio)\n", + "print(ratios)" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10" + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ingredients['eggs']" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [], + "source": [ + "rec = { 'milk': 100, 'flour': 4, 'sugar': 10, 'butter': 5 }\n", + "\n", + "\n", + "ing = { 'milk': 1288, 'flour': 9, 'sugar': 95 }" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 90, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "recipe_batches(rec, ing)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, diff --git a/recipe_batches/recipe_batches.py b/recipe_batches/recipe_batches.py index c845950c5..8db80f2ab 100644 --- a/recipe_batches/recipe_batches.py +++ b/recipe_batches/recipe_batches.py @@ -3,7 +3,22 @@ import math def recipe_batches(recipe, ingredients): - pass + need = [] + have = [] + for i in recipe.keys(): + need.append(i) + for i in ingredients.keys(): + have.append(i) + for i in need: + if i not in have: + return 0 + ratios = [] + for i in recipe: + ratio = ingredients[i] // recipe[i] + if ratio < 1: + return 0 + ratios.append(ratio) + return min(ratios) if __name__ == '__main__': From 793f7dc4d52cbaea96d6eaa9d08821786f63d159 Mon Sep 17 00:00:00 2001 From: mefrem Date: Wed, 18 Mar 2020 21:16:34 -0400 Subject: [PATCH 3/6] cookies problem --- assignment-scratch.ipynb | 145 ++++++++++++++++++++++++++++++- eating_cookies/eating_cookies.py | 18 +++- 2 files changed, 160 insertions(+), 3 deletions(-) diff --git a/assignment-scratch.ipynb b/assignment-scratch.ipynb index f3a2bba5e..8740465e8 100644 --- a/assignment-scratch.ipynb +++ b/assignment-scratch.ipynb @@ -235,12 +235,155 @@ "recipe_batches(rec, ing)" ] }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": {}, + "outputs": [], + "source": [ + "def eating_cookies(n, cache=None):\n", + " ways = 0\n", + " if n < 0:\n", + " ways += 0\n", + " if n == 0:\n", + " ways += 1\n", + " if n == 1:\n", + " ways += 1\n", + " if n == 2:\n", + " ways += 2\n", + " if n == 3:\n", + " ways += 4\n", + " if n > 3:\n", + " ways +=2\n", + " return ways" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "def eating_cookies(n, cache=None):\n", + " ways = [1,1,2,3]" + ] + }, + { + "cell_type": "code", + "execution_count": 118, + "metadata": {}, + "outputs": [], + "source": [ + "def __calculatePaths(currPathLength, paths, currSeries):\n", + " if currPathLength == 0:\n", + " return 1\n", + " elif currPathLength < 0:\n", + " return 0\n", + " paths = 0\n", + " for i in range(1, 4):\n", + " newSeries = list(currSeries) # make new series to track steps\n", + " newSeries.append(i)\n", + " paths += __calculatePaths(currPathLength - i, paths, newSeries)\n", + " return paths\n", + "\n", + "def calculatePaths(pathLength):\n", + " paths = __calculatePaths(pathLength, 0, [])\n", + " return paths" + ] + }, + { + "cell_type": "code", + "execution_count": 120, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 1\n", + "1 1\n", + "2 2\n", + "3 4\n", + "4 7\n", + "5 13\n", + "6 24\n", + "7 44\n", + "8 81\n", + "9 149\n", + "10 274\n", + "11 504\n", + "12 927\n", + "13 1705\n", + "14 3136\n", + "15 5768\n", + "16 10609\n", + "17 19513\n", + "18 35890\n", + "19 66012\n", + "20 121415\n", + "21 223317\n", + "22 410744\n", + "23 755476\n", + "24 1389537\n", + "25 2555757\n", + "26 4700770\n", + "27 8646064\n", + "28 15902591\n" + ] + } + ], + "source": [ + "for i in range(29):\n", + " print(i,calculatePaths(i))" + ] + }, + { + "cell_type": "code", + "execution_count": 104, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 104, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eating_cookies(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 2, 3, 4, 5]\n" + ] + } + ], + "source": [ + "\"\"\"\n", + "write a function that recursively returns the sum of a list of numbers\n", + "\"\"\"\n", + "\n", + "numbers = [1,2,3,4,5]\n", + "\n", + "def sum_of_numbers(num_list):\n", + " # What is our base case?\n", + "\n", + " return num_list\n", + "\n", + "print(sum_of_numbers(numbers))" + ] }, { "cell_type": "code", diff --git a/eating_cookies/eating_cookies.py b/eating_cookies/eating_cookies.py index 62655d803..9e09d01fb 100644 --- a/eating_cookies/eating_cookies.py +++ b/eating_cookies/eating_cookies.py @@ -5,8 +5,22 @@ # The cache parameter is here for if you want to implement # a solution that is more efficient than the naive # recursive solution -def eating_cookies(n, cache=None): - pass + +def __calculatePaths(currPathLength, paths, currSeries): + if currPathLength == 0: + return 1 + elif currPathLength < 0: + return 0 + paths = 0 + for i in range(1, 4): + newSeries = list(currSeries) # make new series to track steps + newSeries.append(i) + paths += __calculatePaths(currPathLength - i, paths, newSeries) + return paths + +def eating_cookies(pathLength, cache=None): + paths = __calculatePaths(pathLength, 0, []) + return paths if __name__ == "__main__": if len(sys.argv) > 1: From 5e34dcb9123992938975ec6f28299aa0eea80dba Mon Sep 17 00:00:00 2001 From: mefrem Date: Thu, 19 Mar 2020 13:44:49 -0400 Subject: [PATCH 4/6] eating cookies assignment --- assignment-scratch.ipynb | 62 ++++++++++++++++++++++++++++++++ eating_cookies/eating_cookies.py | 29 +++++++-------- 2 files changed, 77 insertions(+), 14 deletions(-) diff --git a/assignment-scratch.ipynb b/assignment-scratch.ipynb index 8740465e8..c8931bfb5 100644 --- a/assignment-scratch.ipynb +++ b/assignment-scratch.ipynb @@ -385,6 +385,68 @@ "print(sum_of_numbers(numbers))" ] }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "can't assign to function call (, line 1)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m e_c(n) = e_c(n-1) + e_c(n-2) + e_c(n-3)\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m can't assign to function call\n" + ] + } + ], + "source": [ + "e_c(n) = e_c(n-1) + e_c(n-2) + e_c(n-3)" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "def eating_cookies(n, cache=None):\n", + " if cache is None:\n", + " cache = {}\n", + " if n == 0:\n", + " return 1\n", + " elif n == 1:\n", + " return 1\n", + " elif n == 2:\n", + " return 2\n", + " elif n == 3:\n", + " return 4\n", + " elif cache and cache[n]:\n", + " return cache[n]\n", + " else:\n", + " cache[n] = eating_cookies(n-1, cache) + eating_cookies(n-2, cache) + eating_cookies(n-3, cache)\n", + " return cache[n]" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "410744" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eating_cookies(22)" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/eating_cookies/eating_cookies.py b/eating_cookies/eating_cookies.py index 9e09d01fb..0c6e687d0 100644 --- a/eating_cookies/eating_cookies.py +++ b/eating_cookies/eating_cookies.py @@ -6,21 +6,22 @@ # a solution that is more efficient than the naive # recursive solution -def __calculatePaths(currPathLength, paths, currSeries): - if currPathLength == 0: +def eating_cookies(n, cache=None): + if cache is None: + cache = {} + if n == 0: return 1 - elif currPathLength < 0: - return 0 - paths = 0 - for i in range(1, 4): - newSeries = list(currSeries) # make new series to track steps - newSeries.append(i) - paths += __calculatePaths(currPathLength - i, paths, newSeries) - return paths - -def eating_cookies(pathLength, cache=None): - paths = __calculatePaths(pathLength, 0, []) - return paths + elif n == 1: + return 1 + elif n == 2: + return 2 + elif n == 3: + return 4 + elif cache and cache[n]: + return cache[n] + else: + cache[n] = eating_cookies(n-1, cache) + eating_cookies(n-2, cache) + eating_cookies(n-3, cache) + return cache[n] if __name__ == "__main__": if len(sys.argv) > 1: From 3c766b5641d150edb73d1bf0f975730b8edd9618 Mon Sep 17 00:00:00 2001 From: mefrem Date: Thu, 19 Mar 2020 17:16:56 -0400 Subject: [PATCH 5/6] making change assignment --- assignment-scratch.ipynb | 141 ++++++++++++++++++++++++++++++--- making_change/making_change.py | 9 ++- 2 files changed, 136 insertions(+), 14 deletions(-) diff --git a/assignment-scratch.ipynb b/assignment-scratch.ipynb index c8931bfb5..b216dda6f 100644 --- a/assignment-scratch.ipynb +++ b/assignment-scratch.ipynb @@ -387,20 +387,11 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 28, "metadata": {}, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "can't assign to function call (, line 1)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m e_c(n) = e_c(n-1) + e_c(n-2) + e_c(n-3)\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m can't assign to function call\n" - ] - } - ], + "outputs": [], "source": [ - "e_c(n) = e_c(n-1) + e_c(n-2) + e_c(n-3)" + "# e_c(n) = e_c(n-1) + e_c(n-2) + e_c(n-3)" ] }, { @@ -447,6 +438,132 @@ "eating_cookies(22)" ] }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": {}, + "outputs": [], + "source": [ + "def making_change(amount, denominations):\n", + " cache = [0] * (amount + 1)\n", + " cache[0] = 1\n", + " for coin in denominations:\n", + " for higher_amount in range(coin, amount + 1):\n", + " cache[higher_amount] += cache[higher_amount - coin]\n", + " return cache[amount]" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "50" + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "making_change(50,[1,5,10,25,50])" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [], + "source": [ + "def making_change(n):\n", + " if n == 0:\n", + " return 1\n", + " elif 1 <= n < 5:\n", + " return 1\n", + " elif 5 <= n < 10:\n", + " return 2\n", + " elif n == 10:\n", + " return 4\n", + " elif n == 25:\n", + " return 13\n", + " elif n == 50:\n", + " return 50\n", + " else:\n", + " return making_change(n) + making_change(n-1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def making_change(denominations, n):\n", + " if n == 0:\n", + " return 1\n", + " ways = 0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 1\n", + "1 1\n", + "2 1\n", + "3 1\n", + "4 1\n", + "5 2\n", + "6 2\n", + "7 2\n", + "8 2\n", + "9 2\n", + "10 4\n" + ] + }, + { + "ename": "RecursionError", + "evalue": "maximum recursion depth exceeded in comparison", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mRecursionError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m50\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmaking_change\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m\u001b[0m in \u001b[0;36mmaking_change\u001b[0;34m(n)\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;36m50\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 15\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mmaking_change\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mmaking_change\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "... last 1 frames repeated, from the frame below ...\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36mmaking_change\u001b[0;34m(n)\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;36m50\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 15\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mmaking_change\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mmaking_change\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mRecursionError\u001b[0m: maximum recursion depth exceeded in comparison" + ] + } + ], + "source": [ + "for i in range(50):\n", + " print(i, making_change(i))" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/making_change/making_change.py b/making_change/making_change.py index 9adad4470..e00e0c7f3 100644 --- a/making_change/making_change.py +++ b/making_change/making_change.py @@ -3,7 +3,12 @@ import sys def making_change(amount, denominations): - pass + cache = [0] * (amount + 1) + cache[0] = 1 + for coin in denominations: + for higher_amount in range(coin, amount + 1): + cache[higher_amount] += cache[higher_amount - coin] + return cache[amount] if __name__ == "__main__": @@ -14,4 +19,4 @@ def making_change(amount, denominations): amount = int(sys.argv[1]) print("There are {ways} ways to make {amount} cents.".format(ways=making_change(amount, denominations), amount=amount)) else: - print("Usage: making_change.py [amount]") \ No newline at end of file + print("Usage: making_change.py [amount]") From 97435a0398327caa1d598c31f58ae97711b36575 Mon Sep 17 00:00:00 2001 From: mefrem Date: Thu, 19 Mar 2020 19:04:26 -0400 Subject: [PATCH 6/6] rock paper scissors --- assignment-scratch.ipynb | 298 ++++++++++++++++++++++++++++++++----- rock_paper_scissors/rps.py | 14 +- 2 files changed, 277 insertions(+), 35 deletions(-) diff --git a/assignment-scratch.ipynb b/assignment-scratch.ipynb index b216dda6f..826f1d18b 100644 --- a/assignment-scratch.ipynb +++ b/assignment-scratch.ipynb @@ -498,14 +498,15 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 81, "metadata": {}, "outputs": [], "source": [ - "def making_change(denominations, n):\n", - " if n == 0:\n", - " return 1\n", - " ways = 0" + "def bunnyEars(bunnies):\n", + " if bunnies == 0:\n", + " return 0\n", + "\n", + " return 2 + bunnyEars(bunnies-1)" ] }, { @@ -513,55 +514,284 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "for i in range(1,100):\n", + " print(bunnyEars(i))" + ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 86, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "a = 0\n", + "a = a + 10\n", + "ry" + ] }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10" + ] + }, + "execution_count": 87, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a" + ] + }, + { + "cell_type": "code", + "execution_count": 137, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "0 1\n", - "1 1\n", - "2 1\n", - "3 1\n", - "4 1\n", - "5 2\n", - "6 2\n", - "7 2\n", - "8 2\n", - "9 2\n", - "10 4\n" + "0:00:00.000047\n" + ] + } + ], + "source": [ + "from datetime import datetime\n" + ] + }, + { + "cell_type": "code", + "execution_count": 142, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0:00:00.000118\n" ] - }, + } + ], + "source": [ + "start_time = datetime.now()\n", + "n = 1\n", + "a = 0\n", + "while (a < n * n * n):\n", + " a = a + n * n\n", + "end_time = datetime.now()\n", + "print (end_time - start_time)" + ] + }, + { + "cell_type": "code", + "execution_count": 143, + "metadata": {}, + "outputs": [ { - "ename": "RecursionError", - "evalue": "maximum recursion depth exceeded in comparison", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mRecursionError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m50\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmaking_change\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m\u001b[0m in \u001b[0;36mmaking_change\u001b[0;34m(n)\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;36m50\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 15\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mmaking_change\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mmaking_change\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "... last 1 frames repeated, from the frame below ...\n", - "\u001b[0;32m\u001b[0m in \u001b[0;36mmaking_change\u001b[0;34m(n)\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;36m50\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 15\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mmaking_change\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mmaking_change\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mRecursionError\u001b[0m: maximum recursion depth exceeded in comparison" + "name": "stdout", + "output_type": "stream", + "text": [ + "0:00:00.000295\n" + ] + } + ], + "source": [ + "start_time = datetime.now()\n", + "n = 500\n", + "a = 0\n", + "while (a < n * n * n):\n", + " a = a + n * n\n", + "end_time = datetime.now()\n", + "print (end_time - start_time)" + ] + }, + { + "cell_type": "code", + "execution_count": 147, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 0:00:00.000084\n", + "501 0:00:00.000538\n", + "1001 0:00:00.000877\n", + "1501 0:00:00.001361\n", + "2001 0:00:00.001988\n", + "2501 0:00:00.002945\n", + "3001 0:00:00.004047\n", + "3501 0:00:00.005362\n", + "4001 0:00:00.007522\n", + "4501 0:00:00.009259\n", + "5001 0:00:00.011594\n", + "5501 0:00:00.013601\n", + "6001 0:00:00.018891\n", + "6501 0:00:00.022141\n", + "7001 0:00:00.024703\n", + "7501 0:00:00.028870\n", + "8001 0:00:00.032867\n", + "8501 0:00:00.037575\n", + "9001 0:00:00.041736\n", + "9501 0:00:00.045391\n" + ] + } + ], + "source": [ + "start_time = datetime.now()\n", + "for n in range(1,10000,500):\n", + " a = 0\n", + " while (a < n * n * n):\n", + " a = a + n * n\n", + " end_time = datetime.now()\n", + " print(n, end_time - start_time)" + ] + }, + { + "cell_type": "code", + "execution_count": 105, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "25\n", + "50\n", + "75\n", + "100\n", + "125\n" + ] + } + ], + "source": [ + "a = 0\n", + "while (a < 5 * 5 * 5):\n", + " a = a + 5 * 5\n", + " print(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 148, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n" + ] + }, + { + "cell_type": "code", + "execution_count": 152, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAD4CAYAAAD2FnFTAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deVxVdf7H8deHXQFBBTcQUEHU3EVbrDQ1tdWanNJyWqZtmvbdZpqaX81vptVq2stsm6ks2ywttzbLLHHfQBY3xAVEQQVZP78/uM6PIVRMLucun+fjcR/Cvedc3iXy5pzzPd+vqCrGGGNMfQFOBzDGGOOZrCCMMcY0yArCGGNMg6wgjDHGNMgKwhhjTIOCnA7QVGJiYjQpKcnpGMYY41WWLl1aqKqxDb3mMwWRlJREenq60zGMMcariMjmw71mp5iMMcY0yArCGGNMg6wgjDHGNMgKwhhjTIOsIIwxxjTICsIYY0yD3FoQIjJWRDJFJFtEJjfw+h0isk5EVonIAhFJrPNatYiscD1mujOnMcaYX3LbfRAiEgg8D5wJ5AFLRGSmqq6rs9lyIE1VS0XkBuAx4BLXa2Wq2t9d+Yxxl/KqanJ2HSBr1z5276/gQHkVAQFCqxbBtI8MpWfHVsS3boGIOB3VmCNy541yQ4BsVc0FEJH3gHHAfwpCVb+us/1iYJIb8xjjNkUHKvh0xTa+ytjFTxuLqKiqOeL2rVsGc0ZqO87s1Z6RPdsTEmRne43ncWdBxAFb63yeB5x4hO2vBr6o83mYiKQDVcAjqvpJ/R1E5DrgOoCEhITjDmzMsVqXX8KL3+YwZ80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EpCW1Ix6b/MjZhrkaY4xpkB1BGGOMaZAVhDHGmAZZQRhjjGmQFYQxxpgGWUEYY4xpkBWEMcaYBllBGGOMadD/AUECvM26kNmEAAAAAElFTkSuQmCC\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "s = pd.Series([1, 2, 2.5, 3, 3.5, 4, 5])\n", + "ax = s.plot.kde()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Rock Paper Scissors\n", + "\n", + "Write a function `rock_paper_scissors` to generate all of the possible plays that can be made in a game of \"Rock Paper Scissors\", given some input `n`, which represents the number of plays per round. \n", + "\n", + "For example, given n = 2, your function should output the following:\n", + "\n", + "```python\n", + "[['rock', 'rock'], ['rock', 'paper'], ['rock', 'scissors'], ['paper', 'rock'], ['paper', 'paper'], ['paper', 'scissors'], ['scissors', 'rock'], ['scissors', 'paper'], ['scissors', 'scissors']]\n", + "```\n", + "\n", + "Your output should be a list of lists containing strings. Each inner list should have length equal to the input n.\n", + "\n", + "## Testing\n", + "\n", + "Run the test file by executing `python test_rps.py`.\n", + "\n", + "You can also test your implementation manually by executing `python rps.py [n]`.\n", + "\n", + "## Hints\n", + "\n", + " * You'll want to define a list with all of the possible Rock Paper Scissors plays.\n", + " * Another problem that asks you to generate a bunch of permutations, so we're probably going to want to opt for using recursion again. Since we're building up a list of results, we'll have to pass the list we're constructing around to multiple recursive calls so that each recursive call can add to the overall result. However, the tests only give our function `n` as input. To get around this, we could define an inner recursive helper function that will perform the recursion for us, while allowing us to preserve the outer function's function signature. \n", + " * In Python, you can concatenate two lists with the `+` operator. However, you'll want to make sure that both operands are lists!\n", + " * If you opt to define an inner recursive helper function, don't forget to make an initial call to the recursive helper function to kick off the recursion." + ] + }, + { + "cell_type": "code", + "execution_count": 157, + "metadata": {}, + "outputs": [], + "source": [ + "def add_one_more(list_plays):\n", + " list_return = []\n", + " strings = [['rock'],['paper'],['scissors']]\n", + " for i in list_plays:\n", + " for j in strings:\n", + " list_return.append(i+j)\n", + " return list_return\n", + " \n", + "\n", + "def rock_paper_scissors(n):\n", + " if n <= 0:\n", + " return [[]]\n", + " else:\n", + " return add_one_more(rock_paper_scissors(n-1))" + ] + }, + { + "cell_type": "code", + "execution_count": 168, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 1\n", + "1 3\n", + "2 9\n", + "3 27\n", + "4 81\n", + "5 243\n", + "6 729\n", + "7 2187\n", + "8 6561\n", + "9 19683\n", + "10 59049\n", + "11 177147\n", + "12 531441\n" ] } ], "source": [ - "for i in range(50):\n", - " print(i, making_change(i))" + "for i in range(13):\n", + " lists = rock_paper_scissors(i)\n", + " print(i,len(lists))" ] }, { diff --git a/rock_paper_scissors/rps.py b/rock_paper_scissors/rps.py index 0fc53356e..9e4f4c713 100644 --- a/rock_paper_scissors/rps.py +++ b/rock_paper_scissors/rps.py @@ -2,8 +2,20 @@ import sys +def add_one_more(list_plays): + list_return = [] + strings = [['rock'],['paper'],['scissors']] + for i in list_plays: + for j in strings: + list_return.append(i+j) + return list_return + + def rock_paper_scissors(n): - pass + if n <= 0: + return [[]] + else: + return add_one_more(rock_paper_scissors(n-1)) if __name__ == "__main__":