Skip to content

Instantly share code, notes, and snippets.

@raspi
Last active July 20, 2023 12:59
Show Gist options
  • Save raspi/b4c82b0170b2a8b19fb50369906681d6 to your computer and use it in GitHub Desktop.
Save raspi/b4c82b0170b2a8b19fb50369906681d6 to your computer and use it in GitHub Desktop.
from itertools import permutations
from typing import Generator, List
def gen(s: List[str]) -> Generator:
for i in permutations(s, len(s)):
yield list(i)
def acro(a:List[str]) -> Generator:
for i in gen(a):
firsts:List[str] = []
for item in i:
firsts.append(item[0])
yield firsts, i
if __name__ == '__main__':
a = ['PostgreSQL', 'Go', 'HTMX', 'Linux']
for i in acro(a):
a, b = i
print("".join(a), " ".join(b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment