Skip to content

Instantly share code, notes, and snippets.

@nukdokplex
Created May 18, 2022 19:08
Show Gist options
  • Save nukdokplex/75f5cd1dab77f05a59a2ecc8a9ee679e to your computer and use it in GitHub Desktop.
Save nukdokplex/75f5cd1dab77f05a59a2ecc8a9ee679e to your computer and use it in GitHub Desktop.
# Task 1
def get_spec_digit_count(number, digit):
if digit > len(str(number)):
return 0
if digit < 0:
digit = -digit
return int(str(number)[-digit])
while True:
places = input()
places = places.split("-=-")
good_places = []
for place in places:
if get_spec_digit_count(int(place), 1) > get_spec_digit_count(int(place), 3) and len(place) % 2 == 0:
good_places.append(place)
print("&".join(good_places)) # Nice
# Task 2
places = ("Gloomy",)
data = ["It", "Boring",
"Eve", "Crop"]
def step_by_boss(*data, letters=3):
def get_unique_char_count(s: str):
return len(set(s.lower()))
global places
added_places = []
for d in data:
if d in places:
continue
if get_unique_char_count(d) < letters:
continue
places = (*places, d)
added_places.append(d)
if len(added_places) == 0:
return ""
added_places.sort()
return added_places[-1]
result = step_by_boss(*data, letters=4)
print(result)
# Task 3
def f(line):
return line[::-1]
looks = ["supporting", "agreeing", "friendly", "easygoing"]
params = {
"order": f
}
def glances(*looks, kindly=None, large=None, order=None):
def is_every_word_capitalized(s: str):
for word in s.split(" "):
if word[0].islower():
return False
return True
result = {
"indifferent": [],
"reproachful": [],
"offended": [],
}
for look in looks:
if (
(kindly is None or kindly not in look) and
(large is None or len(look) <= large) and
(kindly is not None or
("a" not in look.lower() and
"e" not in look.lower())
) and
(large is not None or len(look) <= 7)
):
result['indifferent'].append(look)
if (
is_every_word_capitalized(look) and
(large is None or len(look) <= large)
):
result['reproachful'].append(look)
continue
result['offended'].append(look)
if order is not None:
result["indifferent"].sort(key=order)
result["reproachful"].sort(key=order)
result["offended"].sort(key=order)
return result
result = glances(*looks, **params)
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment