Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- def calculate_cool_threshold(input_string):
- threshold = 1
- for char in input_string:
- if char.isdigit():
- threshold *= int(char)
- return threshold
- def get_valid_emojis(emojis_input):
- valid_emojis = list()
- emoji_pattern = r"(\*\*|\:\:)([A-Z][a-z]{2,})\1"
- matched_emojis = re.finditer(emoji_pattern, emojis_input)
- for match in matched_emojis:
- valid_emojis.append(match.group())
- return valid_emojis
- def cool_emoji(emoji_string, threshold):
- emoji_coolness = 0
- for char in emoji_string:
- if char.isalpha():
- emoji_coolness += ord(char)
- if emoji_coolness >= threshold:
- return True
- return False
- emojis_string = input()
- cool_threshold_sum = calculate_cool_threshold(emojis_string)
- emojis = get_valid_emojis(emojis_string)
- print(f"Cool threshold: {cool_threshold_sum}")
- print(f"{len(emojis)} emojis found in the text. The cool ones are:")
- for emoji in emojis:
- if cool_emoji(emoji, cool_threshold_sum):
- print(emoji)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement