feat: completed P-1.29

This commit is contained in:
baphim
2026-09-30 15:53:03 -04:00
parent 605ab16b9c
commit d23b39d984
+11 -1
View File
@@ -1,4 +1,14 @@
""" """
Write a Python program that outputs all possible strings formed by using the chagacters 'c', 'a', 't', 'd', 'o', and 'g' Write a Python program that outputs all possible strings formed by using the characters 'c', 'a', 't', 'd', 'o', and 'g'
exactly once. exactly once.
""" """
def permute(char_pool, current_str):
if len(char_pool) == 0:
print((current_str))
return
for i in range(len(char_pool)):
permute(char_pool[:i] + char_pool[i+1:], current_str + char_pool[i])
permute('catdog', '')