From 77613642d53352157994db61cf6526ea57a65037 Mon Sep 17 00:00:00 2001 From: Jae Date: Fri, 20 Jan 2023 06:25:46 -0500 Subject: [PATCH] tests passing --- lib/newman_conway.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/newman_conway.py b/lib/newman_conway.py index 7f5341a..cc60458 100644 --- a/lib/newman_conway.py +++ b/lib/newman_conway.py @@ -3,4 +3,10 @@ def newman_conway(num): Time Complexity: ? Space Complexity: ? """ - pass + if num <= 0: + raise ValueError("invalid input") + seq = [1,1] + for i in range(2,num): + seq.append(seq[seq[i-1]-1]+seq[i-seq[i-1]]) + return ' '.join(map(str, seq[:num])) +