Compare commits
2 Commits
ff54ec63ec
...
824bc3ee7c
| Author | SHA1 | Date | |
|---|---|---|---|
| 824bc3ee7c | |||
| d5eca55da3 |
23
sortofsorting.py
Normal file
23
sortofsorting.py
Normal 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
19
spellingbee.py
Normal 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)
|
||||
Reference in New Issue
Block a user