From e7682164d6dd16211e76b4166b02fc5892d9975a Mon Sep 17 00:00:00 2001 From: baphim <269010393+baphim@users.noreply.github.com> Date: Wed, 30 Sep 2026 16:30:12 -0400 Subject: [PATCH] feat: added comments to P-1.29 --- lab-3_4/P-1.29.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lab-3_4/P-1.29.py b/lab-3_4/P-1.29.py index 0af3010..07a3c08 100644 --- a/lab-3_4/P-1.29.py +++ b/lab-3_4/P-1.29.py @@ -2,12 +2,15 @@ Write a Python program that outputs all possible strings formed by using the characters 'c', 'a', 't', 'd', 'o', and 'g' exactly once. """ - +# define 'permute' function def permute(char_pool, current_str): + # base case: if char_pool is empty, print value of 'current_str' if len(char_pool) == 0: - print((current_str)) + print(current_str) return + # try each remaining character as the next pick for i in range(len(char_pool)): + # pick character at i: pass down pool without it, and string with it added permute(char_pool[:i] + char_pool[i+1:], current_str + char_pool[i])