source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_instruct_75k
26,957
Write a Python function to convert a given distance in feet to yards, rounded to three decimal places. The function should take an integer `distance` as input, where `0 <= distance <= 10^6`, and return a string representing the equivalent distance in yards, rounded to three decimal places. The code should start with: ...
Here is the Python code to solve the given problem in the markdown block: ```python def feet_to_yards(distance: int) -> str: """ Converts a given distance in feet to yards, rounded to three decimal places. Args: distance (int): The distance in feet, where 0 <= distance <= 10^6. Returns: ...
magic_instruct_75k
26,971
Write a Python function to update the version number of a software project based on the given revision number and a boolean indicating whether the version includes uncommitted changes (dirty status). The function should append the revision number to the current version number and add a suffix "-dirty" if the version is...
Here is the Python code to solve the given problem in the markdown block: ```python def update_version(current_version: str, revision: str, is_dirty: bool) -> str: """ Update the version number of a software project based on the given revision number and dirty status. Args: current_version (str): T...
magic_instruct_75k
26,992
Write a Python function to automate the deployment of a Minecraft server. The function should take a version number as an argument and set up the necessary classpath and system properties for the server to run. The function should also return a string containing the additional properties that will be used. The code sh...
Here is the Python code to solve the given problem in the markdown block: ```python def deploy_minecraft(version: str) -> str: """ Automates the deployment of a Minecraft server by setting up the necessary classpath and system properties. Args: version (str): The version number of the Minecraft ser...
magic_instruct_75k
27,013
Write a Python function to transform a list of tuples, where each tuple contains a SQL query (string) and its execution time in microseconds (integer), into a new list of tuples. Each new tuple should contain the templatized SQL query (string) and the execution time in seconds (float). The templatize_sql function is pr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def mapper_function(input_data: List[Tuple[str, int]]) -> List[Tuple[str, float]]: """ Transforms a list of tuples containing SQL queries and their execution times. Each input tuple contains ...
magic_instruct_75k
27,029
Write a Python function to determine if a given singly-linked list is a palindrome. A singly-linked list is a sequence of nodes where each node contains a value and a reference to the next node. A palindrome is a sequence that reads the same backward as forward. The function should start with: ```python # Definition f...
Here is the Python code to solve the given problem in the markdown block: ```python # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def is_palindrome(head: ListNode) -> bool: """ Determine if a given singly-linked li...
magic_instruct_75k
27,050
Write a Python function to process SQLite data and return feature and target batches. The function should take a list of tuples `sqlite_data`, where each tuple represents a row of data retrieved from an SQLite database. Each tuple contains the features and the target label for a specific data point. The function should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def process_sqlite_data(sqlite_data: List[Tuple]) -> Tuple[List[Tuple], List[any]]: """ Processes SQLite data and returns feature and target batches. Args: sqlite_data (List[Tuple]): ...
magic_instruct_75k
27,065
Write a Python function to generate a setup configuration for a Python package based on the given metadata. The setup configuration should include the following fields: - `install_requires`: A list of required dependencies for the package. - `tests_require`: A list of required dependencies for running tests. - `test_su...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def generate_setup_config(install_requires: List[str], tests_require: List[str], test_suite: str, platforms: List[str], classifiers: List[str]) -> Dict: """ Generates a setup configuration dictiona...
magic_instruct_75k
27,082
Write a Python function to create batches from a given dataset. The function should take a dataset (represented as a list) and a batch size as input and return a list of batches, where each batch is a subset of the original dataset. The batches should be of size `batch_size` as evenly as possible. If the dataset size i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def create_batches(dataset: List[int], batch_size: int) -> List[List[int]]: """ Create batches from the given dataset. Args: dataset (List[int]): A list representing the dataset. bat...
magic_instruct_75k
27,139
Write a Python function `generate_nmcli_commands` that takes a list of network configurations as input and generates the corresponding `nmcli` commands for configuring Open vSwitch (OVS) interfaces and ports. Each network configuration is a dictionary containing details such as connection interface name, connection typ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def generate_nmcli_commands(network_configurations: List[Dict]) -> List[str]: """ Generates `nmcli` commands for configuring Open vSwitch (OVS) interfaces and ports based on the given network confi...
magic_instruct_75k
27,202
Write a Python function to deactivate a specified software package by removing it from a list of active packages. The function should take the list of active packages and the name of the package to deactivate as input, and return the updated list of active packages after deactivation. The function should handle the cas...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def deactivate_package(active_packages: List[str], package_name: str) -> List[str]: """ Deactivates a specified software package by removing it from the list of active packages. Args: active...
magic_instruct_75k
27,207
Write a Python function to parse and process URL routes based on a given configuration. The configuration consists of route names and their corresponding URL patterns. Each URL pattern may contain placeholders for dynamic values, such as IDs. Your function should be able to match a given URL to the appropriate route an...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Tuple, Optional import re def process_route(url: str, routes: Dict[str, str]) -> Optional[Tuple[str, Dict[str, str]]]: """ Parses and processes a URL based on a given configuration of routes. Args:...
magic_instruct_75k
27,209
Write a Python function to find the last occurrence of a substring within a given string. The function should return the index of the last occurrence of the substring. If the substring is not found, the function should return -1. The function should be case-sensitive. The code should start with: ```python def find_las...
Here is the Python code to solve the given problem in the markdown block: ```python def find_last(a: str, b: str) -> int: """ Find the last occurrence of a substring within a given string. Args: a (str): The input string in which to search for the substring. b (str): The substring to find w...
magic_instruct_75k
27,212
Write a Python function `generateAndCheck` that takes in the following parameters: - `script`: a string representing the script name (e.g., "example.sh", "test.xta") - `prefix`: a string representing the prefix for file names - `args`: a list of additional arguments The function should perform the following tasks: 1. ...
Here is the Python code to solve the given problem in the markdown block: ```python def generateAndCheck(script: str, prefix: str, *args) -> dict: """ Generates necessary file paths and checks the type of script based on the given parameters. Args: script (str): The name of the script file. ...
magic_instruct_75k
27,220
Write a Python function to generate a SQL `CREATE TABLE` query based on the given column specifications. The function should take a list of dictionaries, where each dictionary represents a column and its properties. The properties include the column name, data type, primary key status, uniqueness, and nullability. The ...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_create_table_query(columns: list) -> str: """ Generates a SQL CREATE TABLE query based on the given column specifications. Args: columns (list): A list of dictionaries, where each dictionary represents ...
magic_instruct_75k
27,237
Write a Python function to calculate the maximum profit that can be obtained by buying and selling a stock on different days. The function should take a list of integers representing the daily stock prices and return the maximum profit. You can only make one transaction (i.e., buy one and sell one share of the stock), ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_profit(prices: List[int]) -> int: """ Calculate the maximum profit that can be obtained by buying and selling a stock on different days. Args: prices (List[int]): A list of integers ...
magic_instruct_75k
27,241
Write a Python function to check if at least one element in the last list of a given list of lists `dp` is `True`. The function should return `True` if there is at least one `True` value in the last list, and `False` otherwise. The function should handle the case where the input list `dp` contains at least one list, an...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def check_last_list(dp: List[List[bool]]) -> bool: """ Check if at least one element in the last list of a given list of lists is `True`. Args: dp (List[List[bool]]): A list of lists contain...
magic_instruct_75k
27,250
Write a Python function to determine the final value of the variable `m` after executing a given code snippet that manipulates the variables `n`, `m`, and `a0`. The code snippet increments `n` by 1, checks if `n` is greater than `m`, updates `m` if the condition is true, and then increments `a0` by 1. The function shou...
Here is the Python code to solve the given problem in the markdown block: ```python def final_m_value(n: int, m: int, a0: int) -> int: """ Determine the final value of the variable `m` after executing a given code snippet. The code snippet performs the following operations: 1. Increment `n` by 1. 2...
magic_instruct_75k
27,278
Write a Python function to filter a list of input devices based on a specified type. Each input device is represented as a named tuple with the attributes `type`, `id`, and `name`. The function should take the list of input devices and a target type as input and return a list of input devices that match the target type...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List from collections import namedtuple # Define the named tuple for an input device XInputDevice = namedtuple('XInputDevice', 'type id name') def filter_input_devices(input_devices: List[XInputDevice], target_type:...
magic_instruct_75k
27,305
Write a Python function to generate an access control policy for a serverless application based on the user's details and the requested method. The function should take four parameters: `principalId` (user's unique identifier), `userDetails` (user's details such as role or permissions), `effect` (whether to allow or de...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_policy(principal_id: str, user_details: dict, effect: str, method_arn: str) -> dict: """ Generates an access control policy for a serverless application based on the user's details and the requested method. Arg...
magic_instruct_75k
27,310
Write a Python function to calculate the national vaccination progress percentage for the entire United States based on the vaccination progress percentages of individual states. The function should take a dictionary where the keys are state abbreviations and the values are the vaccination progress percentages for thos...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def calculate_national_vaccination_percentage(state_percentages: Dict[str, float]) -> float: """ Calculate the national vaccination progress percentage based on the vaccination progress percentages of in...
magic_instruct_75k
27,328
Write a Python function to multiply two non-negative integers represented as strings without using any built-in BigInteger library or directly converting the inputs to integers. The function should return the product as a string. The code should start with: ```python def multiply(num1: str, num2: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def multiply(num1: str, num2: str) -> str: """ Multiplies two non-negative integers represented as strings and returns the product as a string. Args: num1 (str): The first non-negative integer represented as a strin...
magic_instruct_75k
27,332
Write a Python function to convert a given time duration from one unit to another and calculate the total number of seconds represented by the time duration. The function should support the following time units: seconds, minutes, hours, days, weeks, months, and years. The conversion should be based on the following ass...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def convert_time_to_seconds(unit: str, value: int) -> int: """ Converts a given time duration from one unit to seconds. Args: unit (str): The unit of the time duration. Supported units are ...
magic_instruct_75k
27,343
Write a Python function to validate whether all the expected fields are present in the input data. The function should take a list of input fields as a parameter and return a boolean value indicating whether all the expected fields are present in the input data. The function should return `True` if all the expected fie...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def validate_fields(input_fields: List[str]) -> bool: """ Validates whether all the expected fields are present in the input data. Args: input_fields (List[str]): A list of strings represent...
magic_instruct_75k
27,346
Write a Python function to validate pre-conditions before executing a function. The function should raise a `ValueError` with a meaningful error message if any pre-condition is not met. The function should accept a list of conditions and a list of corresponding error messages. The code should start with: ```python fro...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def validate_pre_conditions(conditions: List[bool], error_messages: List[str]) -> None: """ Validates a list of pre-conditions and raises a ValueError with the corresponding error message if any conditio...
magic_instruct_75k
27,351
Write a Python function to determine the environment mode based on a given input string. The environment mode can be one of the following: "development", "testing", "staging", or "production". The input string may contain variations of these mode names, and your function should be able to identify the mode based on the...
Here is the Python code to solve the given problem in the markdown block: ```python def determine_environment_mode(input_string: str) -> str: """ Determines the environment mode based on the given input string. The function identifies the environment mode from a set of predefined variations of mode nam...
magic_instruct_75k
27,356
Create a Python function to efficiently log messages with different log levels (DEBUG, INFO, WARN, ERROR) and handle a large number of log entries without significant performance degradation. The function should support formatting log messages with variable arguments. The code should start with: ```python from typing ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Any # Define log levels DEBUG = "DEBUG" INFO = "INFO" WARN = "WARN" ERROR = "ERROR" def log_message(log_level: str, message: str, *args: Any) -> None: """ Logs a message with the specified log l...
magic_instruct_75k
27,363
Write a Python decorator function named `add_cors_headers` that adds CORS (Cross-Origin Resource Sharing) headers to a given HTTP response. The decorator should take two parameters: - `allow_credentials` (boolean): Indicates whether the response should allow credentials to be included in cross-origin requests. - `wrapp...
Here is the Python code to solve the given problem in the markdown block: ```python def add_cors_headers(allow_credentials): """ A decorator function that adds CORS headers to an HTTP response. Args: allow_credentials (bool): Indicates whether the response should allow credentials to be included in...
magic_instruct_75k
27,376
Write a Python function to calculate the impact factors of characters in a given string based on a provided dictionary. The function should return a list of impact factors corresponding to each character in the string. If a character is not found in the dictionary, the function should raise an exception with the messag...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_impact_factors(s: str, impact_factor: dict) -> List[int]: """ Calculate the impact factors of characters in the given string based on the provided dictionary. Args: s (str): Th...
magic_instruct_75k
27,385
Write a Python function to process a list of external IDs and return a dictionary containing the IDs as keys and their corresponding lengths as values. The function should handle cases where the external IDs are not unique and should ignore any IDs that are empty or `None`. The code should start with: ```python from t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def process_external_ids(external_ids: List[str]) -> Dict[str, int]: """ Processes a list of external IDs and returns a dictionary containing the IDs as keys and their corresponding lengths as valu...
magic_instruct_75k
27,395
Write a Python function to perform random search for hyperparameter optimization in a machine learning model. The function should take the number of experiments and a dictionary of hyperparameters with their corresponding sampling functions as input. It should return a list of dictionaries, where each dictionary repres...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def random_search_hyperparams(n_experiments: int, hyperparams_setup: dict) -> list: """ Perform random search to sample hyperparameter values for a machine learning model. Args: n_experiments (in...
magic_instruct_75k
27,397
Write a Python function to retrieve all queries that match a given list of query names and contain a specified tag. The function should take a list of query names and a tag as input and return a list of queries that meet both criteria. Each query is represented by an instance of a `Query` class, which has attributes `n...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, NamedTuple class Query(NamedTuple): name: str tags: List[str] def get_queries_by_names_and_tag(queries: List[Query], query_names: List[str], tag: str) -> List[Query]: """ Retrieve all queries t...
magic_instruct_75k
27,406
Write a Python function to select a random subset of images from a given dataset. The function should take in the following parameters: - `labels`: An integer representing the number of labels to randomly select. - `max_number`: An integer representing the maximum number of images to use. If set to -1, all images will ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple import random def select_random_images(labels: int, max_number: int, size: Tuple[int, int]) -> Dict[int, List[str]]: """ Selects a random subset of images from a given dataset. Args: ...
magic_instruct_75k
27,451
Write a Python function to enable specific features on a wireless communication module, such as the nRF24L01+. The function should take a list of feature names and enable them on the module. The available features are: 1. No-acknowledgment (no_ack) functionality 2. Dynamic payload length (dynamic_payload) 3. Enhanced S...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def enable_features(features: List[str]) -> None: """ Enables specific features on a wireless communication module, such as the nRF24L01+. Args: features (List[str]): A list of feature names...
magic_instruct_75k
27,455
Write a Python function to calculate the maximum profit that can be obtained by buying and selling a stock at most once, given a list of integers representing the daily stock prices. If it is not possible to make any profit, the function should return 0. The code should start with: ```python from typing import List d...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_profit(prices: List[int]) -> int: """ Calculate the maximum profit that can be obtained by buying and selling a stock at most once. Args: prices (List[int]): A list of integers where...
magic_instruct_75k
27,461
Write a Python function to find the top three results from a list of tuples, where each tuple contains a score and a corresponding letter. The function should return the top three scores along with their corresponding letters, sorted in descending order by score. If there are fewer than three results, the function shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def top_three_results(results: List[Tuple[int, str]]) -> List[Tuple[int, str]]: """ Returns the top three results from a list of tuples, where each tuple contains a score and a corresponding lette...
magic_instruct_75k
27,473
Write a Python function `process_arguments(input_list: List[str]) -> Dict[str, Union[bool, str]]` that processes a list of command-line arguments and returns an updated dictionary `args`. The input list contains strings where each string represents a command-line argument. Each argument may be a flag (starting with '-'...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Union def process_arguments(input_list: List[str]) -> Dict[str, Union[bool, str]]: """ Processes a list of command-line arguments and returns an updated dictionary. Args: input_list (...
magic_instruct_75k
27,474
Create a Python function to map unique identifiers (ubids) to their corresponding specifications and another function to check the existence of specific ubids within a registry of specifications. The `mapped` function should take a list of ubids and a list of specifications as input and return a dictionary mapping colo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Tuple def mapped(ubids: List[str], specs: List[Dict[str, str]]) -> Dict[str, Tuple[Dict[str, str], ...]]: """ Maps unique identifiers (ubids) to their corresponding specifications. Args: ...
magic_instruct_75k
27,485
Write a Python function to find and return a list of unique elements from a given array of integers while maintaining the order of their first appearance. If the input array is empty, the function should return an empty array. The code should start with: ```python from typing import List def findUniqueElements(arr: L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def findUniqueElements(arr: List[int]) -> List[int]: """ Returns a list of unique elements from the given array, maintaining the order of their first appearance. Args: arr (List[int]): The i...
magic_instruct_75k
27,489
Create a Python function to parse a list of option pairs and perform specific actions based on the presence and value of a "device" option. If the "device" option is found, the function should return a specific message based on the value of the "device" option. If the "device" option is not found, the function should r...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def parse_options(options: List[Tuple[str, str]]) -> str: """ Parses a list of option pairs and performs specific actions based on the presence and value of a "device" option. Args: o...
magic_instruct_75k
27,494
Write a Python function `process_mail_items(mail_items)` that processes a list of mail items according to specific rules. Each mail item is represented as a dictionary with the following keys: "recipient" (string), "weight" (float), and "postage_paid" (boolean). The function should: 1. Set the "postage_paid" key to Tru...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def process_mail_items(mail_items: List[Dict[str, any]]) -> List[Dict[str, any]]: """ Processes a list of mail items according to specific rules based on the weight of each item. Args: ...
magic_instruct_75k
27,507
Write a Python function to process JSON input data containing information about electoral districts (`dapil`) and their corresponding sub-districts (`wilayah`). The function should generate a CSV file with the following columns: - `idDapil`: The ID of the electoral district - `namaDapil`: The name of the electoral dist...
Here is the Python code to solve the given problem in the markdown block: ```python import json import csv from typing import Dict, List def process_election_data(json_data: Dict, csv_filename: str) -> None: """ Processes JSON input data containing electoral district and sub-district information, and gener...
magic_instruct_75k
27,515
Write a Python function to validate video aspect ratios based on a given string input. The aspect ratio is represented as a fraction in the form "width:height", where both width and height are positive integers. The function should return a boolean value indicating whether the aspect ratio is supported or not. An aspec...
Here is the Python code to solve the given problem in the markdown block: ```python import re def validateAspectRatio(aspectRatio: str) -> bool: """ Validates whether the given aspect ratio is supported based on the specified criteria. Args: aspectRatio (str): A string representing the aspect rati...
magic_instruct_75k
27,556
Write a Python function to generate Django migration code for a new field in a model. The function should take the model name, field name, field type, related name, and on_delete behavior as input and return the migration code as a string. The field type is a foreign key to another model, and the migration code should ...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_migration_code(model_name: str, field_name: str, field_type: str, related_name: str, on_delete: str) -> str: """ Generates Django migration code for a new field in a model. Args: model_name (str): The n...
magic_instruct_75k
27,588
Write a Python function to find the highest score from a list of scores. If the list is empty, the function should return 0. The function should be efficient and handle edge cases appropriately. The code should start with: ```python from typing import List def highest_score(scores: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def highest_score(scores: List[int]) -> int: """ Find the highest score from a list of scores. If the list is empty, return 0. Args: scores (List[int]): A list of integers representing the s...
magic_instruct_75k
27,593
Write a Python function to validate and filter a dictionary containing configuration settings for a plotting library. The function should return a new dictionary containing only the valid configuration settings. A valid configuration setting is defined as a key-value pair where the key starts with "figure.subplot." and...
Here is the Python code to solve the given problem in the markdown block: ```python def validate_plot_settings(input_settings: dict) -> dict: """ Validates and filters a dictionary of configuration settings for a plotting library. Args: input_settings (dict): A dictionary containing configuration s...
magic_instruct_75k
27,596
Write a Python function to filter out system-reserved MinIO buckets from a given list of bucket names. The system-reserved buckets are predefined in a list. The function should return a new list containing only the non-system-reserved buckets. The code should start with: ```python from typing import List def filter_s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_system_reserved_buckets(bucket_list: List[str]) -> List[str]: """ Filters out system-reserved MinIO buckets from a given list of bucket names. Args: bucket_list (List[str]): A lis...
magic_instruct_75k
27,609
Write a Python function to retrieve the atomic numbers of given chemical symbols from a dictionary. The function should ignore any symbols that are not present in the dictionary. The function signature should be: ```python def get_atomic_numbers(elements: dict, symbols: list) -> list: ```
Here is the Python code to solve the given problem in the markdown block: ```python def get_atomic_numbers(elements: dict, symbols: list) -> list: """ Retrieves the atomic numbers of the given chemical symbols from the provided dictionary. Ignores any symbols that are not present in the dictionary. Arg...
magic_instruct_75k
27,622
Write a Python function to perform specific operations on three input arrays using NumPy. The function should take in three input arrays: `auto_spectra`, `Hfunc`, and `Sigma`, and an integer `nChannels`. The function should perform the following operations: 1. Create a 3D array `Smat` of shape `(auto_spectra.shape[0],...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def array_operations(auto_spectra, Hfunc, Sigma, nChannels): """ Perform specific operations on three input arrays using NumPy. Args: auto_spectra (numpy.ndarray): A 2D array. Hfunc (nump...
magic_instruct_75k
27,646
Write a Python function to validate "slug" strings used in a web application. A "slug" is a URL-friendly string typically used to uniquely identify resources. The validation function should ensure that the input string consists only of lowercase letters (a-z), numbers (0-9), underscores (_), or hyphens (-). Additionall...
Here is the Python code to solve the given problem in the markdown block: ```python import re def validate_slug(slug: str) -> str: """ Validates if the input string is a valid "slug". A valid "slug" can only contain lowercase letters (a-z), numbers (0-9), underscores (_), or hyphens (-). The input str...
magic_instruct_75k
27,668
Write a Python function to validate a configuration file against a given JSON schema. The schema is provided as a dictionary, and the function should check if a given configuration file adheres to the schema. The schema may contain various data types and constraints, including string, integer, boolean, and default valu...
Here is the Python code to solve the given problem in the markdown block: ```python def validate_config(config: dict, schema: dict) -> bool: """ Validates a configuration file against a given JSON schema. Args: config (dict): The configuration file to be validated. schema (dict): The JSON s...
magic_instruct_75k
27,674
Write a Python function to sort a list of objects based on two specific attributes: `abbreviation` (a string) and `far_order` (an integer). The sorting should be done first by the `abbreviation` attribute in ascending order, and then by the `far_order` attribute in descending order. The function should take a list of d...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def custom_sort(objects: List[Dict[str, any]]) -> List[Dict[str, any]]: """ Sorts a list of objects based on two specific attributes: `abbreviation` (a string) and `far_order` (an integer). The...
magic_instruct_75k
27,680
Write a Python function to URL-encode a given string. The function should replace each character in the string with its corresponding URL-encoded value. The URL-encoded value for a character is represented as a '%' followed by the ASCII code of the character in hexadecimal. For example, the character 'A' would be encod...
Here is the Python code to solve the given problem in the markdown block: ```python def url_encode(s: str) -> str: """ URL-encodes a given string by replacing each character with its corresponding URL-encoded value. Args: s (str): The input string to be URL-encoded. Returns: str: The U...
magic_instruct_75k
27,716
Write a Python function to validate the data types of various fields in a trial record based on a provided schema. The schema is represented as a dictionary where the keys are field names and the values are the expected data types for those fields. The data types can be 'str' for string, 'bool' for boolean, or 'list[st...
Here is the Python code to solve the given problem in the markdown block: ```python def validate_trial_data(data: dict, schema: dict) -> bool: """ Validates the data types of various fields in a trial record based on a provided schema. Args: data (dict): A dictionary representing the trial record w...
magic_instruct_75k
27,726
Write a Python function `construct_sql_query` that takes a list of protein accessions and returns a complete SQL query to retrieve peptide sequences associated with those proteins. The SQL query should use the `IN` clause to filter the peptide sequences based on the provided protein accessions. The function should sta...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def construct_sql_query(proteins: List[str]) -> str: """ Constructs a SQL query to retrieve peptide sequences associated with the given protein accessions. Args: proteins (List[str]): A list...
magic_instruct_75k
27,731
Write a Python function `get_host_info` that interacts with a mock setup for testing a connection to a database. The function should take a database connection object as an argument and return a dictionary containing the name and ID of the database host. The mock setup ensures that the function makes a single call to e...
Here is the Python code to solve the given problem in the markdown block: ```python def get_host_info(connection): """ Extracts the host name from the given connection dictionary and returns a dictionary containing the host name and a None value for the ID. Args: connection (dict): A dictionary...
magic_instruct_75k
27,738
Write a Python function to generate a backup script that automates the backup of specific files and directories to a designated location. The function should also provide an option to force the backup, as well as a confirmation prompt to ensure the user is aware of potential file overwrites. The function should return ...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_backup_script(files_and_directories: list, force: bool = False) -> str: """ Generates a backup script that automates the backup of specific files and directories to a designated location. The script also provide...
magic_instruct_75k
27,761
Write a Python function to split a given dataset into training and validation sets. The function should take in the dataset and the desired validation set size as input, and then return the training set, validation set, and their corresponding labels. The dataset is represented as a dictionary with keys 'X' and 'y', w...
Here is the Python code to solve the given problem in the markdown block: ```python import random from typing import Dict, List, Tuple def split_dataset(dataset: Dict[str, List], val_size: float) -> Tuple[List, List, List, List]: """ Splits a given dataset into training and validation sets. Args: ...
magic_instruct_75k
27,763
Write a Python function `extract_keys` that takes in a list of dictionaries `trees` and a verbosity level `verbosity`. The function should return the keys of the first dictionary in the list. If the verbosity level is 3, the function should also print the keys and their types. The function signature should be: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Any def extract_keys(trees: List[Dict[str, Any]], verbosity: int) -> List[str]: """ Extracts and returns the keys of the first dictionary in a list of dictionaries. If the verbosity level is 3...
magic_instruct_75k
27,775
Write a Python function to retrieve the description of a constant from an XML structure. The XML structure represents a class, and the constants are stored within it. Your task is to write a function that takes the `old_class` and the name of the constant as input and returns the description of the constant if it exist...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Optional from xml.etree import ElementTree as ET def find_constant_descr(old_class: ET.Element, name: str) -> Optional[str]: """ Retrieve the description of a constant from an XML structure. Args: ...
magic_instruct_75k
27,797
Write a Python function to manage a list of events. Each event has a unique identifier, a title, a date, and a description. The function should allow users to create, update, and delete events, as well as display a list of all events. The code should start with: ```python from typing import List, Optional class Event:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional class Event: def __init__(self, event_id: int, title: str, date: str, description: str): """ Initialize an Event object with a unique identifier, title, date, and description. ...
magic_instruct_75k
27,799
Write a Python function to format a given date and time according to a specific format string. The format string consists of various placeholders that represent different components of the date and time. The function should take a date string in the format "YYYY-MM-DD", a time string in the format "HH:MM:SS", and a for...
Here is the Python code to solve the given problem in the markdown block: ```python from datetime import datetime def formatDateTime(date: str, time: str, format: str) -> str: """ Formats a given date and time according to a specific format string. Args: date (str): A string representing the date ...
magic_instruct_75k
27,815
Write a Python function to sort a given list of integers in ascending order using the insertion sort algorithm. The insertion sort algorithm works by iteratively taking an element from the unsorted part of the list and inserting it into its correct position in the sorted part of the list. The code should start with: `...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def insertion_sort(alist: List[int]) -> List[int]: """ Sorts a given list of integers in ascending order using the insertion sort algorithm. Args: alist (List[int]): The list of integers to ...
magic_instruct_75k
27,862
Write a Python function to find the maximum sum of a contiguous subarray within a given list of integers. The function should handle both positive and negative numbers. The code should start with: ```python from typing import List def max_subarray_sum(nums: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_subarray_sum(nums: List[int]) -> int: """ Find the maximum sum of a contiguous subarray within the given list of integers. Args: nums (List[int]): The list of integers from which to ...
magic_instruct_75k
27,879
Write a Python function to modify a given list of integers based on specific rules. The function should take a list of integers as input and return a modified list according to the following rules: 1. If the input list contains any negative integers, they should be replaced with their absolute values. 2. If the input l...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def modify_list(input_list: List[int]) -> List[int]: """ Modify a list of integers based on the following rules: 1. Replace any negative integers with their absolute values. 2. If the input list ...
magic_instruct_75k
27,885
Write a Python function to select a combination of coins from a given list such that their sum equals a specified target sum. Each coin is represented by an object with an `amount` attribute indicating its value. If no combination of coins can achieve the target sum, the function should return an empty set. The functio...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Set def select_coins(coins: List[object], target: int) -> Set[object]: """ Select a combination of coins from the given list such that their sum equals the target. Args: coins (List[object]...
magic_instruct_75k
27,888
Write a Python function to calculate the Euclidean distance between two points in a 2D plane. The function should take four parameters: the x and y coordinates of the first point, and the x and y coordinates of the second point. The distance between two points \((x1, y1)\) and \((x2, y2)\) is given by the formula: \[ ...
Here is the Python code to solve the given problem in the markdown block: ```python import math def calculate_distance(x1: float, y1: float, x2: float, y2: float) -> float: """ Calculate the Euclidean distance between two points (x1, y1) and (x2, y2) in a 2D plane. Args: x1 (float): The x-coordina...
magic_instruct_75k
27,926
Write a Python function to process a list of tags and their counts, and return a dictionary where the keys are the tags and the values are the aggregated counts. Each tag is represented as a string, and its count is a non-negative integer. The function should handle edge cases such as an empty input list and negative c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def list_tags_with_counts(tag_counts: List[Tuple[str, int]]) -> Dict[str, int]: """ Processes a list of tags and their counts, and returns a dictionary where the keys are the tags and the va...
magic_instruct_75k
27,946
Write a Python function to calculate the total balance for a specific account by processing a list of transactions. Each transaction is represented as a tuple containing the date, description, and amount. The function should handle both deposits (positive amounts) and withdrawals (negative amounts). The code should st...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def calculate_balance(transactions: List[Tuple[str, str, float]], account: str) -> float: """ Calculate the total balance for a specific account by processing a list of transactions. Args: ...
magic_instruct_75k
27,949
Write a Python function to find the length of the longest substring that contains at most two distinct characters in a given string `s`. The function should return the length of this longest substring. The code should start with: ```python def longest_substring_with_two_distinct_chars(s: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def longest_substring_with_two_distinct_chars(s: str) -> int: """ Find the length of the longest substring that contains at most two distinct characters. Args: s (str): The input string consisting of lowercase Engli...
magic_instruct_75k
27,952
Create a Python function to simulate the backend logic for handling code submissions and another function to simulate the frontend logic for displaying a success message and a link to navigate back to the submissions page. The backend function should accept a code submission, process it, and return a success message. T...
Here is the Python code to solve the given problem in the markdown block: ```python def handle_code_submission(code: str) -> str: """ Simulate the backend logic for handling code submissions. Args: code (str): The code submitted by the user. Returns: str: A success message that include...
magic_instruct_75k
27,970
Write a Python function to process the output of an emotion recognition model and return the dominant emotion along with its corresponding color. The model outputs a list of probabilities for five emotions: 'neutral', 'happy', 'sad', 'surprise', and 'anger'. The function should identify the emotion with the highest pro...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple # Predefined list of emotions and corresponding colors EMOTIONS = ['neutral', 'happy', 'sad', 'surprise', 'anger'] COLORS = [[255, 0, 0], [255, 85, 0], [255, 170, 0], [255, 255, 0], [170, 255, 0], [85, 25...
magic_instruct_75k
27,972
Write a Python function to find the length of the longest common subsequence (LCS) of two given strings using dynamic programming. The function should take two strings as input and return the length of the longest common subsequence. The code should start with: ```python def longestCommonSubsequence(s1: str, s2: str) ...
Here is the Python code to solve the given problem in the markdown block: ```python def longestCommonSubsequence(s1: str, s2: str) -> int: """ Calculate the length of the longest common subsequence (LCS) of two given strings. Args: s1 (str): The first string. s2 (str): The second string. ...
magic_instruct_75k
27,992
Write a Python function to simulate the backend logic for internship application approval. The function should take the internship application details, the approval status, and the user details as input. It should update the application status and available slots for the internship accordingly. Additionally, the functi...
Here is the Python code to solve the given problem in the markdown block: ```python from datetime import date def process_internship_application(pendaftaran: dict, request: dict, user: dict) -> dict: """ Simulates the backend logic for internship application approval. Args: pendaftaran (dict): A d...
magic_instruct_75k
28,000
Write a Python function to construct the file path for a specific fringe file generated during the processing of Subaru telescope data. The function should take the base directory (`SUBARUDIR`), run number (`run`), filter (`filter`), and chip identifier (`CHIP`) as inputs and return the constructed file path as a strin...
Here is the Python code to solve the given problem in the markdown block: ```python def construct_fringe_file_path(SUBARUDIR: str, run: str, filter: str, CHIP: str) -> str: """ Constructs the file path for a specific fringe file generated during the processing of Subaru telescope data. Args: SUBARU...
magic_instruct_75k
28,016
Write a Python function to calculate the total number of GitHub stars associated with all exported modules in a given TypeScript file snippet. The TypeScript file snippet contains comments and exported modules, each preceded by the number of GitHub stars it has. The function should extract this information and compute ...
Here is the Python code to solve the given problem in the markdown block: ```python import re def calculate_total_stars(typescript_snippet: str) -> int: """ Calculate the total number of GitHub stars for all exported modules in a TypeScript file snippet. Args: typescript_snippet (str): The TypeScr...
magic_instruct_75k
28,030
Write a Python function `get_triangle_indices(initial_index)` that takes an integer `initial_index` as input and returns a list of tuples, where each tuple contains the indices of the vertices for a triangle added to a mesh builder. The mesh builder is a data structure that allows the addition of triangles using the `a...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def get_triangle_indices(initial_index: int) -> List[Tuple[int, int, int]]: """ Calculate the indices of the vertices for each triangle added to the mesh builder. Args: initial_index ...
magic_instruct_75k
28,033
Write a Python function to process tournament data and generate a textual description and a link for the tournament. The function should take a dictionary `context` as input and return the textual description and the link for the tournament. The function should resolve the tournament data from the context, generate the...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Tuple def get_what_teams_called(tourney: Dict) -> str: """ Generates a textual description for the tournament based on the tournament data. Args: tourney (dict): The tournament data. R...
magic_instruct_75k
28,044
Write a Python function to check for duplicates in a given list of integers. The function should return "There are no duplicates" if the list contains no duplicate elements, and "Things are not ok" if there are any duplicate elements in the list. The code should start with: ```python from typing import List def check...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def check_for_duplicates(input_list: List[int]) -> str: """ Checks for duplicates in a given list of integers. Args: input_list (List[int]): The list of integers to check for duplicates. ...
magic_instruct_75k
28,046
Write a Python function to process a Django model definition string and extract information about the model's fields and their relationships. The model definition is provided as a string in the format of a Django migration file, which includes the fields and their relationships. The function should be named `extract_m...
Here is the Python code to solve the given problem in the markdown block: ```python import re def extract_model_info(model_definition: str) -> dict: """ Extracts information about a Django model from a model definition string. Args: model_definition (str): A string containing the model definition ...
magic_instruct_75k
28,055
Create a Python class `MaxStack` that implements a custom stack data structure with the following methods: 1. `push(element: int)`: Adds the element to the top of the stack. 2. `pop() -> int`: Removes and returns the element at the top of the stack. If the stack is empty, raise an `IndexError`. 3. `max() -> int`: Retur...
Here is the Python code to solve the given problem in the markdown block: ```python class MaxStack: def __init__(self): """ Initialize the stack and the max stack. """ self.stack = [] # Main stack to store elements self.max_stack = [] # Stack to store the maximum elements ...
magic_instruct_75k
28,063
Write a Python function to perform a binary search on a list of animals that are sorted in alphabetical order. The function should return the index of the target animal if it is found in the list; otherwise, it should return -1. The function should be efficient and use the binary search algorithm. The code should star...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def binary_search_animal(animal_list: List[str], target_animal: str) -> int: """ Perform a binary search to find the index of a target animal in a sorted list of animals. Args: animal_list (...
magic_instruct_75k
28,121
Implement a performance counter system in Python that tracks the time taken by different sections of the application. The system should be able to start and stop timing for specific sections of the code, calculate the elapsed time in milliseconds, and provide a debug printer to display the performance data in a human-r...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Optional import time class PerfCounter: _start_times: Dict[str, Optional[float]] = {} _elapsed_times: Dict[str, float] = {} @staticmethod def initialize() -> None: """Initialize the per...
magic_instruct_75k
28,127
Write a Python function to add two matrices of the same size. The function should take two matrices as input and return the resultant matrix, which is the sum of the two input matrices. The matrices are represented as lists of lists of integers. The code should start with: ```python from typing import List def add_ma...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def add_matrices(matrixA: List[List[int]], matrixB: List[List[int]]) -> List[List[int]]: """ Adds two matrices of the same size. Args: matrixA (List[List[int]]): The first matrix. ma...
magic_instruct_75k
28,142
Write a Python function to perform eigenvalue decomposition and validation for a symmetric matrix. The function should take a symmetric matrix as input and return a tuple containing the eigenvalues and eigenvectors of the input matrix. Additionally, write a function to validate that the input eigenvalues and eigenvecto...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import Tuple from numpy.linalg import eigh, norm def eigen_decomposition(matrix: np.ndarray) -> Tuple[np.ndarray, np.ndarray]: """ Perform eigenvalue decomposition of a symmetric matrix. Args...
magic_instruct_75k
28,157
Write a Python function to modify a list of query points to ensure they contain a "class:" clause if they are not inside fold, optional, or recursion scope. The function should take a list of query points as input and return a modified list where query points not inside fold, optional, or recursion scope contain a "cla...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def modify_query_points(query_points: List[str]) -> List[str]: """ Modifies a list of query points to ensure they contain a "class:" clause if they are not inside fold, optional, or recursion scope. ...
magic_instruct_75k
28,163
Write a Python function to extract specific attributes from a list of task objects. Each task object is represented as a dictionary containing various attributes. The function should extract the "task_id" and "task_chain_id" attributes from each task object and return them as a list of tuples. The "task_chain_id" attri...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Union, Tuple def extract_task_attributes(tasks: List[Dict[str, Union[int, str, None]]]) -> List[Tuple[int, Union[int, None]]]: """ Extracts the "task_id" and "task_chain_id" attributes from each t...
magic_instruct_75k
28,185
Write a Python function to calculate the average score of a game, excluding the lowest and highest scores from the given list of integers. The function should handle lists with at least 3 scores and return the average rounded to two decimal places. If the list has fewer than 3 scores, the function should return a speci...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_average_excluding_extremes(scores: List[int]) -> float: """ Calculate the average score of a game, excluding the lowest and highest scores. Args: scores (List[int]): A list of ...
magic_instruct_75k
28,186
Write a Python function to extract trainable variables from a nested dictionary structure. The function should take in a dictionary representing module variables and return a list of tuples containing the names and values of trainable variables within the modules. The dictionary keys follow a specific format: `submodul...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple def extract_trainable_variables(module_variable_dict: Dict[str, int]) -> List[Tuple[str, int]]: """ Extracts trainable variables from a nested dictionary structure. Args: module...
magic_instruct_75k
28,187
Write a Python function to generate Terraform configuration for managing SSH keys and startup scripts on the Vultr cloud platform. The function should take in a list of SSH keys and a list of startup scripts as input and produce the corresponding Terraform configuration code as output. The Terraform configuration code ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_vultr_config(ssh_keys: List[str], startup_scripts: List[str]) -> str: """ Generates Terraform configuration for managing SSH keys and startup scripts on the Vultr cloud platform. Args: ...
magic_instruct_75k
28,190
Write a Python function to validate and process input data for a module. The function should ensure that all input arguments meet specific requirements and return a dictionary containing the processed data if the input is valid. If any input argument fails to meet the specified requirements, the function should raise a...
Here is the Python code to solve the given problem in the markdown block: ```python def process_module_data(mod_yaml, name, stream, version, context, arch, summary, description, module_licenses, content_licenses, rpms_nevras): """ Validates and processes input data for a module. Args: mod_yaml (str...
magic_instruct_75k
28,196
Write a Python function to preprocess data based on language-specific parameters. The function `preprocess` takes two parameters: `data`, a dictionary containing data to be preprocessed, and `lang`, a string representing the language for which the preprocessing is being done. The function should add two new key-value p...
Here is the Python code to solve the given problem in the markdown block: ```python def preprocess(data: dict, lang: str) -> dict: """ Preprocesses the given data dictionary by adding two new key-value pairs based on language-specific parameters. Args: data (dict): The dictionary containing the dat...
magic_instruct_75k
28,229
Write a Python function `custom_path_append(directory: str, search_path: List[str]) -> List[str]` that simulates a simplified version of the `sys.path.append()` method. The function should take a directory string and a list of strings representing the current search path. The function should return a new list represent...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def custom_path_append(directory: str, search_path: List[str]) -> List[str]: """ Simulates a simplified version of the `sys.path.append()` method. Args: directory (str): The directory to be ...
magic_instruct_75k
28,257
Write a Python function to categorize a list of source file paths based on their codec types and functionalities. The file paths are given in the format `"media-server/src/{codec_type}/{file_name}.cpp"`. The function should organize these files into a nested dictionary where the top-level keys are codec types (e.g., `h...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def categorize_files(file_paths: List[str]) -> Dict[str, Dict[str, List[str]]]: """ Categorizes a list of source file paths based on their codec types and functionalities. Args: file_p...
magic_instruct_75k
28,264
Write a Python function to calculate the total balance of a bank account based on a list of transactions and a balance factor. Each transaction is represented as a tuple containing the transaction ID and the amount involved. The balance factor is a constant multiplier used to adjust the balance. The function should tak...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def calculate_total_balance(transactions: List[Tuple[int, float]], balance_factor: float) -> float: """ Calculate the total balance of a bank account based on a list of transactions and a balance ...
magic_instruct_75k
28,268
Write a Python function to find the positions of missing numbers in a grid of numbers. Each row in the grid represents a set of numbers separated by commas, and some numbers are replaced with the value `-1`, indicating a missing value. The function should return a list of tuples, where each tuple contains the row and c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_missing_numbers_positions(grid: str) -> List[Tuple[int, int]]: """ Find the positions of missing numbers in a grid of numbers. Args: grid (str): A string representing the gri...
magic_instruct_75k
28,276
Write a Python function to process a list of database migration operations and extract specific information from it. The function should identify the names of the models being created and the dependencies they have on other models. The function should return a dictionary containing the names of the models being created...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def extract_migration_info(operations: List[Dict[str, any]]) -> Dict[str, List[str]]: """ Extracts the names of the models being created and their dependencies from a list of migration operations. ...
magic_instruct_75k
28,283
Write a Python function to return a list of unique strings from a given list of strings. The function should ensure that each string appears only once in the output list, maintaining the order of their first appearance in the input list. The function should start with: ```python from typing import List def get_unique...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_unique_strings(input_list: List[str]) -> List[str]: """ Returns a list of unique strings from the given input list, preserving the order of their first appearance. Args: input_list (...
magic_instruct_75k
28,300
Write a Python function `process_config` that takes a dictionary `config` as input and performs the following operations: 1. Check if the key 'github' exists in the dictionary. 2. If the key 'github' exists, retrieve its value and store it in a variable called `github_config`. 3. If the key 'github' does not exist, set...
Here is the Python code to solve the given problem in the markdown block: ```python def process_config(config: dict) -> dict: """ Processes the input configuration dictionary to retrieve or set the 'github' configuration. Args: config (dict): The input configuration dictionary. Returns: ...
magic_instruct_75k
28,309
Write a Python function to parse a list of route definitions and return a dictionary where the keys are the route patterns and the values are dictionaries containing the HTTP method and the handler for each route. The function should handle different HTTP request methods and route patterns. The code should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def parseRoutes(routes: List[Dict[str, str]]) -> Dict[str, Dict[str, str]]: """ Parses a list of route definitions and returns a dictionary where the keys are the route patterns and the values ...
magic_instruct_75k
28,317
Write a Python function to count the frequency of each word in a list of strings, ignoring case sensitivity and considering only alphanumeric characters. The function should exclude common English stop words from the frequency count. The function should start with: ```python from typing import List, Dict import re from...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict import re from collections import Counter def word_frequency_counter(words: List[str]) -> Dict[str, int]: """ Counts the frequency of each word in a list of strings, ignoring case sensitivity and c...