From f95c583a9d8d8fb2d276e73e5ff5c1198f876f5c Mon Sep 17 00:00:00 2001 From: Huma Hameed Date: Thu, 19 Jan 2023 20:58:22 -0500 Subject: [PATCH] passed all tests --- .vscode/settings.json | 7 +++++++ lib/newman_conway.py | 12 +++++++++++- 2 files changed, 18 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..98ba633 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "." + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} diff --git a/lib/newman_conway.py b/lib/newman_conway.py index 7f5341a..17e7f38 100644 --- a/lib/newman_conway.py +++ b/lib/newman_conway.py @@ -3,4 +3,14 @@ def newman_conway(num): Time Complexity: ? Space Complexity: ? """ - pass + values = [] + if num < 1: + raise ValueError("Please enter a positive number.") + for i in range(1,num+1): + values.append(dp(i, values)) + return " ".join(map(str, values)) + +def dp(num, values): + if num == 1 or num ==2: + return 1 + return values[values[num-2]-1]+values[num - values[num-2]-1] \ No newline at end of file