source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_instruct_75k | 48,878 | Write a Python function to format a list of required package dependencies into a string that can be used in a Python `setup.py` file. The function should take a list of package names as input and return a string in the format commonly used for specifying package dependencies in a `setup.py` file.
The format for specif... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def format_dependencies(package_list: List[str]) -> str:
"""
Formats a list of required package dependencies into a string suitable for use in a Python `setup.py` file.
Args:
package_list (L... |
magic_instruct_75k | 48,881 | Write a Python function called `find_min_index` that takes a list of comparable elements as input and returns the index of the minimum element in the list. If there are multiple occurrences of the minimum element, return the index of the first occurrence. The function should not use any built-in functions like `min()` ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_min_index(arr: List[int]) -> int:
"""
Find the index of the minimum element in a list of comparable elements.
Args:
arr (List[int]): The list of elements to search for the minimum e... |
magic_instruct_75k | 48,889 | Write a Python function to validate a given JSON payload against a set of predefined rules. The function should handle cases where the payload is empty and return an appropriate response. The function should be named `validate_payload` and should take a single argument `payload`, which is a JSON object. The function sh... | Here is the Python code to solve the given problem in the markdown block:
```python
def validate_payload(payload: dict) -> bool:
"""
Validates a given JSON payload against a set of predefined rules.
Args:
payload (dict): The JSON payload to be validated.
Returns:
bool: True if the payl... |
magic_instruct_75k | 48,900 | Write a Python function to parse a series of directives from a given input string. Each directive is represented as a string and is prefixed by a specific directive name. The input string is formatted as follows:
- Directives are separated by spaces.
- Each directive consists of a directive name followed by one or more... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def parse_directives(input: str) -> Dict[str, List[str]]:
"""
Parses a series of directives from a given input string and returns a dictionary
mapping directive names to their associated tokens... |
magic_instruct_75k | 48,902 | Write a Python function to determine the appropriate import method for a given file based on its extension. The function should handle different types of files such as maps, models, and textures. If the file extension is not recognized, the function should do nothing.
The function should start with:
```python
import o... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
from typing import Callable, Dict, List
def import_file(filename: str, importers: Dict[str, Callable[[str], None]], supported_mesh_extensions: List[str], supported_image_extensions: List[str]) -> None:
"""
Determines ... |
magic_instruct_75k | 48,950 | Write a Python function to find the common elements between two NumPy arrays, without any duplicates, and in sorted order. The function should take two NumPy arrays as input and return a new NumPy array containing the common elements.
The code should start with:
```python
import numpy as np
def find_common_elements(a... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def find_common_elements(a: np.ndarray, b: np.ndarray) -> np.ndarray:
"""
Find the common elements between two NumPy arrays, without any duplicates, and in sorted order.
Args:
a (np.ndarray): The... |
magic_instruct_75k | 48,962 | Write a Python function to count the number of users with each unique role from a list of user dictionaries. Each user dictionary contains the keys "name" and "role". The function should return a dictionary where the keys are the unique roles and the values are the counts of users with each role.
The code should start... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_users_by_role(users: List[Dict[str, str]]) -> Dict[str, int]:
"""
Counts the number of users with each unique role from a list of user dictionaries.
Args:
users (List[Dict[st... |
magic_instruct_75k | 48,966 | Write a Python function to truncate a given string to a specified length and append an ellipsis ("...") if the string exceeds the specified length. If the input is not a string or the specified length is not a positive integer, the function should return "Invalid input".
The function should be named `truncate_string` ... | Here is the Python code to solve the given problem in the markdown block:
```python
def truncate_string(value: str, length: int) -> str:
"""
Truncates a given string to a specified length and appends an ellipsis ("...") if the string exceeds the specified length.
Args:
value (str): The input string... |
magic_instruct_75k | 48,995 | Write a Python function `calculate_difference(entries)` that processes a list of dictionary entries and calculates the difference between two specific fields within each entry. The function should take the list of dictionary entries as input and return a new list of dictionary entries with an additional field represent... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def calculate_difference(entries: List[Dict[str, float]]) -> List[Dict[str, float]]:
"""
Calculate the difference between 'init_rot_error' and 'rot_error' for each entry in the list of dictionaries... |
magic_instruct_75k | 49,006 | Write a Python function to process stock market tick data. The function should take a list of dictionaries, where each dictionary represents a tick data entry with keys "timestamp", "price", and "volume". The function should return a modified list of tick data entries after removing any entries where the price is less ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def process_tick_data(tick_data: List[Dict[str, Union[str, float]]]) -> List[Dict[str, Union[str, float]]]:
"""
Process a list of stock market tick data by removing entries with non-positive... |
magic_instruct_75k | 49,007 | Write a Python function to calculate the sum of all positive values in a given list of grid data. The grid data is represented as a list of integers, and the function should ignore any negative values when calculating the sum. The function should start with:
```python
from typing import List
def sum_positive_grid_valu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_positive_grid_values(grid_data: List[int]) -> int:
"""
Calculate the sum of all positive values in a given list of grid data.
Args:
grid_data (List[int]): A list of integers represen... |
magic_instruct_75k | 49,028 | Write a Python function to generate a personalized greeting message based on the provided name. The greeting message should be in the format "Hello, [Name]! Welcome to the program." The function should take a single string argument representing the name and return the formatted greeting message.
The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_greeting(name: str) -> str:
"""
Generates a personalized greeting message based on the provided name.
Args:
name (str): The name to be included in the greeting message.
Returns:
str: A gree... |
magic_instruct_75k | 49,040 | Write a Python function to generate a random integer within a specified range using a linear congruential generator (LCG) algorithm. The LCG algorithm is defined by the recurrence relation: \( X_{n+1} = (a \cdot X_n + c) \mod m \), where \( X_0 \) is the seed, \( a \) is the multiplier, \( c \) is the increment, and \(... | Here is the Python code to solve the given problem in the markdown block:
```python
def lcg_random(seed: int, range_start: int, range_end: int) -> int:
"""
Generate a random integer within a specified range using a linear congruential generator (LCG) algorithm.
The LCG algorithm is defined by the recurrenc... |
magic_instruct_75k | 49,058 | Write a Python function to interpret a 3x3 grid of characters representing a digit and return the corresponding numerical representation. The grid consists of characters: space (" "), underscore ("_"), and vertical bar ("|"). Each digit is formed by a specific pattern of these characters. The function should take a lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def interpretDigit(grid: List[str]) -> str:
"""
Interprets a 3x3 grid of characters representing a digit and returns the corresponding numerical representation.
Args:
grid (List[str]): A lis... |
magic_instruct_75k | 49,072 | Write a Python function to automate the process of checking the status of a healthcare dataset using the Google Cloud Healthcare API. The function should take in the project location, dataset name, and store name as input parameters and then use the `gcloud` command-line tool to describe the dataset. The function shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
import subprocess
def describe_healthcare_dataset(project: str, location: str, dataset: str) -> None:
"""
Automates the process of checking the status of a healthcare dataset using the Google Cloud Healthcare API.
Args:
... |
magic_instruct_75k | 49,104 | Write a Python function to generate a list of unique random integers within a specified range and size. The function should take three parameters: `range_start` and `range_end`, which define the inclusive range within which the random integers should be generated, and `size`, which specifies the number of random intege... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_random_integers(range_start: int, range_end: int, size: int) -> List[int]:
"""
Generates a list of unique random integers within a specified range.
Args:
range_sta... |
magic_instruct_75k | 49,107 | Write a Python function to find the set of unique track names that appear in all three lists within a given dictionary of music streaming data. The dictionary contains three keys: "tracks_short_term", "tracks_medium_term", and "tracks_long_term", each holding a list of track names that the user has listened to in the r... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Set
def common_tracks(tracks_data: Dict[str, List[str]]) -> Set[str]:
"""
Find the set of unique track names that appear in all three lists within the given dictionary.
Args:
tracks_d... |
magic_instruct_75k | 49,122 | Write a Python function to generate a list of unique random numbers within a specified range. The function should take two integer parameters, `start` and `end`, representing the inclusive range within which the random numbers should be generated. The function should return a list of unique random numbers within the sp... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
from typing import List
def generate_random_numbers(start: int, end: int) -> List[int]:
"""
Generates a list of unique random numbers within a specified range.
Args:
start (int): The lower bound (incl... |
magic_instruct_75k | 49,125 | Write a Python function to categorize a list of file names representing variant call format (VCF) files from a genetic sequencing experiment. The file names follow a specific pattern, where `${pre}` represents a placeholder for a prefix. The files contain information about single nucleotide variants (SNVs) and insertio... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def categorize_vcf_files(file_names: List[str]) -> Dict[str, Dict[str, int]]:
"""
Categorizes a list of VCF file names based on their type (SNV or indel) and genomic region.
Args:
file... |
magic_instruct_75k | 49,127 | Write a Python function to merge two sorted arrays into a single sorted array. The function should efficiently combine the elements from both arrays while maintaining the sorted order. The code should start with:
```python
from typing import List
def merge_sorted_arrays(sorted_output1: List[int], sorted_output2: List[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sorted_arrays(sorted_output1: List[int], sorted_output2: List[int]) -> List[int]:
"""
Merges two sorted arrays into a single sorted array.
Args:
sorted_output1 (List[int]): A sorte... |
magic_instruct_75k | 49,138 | Write a bash script to automate the setup of AWS CloudTrail for multiple regions. The script should check if a CloudTrail is already set up for a specific region and account, and if not, it should create a new CloudTrail with a specified naming convention. The script should also handle the case where the S3 bucket for ... | Here is the Python code to solve the given problem in the markdown block:
```bash
#!/bin/bash
# Define variables
profile="your_aws_profile"
accountId="your_aws_account_id"
trailname="your_trail_name"
trailbucket="your_s3_bucket_name"
regions=("us-east-1" "us-west-2" "eu-west-1") # Add all required regions
# Function... |
magic_instruct_75k | 49,143 | Write a Python function to read a file named `lines.txt` containing multiple lines of text, calculate the length of each line, and then print the length of each line. Additionally, the function should only process and print the length of the first three lines of the file.
The code should start with:
```python
def proc... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_file(file_path: str) -> None:
"""
Reads a file and prints the length of each line for the first three lines.
Args:
file_path (str): The path to the file to be processed.
Returns:
None: The f... |
magic_instruct_75k | 49,145 | Write a Python function to count the occurrences of each unique event type in a list of event dictionaries. Each event dictionary contains a key "type" that indicates the event type. If an event dictionary does not have a "type" key or its value is not a string, it should be ignored. The function should be named `count... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_event_types(events: List[Dict[str, str]]) -> Dict[str, int]:
"""
Counts the occurrences of each unique event type in a list of event dictionaries.
Args:
events (List[Dict[str... |
magic_instruct_75k | 49,163 | Write a Python function to generate a message based on a set of constraints. The function should take a list of strings representing the constraints and return a message according to the number of constraints provided.
The function should follow these rules:
- If there are no constraints, the message should be "no con... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_message(constraints: List[str]) -> str:
"""
Generates a message based on the number of constraints provided.
Args:
constraints (List[str]): A list of strings representing the co... |
magic_instruct_75k | 49,166 | Write a Python function to extract all code snippets enclosed within triple quotes (`"""`) from a given string. The function should return a list of these code snippets in the order they appear in the input string. The code should start with:
```python
from typing import List
def extract_code_snippets(input_string: st... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_code_snippets(input_string: str) -> List[str]:
"""
Extracts all code snippets enclosed within triple quotes from the given input string.
Args:
input_string (str): The input strin... |
magic_instruct_75k | 49,167 | Create a Python class `AsyncHTTPManager` that manages asynchronous HTTP requests and provides a mechanism to handle the responses. The class should have the following specifications:
1. A method `sendHTTPRequest` that takes an HTTP request handle and returns a call handle for asynchronous response handling.
2. A mechan... | Here is the Python code to solve the given problem in the markdown block:
```python
class AsyncHTTPManager:
def __init__(self):
"""
Initialize the AsyncHTTPManager with necessary data structures.
"""
self.call_handles = {} # Dictionary to store call handles and their callbacks
... |
magic_instruct_75k | 49,183 | Write a Python function to generate a command-line string from a list of server configuration options. Each option is represented as a key-value pair in the form of a tuple. The command-line string should be constructed by concatenating the keys and values in a specific format.
The format for each option is as follows... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def generateCommandLine(options: List[Tuple[str, str]]) -> str:
"""
Generates a command-line string from a list of server configuration options.
Each option is represented as a key-value pair... |
magic_instruct_75k | 49,188 | Write a Python function to calculate the final score of a game based on the player's performance in multiple levels. The function should take a list of integers representing the points earned in each level and return the final score according to the following rules:
- The player starts with a score of 0.
- For each lev... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_final_score(levels: List[int]) -> int:
"""
Calculate the final score of a game based on the player's performance in multiple levels.
Args:
levels (List[int]): A list of integer... |
magic_instruct_75k | 49,210 | Write a Python function to convert a given month name into its corresponding numerical representation. The function should take a string representing the month name in lowercase as input and return the numerical representation of the month. If the input is not a valid month name, the function should return -1.
The cod... | Here is the Python code to solve the given problem in the markdown block:
```python
def month_to_number(month: str) -> int:
"""
Converts a given month name into its corresponding numerical representation.
Args:
month (str): A string representing the month name in lowercase (e.g., "january", "februa... |
magic_instruct_75k | 49,213 | Write a Python function to combine the data from a list of dictionaries representing different types of coins into a single dictionary. Each dictionary in the list represents the attributes and values of a particular coin. The keys of the dictionaries represent the attributes of the coins, and the values represent the ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
from collections import defaultdict
def combine_coindata(coindata_cmb: Dict[str, List[Dict[str, any]]]) -> Dict[str, List[any]]:
"""
Combines the data from a list of dictionaries representing diffe... |
magic_instruct_75k | 49,216 | Write a Python function `format_flake8_config(config: dict) -> str` that processes a configuration dictionary for a project's Flake8 settings and returns a formatted string representing the Flake8 configuration settings. The configuration dictionary contains various properties and their corresponding values. The format... | Here is the Python code to solve the given problem in the markdown block:
```python
def format_flake8_config(config: dict) -> str:
"""
Formats the Flake8 configuration dictionary into a specific string format.
Args:
config (dict): A dictionary containing Flake8 configuration settings.
Returns:... |
magic_instruct_75k | 49,223 | Write a Python function to find the minimum number of coins needed to make up a given amount using the provided coin denominations. If it is not possible to make up the amount using the given denominations, return -1.
The function should start with:
```python
from typing import List
def min_coins(coins: List[int], am... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def min_coins(coins: List[int], amount: int) -> int:
"""
Calculate the minimum number of coins needed to make up a given amount using the provided coin denominations.
Args:
coins (List[int])... |
magic_instruct_75k | 49,234 | Write a Python function `manipulate_list(src, m)` that takes a list of integers `src` and an integer `m` as input and returns a new list of strings. The new list should contain the ASCII value of each integer in `src` multiplied by `m` and converted to a string.
The code should start with:
```python
from typing import... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def manipulate_list(src: List[int], m: int) -> List[str]:
"""
Manipulates a list of integers by converting each integer to its ASCII character,
multiplying the ASCII value by a given integer `m`, and... |
magic_instruct_75k | 49,235 | Write a Python function to implement the Sieve of Eratosthenes algorithm, which finds all prime numbers up to a given integer `n`. The function should return a list of all prime numbers less than or equal to `n`. The function should start with:
```python
def sieve_of_eratosthenes(n: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sieve_of_eratosthenes(n: int) -> List[int]:
"""
Find all prime numbers up to a given integer n using the Sieve of Eratosthenes algorithm.
Args:
n (int): The upper limit to find all prime... |
magic_instruct_75k | 49,254 | Write a Python function to calculate the Julian day number corresponding to a given fixed date. The fixed date is represented as an integer, where 0 corresponds to November 24, 4714 BCE, and each subsequent day is represented by an incrementing integer. The Julian day number is a continuous count of days since the begi... | Here is the Python code to solve the given problem in the markdown block:
```python
def jd_from_fixed(date: int) -> int:
"""
Calculate the Julian day number corresponding to a given fixed date.
The fixed date is represented as an integer, where 0 corresponds to November 24, 4714 BCE.
The Julian day num... |
magic_instruct_75k | 49,255 | Write a Python function to calculate the maximum amount of water that can be trapped between walls represented by a list of integers. Each integer in the list represents the height of a wall at a specific position. The water is trapped if there are higher walls on both sides of a wall. The width of each wall is 1 unit.... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_trapped_water(heights: List[int]) -> int:
"""
Calculate the maximum amount of water that can be trapped between walls.
Args:
heights (List[int]): A list of integers representing the ... |
magic_instruct_75k | 49,256 | Write a Python function to calculate the total balance for a given account based on a list of transactions. Each transaction is represented as a tuple containing the date, description, and amount. The amount can be positive for deposits and negative for withdrawals. The function should take a list of transactions as in... | 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]]) -> float:
"""
Calculate the total balance for a given account based on a list of transactions.
Args:
transactions (Li... |
magic_instruct_75k | 49,258 | Write a Python function to extract information about Django app configurations from a list of file paths. Each file path corresponds to a Python file that contains a Django app configuration class. The file paths are formatted as `<filename><app_name>/apps.py<gh_stars><num_stars>`, where `<filename>` is the name of the... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
import re
def extract_app_config_info(file_paths: List[str]) -> Dict[str, Dict[str, str]]:
"""
Extracts information about Django app configurations from a list of file paths.
Args:
fil... |
magic_instruct_75k | 49,286 | Write a Python function to retrieve the corresponding error message for a given error code from a predefined set of error codes and messages. The error codes are structured hierarchically, with the first digit representing the error type, the next two digits representing the error category within the type, and the last... | Here is the Python code to solve the given problem in the markdown block:
```python
def get_error_message(error_code: int) -> str:
"""
Retrieve the corresponding error message for a given error code from a predefined set.
Args:
error_code (int): The error code to look up.
Returns:
str:... |
magic_instruct_75k | 49,296 | Write a Python function to calculate the download progress of multiple JSON files and return a formatted string representing the progress. The function should take a dictionary `paperinfo` as input, which contains information about the JSON files to be downloaded. The dictionary has the following keys:
- `download_url`... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_download_progress(paperinfo: dict) -> str:
"""
Calculate the download progress of multiple JSON files and return a formatted string representing the progress.
Args:
paperinfo (dict): A dictionary conta... |
magic_instruct_75k | 49,301 | Write a Python function to find the first element of a given list of integers. The function should handle lists of any length, including empty lists, by returning `None` if the list is empty. The function should also handle cases where the list contains non-integer elements by returning `None` for such lists.
The code... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def get_first_element(n: List[int]) -> Optional[int]:
"""
Returns the first element of a given list of integers.
Args:
n (List[int]): The list of integers from which to extract the... |
magic_instruct_75k | 49,315 | Write a Python function to count the occurrences of each unique action in a given list of actions. Each action is represented as a string. The function should return a dictionary where the keys are the unique actions and the values are the counts of each action in the input list.
The code should start with:
```python
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_actions(actions: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of each unique action in a given list of actions.
Args:
actions (List[str]): A list of strings repre... |
magic_instruct_75k | 49,351 | Write a Python function to process a list of alerts and update their information based on certain criteria. Each alert is represented as a dictionary with keys "alert_url" and "source_name". The function should update the "alert_url" field in each alert dictionary with a new value provided as an argument to the functio... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def process_alerts(alerts: List[Dict[str, str]], new_alert_url: str) -> List[Dict[str, str]]:
"""
Process a list of alerts and update the "alert_url" field in each alert dictionary with a new value... |
magic_instruct_75k | 49,353 | Write a Python function to generate a command-line prompt string based on the provided username, machine name, and current working directory. The prompt should indicate whether the user is a regular user or a superuser by using a specific symbol. The function should return the formatted prompt string.
The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_prompt(username: str, machine_name: str, working_directory: str) -> str:
"""
Generates a command-line prompt string based on the provided username, machine name, and current working directory.
Args:
use... |
magic_instruct_75k | 49,357 | 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 of a company. If it is not possible to make any profit, return 0.
The function should start with:
```python
from typing import List
def ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def maxProfit(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 repres... |
magic_instruct_75k | 49,413 | Write a Python function to compute the next state of a cellular automaton represented by a 2D grid of cells. Each cell can be either alive (denoted by 1) or dead (denoted by 0). The function should apply the rules of Conway's Game of Life to determine the next state of the grid. The rules are as follows:
1. Any live ce... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def next_generation(grid: List[List[int]]) -> List[List[int]]:
"""
Compute the next state of a cellular automaton represented by a 2D grid of cells.
Args:
grid (List[List[int]]): A 2D list o... |
magic_instruct_75k | 49,418 | Write a Python function to calculate the average value of a given list of numbers in batches for a specified number of epochs. The function should take into account the size of the data, the batch size, and the number of epochs for training a machine learning model. The function should return a list of average values, ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_batch_averages(data: List[float], batch_size: int, epoch_num: int) -> List[float]:
"""
Calculate the average value of a given list of numbers in batches for a specified number of epochs.
... |
magic_instruct_75k | 49,422 | Write a Python function to filter geographical locations based on the absolute difference between their longitude and latitude. The function should take a JSON-like dictionary containing location data and a threshold value as input. It should return a list of dictionaries containing only the "county" and "stateCode" fo... | Here is the Python code to solve the given problem in the markdown block:
```python
def filter_locations(json_data: dict, threshold: float) -> list:
"""
Filters geographical locations based on the absolute difference between their longitude and latitude.
Args:
json_data (dict): A dictionary represe... |
magic_instruct_75k | 49,436 | Write a Python function to generate HTML code for a list of strings representing HTML elements. Each string in the input list represents an HTML element with its attributes. The function should handle two types of HTML elements: disabled checkboxes and checked disabled checkboxes.
The input list will contain strings i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_html_code(elements: List[str]) -> str:
"""
Generates HTML code for a list of strings representing HTML elements.
Args:
elements (List[str]): A list of strings where each string ... |
magic_instruct_75k | 49,448 | Write a Python function to generate Django URL patterns for a given set of view names. The function should take a list of view names and return a list of URL patterns in the format `url(r'^<view_name>/$', <view_name>),` where `<view_name>` is the name of the view. The function should start with:
```python
from typing i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_url_patterns(views: List[str]) -> List[str]:
"""
Generates Django URL patterns for a given list of view names.
Args:
views (List[str]): A list of strings representing the names ... |
magic_instruct_75k | 49,449 | Write a Python function to generate a command string for the `mJPEG` command-line tool that converts a FITS file to a JPEG image. The function should accept the input FITS file path, processing parameters, and the output JPEG file path as arguments, and then construct the command string based on these inputs.
The code... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_mJPEG_command(fits_file_path: str, processing_params: str, output_jpeg_path: str) -> str:
"""
Generates a command string for the mJPEG tool to convert a FITS file to a JPEG image.
Args:
fits_file_path (... |
magic_instruct_75k | 49,457 | Write a Python function to convert a given icon name into its corresponding Unicode representation. The function should take a string representing the icon name and return the Unicode representation of the icon. If the icon name is not found in the mapping, the function should return a default message indicating that t... | Here is the Python code to solve the given problem in the markdown block:
```python
def iconToUnicode(iconName: str) -> str:
"""
Converts a given icon name into its corresponding Unicode representation.
Args:
iconName (str): The name of the icon to be converted.
Returns:
str: The Unico... |
magic_instruct_75k | 49,485 | Write a Python function to perform a binary operation on two matrices and then compare the result with another matrix. The matrices are represented as lists of lists, and the binary operation is performed using a custom function. The function should return `True` if the result of the binary operation on the two matrice... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Callable
def compare_matrices(matrix1: List[List[int]], matrix2: List[List[int]], expected_result: List[List[int]], binary_op: Callable[[int, int], int]) -> bool:
"""
Compares the result of a binary ope... |
magic_instruct_75k | 49,489 | Write a Python function `generate_setup_py` that generates the content for a `setup.py` file for a Django package. The function should take the following parameters:
- `PACKAGE_NAME` (string): The name of the Django package.
- `INSTALL_REQUIRES` (list of strings): The list of required dependencies for the package.
- `K... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_setup_py(PACKAGE_NAME: str, INSTALL_REQUIRES: list, KEYWORDS: list, CLASSIFIERS: list) -> str:
"""
Generates the content for a `setup.py` file for a Django package.
Args:
PACKAGE_NAME (str): The name of... |
magic_instruct_75k | 49,526 | Write a Python function to generate a C++ class definition with member variables based on a given number of `BOOST_MOVE_MREF` macro expansions. The `BOOST_MOVE_MREF` macro is used to define member variables with names `m_p0`, `m_p1`, `m_p2`, etc., in the order specified by the number of members. The function should ret... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_cpp_class(classname: str, num_members: int) -> str:
"""
Generates a C++ class definition with member variables based on the given number of BOOST_MOVE_MREF macro expansions.
Args:
classname (str): The n... |
magic_instruct_75k | 49,527 | Write a Python function to calculate the average word count per user in a chat application. The function should take a list of comments as input and return a dictionary where the keys are user IDs and the values are the average word count of comments made by each user.
Each comment in the list is represented as a dict... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def avg_word_count_by_user(comments: List[Dict[str, any]]) -> Dict[int, float]:
"""
Calculate the average word count per user based on the provided comments.
Args:
comments (List[Dict[... |
magic_instruct_75k | 49,556 | Write a Python function to analyze a given configuration dictionary representing the memory hierarchy and pipeline status of a computer system. The function should return a summary string that lists the memory hierarchy levels and indicates whether the pipeline is enabled or not.
The configuration dictionary has the f... | Here is the Python code to solve the given problem in the markdown block:
```python
def analyze_configuration(config: dict) -> str:
"""
Analyzes the given configuration dictionary and returns a summary string.
The configuration dictionary contains two keys:
- 'memory_hierarchy': A list of memory levels... |
magic_instruct_75k | 49,579 | Write a Python function to calculate the absolute difference between a given age and a reference age. The function should take two integer arguments: the age to be compared and the reference age. The absolute difference between the two ages should be returned as the output.
The code should start with:
```python
def ca... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_age_difference(age: int, reference_age: int) -> int:
"""
Calculate the absolute difference between a given age and a reference age.
Args:
age (int): The age to be compared.
reference_age (int):... |
magic_instruct_75k | 49,599 | Write a Python function to validate the uniqueness of a proposed unique name for a new channel in a channel management system. The function should check if the proposed name is already used by any existing channel. The function should return `True` if the name is unique and `False` if it is already in use.
The `channe... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
class Channel:
def __init__(self, owner, name_display, name_unique, about, css):
self.owner = owner
self.name_display = name_display
self.name_unique = name_unique
self.about ... |
magic_instruct_75k | 49,604 | Write a Python function to parse callback data in a specific format. The callback data is a string in the format "field1=value1&field2=value2&field3=value3", where "field" is the name of the field and "value" is its corresponding value. Your task is to write a function `parse_callback_data` that takes a string `data` a... | Here is the Python code to solve the given problem in the markdown block:
```python
def parse_callback_data(data: str) -> dict:
"""
Parses a callback data string in the format "field1=value1&field2=value2&field3=value3"
and returns a dictionary containing the parsed field-value pairs.
Args:
dat... |
magic_instruct_75k | 49,638 | Write a Python function to calculate the nth number in the Fibonacci sequence using an iterative approach. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The sequence goes as follows: 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on. The fun... | Here is the Python code to solve the given problem in the markdown block:
```python
def fibonacci_iterative(n: int) -> int:
"""
Calculate the nth number in the Fibonacci sequence using an iterative approach.
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ... |
magic_instruct_75k | 49,666 | Write a Python function to find the maximum sum of a contiguous subarray within a given list of integers. The function should efficiently compute the maximum sum using an optimal approach.
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 | 49,685 | Write a Python function to evaluate a given mathematical expression represented as a string. The expression contains only non-negative integers, the four basic arithmetic operators (`+`, `-`, `*`, `/`), and parentheses. The function should follow the standard rules of arithmetic operations, including operator precedenc... | Here is the Python code to solve the given problem in the markdown block:
```python
def evaluate_math_expression(expression: str) -> int:
"""
Evaluate a mathematical expression represented as a string.
The expression contains only non-negative integers, the four basic arithmetic operators (+, -, *, /), and... |
magic_instruct_75k | 49,700 | Write a Python function to determine if a given set of pinyin syllables is included in another set of pinyin syllables. Each pinyin syllable is represented by a list of letters, and a set of pinyin syllables is represented by a list of lists of letters. The function should return `True` if the `subset` is included in t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def includes(pinyinSet: List[List[str]], subset: List[List[str]]) -> bool:
"""
Determines if the given subset of pinyin syllables is included in the pinyinSet.
Args:
pinyinSet (List[List[str... |
magic_instruct_75k | 49,710 | Write a Python function to evaluate the performance of a distilled model on the CelebA dataset. The function should take the distilled model and the test dataset as inputs, evaluate the model's performance on the test dataset, and return the accuracy of the model.
The code should start with:
```python
from typing impo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
def test_celeba_distill_model(distilled_model, test_data: Tuple[list, list]) -> float:
"""
Evaluate the performance of a distilled model on the CelebA test dataset and return the accuracy.
Args:
... |
magic_instruct_75k | 49,721 | Write a Python function to process labeled features from a dataset and return a dictionary where the keys are the labels and the values are lists of corresponding features. The function should handle large datasets efficiently.
The function signature should be:
```python
from typing import List, Tuple, Dict
def proce... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def process_features(labels: List[int], features: List[Tuple[int, List[str]]]) -> Dict[int, List[List[str]]]:
"""
Processes labeled features and returns a dictionary where the keys are the l... |
magic_instruct_75k | 49,732 | Write a Python function to process audio channels based on the given configuration parameters. The function should handle the following parameters:
- `num_channels`: A positive integer representing the number of channels to be selected from the audio file. If this parameter is not specified, all channels in the origin... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_audio_channels(num_channels: int = None, convert_to_mono: bool = False) -> str:
"""
Process audio channels based on the given configuration parameters.
Args:
num_channels (int, optional): The number of c... |
magic_instruct_75k | 49,761 | Write a Python function to count the number of adjacent pairs of buttons in a grid that have the same value. Adjacency is defined as buttons that are directly next to each other horizontally or vertically (not diagonally). The grid is represented by a list of lists, where each inner list represents a row of buttons, an... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_adjacent_pairs(grid: List[List[int]]) -> int:
"""
Counts the number of adjacent pairs of buttons in a grid that have the same value.
Args:
grid (List[List[int]]): A 2D list represe... |
magic_instruct_75k | 49,802 | Write a Python function `paginate_guilds` that organizes a list of guild dictionaries into pages, with each page containing up to 10 guild entries. The function should take two parameters:
- `guilds`: A list of dictionaries, where each dictionary represents a guild with keys "id", "name", "leader", and "members".
- `pa... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def paginate_guilds(guilds: List[Dict], page: int) -> List[str]:
"""
Organizes a list of guild dictionaries into pages, with each page containing up to 10 guild entries.
Args:
guilds (... |
magic_instruct_75k | 49,840 | Write a Python function to parse command-line arguments and perform specific actions based on the provided arguments. The function should handle the initialization of a hypothetical Simple DirectMedia Layer (SDL) and process the command-line arguments to perform various operations.
The function should start with:
```p... | Here is the Python code to solve the given problem in the markdown block:
```python
def init(args: list) -> None:
"""
Parses command-line arguments and performs specific actions based on the provided arguments.
Args:
args (list): A list of command-line arguments.
Returns:
None
"""
... |
magic_instruct_75k | 49,844 | Write a Python function to sort a list of dictionaries based on the values of a specified key in descending order. Each dictionary in the list represents a keyword and its associated count. The function should return the sorted list of dictionaries.
The code should start with:
```python
from typing import List, Dict
f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
from operator import itemgetter
def sort_keywords_by_count(keywords: List[Dict[str, any]], key: str) -> List[Dict[str, any]]:
"""
Sorts a list of dictionaries based on the values of a specified key... |
magic_instruct_75k | 49,857 | Write a Python function to simulate the movement of a diagnostic device to a specific position and trigger a measurement using a synchrotron counter. The function should take the diagnostic device (either `diag5_y` or `diag6_y`) and a position as input, move the specified diagnostic device to the given position, trigge... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
class EpicsMotor:
def __init__(self, name: str):
self.name = name
self.position = 0.0
def move(self, position: float):
self.position = position
print(f"Moved {self.name} ... |
magic_instruct_75k | 49,858 | Write a Python function to find the prime factorization of a given integer `m`. The function should return a list of prime factors in ascending order. The code should start with:
```python
def prime_factorization(m: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def prime_factorization(m: int) -> List[int]:
"""
Returns the prime factorization of a given integer `m` as a list of prime factors in ascending order.
Args:
m (int): The integer to be facto... |
magic_instruct_75k | 49,867 | Write a Python function to validate a dictionary representing a function's parameters against a given signature. The signature is also represented as a dictionary, where the keys are parameter names and the values are the expected types. The function should return `True` if the parameters match the signature, and `Fals... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
# Constants for parameter types
BOOLEAN_TYPE = '<boolean>'
ENUM_TYPE = '<enum>'
ARBITRARY_OBJ_TYPE = '<arbitrary-obj>'
def validate_parameters(signature: Dict[str, str], parameters: Dict[str, any]) -> bool:
... |
magic_instruct_75k | 49,904 | Write a Python function to synchronize the current system time by adding a specified time offset in seconds. The function should return the synchronized time in a human-readable format. Additionally, create a script that can be invoked from the command line with the time offset as an argument. The script should display... | Here is the Python code to solve the given problem in the markdown block:
```python
import datetime
import sys
def sync_time(offset: int) -> str:
"""
Synchronizes the current system time by adding a specified time offset in seconds.
Args:
offset (int): The time offset in seconds to add to the curr... |
magic_instruct_75k | 49,923 | Write a Python function to perform matrix multiplication on two given matrices and return the resulting matrix. The function should handle matrices of different data types and ensure that the dimensions of the input matrices are compatible for multiplication.
The code should start with:
```python
from typing import Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, TypeVar, Generic
T = TypeVar('T')
class Matrix(Generic[T]):
def __init__(self, data: List[List[T]]):
self.data = data
self.rows = len(data)
self.cols = len(data[0]) if self.rows > 0... |
magic_instruct_75k | 49,986 | Write a Python function to extract and sort all the write operations from a given program execution trace. The trace is a string where each line represents an action taken by the program. Lines starting with the `>` character indicate write operations. The function should return a sorted list of these write operations.... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_and_sort_writes(trace: str) -> List[str]:
"""
Extracts and sorts all write operations from a given program execution trace.
Args:
trace (str): A string representing the trace of ... |
magic_instruct_75k | 50,012 | Write a Python function to construct the request body for a form submission that includes "Begin Date" and "End Date" fields. The function should take two strings representing the dates in the format "YYYY-MM-DD" and return a dictionary with keys "beginDate" and "endDate" containing the corresponding date values.
The ... | Here is the Python code to solve the given problem in the markdown block:
```python
def construct_request_body(begin_date: str, end_date: str) -> dict:
"""
Constructs the request body for a form submission that includes "Begin Date" and "End Date" fields.
Args:
begin_date (str): The "Begin Date" in... |
magic_instruct_75k | 50,032 | Write a Python function to manage a dataset of video game test results. The dataset is represented as a dictionary where the keys are the names of the video games and the values are lists of test results. Each test result is a tuple containing the test date and the test score. The function should add a new test result ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Tuple
def add_test_result(dataset_vg_test: Dict[str, List[Tuple[str, int]]], game_name: str, test_date: str, test_score: int) -> Dict[str, List[Tuple[str, int]]]:
"""
Adds a new test result to the... |
magic_instruct_75k | 50,034 | Write a Python function to process a given dictionary representing a document mapping and return a modified version of the dictionary. The input dictionary contains a nested structure representing document mappings, and the function should perform a specific transformation on this structure.
The input dictionary has t... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_mapping(doc_mapping: dict, doc_type: str) -> dict:
"""
Processes a given document mapping dictionary and returns a modified version of the dictionary.
The input dictionary has a nested structure representing doc... |
magic_instruct_75k | 50,052 | Write a Python function to implement a predicate map function. The function should take a predicate (a function that returns a boolean value) and a list of elements, and apply the predicate to each element in the list. If the predicate returns `True` for an element, the element should be included in the output list; ot... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Callable
def predicate_map(predicate: Callable[[int], bool], elements: List[int]) -> List[int]:
"""
Filters the elements of a list based on a given predicate function.
Args:
predicate (Call... |
magic_instruct_75k | 50,090 | Write a Python function to automate the download of the latest episode of a web series. The function should extract the URL of the next episode from a given URL template and then download the episode if it is newer than the last downloaded episode. The function should also include debug print statements for monitoring ... | Here is the Python code to solve the given problem in the markdown block:
```python
import requests
def download_latest_episode(url_template: str, next_episode: int, num_videos: int, last_episode: int, regexp_result: str) -> None:
"""
Automates the download of the latest episode of a web series.
Args:
... |
magic_instruct_75k | 50,121 | Create a Python class `DataProcessor` that initializes its attributes based on provided parameters. The class should have the following attributes with default values:
- `dir_data`: a string representing the directory path for the data, default value is 'data/vqa2'
- `split`: a string representing the data split, defau... | Here is the Python code to solve the given problem in the markdown block:
```python
class DataProcessor:
def __init__(self,
dir_data='data/vqa2',
split='train',
batch_size=10,
nb_threads=4,
pin_memory=False,
shuffl... |
magic_instruct_75k | 50,123 | Write a Python function to simulate the behavior of a flag buffer `FlagBuf` manipulation based on a sequence of operations. The function should take the initial value of `FlagBuf` and a sequence of operations as input, and return the final value of `FlagBuf` after applying the operations.
The operations are represente... | Here is the Python code to solve the given problem in the markdown block:
```python
def simulateFlagBuffer(initialFlagBuf: int, operations: str) -> int:
"""
Simulate the manipulation of a flag buffer based on a sequence of operations.
Args:
initialFlagBuf (int): The initial value of the flag buffer... |
magic_instruct_75k | 50,149 | Write a Python function to generate an email message for a marketing campaign. The function should take the recipient's name and a list of email addresses as input and return a dictionary containing the email message details. The dictionary should include the following keys:
- 'Subject': A string formatted as "Karatbar... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def generate_email_message(name: str, addressees: List[str]) -> Dict[str, str]:
"""
Generates an email message for a marketing campaign.
Args:
name (str): The recipient's name.
... |
magic_instruct_75k | 50,150 | Write a Python function to convert a given duration string in the format "HH:MM:SS" or "MM:SS" to a standardized format "HH:MM:SS". The function should handle both formats and ensure that the output is always in the "HH:MM:SS" format.
The code should start with:
```python
def convert_duration_to_standard_format(durati... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_duration_to_standard_format(duration_text: str) -> str:
"""
Converts a given duration string in the format "HH:MM:SS" or "MM:SS" to a standardized "HH:MM:SS" format.
Args:
duration_text (str): The durati... |
magic_instruct_75k | 50,152 | Create a Python function to simulate a burst of network traffic based on a given Quality of Service (QoS) level and duration. The QoS level is represented by a series of comma-separated values, each indicating the desired bandwidth in kilobits per second (Kbps) for a specific time period in milliseconds. The function s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def simulate_network_burst(qos_levels: str) -> List[str]:
"""
Simulate a burst of network traffic based on the given QoS levels.
Args:
qos_levels (str): A string of comma-separated values re... |
magic_instruct_75k | 50,158 | Write a Python function to filter out disabled plugins from a list of available plugins based on a configuration setting. The function should take two parameters:
1. A list of tuples representing available plugins, where each tuple contains the category and name of the plugin. For example, `[(category1, name1), (catego... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Set
def initialize_enabled_plugins(available_plugins: List[Tuple[str, str]], disabled_plugins: Set[str]) -> List[Tuple[str, str]]:
"""
Filters out disabled plugins from a list of available plugin... |
magic_instruct_75k | 50,162 | Write a Python function to format a given string using ANSI escape codes based on a list of formatting options. The function should apply the formatting options in the order they appear in the list. If the same option is specified multiple times, it should be applied each time it appears. The function should handle the... | Here is the Python code to solve the given problem in the markdown block:
```python
def format_text(text: str, formatting_options: list) -> str:
"""
Formats the given text using ANSI escape codes based on the provided formatting options.
Args:
text (str): The text to be formatted.
formattin... |
magic_instruct_75k | 50,212 | Implement a Python class `StorableSource` that manages impression data in an advertising system. The class should store information about impressions, including their expiry time and origin. The class should enforce the following constraints:
1. The expiry time for an impression should not exceed 30 days from the time ... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime, timedelta
class StorableSource:
def __init__(self):
"""
Initialize the StorableSource class with attributes to store impression data.
"""
self.occurrence_time = None
... |
magic_instruct_75k | 50,218 | Write a Python function to retrieve all the grasps associated with the current object from a given database. The function should take two parameters:
- `data`: A dictionary containing information about the current object and shown grasps.
- `db`: An object representing the database storing object-to-grasps mappings.
T... | Here is the Python code to solve the given problem in the markdown block:
```python
def retrieve_grasps(data: dict, db: dict) -> list:
"""
Retrieves all the grasps associated with the current object from the database.
Args:
data (dict): A dictionary containing information about the current object a... |
magic_instruct_75k | 50,220 | Write a Python function to implement a hash table using separate chaining as the collision resolution technique. The hash table should support operations such as insertion, deletion, and retrieval of key-value pairs. The keys are strings, and the values are integers. The hash table should use a custom hash function to ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Optional
def hash_function(key: str, table_size: int) -> int:
"""
Custom hash function to map keys to indices in the hash table.
Args:
key: The string key to be hashed.
t... |
magic_instruct_75k | 50,263 | Write a Python function to process a list of integers and return a modified list based on the following rules:
1. If the number is divisible by 3, replace it with "Fizz".
2. If the number is divisible by 5, replace it with "Buzz".
3. If the number is divisible by both 3 and 5, replace it with "FizzBuzz".
4. If none of ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def fizz_buzz(numbers: List[int]) -> List[Union[int, str]]:
"""
Processes a list of integers and returns a modified list based on the following rules:
1. If the number is divisible by 3, repla... |
magic_instruct_75k | 50,272 | Write a Python function to process candidate end-effector poses for a robotic arm. The function should take a list of candidate poses, a function to sample inverse kinematics, and an optional collision checking function. The function should filter out configurations that result in collisions if the collision function i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Callable, Optional
def process_poses(candidate_poses: List, sample_ik_fn: Callable, collision_fn: Optional[Callable] = None, **kwargs) -> List:
"""
Process the candidate end-effector poses for a robotic... |
magic_instruct_75k | 50,283 | Write a Python function to parse and extract information from a configuration file in a specific format. The configuration file contains rules for identifying different types of web technologies and content management systems (CMS). Each rule consists of a type, text, and a list of entities. The type can be either "EQU... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def parse_configuration_file(config_file: List[Dict[str, Union[str, List[Dict[str, str]]]]]) -> Dict[str, List[str]]:
"""
Parses a configuration file and extracts rules and their correspondi... |
magic_instruct_75k | 50,307 | Write a Python function to extract the names of fields that are being altered in a list of database migration operations. Each migration operation is represented as a tuple containing the operation type, model name, and field name. The function should identify all "AlterField" operations and return a list of the field ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def extract_altered_fields(migration_operations: List[Tuple[str, str, str]]) -> List[str]:
"""
Extracts the names of fields that are being altered in a list of database migration operations.
... |
magic_instruct_75k | 50,328 | Write a Python function to filter a list of `UserRoleResources` based on provided criteria. The function should take in a list of `UserRoleResources` and return a filtered list based on the provided criteria. The criteria are passed as keyword arguments (`**kwargs`).
The function signature should be:
```python
def fil... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_user_role_resources(user_role_resources: List[dict], **kwargs) -> List[dict]:
"""
Filters a list of UserRoleResources based on provided criteria.
Args:
user_role_resources (List[d... |
magic_instruct_75k | 50,331 | Write a Python function to organize a list of `BatchDefinition` objects based on their `batch_identifiers`. Each `BatchDefinition` object contains information about the data source, data connector, data asset, and batch identifiers. The `batch_identifiers` are represented as a dictionary within the `BatchDefinition` ob... | Here is the Python code to solve the given problem in the markdown block:
```python
from collections import defaultdict
from typing import List, Dict
class BatchDefinition:
def __init__(self, datasource_name: str, data_connector_name: str, data_asset_name: str, batch_identifiers: Dict[str, int]):
self.data... |
magic_instruct_75k | 50,336 | Write a Python function to perform merge sort on a given list of integers. Merge sort is a divide-and-conquer algorithm that recursively divides the input list into smaller sublists until each sublist contains only one element. It then merges these sublists in a sorted manner to produce the final sorted list.
The func... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sort(arr: List[int]) -> List[int]:
"""
Sorts a list of integers using the merge sort algorithm.
Args:
arr (List[int]): The list of integers to be sorted.
Returns:
List... |
magic_instruct_75k | 50,338 | Write a Python function to calculate the maximum difference between any two numbers in a given list of integers. If the list contains less than two elements, the function should return 0. The function should be efficient and should handle edge cases appropriately.
The code should start with:
```python
from typing impo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_difference(input: List[int]) -> int:
"""
Calculate the maximum difference between any two numbers in the given list.
Args:
input (List[int]): The list of integers from which to find ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.