From 615541265b125d8be038e29c85358ec4fac18ad7 Mon Sep 17 00:00:00 2001 From: Jamie H Date: Thu, 19 Jan 2023 15:40:33 -0500 Subject: [PATCH] done --- .vscode/settings.json | 7 +++++++ lib/newman_conway.py | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9b38853 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/lib/newman_conway.py b/lib/newman_conway.py index 7f5341a..55f737a 100644 --- a/lib/newman_conway.py +++ b/lib/newman_conway.py @@ -3,4 +3,19 @@ def newman_conway(num): Time Complexity: ? Space Complexity: ? """ - pass + if num < 1: + raise ValueError("can't be 0 or neg") + memory = {} + answer_list = [] + for num in range(1, num+1): + if num < 3: + memory[num] = 1 + answer_list.append("1") + continue + recall = memory[num-1] + solution = memory[recall] + memory[num-recall] + memory[num] = solution + answer_list.append(str(solution)) + return " ".join(answer_list) +# newman_conway(4) +