Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
zehengl committed Nov 27, 2023
1 parent 5eb41d1 commit 374370f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/namegeneration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import string
from random import randint, choice

vowels = set("aeiou")
consonants = set(string.ascii_lowercase) - vowels
names = set()


def f(w):
return "".join([choice(list(consonants)) if c else choice(list(vowels)) for c in w])


for _ in range(int(input())):
s = randint(3, 20)
w = []
for i in range(s):
if i < 2:
w.append(randint(0, 1))
else:
if w[-1] == w[-2]:
w.append((w[-2] + 1) % 2)
else:
w.append(randint(0, 1))

name = f(w)
while name in names:
name = f(w)
names.add(name)

print(name)
9 changes: 9 additions & 0 deletions src/zyxab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
n = int(input())
names = [input() for _ in range(n)]
names = [n for n in names if len(set(n)) == len(n) and len(n) >= 5]
if names:
least = min(len(n) for n in names)
names = [n for n in names if len(n) == least]
print(max(names))
else:
print("Neibb")

0 comments on commit 374370f

Please sign in to comment.