From 60c68b3209b3c09d3cbd29b4ef33080546a43fbd Mon Sep 17 00:00:00 2001 From: David Ferrone Date: Fri, 15 Mar 2024 11:21:15 -0400 Subject: Weekly Challenge Blast from the Past --- challenge-014/zapwai/python/ch-1.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 challenge-014/zapwai/python/ch-1.py (limited to 'challenge-014/zapwai/python') diff --git a/challenge-014/zapwai/python/ch-1.py b/challenge-014/zapwai/python/ch-1.py new file mode 100644 index 0000000000..130d5406a2 --- /dev/null +++ b/challenge-014/zapwai/python/ch-1.py @@ -0,0 +1,20 @@ +def vaneck(seq): + if len(seq) == 1: + seq.append(0) + else: + pop = seq[len(seq)-1] + done_flag = False + j = len(seq) - 2 + while j >= 0: + if (not done_flag) and seq[j] == pop: + done_flag = True + seq.append(len(seq) - 1 - j) + j -= 1 + if not done_flag: + seq.append(0) +seq = [0] +N = 19 +for i in range(N): + vaneck(seq) +print(seq) + -- cgit