Compare commits

...

2 Commits

Author SHA1 Message Date
824bc3ee7c Sort of Sorting 2023-07-17 22:58:55 +02:00
d5eca55da3 Spelling Bee 2023-07-17 22:40:25 +02:00
2 changed files with 42 additions and 0 deletions

23
sortofsorting.py Normal file
View File

@@ -0,0 +1,23 @@
from functools import cmp_to_key
n = int(input())
def sorting_method(a, b):
if ord(a[0]) > ord(b[0]):
return 1
elif ord(a[0]) < ord(b[0]):
return -1
elif ord(a[1]) > ord(b[1]):
return 1
elif ord(a[1]) < ord(b[1]):
return -1
return 0
while n:
names = sorted([input() for _ in range(n)], key=cmp_to_key(sorting_method))
for name in names:
print(name)
print()
n = int(input())

19
spellingbee.py Normal file
View File

@@ -0,0 +1,19 @@
letters = input()
n = int(input())
def check_word(word: str, letters: str) -> bool:
for letter in word:
if letter not in letters:
return False
return True
for _ in range(n):
word = input()
if 4 > len(word):
continue
if letters[0] not in word:
continue
if check_word(word, letters):
print(word)