Add some cool queue, stacks, strings, math, bit manipulation examples (#35)

This commit is contained in:
Dr. Marina Souza, PhD 2023-07-16 17:35:14 -07:00 committed by GitHub
parent f3ee2cdf52
commit 0f455a0322
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 932 additions and 13 deletions

View file

@ -0,0 +1,22 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# author: bt3gl
def permutation(string) -> list:
if len(string) == 1:
return [string]
result = []
for i, char in enumerate(string):
for perm in permutation(string[:i] + string[i+1:]):
result += [char + perm]
return result
if __name__ == '__main__':
print('Testing permutation()...')
string = "bt3gl"
print(f'Permutation of {string}: {permutation(string)}')