From 6561f255d7323784a4b5fa7581f0e3e67b1ba272 Mon Sep 17 00:00:00 2001 From: SimonePY <92288879+SimonePY@users.noreply.github.com> Date: Thu, 13 Apr 2023 01:58:11 +0200 Subject: [PATCH] Another wave is completed --- SixteenthWave/detectFloating.py | 15 ++++++++++++++ SixteenthWave/groups.py | 5 +++++ SixteenthWave/mapLambda.py | 14 +++++++++++++ SixteenthWave/reSplit.py | 5 +++++ SixteenthWave/validateEmailfilter.py | 30 ++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+) create mode 100644 SixteenthWave/detectFloating.py create mode 100644 SixteenthWave/groups.py create mode 100644 SixteenthWave/mapLambda.py create mode 100644 SixteenthWave/reSplit.py create mode 100644 SixteenthWave/validateEmailfilter.py diff --git a/SixteenthWave/detectFloating.py b/SixteenthWave/detectFloating.py new file mode 100644 index 0000000..d4fbb88 --- /dev/null +++ b/SixteenthWave/detectFloating.py @@ -0,0 +1,15 @@ +# Enter your code here. Read input from STDIN. Print output to STDOUT +import re + + +class Main(): + def __init__(self): + self.n = int(input()) + + for i in range(self.n): + self.s = input() + print(bool(re.match(r'^[-+]?[0-9]*\.[0-9]+$', self.s))) + + +if __name__ == '__main__': + obj = Main() diff --git a/SixteenthWave/groups.py b/SixteenthWave/groups.py new file mode 100644 index 0000000..bfc8d93 --- /dev/null +++ b/SixteenthWave/groups.py @@ -0,0 +1,5 @@ +# Enter your code here. Read input from STDIN. Print output to STDOUT +import re + +m = re.search(r'([a-zA-Z0-9])\1+', input().strip()) +print(m.group(1) if m else -1) diff --git a/SixteenthWave/mapLambda.py b/SixteenthWave/mapLambda.py new file mode 100644 index 0000000..92c839a --- /dev/null +++ b/SixteenthWave/mapLambda.py @@ -0,0 +1,14 @@ +cube = lambda x: x ** 3 + + +def fibonacci(n): + List = [0, 1] + for i in range(2, n): + List.append(List[i - 1] + List[i - 2]) + + return (List[0:n]) + + +if __name__ == '__main__': + n = int(input()) + print(list(map(cube, fibonacci(n)))) diff --git a/SixteenthWave/reSplit.py b/SixteenthWave/reSplit.py new file mode 100644 index 0000000..13e79cc --- /dev/null +++ b/SixteenthWave/reSplit.py @@ -0,0 +1,5 @@ +regex_pattern = r'[.,]+' + +import re + +print("\n".join(re.split(regex_pattern, input()))) diff --git a/SixteenthWave/validateEmailfilter.py b/SixteenthWave/validateEmailfilter.py new file mode 100644 index 0000000..af5f4ad --- /dev/null +++ b/SixteenthWave/validateEmailfilter.py @@ -0,0 +1,30 @@ +def fun(email): + try: + username, url = email.split('@') + website, extension = url.split('.') + except ValueError: + return False + + if username.replace('-', '').replace('_', '').isalnum() is False: + return False + elif website.isalnum() is False: + return False + elif len(extension) > 3: + return False + else: + return True + + +def filter_mail(emails): + return list(filter(fun, emails)) + + +if __name__ == '__main__': + n = int(input()) + emails = [] + for _ in range(n): + emails.append(input()) + +filtered_emails = filter_mail(emails) +filtered_emails.sort() +print(filtered_emails)