diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml deleted file mode 100644 index 6203961..0000000 --- a/.github/workflows/cd.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# cd.yaml - -name: Build and Deploy - -on: [push] - -jobs: - build-and-deploy: - concurrency: ci-${{ github.ref }} - runs-on: ubuntu-latest - steps: - - name: Checkout 🛎️ - uses: actions/checkout@v3 - - - name: Install and Build 🔧 - run: | - mkdir output - cp readme.md output/ - echo theme: jekyll-theme-cayman >> output/_config.yml - - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@v4.2.5 - with: - branch: gh-pages - folder: output diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 3aa0ad5..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [main] - pull_request: - branches: [main] - schedule: - - cron: "29 21 * * 2" - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: ["python"] - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..277f1f2 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman diff --git a/easy/01_hello_world.py b/easy/01_hello_world.py deleted file mode 100644 index 10800f0..0000000 --- a/easy/01_hello_world.py +++ /dev/null @@ -1,9 +0,0 @@ -""" -The simplest challenge -""" - - -MESSAGE: str = "Hello, World!" - -if __name__ == "__main__": - print(MESSAGE) diff --git a/easy/02_if_else.py b/easy/02_if_else.py deleted file mode 100644 index 12a3953..0000000 --- a/easy/02_if_else.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -Given an integer, *n*, perform the following conditional actions: - -If n is odd, print Weird -If n is even and in the inclusive range of 2 to 5, print Not Weird -If n is even and in the inclusive range of 6 to 20, print Weird -If n is even and greater than 20, print Not Weird -""" - - -# This was my first idea -def weird_or_not(n: int) -> str: - if n % 2: - return "Weird" - - return "Not Weird" if n in range(2, 5) or n > 20 else "Weird" - - -def weird_or_not_two(n: int) -> str: - return {True: "Not Weird", False: "Weird"}[ - n % 2 == 0 and n in range(2, 6) or n > 20 - ] - - -if __name__ == "__main__": - print(weird_or_not(22)) diff --git a/easy/03_division.py b/easy/03_division.py deleted file mode 100644 index 925d72e..0000000 --- a/easy/03_division.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -The provided code stub reads two integers, "a" and "b", from STDIN. - -Add logic to print two lines. -The first line should contain the result of integer division, "a" // "b" . -The second line should contain the result of float division, "a" / "b" . -""" - - -def format_division(a: int, b: int) -> str: - return f"{a//b}\n{a/b}" - - -if __name__ == "__main__": - print(format_division(3, 5)) diff --git a/easy/04_arithmetic.py b/easy/04_arithmetic.py deleted file mode 100644 index bf4509d..0000000 --- a/easy/04_arithmetic.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -The provided code stub reads two integers from STDIN,"a" and "b". -Add code to print three lines where: - -The first line contains the sum of the two numbers. -The second line contains the difference of the two numbers (first - second). -The third line contains the product of the two numbers. -""" - - -def format_arithmetic(a: int, b: int) -> str: - return f"{a+b}\n{a-b}\n{a*b}" - - -if __name__ == "__main__": - print(format_arithmetic(2, 4)) diff --git a/easy/05_loops.py b/easy/05_loops.py deleted file mode 100644 index a02d15d..0000000 --- a/easy/05_loops.py +++ /dev/null @@ -1,13 +0,0 @@ -""" -The provided code stub reads and integer, b, from STDIN. -For all non-negative integers i < n, print i**2. -""" - - -def potency_while_minor_than_n(n: int) -> None: - for i in range(n): - print(i**2) - - -if __name__ == "__main__": - potency_while_minor_than_n(5) diff --git a/easy/06_print_until_n.py b/easy/06_print_until_n.py deleted file mode 100644 index 5b4d123..0000000 --- a/easy/06_print_until_n.py +++ /dev/null @@ -1,18 +0,0 @@ -""" -Without using any string methods, try to print the following: - 123...n - -Note that "..." represents the consecutive values in between. - -Example: -n = 5 -Print the string "12345". -""" - - -def print_until_n(n: int) -> None: - print(*range(1, n + 1), sep="") - - -if __name__ == "__main__": - print_until_n(5) diff --git a/easy/07_find_the_score_xml.py b/easy/07_find_the_score_xml.py deleted file mode 100644 index 04ea3c9..0000000 --- a/easy/07_find_the_score_xml.py +++ /dev/null @@ -1,27 +0,0 @@ -""" -You are given a valid XML document, and you have to print its score. -The score is calculated by the sum of the score of each element. -For any element, the score is equal to the number of attributes it has. - -Input Format - -The first line contains , the number of lines in the XML document. -The next lines follow containing the XML document. - -Output Format - -Output a single line, the integer score of the given XML document. -""" - -import sys -import xml.etree.ElementTree as etree - - -def get_attr_number(node): - return etree.tostring(node).count(b"=") - - -if __name__ == "__main__": - sys.stdin.readline() - tree = etree.ElementTree(etree.fromstring(sys.stdin.read())).getroot() - print(get_attr_number(tree)) diff --git a/easy/08_find_maximum_depth_xml.py b/easy/08_find_maximum_depth_xml.py deleted file mode 100644 index 42e43cf..0000000 --- a/easy/08_find_maximum_depth_xml.py +++ /dev/null @@ -1,28 +0,0 @@ -""" -You are given a valid XML document, and you have to print the -maximum level of nesting in it. Take the depth of the root as 0. - -Input Format - -The first line contains N, the number of lines in the XML document. -The next N lines follow containing the XML document. -""" - -import xml.etree.ElementTree as etree - - -def depth(elem, level): - maxdepth: int = -1 - if level == maxdepth: - maxdepth += 1 - - for child in elem: - depth(child, level + 1) - return maxdepth - - -if __name__ == "__main__": - xml = "" - for i in range(int(input())): - xml = xml + input() + "\n" - print(depth(etree.ElementTree(etree.fromstring(xml)).getroot(), -1)) diff --git a/easy/09_list_comprenhension.py b/easy/09_list_comprenhension.py deleted file mode 100644 index 988885d..0000000 --- a/easy/09_list_comprenhension.py +++ /dev/null @@ -1,22 +0,0 @@ -""" -You are given three integers x,y and z representing the dimensions -of a cuboid along with an integer n. -Print a list of all possible coordinates given by (i,j,k) -on a 3D grid where the sum of i+j+k is not equal to n. -Here, 0 < i < x; 0 < j < y; 0 < k < z. -""" - - -def represent_dimension_cuboid(x, y, z, n) -> list: - return [ - [a, b, c] - for a in range(x + 1) - for b in range(y + 1) - for c in range(z + 1) - if a + b + c != n - ] - - -if __name__ == "__main__": - x, y, z, n = (int(input()) for _ in range(4)) - print(represent_dimension_cuboid(x, y, z, n)) diff --git a/easy/10_nested_list.py b/easy/10_nested_list.py deleted file mode 100644 index 102d54c..0000000 --- a/easy/10_nested_list.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -Given the names and grades for each student in a Physics class of students, -store them in a nested list and print the name(s) of any student(s) having the second lowest grade. -Note: If there are multiple students with the same grade, -order their names alphabetically and print each name on a new line. -""" - - -def calc(lsts: list) -> str: - all_grades = sorted(set([marks for _, marks in data])) - return f"\n".join([a for a, b in sorted(data) if b == all_grades[1]]) - - -if __name__ == "__main__": - data = [[input(), float(input())] for _ in range(int(input()))] - print(calc(data)) diff --git a/easy/11_lists.py b/easy/11_lists.py deleted file mode 100644 index eb6ed89..0000000 --- a/easy/11_lists.py +++ /dev/null @@ -1,75 +0,0 @@ -from os import name, system - -HELP_MESSAGE = """ - commands = { - "append": lambda arg: lst.append(arg), - "print": lambda: print(lst), - "remove": lambda arg: lst.remove(arg), - "insert": lambda pos, item: lst.insert(pos, item), - "pop": lambda: lst.pop(), - "sort": lambda: lst.sort(), - "reverse": lambda: lst.reverse(), - "clear": lambda: clear_console(), - "exit": lambda: exit(), - } -""" - - -def get_lst_max_length(len_of_list=0) -> int: - while len_of_list < 1: - try: - len_of_list = int( - input("Enter the len of the list, it has to be more than one!: ") - ) - except ValueError: - print("You have to pass a number!") - - return len_of_list - - -def main() -> None: - - print("Welcome To UltiList!") - - len_of_list = get_lst_max_length() - - lst = [] - - commands = { - "append": lambda arg: lst.append(arg), - "print": lambda: print(lst), - "remove": lambda arg: lst.remove(arg), - "insert": lambda pos, item: lst.insert(pos, item), - "pop": lambda: lst.pop(), - "sort": lambda: lst.sort(), - "reverse": lambda: lst.reverse(), - "clear": lambda: system("cls" if name in ("nt", "dos") else "clear"), - "exit": lambda: exit(), - "help": lambda: print(HELP_MESSAGE), - } - - while len(lst) <= len_of_list: - print(">> ", end="") - args = input().strip().split(" ") - try: - try: - commands[f"{args[0]}"](int(args[1])) - except ValueError: - print(f"You have to pass a number! Not a {type(args[1])}") - except IndexError: - commands[f"{args[0]}"]() - except TypeError: - try: - commands[f"{args[0]}"](int(args[1]), int(args[2])) - except ValueError: - print( - f"You have to pass two numbers! Not a {type(args[1])} and {type(args[2])}" - ) - except KeyError: - print("That's not a valid command!") - - -if __name__ == "__main__": - main() - -# codereview.stackexchange.com/questions/264384 diff --git a/easy/12_finding_percentage.py b/easy/12_finding_percentage.py deleted file mode 100644 index af1abb4..0000000 --- a/easy/12_finding_percentage.py +++ /dev/null @@ -1,12 +0,0 @@ -def main() -> str: - student_marks = {} - - for _ in range(int(input())): - name, *line = input().split() - student_marks[name] = list(map(float, line)) - - return "%.2f" % (sum(student_marks[input()]) / 3) - - -if __name__ == "__main__": - print(main()) diff --git a/easy/13_swap_case.py b/easy/13_swap_case.py deleted file mode 100644 index abe293a..0000000 --- a/easy/13_swap_case.py +++ /dev/null @@ -1,12 +0,0 @@ -""" -You are given a string and your task is to swap cases. -In other words, convert all lowercase letters to uppercase letters and vice versa. -""" - - -def swap_case(s): - return s.swapcase() - - -if __name__ == "__main__": - print(swap_case(input())) diff --git a/easy/14_string_split_and_join.py b/easy/14_string_split_and_join.py deleted file mode 100644 index fabc7e8..0000000 --- a/easy/14_string_split_and_join.py +++ /dev/null @@ -1,6 +0,0 @@ -def split_and_join(line): - return "-".join(line.split(" ")) - - -if __name__ == "__main__": - print(split_and_join(input())) diff --git a/easy/15_your_name.py b/easy/15_your_name.py deleted file mode 100644 index 81a7d34..0000000 --- a/easy/15_your_name.py +++ /dev/null @@ -1,13 +0,0 @@ -""" -You are given the firstname and lastname of a person on two different lines. -Your task is to read them and print the following: - Hello firstname lastname! You just delved into python. -""" - - -def delved_into_python(first, last): - return f"Hello {first} {last}! You just delved into python." - - -if __name__ == "__main__": - print(delved_into_python(input(), input())) diff --git a/easy/16_mutations.py b/easy/16_mutations.py deleted file mode 100644 index a6d6453..0000000 --- a/easy/16_mutations.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -We have seen that lists are mutable (they can be changed), and tuples are immutable (they cannot be changed). - -Let's try to understand this with an example. - -You are given an immutable string, and you want to make changes to it. -""" - - -def mutate_string(string, pos, char): - return string[:pos] + char + string[pos + 1 :] - - -if __name__ == "__main__": - i, c = input().split() - print(mutate_string(input(), int(i), c)) diff --git a/easy/17_fd_str.py b/easy/17_fd_str.py deleted file mode 100644 index 493a4e3..0000000 --- a/easy/17_fd_str.py +++ /dev/null @@ -1,10 +0,0 @@ -def count_substring(string: str, sub_string: str): - count: int = 0 - for i in range(len(string)): - if string[i:].startswith(sub_string): - count += 1 - return count - - -if __name__ == "__main__": - print(count_substring(input().strip(), input().strip())) diff --git a/easy/18_str_validators.py b/easy/18_str_validators.py deleted file mode 100644 index ab4f807..0000000 --- a/easy/18_str_validators.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -Python has built-in string validation methods for basic data. -It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc. -""" - - -def main(string: str) -> None: - print(any(char.isalnum() for char in string)) - print(any(char.isalpha() for char in string)) - print(any(char.isdigit() for char in string)) - print(any(char.islower() for char in string)) - print(any(char.isupper() for char in string)) - - -if __name__ == "__main__": - main(input()) diff --git a/easy/19_made_a_heart.py b/easy/19_made_a_heart.py deleted file mode 100644 index fe70e98..0000000 --- a/easy/19_made_a_heart.py +++ /dev/null @@ -1,23 +0,0 @@ -from math import sin, radians - - -def main(c: str, w: int) -> None: - print((c * 2).center(w // 2) * 2) - - for i in range(1, w // 10 + 1): - print( - ( - (c * int(sin(radians(i * w // 2)) * w // 4)).rjust(w // 4) - + (c * int(sin(radians(i * w // 2)) * w // 4)).ljust(w // 4) - ) - * 2 - ) - - for i in range(w // 4, 0, -1): - print(((c * i * 4).center(w))) - - print((c * 2).center(w)) - - -if __name__ == "__main__": - main("*", 40) diff --git a/easy/20_text_alignment.py b/easy/20_text_alignment.py deleted file mode 100644 index 4ff1020..0000000 --- a/easy/20_text_alignment.py +++ /dev/null @@ -1,17 +0,0 @@ -def main(t: int, c: str) -> None: - print((c * i).rjust(t - 1) + c + (c * i).ljust(t - 1) for i in range(t)) - - print((c * t).center(t * 2) + (c * t).center(t * 6) for i in range(t + 1)) - - print((c * t * 5).center(t * 6) for i in range((t + 1) // 2)) - - print((c * t).center(t * 2) + (c * t).center(t * 6) for i in range(t + 1)) - - print( - ((c * (t - i - 1)).rjust(t) + c + (c * (t - i - 1)).ljust(t)).rjust(t * 6) - for i in range(t) - ) - - -if __name__ == "__main__": - main(int(input()), "H") diff --git a/easy/21_capitalize.py b/easy/21_capitalize.py deleted file mode 100644 index c600e77..0000000 --- a/easy/21_capitalize.py +++ /dev/null @@ -1,6 +0,0 @@ -def capitalize(string: str): - return " ".join([word.capitalize() for word in string.split(" ")]) - - -if __name__ == "__main__": - print(capitalize("sabare reque")) diff --git a/easy/22_minion_game.py b/easy/22_minion_game.py deleted file mode 100644 index 3048732..0000000 --- a/easy/22_minion_game.py +++ /dev/null @@ -1,17 +0,0 @@ -def minion_game(string): - VOWELS: list = ["A", "E", "I", "O", "U"] - S: int = 0 - K: int = 0 - - for i in range(len(string)): - if string[i] in VOWELS: - K += len(string) - i - else: - S += len(string) - i - - if S > K: - print(f"Stuart {S}") - elif K > S: - print(f"Kevin {K}") - else: - print("Draw") diff --git a/easy/23_merge_tools.py b/easy/23_merge_tools.py deleted file mode 100644 index c847165..0000000 --- a/easy/23_merge_tools.py +++ /dev/null @@ -1,8 +0,0 @@ -def merge_the_tools(s: str, k: int) -> None: - for part in zip(*[iter(s)] * k): - d = dict() - print("".join([d.setdefault(c, c) for c in part if c not in d])) - - -if __name__ == "__main__": - merge_the_tools(input(), int(input())) diff --git a/easy/24_text_wrap.py b/easy/24_text_wrap.py deleted file mode 100644 index 67308e9..0000000 --- a/easy/24_text_wrap.py +++ /dev/null @@ -1,10 +0,0 @@ -import textwrap - - -def wrap(string: str, max_width: int): - # return "\n".join([string[i : i + max_width] for i in range(len(string), max_width)]) - return "\n".join(textwrap.wrap(string, max_width)) - - -if __name__ == "__main__": - print(wrap("ABCDEFGHIJKLIMNOQRSTUVWXYZ", 4)) diff --git a/easy/25_draw_door.py b/easy/25_draw_door.py deleted file mode 100644 index 2328ecb..0000000 --- a/easy/25_draw_door.py +++ /dev/null @@ -1,4 +0,0 @@ -if __name__ == "__main__": - n, m = map(int, input().split()) - pattern = [(".|." * (2 * i + 1)).center(m, "-") for i in range(n // 2)] - print("\n".join(pattern + ["WELCOME".center(m, "-")] + pattern[::-1])) diff --git a/easy/26_str_formatting.py b/easy/26_str_formatting.py deleted file mode 100644 index 2e37e38..0000000 --- a/easy/26_str_formatting.py +++ /dev/null @@ -1,13 +0,0 @@ -def main() -> list: - return [ - [str(i), str(oct(i)[2:]), str(hex(i)[2:]).upper(), str(bin(i)[2:])] - for i in range(1, int(input()) + 1) - ] - - -if __name__ == "__main__": - results = main() - width = len(results[-1][3]) - - for item in results: - print(*(rep.rjust(width) for rep in item)) diff --git a/easy/27_rangoli.py b/easy/27_rangoli.py deleted file mode 100644 index 2fe994b..0000000 --- a/easy/27_rangoli.py +++ /dev/null @@ -1,16 +0,0 @@ -from string import ascii_lowercase - - -def print_rangoli(n: int) -> str: - alpha = ascii_lowercase - lst = [] - for item in range(n): - s = "-".join(alpha[item:n]) - lst.append((s[::-1] + s[1:]).center(4 * n - 3, "-")) - - return "\n".join(lst[:0:-1] + lst) - - -if __name__ == "__main__": - n = int(input()) - print_rangoli(n) diff --git a/easy/28_iter_product.py b/easy/28_iter_product.py deleted file mode 100644 index 24f2fbb..0000000 --- a/easy/28_iter_product.py +++ /dev/null @@ -1,9 +0,0 @@ -from itertools import product - - -def run(a, b): - print(*product(a, b)) - - -if __name__ == "__main__": - run(list(map(int, input().split())), list(map(int, input().split()))) diff --git a/easy/29_itertools_permutations.py b/easy/29_itertools_permutations.py deleted file mode 100644 index 6e2d2d3..0000000 --- a/easy/29_itertools_permutations.py +++ /dev/null @@ -1,11 +0,0 @@ -from itertools import permutations - - -def run() -> None: - s, n = input().split() - - print(*["".join(i) for i in permutations(sorted(s), int(n))], sep="\n") - - -if __name__ == "__main__": - run() diff --git a/easy/30_sets.py b/easy/30_sets.py deleted file mode 100644 index 9ae481d..0000000 --- a/easy/30_sets.py +++ /dev/null @@ -1,2 +0,0 @@ -def get_average(array): - return sum(set(array)) / len(set(array)) diff --git a/easy/31_polar_cordinates.py b/easy/31_polar_cordinates.py deleted file mode 100644 index 4f5d0b1..0000000 --- a/easy/31_polar_cordinates.py +++ /dev/null @@ -1,9 +0,0 @@ -from cmath import polar - - -def run() -> None: - print(*polar(complex(input())), sep="\n") - - -if __name__ == "__main__": - run() diff --git a/easy/32_default_dict.py b/easy/32_default_dict.py deleted file mode 100644 index db45431..0000000 --- a/easy/32_default_dict.py +++ /dev/null @@ -1,17 +0,0 @@ -from collections import defaultdict - - -def run(): - d = defaultdict(list) - - n, m = map(int, input().split()) - - for i in range(1, n + 1): - d[input()].append(str(i)) - - for i in range(m): - print(" ".join(d[input()]) or -1) - - -if __name__ == "__main__": - run() diff --git a/easy/33_calendar_module.py b/easy/33_calendar_module.py deleted file mode 100644 index 0efcdaa..0000000 --- a/easy/33_calendar_module.py +++ /dev/null @@ -1,6 +0,0 @@ -import calendar - - -if __name__ == "__main__": - n1, n2, n3 = map(int, input().split()) - print((calendar.day_name[calendar.weekday(n3, n1, n2)]).upper()) diff --git a/easy/34_exceptions.py b/easy/34_exceptions.py deleted file mode 100644 index c201245..0000000 --- a/easy/34_exceptions.py +++ /dev/null @@ -1,11 +0,0 @@ -def main(): - for _ in range(int(input())): - try: - a, b = map(int, input().split()) - print(a // b) - except BaseException as e: - print("Error Code:", e) - - -if __name__ == "__main__": - main() diff --git a/easy/35_coolections_named_tuple.py b/easy/35_coolections_named_tuple.py deleted file mode 100644 index 78f1c55..0000000 --- a/easy/35_coolections_named_tuple.py +++ /dev/null @@ -1,11 +0,0 @@ -from collections import namedtuple - - -def run(): - n, score = int(input()), namedtuple("Score", input().split()) - scores = [score(*input().split()).MARKS for i in range(n)] - print("%.2f" % (sum(map(int, scores)) / n)) - - -if __name__ == "__main__": - run() diff --git a/easy/36_ord_dict.py b/easy/36_ord_dict.py deleted file mode 100644 index 4342a4c..0000000 --- a/easy/36_ord_dict.py +++ /dev/null @@ -1,15 +0,0 @@ -from collections import OrderedDict - - -def run(): - d = OrderedDict() - - for _ in range(int(input())): - item, _, quantity = input().rpartition(" ") - d[item] = d.get(item, 0) + int(quantity) - for item, quantity in d.items(): - print(item, quantity) - - -if __name__ == "__main__": - run() diff --git a/easy/37_symetric_differece.py b/easy/37_symetric_differece.py deleted file mode 100644 index 2a07724..0000000 --- a/easy/37_symetric_differece.py +++ /dev/null @@ -1,7 +0,0 @@ -def run(): - a, b = [set(input().split()) for _ in range(4)][1::2] - print(*sorted(a ^ b, key=int), sep="\n") - - -if __name__ == "__main__": - run() diff --git a/easy/38_combinations.py b/easy/38_combinations.py deleted file mode 100644 index f1262d2..0000000 --- a/easy/38_combinations.py +++ /dev/null @@ -1,13 +0,0 @@ -from itertools import combinations - - -def run(): - s, n = input().split() - - for i in range(1, int(n) + 1): - for j in combinations(sorted(s), i): - print("".join(j)) - - -if __name__ == "__main__": - run() diff --git a/easy/39_incorrect_regex.py b/easy/39_incorrect_regex.py deleted file mode 100644 index c9b3d24..0000000 --- a/easy/39_incorrect_regex.py +++ /dev/null @@ -1,14 +0,0 @@ -import re - - -def is_valid_regex(regex): - try: - re.compile(regex) - except re.error: - return False - return True - - -if __name__ == "__main__": - for _ in range(int(input())): - print(is_valid_regex(input())) diff --git a/easy/40_powers.py b/easy/40_powers.py deleted file mode 100644 index c393392..0000000 --- a/easy/40_powers.py +++ /dev/null @@ -1,7 +0,0 @@ -def main(): - a, b, m = [int(input()) for _ in "123"] - print(pow(a, b), pow(a, b, m), sep="\n") - - -if __name__ == "__main__": - main() diff --git a/easy/41_mod_vidmod.py b/easy/41_mod_vidmod.py deleted file mode 100644 index ad00727..0000000 --- a/easy/41_mod_vidmod.py +++ /dev/null @@ -1,6 +0,0 @@ -def main(a: int, b: int) -> str: - return "{0}\n{1}\n({0}, {1})".format(*divmod(a, b)) - - -if __name__ == "__main__": - print(main(int(input()), int(input()))) diff --git a/easy/42_inter_op.py b/easy/42_inter_op.py deleted file mode 100644 index 20763d7..0000000 --- a/easy/42_inter_op.py +++ /dev/null @@ -1,9 +0,0 @@ -def main() -> int: - _, a = input(), set(input().split()) - _, b = input(), set(input().split()) - - return len(a.intersection(b)) - - -if __name__ == "__main__": - print(main()) diff --git a/easy/43_set_union_op.py b/easy/43_set_union_op.py deleted file mode 100644 index b1bd684..0000000 --- a/easy/43_set_union_op.py +++ /dev/null @@ -1,11 +0,0 @@ -from functools import reduce as rd - - -def main() -> int: - return len( - rd(lambda a, b: a | b, [set(input().strip().split()) for j in range(4)][1::2]) - ) - - -if __name__ == "__main__": - print(main()) diff --git a/easy/44_set_add.py b/easy/44_set_add.py deleted file mode 100644 index bba2bf8..0000000 --- a/easy/44_set_add.py +++ /dev/null @@ -1,6 +0,0 @@ -def main(num: int) -> int: - return len(set(input() for i in range(num))) - - -if __name__ == "__main__": - print(main(int(input()))) diff --git a/easy/45_iter_com_repl.py b/easy/45_iter_com_repl.py deleted file mode 100644 index f589a25..0000000 --- a/easy/45_iter_com_repl.py +++ /dev/null @@ -1,11 +0,0 @@ -from itertools import combinations_with_replacement as cwr - - -def main(s, k) -> None: - for c in cwr(sorted(s), int(k)): - print("".join(c)) - - -if __name__ == "__main__": - s, k = input().split() - main(s, k) diff --git a/easy/46_deque_col.py b/easy/46_deque_col.py deleted file mode 100644 index 2c74f60..0000000 --- a/easy/46_deque_col.py +++ /dev/null @@ -1,12 +0,0 @@ -from collections import deque - - -def main(d: deque) -> list: - for _ in range(int(input())): - inp = input().split() - getattr(d, inp[0])(*[inp[1]] if len(inp) > 1 else []) - return [item for item in d] - - -if __name__ == "__main__": - print(*main(deque())) diff --git a/easy/47_set_dis_rem_pop.py b/easy/47_set_dis_rem_pop.py deleted file mode 100644 index 5f60214..0000000 --- a/easy/47_set_dis_rem_pop.py +++ /dev/null @@ -1,15 +0,0 @@ -def main(n: int) -> int: - - s = set(map(int, input().split())) - - for _ in range(int(input())): - - c, *args = map(str, input().split()) - - getattr(s, c)(*(int(x) for x in args)) - - return sum(s) - - -if __name__ == "__main__": - print(main(int(input()))) diff --git a/easy/48_set_mutations.py b/easy/48_set_mutations.py deleted file mode 100644 index 4620057..0000000 --- a/easy/48_set_mutations.py +++ /dev/null @@ -1,12 +0,0 @@ -def main(atrr, times: int) -> int: - - for _ in range(times): - (command, new__set) = (input().split()[0], set(map(int, input().split()))) - getattr(atrr, command)(new__set) - - return sum(atrr) - - -if __name__ == "__main__": - (_, a) = (int(input()), set(map(int, input().split()))) - print(main(a, int(input()))) diff --git a/easy/49_set_diff_opp.py b/easy/49_set_diff_opp.py deleted file mode 100644 index 8f2d542..0000000 --- a/easy/49_set_diff_opp.py +++ /dev/null @@ -1,13 +0,0 @@ -def main() -> int: - - unused_one = input() - set_one = set(map(int, input().split())) - - unused_two = input() - set_two = set(map(int, input().split())) - - return len(set_one - set_two) - - -if __name__ == "__main__": - print(main()) diff --git a/easy/50_int_in_all_sizes.py b/easy/50_int_in_all_sizes.py deleted file mode 100644 index 995198a..0000000 --- a/easy/50_int_in_all_sizes.py +++ /dev/null @@ -1,7 +0,0 @@ -def main(a, b, c, d): - return pow(a, b) + pow(c, d) - - -if __name__ == "__main__": - a, b, c, d = (int(input()) for _ in range(4)) - print(main(a, b, c, d)) diff --git a/easy/51_set_sym_dif_op.py b/easy/51_set_sym_dif_op.py deleted file mode 100644 index 356bc3f..0000000 --- a/easy/51_set_sym_dif_op.py +++ /dev/null @@ -1,8 +0,0 @@ -def main(a: set, b: set) -> int: - return len(a.symmetric_difference(b)) - - -if __name__ == "__main__": - _, a = input(), set(input().split()) - _, b = input(), set(input().split()) - print(main(a, b)) diff --git a/easy/52_captain_room.py b/easy/52_captain_room.py deleted file mode 100644 index 03763a3..0000000 --- a/easy/52_captain_room.py +++ /dev/null @@ -1,11 +0,0 @@ -def main(_, rooms, single, multiple): - - for room in rooms: - single.add(room) if room not in single else multiple.add(room) - - return single.difference(multiple).pop() - - -if __name__ == "__main__": - k, rooms, single, multiple = input(), input().split(), set(), set() - print(main(k, rooms, single, multiple)) diff --git a/easy/53_zip.py b/easy/53_zip.py deleted file mode 100644 index edb564f..0000000 --- a/easy/53_zip.py +++ /dev/null @@ -1,8 +0,0 @@ -def main(n, x): - for i in zip(*[map(float, input().split()) for _ in range(x)]): - print(sum(i) / len(i)) - - -if __name__ == "__main__": - n, x = map(int, input().split()) - main(n, x) diff --git a/easy/54_input.py b/easy/54_input.py deleted file mode 100644 index a8cf614..0000000 --- a/easy/54_input.py +++ /dev/null @@ -1,7 +0,0 @@ -def main(x, k): - return k == eval(input()) - - -if __name__ == "__main__": - x, k = map(int, input().split()) - print(main(x, k)) diff --git a/easy/55_eval.py b/easy/55_eval.py deleted file mode 100644 index 915507d..0000000 --- a/easy/55_eval.py +++ /dev/null @@ -1,2 +0,0 @@ -if __name__ == "__main__": - eval(input()) diff --git a/easy/56_any_all.py b/easy/56_any_all.py deleted file mode 100644 index 4cee852..0000000 --- a/easy/56_any_all.py +++ /dev/null @@ -1,7 +0,0 @@ -def main(_, n): - return all([int(i) > 0 for i in n]) and any([j == j[::-1] for j in n]) - - -if __name__ == "__main__": - _, n = int(input()), input().split() - print(main(_, n)) diff --git a/exams/01_fiz_buzz.py b/exams/01_fiz_buzz.py deleted file mode 100644 index 08e2764..0000000 --- a/exams/01_fiz_buzz.py +++ /dev/null @@ -1,20 +0,0 @@ -""" -The Classic FizzBuzz :D -""" - - -def fizz_buzz(num: int): - if num % 3 == 0 and num % 5 == 0: - return "FizzBuzz" - elif num % 3 == 0 and not num % 5 == 0: - return "Fizz" - elif num % 5 == 0 and not num % 3 == 0: - return "Buzz" - else: - return num - - -if __name__ == "__main__": - n = 5 - for num in range(1, n + 1): - print(fizz_buzz(num)) diff --git a/exams/02_reverse_words_and_swapcases.py b/exams/02_reverse_words_and_swapcases.py deleted file mode 100644 index 071c082..0000000 --- a/exams/02_reverse_words_and_swapcases.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -Implement a function that takes a string consisting of words separated by -single spaces and returns a string containing all those words but in the -reverse order and such that all cases of letters in the original -string are swapped, i.e. lowercase letters become uppercase and -uppercase letters become lowercase. -""" - - -def reverse_words_order_and_swap_cases(sentence: str) -> str: - return " ".join([word.swapcase() for word in reversed(sentence.split())]) - - -if __name__ == "__main__": - print(reverse_words_order_and_swap_cases("fAST. rUNS dOG")) diff --git a/exams/03_string_representation_of_objects.py b/exams/03_string_representation_of_objects.py deleted file mode 100644 index a18f7e5..0000000 --- a/exams/03_string_representation_of_objects.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -Implement two vehicle classes: - - Car and Boat -""" - - -class Car: - def __init__(self, maximum_speed, notation_units): - self.maximum_speed = maximum_speed - self.notation_units = notation_units - - def __str__(self): - return ( - f"Car with the maximum speed of {self.maximum_speed} {self.notation_units}" - ) - - -class Boat: - def __init__(self, maximum_speed): - self.maximum_speed = maximum_speed - - def __str__(self): - return f"Boat with the maximum speed of {self.maximum_speed} knots" - - -if __name__ == "__main__": - my_bot = Boat(82) - print(my_bot) - - my_car = Car(122, "mhp") - print(my_car) diff --git a/hard/01_matrix.py b/hard/01_matrix.py deleted file mode 100644 index c80a364..0000000 --- a/hard/01_matrix.py +++ /dev/null @@ -1,11 +0,0 @@ -from re import sub - - -n, m = map(int, input().split()) - -a, b = [input() for _ in range(n)], "" - -for z in zip(*a): - b += "".join(z) - -print(sub(r"(?<=\w)([^\w]+)(?=\w)", " ", b)) diff --git a/hard/02_maximize.py b/hard/02_maximize.py deleted file mode 100644 index 48ad119..0000000 --- a/hard/02_maximize.py +++ /dev/null @@ -1,13 +0,0 @@ -from itertools import product - - -def run(): - K, M = map(int, input().split()) - - N = (list(map(int, input().split()))[1:] for _ in range(K)) - - print(max(map(lambda x: sum(i**2 for i in x) % M, product(*N)))) - - -if __name__ == "__main__": - run() diff --git a/hard/03_postal_codes.py b/hard/03_postal_codes.py deleted file mode 100644 index b7a6de6..0000000 --- a/hard/03_postal_codes.py +++ /dev/null @@ -1,13 +0,0 @@ -from re import match, findall - -regex_integer_in_range = r"_________" -regex_alternating_repetitive_digit_pair = r"_________" - -if __name__ == "__main__": - string = input() - print( - bool( - match(r"^[1-9][\d]{5}$", string) - and len(findall(r"(\d)(?=\d\1)", string)) < 2 - ) - ) diff --git a/license.md b/license.md deleted file mode 100644 index d0c9eed..0000000 --- a/license.md +++ /dev/null @@ -1,21 +0,0 @@ -# MIT License - -Copyright (c) 2022 Eliaz Bobadilla -(https://ultirequiem.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/medium/01_leap_year.py b/medium/01_leap_year.py deleted file mode 100644 index 97e58ff..0000000 --- a/medium/01_leap_year.py +++ /dev/null @@ -1,28 +0,0 @@ -""" -An extra day is added to the calendar almost every four years as February 29, -and the day is called a leap day. -It corrects the calendar for the fact that our planet takes approximately 365.25 -days to orbit the sun. A leap year contains a leap day. - -In the Gregorian calendar, three conditions are used to identify leap years: - -The year can be evenly divided by 4, is a leap year, unless: -The year can be evenly divided by 100, it is NOT a leap year, unless: -The year is also evenly divisible by 400. Then it is a leap year. - -This means that in the Gregorian calendar, the years 2000 and 2400 are leap years, -while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years. - -Task - -Given a year, determine whether it is a leap year. If it is a leap year, -return the Boolean True, otherwise return False. -""" - - -def is_leap(year: int) -> bool: - return year % 4 == 0 and (year % 400 == 0 or year % 100 != 0) - - -if __name__ == "__main__": - print(is_leap(2024)) diff --git a/medium/02_find_angle_MBC.py b/medium/02_find_angle_MBC.py deleted file mode 100644 index e0f8c66..0000000 --- a/medium/02_find_angle_MBC.py +++ /dev/null @@ -1,10 +0,0 @@ -from math import hypot, degrees, acos - - -def calc(ab: int, bc: int): - return round(degrees(acos(bc / hypot(ab, bc)))), chr(176) - - -if __name__ == "__main__": - res, degree = calc(int(input()), int(input())) - print(res, degree, sep="") diff --git a/medium/03_write_func.py b/medium/03_write_func.py deleted file mode 100644 index bda95eb..0000000 --- a/medium/03_write_func.py +++ /dev/null @@ -1,6 +0,0 @@ -def is_leap(year: int) -> bool: - return year % 4 == 0 and (year % 400 == 0 or year % 100 != 0) - - -if __name__ == "__main__": - print(is_leap(int(input()))) diff --git a/medium/04_time_delta.py b/medium/04_time_delta.py deleted file mode 100644 index 0a1a418..0000000 --- a/medium/04_time_delta.py +++ /dev/null @@ -1,20 +0,0 @@ -from datetime import datetime as dt - - -def main(date_format: str) -> None: - for _ in range(int(input())): - - print( - int( - abs( - ( - dt.strptime(input(), date_format) - - dt.strptime(input(), date_format) - ).total_seconds() - ) - ) - ) - - -if __name__ == "__main__": - main("%a %d %b %Y %H:%M:%S %z") diff --git a/medium/05_no_idea.py b/medium/05_no_idea.py deleted file mode 100644 index cd78bad..0000000 --- a/medium/05_no_idea.py +++ /dev/null @@ -1,13 +0,0 @@ -def main() -> int: - unused_one, unused_two = input().split() - - input_one = input().split() - - input_three = set(input().split()) - input_four = set(input().split()) - - return sum([(item in input_three) - (item in input_four) for item in input_one]) - - -if __name__ == "__main__": - print(main()) diff --git a/medium/06_word_order.py b/medium/06_word_order.py deleted file mode 100644 index 8de122b..0000000 --- a/medium/06_word_order.py +++ /dev/null @@ -1,17 +0,0 @@ -from collections import Counter, OrderedDict - - -# I nned a class that inherits Counter and OrderedDict -class OrderedCounter(Counter, OrderedDict): - pass - - -def main(): - ordered_counter_instance = OrderedCounter(input() for _ in range(int(input()))) - - print(len(ordered_counter_instance)) - print(*ordered_counter_instance.values()) - - -if __name__ == "__main__": - main() diff --git a/medium/07_compress_string.py b/medium/07_compress_string.py deleted file mode 100644 index 91f12c5..0000000 --- a/medium/07_compress_string.py +++ /dev/null @@ -1,9 +0,0 @@ -from itertools import groupby - - -def main(): - return [(len(list(c)), int(k)) for k, c in groupby(input())] - - -if __name__ == "__main__": - print(*main()) diff --git a/medium/08_ierables_and_iterators.py b/medium/08_ierables_and_iterators.py deleted file mode 100644 index 559f124..0000000 --- a/medium/08_ierables_and_iterators.py +++ /dev/null @@ -1,16 +0,0 @@ -from itertools import combinations - - -def main(): - unused_one = int(input()) - lst = input().split() - num = int(input()) - - C = list(combinations(lst, num)) - F = filter(lambda c: "a" in c, C) - - return "{0:.3}".format(len(list(F)) / len(C)) - - -if __name__ == "__main__": - print(main()) diff --git a/medium/09_trinagle_quest_2.py b/medium/09_trinagle_quest_2.py deleted file mode 100644 index 64c46e2..0000000 --- a/medium/09_trinagle_quest_2.py +++ /dev/null @@ -1,3 +0,0 @@ -def main() -> None: - for num in range(1, int(input()) + 1): - print((10**num // 9) ** 2) diff --git a/medium/10_company_logo.py b/medium/10_company_logo.py deleted file mode 100644 index a083bb0..0000000 --- a/medium/10_company_logo.py +++ /dev/null @@ -1,9 +0,0 @@ -from collections import Counter - - -def main() -> None: - [print(*c) for c in Counter(sorted(input())).most_common(3)] - - -if __name__ == "__main__": - main() diff --git a/medium/11_default_args.py b/medium/11_default_args.py deleted file mode 100644 index 8e519c1..0000000 --- a/medium/11_default_args.py +++ /dev/null @@ -1,24 +0,0 @@ -class EvenStream(object): - def __init__(self): - self.current = 0 - - def get_next(self): - to_return = self.current - self.current += 2 - return to_return - - -class OddStream(object): - def __init__(self): - self.current = 1 - - def get_next(self): - to_return = self.current - self.current += 2 - return to_return - - -def print_from_stream(n, stream=EvenStream()): - stream.__init__() - for _ in range(n): - print(stream.get_next()) diff --git a/medium/12_word_score.py b/medium/12_word_score.py deleted file mode 100644 index bda2acf..0000000 --- a/medium/12_word_score.py +++ /dev/null @@ -1,2 +0,0 @@ -def score_words(words: str) -> int: - return sum(sum(char in "aeiouy" for char in word) % 2 or 2 for word in words) diff --git a/medium/13_validate_credit_card_nums.py b/medium/13_validate_credit_card_nums.py deleted file mode 100644 index 794fdfe..0000000 --- a/medium/13_validate_credit_card_nums.py +++ /dev/null @@ -1,10 +0,0 @@ -from re import compile - - -def run(DATA): - for _ in range(int(input().strip())): - print("Valid" if DATA.search(input().strip()) else "Invalid") - - -if __name__ == "__main__": - run(compile(r"^" r"(?!.*(\d)(-?\1){3})" r"[456]" r"\d{3}" r"(?:-?\d{4}){3}" r"$")) diff --git a/medium/14_reduce.py b/medium/14_reduce.py deleted file mode 100644 index 74ef107..0000000 --- a/medium/14_reduce.py +++ /dev/null @@ -1,7 +0,0 @@ -from functools import reduce -from operator import mul - - -def product(fracs): - t = reduce(mul, fracs) - return t.numerator, t.denominator diff --git a/medium/15_validate_email_Adress.py b/medium/15_validate_email_Adress.py deleted file mode 100644 index 134dc0a..0000000 --- a/medium/15_validate_email_Adress.py +++ /dev/null @@ -1,5 +0,0 @@ -from re import compile - - -def fun(s): - return compile("^[\\w-]+@[0-9a-zA-Z]+\\.[a-z]{1,3}$").match(s) diff --git a/medium/16_athelete_sort.py b/medium/16_athelete_sort.py deleted file mode 100644 index 722f5ac..0000000 --- a/medium/16_athelete_sort.py +++ /dev/null @@ -1,11 +0,0 @@ -def run() -> None: - N, _ = map(int, input().split()) - rows = [input() for _ in range(N)] - K = int(input()) - - for row in sorted(rows, key=lambda row: int(row.split()[K])): - print(row) - - -if __name__ == "__main__": - run() diff --git a/medium/17_triangle_quest.py b/medium/17_triangle_quest.py deleted file mode 100644 index 5974210..0000000 --- a/medium/17_triangle_quest.py +++ /dev/null @@ -1,2 +0,0 @@ -for i in range(1, int(input())): - print((10 ** (i) // 9) * i)