source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_instruct_75k | 70,212 | Write a Python function `is_bijective(lst: List[int]) -> bool` that determines whether the input list `lst` represents a bijective function. A bijective function is a function where each element in the domain is paired with exactly one element in the codomain, and each element in the codomain is paired with exactly one... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_bijective(lst: List[int]) -> bool:
"""
Determines whether the input list represents a bijective function.
A bijective function is a function where each element in the domain is paired with ex... |
magic_instruct_75k | 70,229 | Write a Python function to calculate the sum of all integer values in a given dictionary. The dictionary contains various operations as keys and their corresponding results as values. Some of the results are integers, while others are strings. The function should iterate through the dictionary values, filter out the in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def calculate_result_sum(results: Dict[str, int]) -> int:
"""
Calculate the sum of all integer values in the given dictionary.
Args:
results (Dict[str, int]): A dictionary where keys are ope... |
magic_instruct_75k | 70,231 | Write a Python function to adjust game sector coordinates based on the given rules. The game coordinates are 0-based, and you need to implement a function to adjust the sector coordinates based on the given rules. The function should take the original sector coordinates (`sectorX` and `sectorY`) and the number of rows ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
def adjustCoordinates(sectorX: int, sectorY: int, QUADRANT_ROWS: int) -> Tuple[int, int]:
"""
Adjusts the game sector coordinates based on the given rules.
Args:
sectorX (int): The original... |
magic_instruct_75k | 70,250 | Write a Python function to generate sysctl configuration lines based on the total amount of RAM on a system. The function should allow up to 50% of physical memory to be allocated into shared memory. The sysctl configuration lines should set the kernel parameters `shmmax` and `shmall` based on the total RAM. The functi... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_sysctl_config(total_ram: int) -> str:
"""
Generates sysctl configuration lines based on the total amount of RAM.
Args:
total_ram (int): The total amount of RAM in bytes.
Returns:
str: The s... |
magic_instruct_75k | 70,287 | Write a Python function to extract specific details from a given string containing repository information. The repository information is in the following format:
```
<reponame><seelang2>/ClassArchive<gh_stars>0
```
Where:
- `<reponame>`: Represents the name of the repository.
- `<seelang2>`: Represents the programming ... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_repository_details(repo_info: str) -> dict:
"""
Extracts the repository name, programming language, and number of stars from a given repository information string.
Args:
repo_info (str): The repository i... |
magic_instruct_75k | 70,289 | Write a Python function to calculate the product of all elements in an iterable, with an optional `start` parameter that represents the initial value for the product calculation. The function should be implemented using the `reduce` function from the `functools` module and the `mul` function from the `operator` module.... | Here is the Python code to solve the given problem in the markdown block:
```python
from functools import reduce
from operator import mul
def product(iterable=(), start=1):
"""
Calculate the product of all elements in an iterable, starting with an optional initial value.
Args:
iterable (iterable, ... |
magic_instruct_75k | 70,304 | Write a Python function to count the number of unique ontologies for each URI prefix in a given set of synonym label URIs. The URI prefix is defined as the part of the URI before the first '#' character. The function should return a dictionary where the keys are the URI prefixes and the values are the count of unique o... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Set, Dict
def count_uri_prefixes(synonymLabelURIs: Set[str]) -> Dict[str, int]:
"""
Count the number of unique ontologies for each URI prefix in a given set of synonym label URIs.
Args:
synonymLa... |
magic_instruct_75k | 70,324 | Write a Python function to process a list of URL patterns and extract the view names associated with each URL. The URL patterns are provided in the format `(regex_pattern, view_name)`. Your function should return a dictionary where the keys are the unique view names and the values are lists of corresponding URL pattern... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def extract_view_names(url_patterns: List[Tuple[str, str]]) -> Dict[str, List[str]]:
"""
Processes a list of URL patterns and extracts the view names associated with each URL.
Args:
... |
magic_instruct_75k | 70,339 | Write a Python function to automate the process of waiting for a Fuseki server to become available before executing further commands. The function should continuously check if the Fuseki server is available using the `socket` module. If the server is not available, the function should sleep for a short duration and the... | Here is the Python code to solve the given problem in the markdown block:
```python
import socket
import time
import os
def wait_for_fuseki_server() -> None:
"""
Waits for the Fuseki server to become available before executing further commands.
This function continuously checks if the Fuseki server is ava... |
magic_instruct_75k | 70,343 | Write a Python function to validate whether a given string is a valid email address according to the specified format. The function should return `True` if the email is valid and `False` otherwise. The email format should adhere to the following rules:
- The username can contain letters, numbers, periods (`.`), hyphens... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_valid_email(email: str) -> bool:
"""
Validates whether the given string is a valid email address according to the specified format.
Args:
email (str): The email address to validate.
Returns:
... |
magic_instruct_75k | 70,352 | Write a Python function to manage stock trading orders based on the market condition. The function should close all buy orders if the market is bearish, and close all sell orders if the market is bullish. The function should take a list of orders and a boolean indicating the market condition as input and return the upd... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def close_all_orders(orders: List[int], market_bearish: bool) -> List[int]:
"""
Manages stock trading orders based on the market condition.
Args:
orders (List[int]): A list of integers repre... |
magic_instruct_75k | 70,358 | Create a Python program that simulates a simple traffic light system. The traffic light should cycle through the following states: Green, Yellow, and Red, with each state lasting for a specific duration. Your program should use multithreading to control the timing of each state transition.
Your task is to implement th... | Here is the Python code to solve the given problem in the markdown block:
```python
import threading
import time
class TrafficLight:
"""
A class to simulate a traffic light system using multithreading.
The traffic light cycles through the states: Green, Yellow, and Red,
with each state lasting for a s... |
magic_instruct_75k | 70,359 | Write a Python function to validate longitude strings according to the given rules. A longitude string is considered valid if it represents a number between -180 and 180, inclusive, and is followed by either "E" for East or "W" for West. The longitude number can be an integer or a decimal number with up to 6 decimal pl... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_longitude(longitude: str) -> bool:
"""
Validates if the given string represents a valid longitude.
A valid longitude string should:
1. Consist of a number between -180 and 180, inclusive.
2. ... |
magic_instruct_75k | 70,380 | Write a Python script that analyzes the performance of a system based on a set of test results. The script should take command-line arguments to determine the output file and the option for the analysis. The script should have the following functionality:
- If the command-line argument is "new", set the `option` variab... | Here is the Python code to solve the given problem in the markdown block:
```python
import sys
def analyze_performance():
"""
Analyzes the performance of a system based on command-line arguments.
The function sets the option variable based on the command-line argument:
- If the argument is "new", the ... |
magic_instruct_75k | 70,383 | Write a Python function to compare two lists of floating-point numbers and determine if they are approximately equal. The function should return `True` if the two lists have the same length and each pair of corresponding elements is either both `NaN` or both not `NaN`. If any pair of corresponding elements contains a `... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
from typing import List
def compare_float_lists(got: List[float], expected: List[float]) -> bool:
"""
Compare two lists of floating-point numbers to determine if they are approximately equal.
The function retur... |
magic_instruct_75k | 70,395 | Write a Python function to automate the process of generating and publishing code coverage reports for multiple modules in a Java project. The function should iterate through a list of module names, check for the existence of a specific code coverage report file for each module, and if found, publish the report using a... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import os
import subprocess
def publish_code_coverage_reports(modules: List[str], project_token: str) -> None:
"""
Automates the process of generating and publishing code coverage reports for multiple mo... |
magic_instruct_75k | 70,397 | Write a Python function to generate a Bash script for submitting a computational job to a high-performance computing (HPC) cluster using the Slurm workload manager. The script should set the necessary parameters for the job, load a required module, and specify an email address for job notifications. The function should... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_slurm_script(nodes: int, tasks_per_node: int, runtime: int, partition: str, job_name: str, email: str, module_name: str) -> str:
"""
Generates a Bash script for submitting a computational job to an HPC cluster using... |
magic_instruct_75k | 70,400 | Write a Python function to calculate the time period for different types of stars based on the provided conditions. The function should take the following parameters:
- `periodos` (list): A list of time periods for different stars.
- `tipo_estrella` (string): The type of star.
- `N_mult_fnP` (list): A list of numerical... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_time_period(periodos, tipo_estrella, N_mult_fnP, k, numero_estrella, label_path, extension):
"""
Calculate the time period for a specific type of star based on given conditions.
Args:
periodos (list): ... |
magic_instruct_75k | 70,401 | Implement a Python class `FileStore` that simulates a simple file store system. The file store should support the following operations:
1. **Adding files**: Add a file to the file store. If the file already exists, print a message indicating that the file already exists.
2. **Removing files**: Remove a file from the fi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
class FileStore:
"""
A class to simulate a simple file store system.
Attributes:
files (dict): A dictionary to store file names as keys and their access counts as values.
Methods:
... |
magic_instruct_75k | 70,403 | Write a Python function to extract names and ages from a given text and organize them into a dictionary. The text contains details about a family gathering, including the ages and names of the attendees. Each line in the text follows one of the following formats:
1. `<NAME>, <AGE>`
2. `<RELATION> <NAME>, <AGE>`
Where:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
import re
def extract_names_and_ages(text: str) -> Dict[str, int]:
"""
Extracts names and ages from a given text and organizes them into a dictionary.
Args:
text (str): The input text contai... |
magic_instruct_75k | 70,414 | Write a Python function `process_entities(words, netags)` that processes a sequence of words and their corresponding named entity tags. The function should identify and extract specific information based on the given rules. The function should take in two lists:
- `words`: a list of word objects, where each word object... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, NamedTuple
class Word(NamedTuple):
lemma: str
def process_entities(words: List[Word], netags: List[str]) -> str:
"""
Processes a sequence of words and their corresponding named entity tags to extra... |
magic_instruct_75k | 70,416 | Write a Python function to count the occurrences of each unique license type in a given list of software licenses. Each license is represented by a string, and the function should return a dictionary where the keys are the unique license types and the values are the counts of each license type in the input list. The fu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_license_types(licenses: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of each unique license type in a given list of software licenses.
Args:
licenses (List[str]):... |
magic_instruct_75k | 70,417 | Write a Python function to update user information based on provided keyword arguments. The function should take an existing user item represented as a dictionary and a set of keyword arguments. It should return a dictionary containing the updated user information. If a keyword argument is not provided, the function sh... | Here is the Python code to solve the given problem in the markdown block:
```python
def update_user_info(item: dict, **kwargs) -> dict:
"""
Updates user information based on the provided keyword arguments.
Args:
item (dict): A dictionary representing the user item with keys "id", "username", "email... |
magic_instruct_75k | 70,430 | Write a Python function to extract the conditions that must be met for redistribution and use from a given software license text. The license text is provided as a string, and the conditions are specified after the phrase "the following conditions are met:". The conditions are listed as bullet points, each starting wit... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_license_conditions(license_text: str) -> List[str]:
"""
Extracts the conditions that must be met for redistribution and use from a given software license text.
Args:
license_text... |
magic_instruct_75k | 70,437 | Write a Python function to generate a script for automating the installation process of a software package. The script should include commands for configuring, building, and installing the software package, taking into account the installation prefix, the prefix for the PCRE library, and the number of CPU cores availab... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_installation_script(prefix: str, pcre_prefix: str, cpu_count: int) -> str:
"""
Generates a script for automating the installation process of a software package.
The script includes commands for configuring, bui... |
magic_instruct_75k | 70,439 | Write a Python function `process_unitaries(chars_batch: List[str]) -> Tuple[List[int], List[int]]` that processes a list of strings `chars_batch`. Each string in `chars_batch` represents a sequence of characters, where each character corresponds to a unitary operation on a quantum spin. The function should iterate thro... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def process_unitaries(chars_batch: List[str]) -> Tuple[List[int], List[int]]:
"""
Processes a list of strings and returns two lists of indices based on the characters.
Args:
chars_bat... |
magic_instruct_75k | 70,457 | Write a Python function to process a given text by removing all leading and trailing whitespace characters, as well as leading and trailing newline characters. The function should return the processed text.
The code should start with:
```python
def process_text(text: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def process_text(text: str) -> str:
"""
Processes the input text by removing all leading and trailing whitespace characters,
as well as leading and trailing newline characters.
Args:
text (str): The input text t... |
magic_instruct_75k | 70,462 | Write a Python function to process a list of tuples representing TV show data and return a dictionary containing specific information about the shows. Each tuple in the input list represents a TV show and contains the following information: `(show_type, title, data)`.
The `show_type` can be one of the following string... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def process_tv_shows(data: List[Tuple[str, str, str]]) -> Dict[str, Dict[str, int]]:
"""
Processes a list of tuples representing TV show data and returns a dictionary
containing the coun... |
magic_instruct_75k | 70,464 | Write a Python function to count the number of set bits (binary 1s) in the binary representation of a given non-negative integer `A`. The function should efficiently count the set bits using bitwise operations.
The code should start with:
```python
def count_set_bits(A: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_set_bits(A: int) -> int:
"""
Counts the number of set bits (binary 1s) in the binary representation of a given non-negative integer `A`.
Args:
A (int): The non-negative integer whose set bits are to be cou... |
magic_instruct_75k | 70,472 | Write a Python function to simulate rolling a specified number of dice with a given number of sides and return the total sum of the rolled values. The function should handle invalid inputs gracefully and return an appropriate error message if the number of dice or the number of sides is not a positive integer.
The cod... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
def roll_dice(num_dice: int, num_sides: int) -> int:
"""
Simulates rolling a specified number of dice with a given number of sides and returns the total sum of the rolled values.
Args:
num_dice (int):... |
magic_instruct_75k | 70,480 | Write a Python function to organize a list of attachment IDs into a dictionary where the keys are the mailing IDs and the values are lists of attachment IDs associated with each mailing. The input is a list of tuples, where each tuple contains a mailing ID and an attachment ID. The function should return a dictionary w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def organize_attachments(attachment_ids: List[Tuple[int, int]]) -> Dict[int, List[int]]:
"""
Organizes a list of attachment IDs into a dictionary where the keys are the mailing IDs
and t... |
magic_instruct_75k | 70,497 | Write a Python function to implement the quicksort algorithm. The function should take an array `arr` and the indices `l` and `r` representing the left and right boundaries of the sub-array to be sorted. Additionally, implement the `partition` function that is called by `quicksort` to partition the array. The `partitio... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def quicksort(arr: List[int], l: int, r: int) -> List[int]:
"""
Sorts the given array in non-decreasing order using the quicksort algorithm.
Args:
arr (List[int]): The array to be sorted.
... |
magic_instruct_75k | 70,508 | Write a Python function to perform counting sort on a given array of integers. Counting sort is an efficient algorithm for sorting a collection of objects according to keys that are small integers. The algorithm works by counting the number of occurrences of each unique element in the input array and using this informa... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def counting_sort(arr: List[int]) -> List[int]:
"""
Sorts the input array of integers using the counting sort algorithm.
Args:
arr (List[int]): The input array of integers to be sorted.
... |
magic_instruct_75k | 70,517 | Create a Python function to implement a simple HTTP server that listens on a specified port and responds to incoming GET requests for a specific endpoint with a predefined message. The server should be able to handle basic HTTP GET requests and return a response with the appropriate status code and content.
The code s... | Here is the Python code to solve the given problem in the markdown block:
```python
import socket
def start_http_server(port: int, endpoint: str, message: str) -> None:
"""
Starts a simple HTTP server that listens on the specified port and responds to GET requests
for a specific endpoint with a predefined ... |
magic_instruct_75k | 70,530 | Write a Python function to securely send a shared symmetric key from a driver to multiple enclaves after attestation succeeds. The function should ensure that the key is sent and stored securely within the enclaves. The shared key is represented as an array of unsigned characters, and its size is defined as `CIPHER_KEY... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sendSharedKeyToEnclaves(shared_key: List[int], CIPHER_KEY_SIZE: int) -> None:
"""
Securely sends the shared symmetric key from the driver to the enclaves after attestation succeeds.
Args:
... |
magic_instruct_75k | 70,566 | Write a Python function to simulate the file download and processing steps as described in the given code snippet. Specifically, the function should:
1. Print the values of four variables: `bam_to_call`, `chrom_sizes`, `hotspot_mappable`, and `minor_chroms`.
2. Extract the root name of the BAM file from its path and do... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
def process_dna_files(bam_to_call: str, chrom_sizes: str, hotspot_mappable: bool, minor_chroms: bool):
"""
Simulates the file download and processing steps for DNA sequencing data.
Args:
bam_to_call (str)... |
magic_instruct_75k | 70,568 | Implement a Python function `get_next_values` that simulates a reinforcement learning algorithm. The function should take three parameters: a dictionary `C`, a string `B`, and a string `A`. The dictionary `C` contains a key "q_value" with a value of `A`. The function should also use a `ref_model` attribute with a `valu... | Here is the Python code to solve the given problem in the markdown block:
```python
def get_next_values(C: dict, B: str, A: str) -> tuple:
"""
Simulates a reinforcement learning algorithm by returning a tuple containing the value of "q_value" from the dictionary `C`,
the string `B`, and the string `A` in re... |
magic_instruct_75k | 70,576 | Write a Python function to remove all occurrences of a specified character from a given string. The function should not use any built-in string manipulation functions. The code should start with:
```python
def remove_all(s: str, c: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def remove_all(s: str, c: str) -> str:
"""
Removes all occurrences of the specified character `c` from the string `s`.
Args:
s (str): The input string from which to remove the character.
c (str): The charact... |
magic_instruct_75k | 70,592 | Create a Python class `ImportSpecialPersonnelRequest` that manages requests for importing special personnel data into a system. The class should have the following methods:
1. A method `set_body_parameter` that takes a list of integers representing store IDs and sets the private member variable `store_ids_` accordingly... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
class ImportSpecialPersonnelRequest:
"""
A class to manage requests for importing special personnel data into a system.
Attributes:
__store_ids_ (List[int]): A private member variable to sto... |
magic_instruct_75k | 70,607 | Write a Python function to calculate the total alignment score of a given 2D numpy array `cleanarr`. Each element in the array represents the score of aligning the corresponding sequences at that position. The total alignment score is the sum of the scores of all cells in the alignment matrix.
The code should start wi... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def calculate_alignment_score(cleanarr: np.ndarray) -> int:
"""
Calculate the total alignment score of a given 2D numpy array.
Args:
cleanarr (np.ndarray): A 2D numpy array where each element rep... |
magic_instruct_75k | 70,638 | Write a Python function to generate a CORS (Cross-Origin Resource Sharing) middleware configuration for a web application framework. The function should take in the allowed origins, credentials, methods, and headers as input and return the middleware configuration as a dictionary. The middleware configuration should in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def generate_cors_middleware(allow_origins: List[str], allow_credentials: bool, allow_methods: List[str], allow_headers: List[str]) -> Dict[str, Union[List[str], bool]]:
"""
Generates a CORS... |
magic_instruct_75k | 70,641 | Write a Python function to calculate the dual norm of a given vector. The dual norm of a vector \( x \) in a vector space is defined as the supremum of the dot product of \( x \) and any vector \( y \) in the space, such that the norm of \( y \) is less than or equal to 1. In other words, the dual norm of \( x \) is th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import numpy as np
def dual_norm(vector: List[float]) -> float:
"""
Calculate the dual norm of a given vector.
The dual norm of a vector x is defined as the supremum of the dot product of x and any ... |
magic_instruct_75k | 70,646 | Write a Python function `generate_report(teams)` that processes a list of team dictionaries to generate a report. Each team dictionary contains the following keys: "id" (team ID), "score" (team's base score), and "taskStats" (a list of dictionaries representing task statistics). Each task statistic dictionary contains ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def generate_report(teams: List[Dict[str, Union[int, str, List[Dict[str, Union[str, int]]]]]]) -> List[Dict[str, Union[int, str, float]]]:
"""
Generates a report from a list of team dictiona... |
magic_instruct_75k | 70,690 | Write a Python function to generate a file path for storing training results in a specific directory. The file name should include various parameters such as date and time, name, iterations, maximum epochs for negative log likelihood (NLL) and mean absolute error (MAE), and patience for NLL and MAE. The function should... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
def generate_file_path(directory: str, name: str, iterations: int, max_epochs_nll: int, max_epochs_mae: int, patience_nll: int, patience_mae: int) -> str:
"""
Generates a file path for storing trai... |
magic_instruct_75k | 70,698 | Write a Python function to perform a Caesar cipher encryption on a given line of text. The Caesar cipher is a simple substitution cipher where each letter in the plaintext is shifted a certain number of places down or up the alphabet. The function should handle both uppercase and lowercase letters and ignore any non-al... | Here is the Python code to solve the given problem in the markdown block:
```python
def caesar_cipher(text: str, shift: int) -> str:
"""
Encrypts a given line of text using a Caesar cipher with the specified shift value.
Args:
text (str): The line of text to be encrypted.
shift (int): The n... |
magic_instruct_75k | 70,712 | Write a Python function to parse a custom configuration file format. The configuration file consists of sections and key-value pairs. Each section is denoted by square brackets, and key-value pairs are separated by an equal sign. The function should read and extract the key-value pairs from the configuration file and r... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def parse_config(config_content: str) -> Dict[str, Dict[str, str]]:
"""
Parses a custom configuration file format and returns a dictionary containing the parsed key-value pairs.
Args:
config... |
magic_instruct_75k | 70,731 | Implement a URL matching and content setting retrieval system in Python. The system should iterate through a collection of rules, each consisting of a primary URL pattern, a secondary URL pattern, and a corresponding content setting. The primary and secondary URL patterns are used to match against given primary and sec... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
class Pattern:
def __init__(self, pattern: str):
self.pattern = pattern
def matches(self, url: str) -> bool:
"""
Check if the given URL matches the pattern.
Ar... |
magic_instruct_75k | 70,741 | Write a Python function `calculate_total_setup_rate` that takes in a dictionary `expected_flow_setup_rate` and returns a dictionary with the total expected flow setup rates for 'policy' and 'nat' configurations. The input dictionary contains two sub-dictionaries: 'policy' and 'nat', each with flow setup rates for diffe... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_total_setup_rate(expected_flow_setup_rate: dict) -> dict:
"""
Calculate the total expected flow setup rates for 'policy' and 'nat' configurations.
Args:
expected_flow_setup_rate (dict): A dictionary co... |
magic_instruct_75k | 70,755 | Write a Python function to count the number of elements in a given list of integers that are greater than their preceding element. The function should return a tuple containing the count of such elements and the total number of elements processed.
The code should start with:
```python
from typing import List, Tuple
d... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def count_greater_elements(arr: List[int]) -> Tuple[int, int]:
"""
Counts the number of elements in the list that are greater than their preceding element.
Args:
arr (List[int]): A li... |
magic_instruct_75k | 70,758 | Write a Python function to determine the valid loading order of modules in a software system, given a list of modules and their dependencies. Each module has a name and may depend on other modules. The function should ensure that all dependencies are satisfied before loading a module.
The function should start with:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def module_loading_order(modules: List[str], dependencies: List[Tuple[str, str]]) -> List[str]:
"""
Determine the valid loading order of modules in a software system, ensuring all dependencies are... |
magic_instruct_75k | 70,761 | Write a Python function to process a list of strings and populate a dictionary `g` and a list `table`. The function should split each string into two parts, update the dictionary `g` with the first part as the key and the second part as the value, and ensure that both parts are added to the list `table` if they are not... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def process_input(input_list: List[str]) -> None:
"""
Processes a list of strings and populates a dictionary `g` and a list `table`.
The function splits each string into two parts, updates the ... |
magic_instruct_75k | 70,765 | Write a Python function to find the indices of the minimum and maximum values for both x and y coordinates in a 2D array of integers. The function should return a tuple containing four integers: the indices of the minimum x-coordinate, maximum x-coordinate, minimum y-coordinate, and maximum y-coordinate. If the input a... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_min_max_indices(arr: List[List[int]]) -> Tuple[int, int, int, int]:
"""
Find the indices of the minimum and maximum values for both x and y coordinates in a 2D array.
Args:
a... |
magic_instruct_75k | 70,818 | Write a Python function to find the index of the leftmost unique character in a given string. If there are no unique characters, the function should return -1. The function should be efficient and should handle strings of varying lengths.
The code should start with:
```python
def first_unique_char_index(s: str) -> int... | Here is the Python code to solve the given problem in the markdown block:
```python
from collections import defaultdict
def first_unique_char_index(s: str) -> int:
"""
Find the index of the leftmost unique character in the given string.
Args:
s (str): The input string consisting of lowercase Engli... |
magic_instruct_75k | 70,835 | Write a Python function `sort_skus(stock_data: List[str]) -> List[str]` that takes a list of strings `stock_data`, where each string represents a line of the stock data file in the format "SKU\tInformation", and returns a sorted list of SKUs. The function should handle the input data by splitting each line on the tab c... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_skus(stock_data: List[str]) -> List[str]:
"""
Sorts the SKUs from a list of tab-separated strings representing stock data.
Args:
stock_data (List[str]): A list of strings where each... |
magic_instruct_75k | 70,840 | Write a Python function to simulate the behavior of a command processing system for a graphics application. The system processes different types of commands, each with its own specific functionality. Your goal is to implement a function that processes a series of commands and updates the data pointer accordingly.
The ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_commands(commands: List[int], dptr: int) -> int:
"""
Processes a series of command codes and updates the data pointer accordingly.
Args:
commands (List[int]): A list of command c... |
magic_instruct_75k | 70,844 | Write a Python function to organize a list of vendor libraries into a hierarchical structure based on their dependencies. Each library is represented as a string in the format 'vendor/library', and the dependencies are listed in the input list. The function should return a nested dictionary that represents the dependen... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def organize_libraries(libs: List[str]) -> Dict:
"""
Organizes a list of vendor libraries into a hierarchical structure based on their dependencies.
Args:
libs (List[str]): A list of s... |
magic_instruct_75k | 70,849 | Write a Python function `merge_stats` that takes two dictionaries, `unit_stats` and `defensive_building_stats`, as input. These dictionaries contain statistics for units and defensive buildings, respectively. Each dictionary has keys representing the names of the units or defensive buildings and values representing the... | Here is the Python code to solve the given problem in the markdown block:
```python
def merge_stats(unit_stats: dict, defensive_building_stats: dict) -> dict:
"""
Merges two dictionaries containing unit and defensive building statistics into a single dictionary.
If a unit and a defensive building share the ... |
magic_instruct_75k | 70,886 | Implement the `bp_fit` function to train a neural network using the backpropagation algorithm. The function should take the following parameters:
- `c`: a tuple representing the number of nodes in each layer of the neural network
- `X_train`: the input training data
- `y_train`: the target training data
- `lr`: the lea... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def sigmoid(x):
"""Sigmoid activation function."""
return 1 / (1 + np.exp(-x))
def sigmoid_derivative(x):
"""Derivative of the sigmoid function."""
return x * (1 - x)
def bp_fit(c, X_train, y_train,... |
magic_instruct_75k | 70,889 | Write a Python function to determine if a given string is a valid IPv4 address. An IPv4 address is a string that consists of four decimal numbers, each ranging from 0 to 255, separated by dots. The function should return `True` if the string is a valid IPv4 address, and `False` otherwise.
The code should start with:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_valid_ipv4(ip: str) -> bool:
"""
Determines if the given string is a valid IPv4 address.
Args:
ip (str): The string to check for IPv4 validity.
Returns:
bool: True if the string is a valid IPv4 a... |
magic_instruct_75k | 70,920 | Write a Python function to calculate the average review scores rating for vehicles with a company rating of 1 from a given list of vehicle objects. Each vehicle object is represented as a dictionary with the following properties:
- "engines": the number of engines the vehicle has
- "passenger_capacity": the maximum num... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def average_review_score_for_company_rating_one(vehicles: List[Dict[str, Union[int, float]]]) -> float:
"""
Calculate the average review scores rating for vehicles with a company rating of 1... |
magic_instruct_75k | 70,928 | Write a Python function `get_dashboard_data(db)` that retrieves the required data from a database and organizes it for display on a web application. The function should take a database connection `db` as input and return a dictionary with the following keys:
- "latest_posts": a list of dictionaries containing the `id`,... | Here is the Python code to solve the given problem in the markdown block:
```python
def get_dashboard_data(db):
"""
Retrieves and organizes data from the database for display on a web application dashboard.
Args:
db: A database connection object that provides a `select` method to query tables.
... |
magic_instruct_75k | 70,938 | Write a Python function to create a new Mach-O section based on the given specifications. The function should handle both 32-bit and 64-bit Mach-O files and set the properties of the new section accordingly. The function should take in the following parameters:
- `new_segment`: An object representing the new segment wi... | Here is the Python code to solve the given problem in the markdown block:
```python
def create_new_macho_section(new_segment, vmaddr, INJECTION_SECTION_NAME, is_64_bit, section_64, section):
"""
Creates a new Mach-O section based on the given specifications.
Args:
new_segment: An object representin... |
magic_instruct_75k | 70,955 | Write a Python function `moduleControllerMapping` that takes in a list of module configurations and returns a mapping of modules to their respective controllers. Each module configuration is a dictionary containing two keys: `'imports'` (a list of module names) and `'controllers'` (a list of controller names associated... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def moduleControllerMapping(module_configurations: List[Dict[str, Union[str, List[str]]]]) -> Dict[str, List[str]]:
"""
Creates a mapping of modules to their respective controllers based on ... |
magic_instruct_75k | 70,964 | Write a Python function to find the maximum product of any three numbers in a given list of integers. If the input list contains less than three integers, the function should return 0. The function should be efficient and avoid sorting the list, as sorting can be computationally expensive for large lists.
The code sho... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_product_of_three(nums: List[int]) -> int:
"""
Calculate the maximum product of any three numbers in the given list.
Args:
nums (List[int]): The list of integers from which to find th... |
magic_instruct_75k | 70,974 | Write a Python function to validate postal codes based on specific criteria. A valid postal code must adhere to the following rules:
1. The postal code must be exactly 6 characters long.
2. The first three characters must be digits.
3. The last three characters must be uppercase letters.
The function should start with... | Here is the Python code to solve the given problem in the markdown block:
```python
def validate_postal_code(postal_code: str) -> bool:
"""
Validates a postal code based on specific criteria.
Args:
postal_code (str): The postal code to be validated.
Returns:
bool: True if the postal co... |
magic_instruct_75k | 70,983 | Write a Python function to calculate the greatest common divisor (GCD) of two positive integers using the Euclidean algorithm. The function should take two positive integers as input and return their GCD. The Euclidean algorithm is an efficient method for finding the GCD of two numbers.
The code should start with:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
def gcd_euclidean(a: int, b: int) -> int:
"""
Calculate the greatest common divisor (GCD) of two positive integers using the Euclidean algorithm.
Args:
a (int): The first positive integer.
b (int): The secon... |
magic_instruct_75k | 70,995 | Write a Python function to determine if a given HTML document is properly structured. The function should ensure that all HTML tags are properly nested and closed in the correct order. The function should handle only well-formed HTML without attributes or self-closing tags.
The code should start with:
```python
def is... | Here is the Python code to solve the given problem in the markdown block:
```python
def isProperlyStructuredHTML(html: str) -> bool:
"""
Determines if a given HTML document is properly structured.
Args:
html (str): A string representing the HTML document.
Returns:
bool: True if the HTM... |
magic_instruct_75k | 70,998 | Write a Python function to optimize the manipulation of a message string `msgP` by replacing specific substrings with other substrings. The function should handle a list of replacement pairs efficiently and ensure that the replacements are performed correctly. 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, Tuple
def optimize_message(msgP: str, colors_array: List[Tuple[str, str]]) -> str:
"""
Optimizes the manipulation of a message string by replacing specific substrings with other substrings.
Args:
... |
magic_instruct_75k | 71,012 | Write a Python function to process a series of commands that manipulate a list of excluded letters. The function should support the following command:
1. "r <letter>": Remove the specified letter from the list of excluded letters.
The function should ignore any attempt to remove a letter that is not currently in the ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_commands(commands: List[str], excluded_letters: List[str]) -> List[str]:
"""
Process a series of commands to manipulate a list of excluded letters.
The function supports the following co... |
magic_instruct_75k | 71,041 | Write a Python function to determine the minimum power of 2 or 5 that divides a given positive integer `n` evenly. If `n` is not divisible by either 2 or 5, the function should return 0. The function should be efficient and handle large values of `n`.
The code should start with:
```python
def min_power_of_2_or_5(n: in... | Here is the Python code to solve the given problem in the markdown block:
```python
def min_power_of_2_or_5(n: int) -> int:
"""
Determine the minimum power of 2 or 5 that divides the given positive integer `n` evenly.
Args:
n (int): The positive integer to be factorized.
Returns:
int: ... |
magic_instruct_75k | 71,045 | Write a Python function `process_webhook_input` that processes input from a webhook and performs specific actions based on the input. The function should handle various input scenarios and ensure that the required input is present and correctly formatted. The function should take in three parameters:
1. `webhook` (stri... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_webhook_input(webhook: str, secret: str = None, count: str = None) -> tuple:
"""
Processes webhook input and performs specific actions based on the input.
Args:
webhook (str): The webhook input received ... |
magic_instruct_75k | 71,086 | Write a Python function to remove duplicate cities from a list based on their population values. Each city is represented as a tuple containing the city name and its population. The function should return a new list with duplicate population values removed, keeping only the first occurrence of each unique population va... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def remove_duplicate_cities(cities: List[Tuple[str, int]]) -> List[Tuple[str, int]]:
"""
Removes duplicate cities from a list based on their population values.
Args:
cities (List[Tupl... |
magic_instruct_75k | 71,089 | Design a Python class to manage resource data with the ability to add, retrieve, and replace resource data based on specific criteria. The resource data is defined by a combination of `type`, `id`, and `lang` attributes. When new resource data is added, it should replace any existing data with the same values for `type... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
class ResourceManager:
def __init__(self):
"""
Initialize the ResourceManager with an empty dictionary to store resource data.
"""
self.resource_data = {}
def add_o... |
magic_instruct_75k | 71,100 | Write a Python function to process the content of a file received from a client in a client-server architecture. The function should perform the following tasks:
1. Count the total number of words in the file content.
2. Calculate the frequency of each word in the file content.
The function should return a dictionary ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def process_file_content(file_content: str) -> Dict[str, int]:
"""
Processes the content of a file received from a client by counting the total number of words and calculating the frequency of each word.... |
magic_instruct_75k | 71,125 | Write a Python function to count the occurrences of each word in a given input string. The function should handle both single and double quotation marks and should be case-insensitive. For example, the input `"First: don't laugh. Then: don't cry."` should produce the following word count:
- first: 1
- don't: 2
- laugh:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
import re
def word_count(input_string: str) -> Dict[str, int]:
"""
Count the occurrences of each word in a given input string.
The function handles both single and double quotation marks and is case... |
magic_instruct_75k | 71,178 | Write a Python function to convert a dictionary of coordinate reference systems (CRS) with their corresponding parameters into a new dictionary containing the CRS names and their corresponding ellipsoid parameters. The ellipsoid parameters are represented as a tuple (a, b), where 'a' and 'b' are the semi-major and semi... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_to_ellipsoid_params(crs_dict: dict) -> dict:
"""
Converts a dictionary of CRS parameters into a dictionary of ellipsoid parameters.
Args:
crs_dict (dict): A dictionary where each key is a string represen... |
magic_instruct_75k | 71,179 | Write a Python function to extract specific information from a given dictionary representing a test case for a doctest. The dictionary contains information about the test case, including the code to be executed, whether it's hidden or locked, and other metadata. The function should return a tuple containing the values ... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_test_case_info(test_case_dict: dict) -> tuple:
"""
Extracts and returns specific information from a dictionary representing a test case for a doctest.
Args:
test_case_dict (dict): A dictionary containing... |
magic_instruct_75k | 71,184 | Write a Python function `filter_docker_contexts(contexts)` that processes a dictionary of Docker contexts and returns a list of context names for which the `docker_cli` attribute is set to `True`. The input dictionary `contexts` contains Docker context names as keys and corresponding attributes as values. Each attribut... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def filter_docker_contexts(contexts: Dict[str, Dict[str, bool]]) -> List[str]:
"""
Filters a dictionary of Docker contexts and returns a list of context names for which the `docker_cli` attribute i... |
magic_instruct_75k | 71,185 | Write a Python function to identify and return a list of network interfaces that are in an "up" status but have their protocol status set to "down". The input to the function will be a dictionary where the keys are interface names and the values are dictionaries containing various attributes such as IP address, status,... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def find_interfaces_with_protocol_down(interface_status_data: Dict[str, Dict[str, str]]) -> List[str]:
"""
Identify and return a list of network interfaces that are in an "up" status but have their... |
magic_instruct_75k | 71,195 | Write a Python function `generate_specialized_specifications(arity)` that takes an integer `arity` as input and returns a list of specialized specifications based on the given arity. The function should follow specific rules for generating the specialized specifications, including type declarations, module inclusions, ... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_specialized_specifications(arity: int) -> list:
"""
Generates specialized specifications based on the given arity.
Args:
arity (int): The number of arguments for the type declaration.
Returns:
... |
magic_instruct_75k | 71,218 | Write a Python function to calculate the average value for each metric from a list of dictionaries. Each dictionary in the list represents the metrics and their values for a specific iteration. The function should return a dictionary with the metric names as keys and their average values as the corresponding values.
T... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def calculate_average_metrics(metrics_data: List[Dict[str, int]]) -> Dict[str, float]:
"""
Calculate the average value for each metric from a list of dictionaries.
Args:
metrics_data (... |
magic_instruct_75k | 71,226 | Write a Python function to determine the supported policy types for different AWS services based on predefined rules. The function should return the supported policy type(s) for a given AWS service name. If the service name is not recognized or not provided, the function should return the default policy type.
The code... | Here is the Python code to solve the given problem in the markdown block:
```python
def selectPolicyType(service: str) -> str:
"""
Determine the supported policy type(s) for a given AWS service.
Args:
service (str): The name of the AWS service.
Returns:
str: The supported policy type(s... |
magic_instruct_75k | 71,270 | Write a Python function to configure PHP settings for a server. The function should perform the following tasks:
1. Copy the `php.ini` configuration file for the command-line interface (CLI) and PHP-FPM from a specified source directory to the respective directories `/etc/php/7.0/cli/` and `/etc/php/7.0/fpm/`.
2. Set t... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
import shutil
def configure_php_settings(assets_directory: str, php_timezone: str, data_directory: str):
"""
Configure PHP settings for a server by performing the following tasks:
1. Copy the `php.ini` configurati... |
magic_instruct_75k | 71,297 | Create a Python function to simulate the behavior of a custom button component for a web application. The button should have the following features:
1. The button should be able to display text or an icon, or both.
2. It should support different sizes such as small, medium, and large.
3. The button should have differen... | Here is the Python code to solve the given problem in the markdown block:
```python
def create_button(text: str = None, icon: str = None, size: str = 'medium', color_variant: str = 'default', disabled: bool = False) -> str:
"""
Simulates the creation of a custom button component with configurable properties.
... |
magic_instruct_75k | 71,299 | Write a Python function `control_robot_movement` that controls the movement of a robot to a specified target pose, triggers a program call at the end of the movement, and then moves the robot back to a reference pose. The function should take the following parameters:
- `robot`: An object representing the robot's contr... | Here is the Python code to solve the given problem in the markdown block:
```python
def control_robot_movement(robot, target_pose, reference_pose):
"""
Controls the movement of a robot to a specified target pose, triggers a program call,
and then moves the robot back to a reference pose.
Args:
... |
magic_instruct_75k | 71,305 | Write a Python function to determine if the order of parentheses, curly braces, and square brackets in a given string is valid. The function should return `True` if the order is valid and `False` otherwise. A valid order means that for every opening parenthesis, there is a corresponding closing parenthesis in the corre... | Here is the Python code to solve the given problem in the markdown block:
```python
def validParenthesesOrder(s: str) -> bool:
"""
Determines if the order of parentheses, curly braces, and square brackets in a given string is valid.
Args:
s (str): The input string containing only parentheses, curly... |
magic_instruct_75k | 71,306 | Write a Python function to implement a simple operation registration system. The system should allow registering operations and retrieving a list of registered operations. Each operation is represented by a unique string identifier.
The code should start with:
```python
from typing import List, Dict
def register_oper... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def register_operation(operation_store: Dict[str, int], operation_id: str) -> None:
"""
Register an operation with a unique string identifier.
Args:
operation_store (Dict[str, int]): A... |
magic_instruct_75k | 71,318 | Write a Python function to validate the structure and content of an order model for an e-commerce platform. The order model is represented as a JSON object and must adhere to a specific structure. The function should check if the JSON object contains all the required attributes and if their respective data types are as... | Here is the Python code to solve the given problem in the markdown block:
```python
import json
def validate_order_model(order_json: dict) -> bool:
"""
Validates the structure and content of an order model represented as a JSON object.
Args:
order_json (dict): A dictionary representing the order m... |
magic_instruct_75k | 71,350 | Write a Python function to extract the names of the models and fields that are being altered from a list of database migration operations. Each migration operation is represented as a tuple containing the model name, field name, and the new field definition. The function should return a list of tuples, where each tuple... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def get_altered_fields(migrations: List[Tuple[str, str, str]]) -> List[Tuple[str, str]]:
"""
Extracts the names of the models and fields that are being altered from a list of database migration op... |
magic_instruct_75k | 71,360 | Write a Python script to manage the installation of various command-line tools based on the operating system. The script should handle the installation of different tools using the appropriate package managers for macOS (Homebrew) and other Unix-like systems (crates.io for Rust tools). The script should:
1. Define the ... | Here is the Python code to solve the given problem in the markdown block:
```python
import platform
from typing import List, Dict
def append_to_install(tool: str, install_list: List[str], os_type: str) -> None:
"""
Append the specified tool to the installation list based on the operating system.
Args:
... |
magic_instruct_75k | 71,369 | Write a Python function to validate a set of action parameters based on given constraints. The function should take a dictionary of action parameters and their corresponding values, and return `True` if all parameters satisfy the constraints, and `False` otherwise.
The constraints for the action parameters are as foll... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Union
def validate_action_parameters(action_parameters: Dict[str, Union[str, int, float, None]]) -> bool:
"""
Validates a set of action parameters based on given constraints.
Args:
action_p... |
magic_instruct_75k | 71,376 | Write a Python function to parse command-line options for a script that processes files. The script should support three options: `verbose`, `quiet`, and `recursive`. The function should correctly interpret the provided options and perform the appropriate actions based on the chosen options. The function should start w... | Here is the Python code to solve the given problem in the markdown block:
```python
import sys
def parse_options(args: list) -> dict:
"""
Parse command-line options for a file processing script.
The script supports three options:
- `verbose`: Enable verbose output.
- `quiet`: Enable quiet mode (su... |
magic_instruct_75k | 71,383 | Write a Python function to process a dictionary containing information about a rendering path for a 3D model and return a formatted string. The dictionary contains the following keys:
- "rendering_path": a string representing the file path for the rendering
- "resolution": a tuple of two integers representing the width... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_rendering_info(rendering_info: dict) -> str:
"""
Processes a dictionary containing rendering information and returns a formatted string.
Args:
rendering_info (dict): A dictionary containing the following... |
magic_instruct_75k | 71,399 | Write a Python function to extract metadata from all image files in a specified directory using the ExifTool utility. The function should handle the case where the ExifTool is not installed in the default system path by using a specific path to the ExifTool executable. The function should return a dictionary where the ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
import subprocess
import os
def extract_image_metadata(directory_path: str, exiftool_path: str = "exiftool") -> Dict[str, Dict]:
"""
Extracts metadata from all image files in the specified director... |
magic_instruct_75k | 71,403 | Write a Python function to filter and process profiles based on the specified number of time steps. The function should:
1. Filter out profiles that do not have the specified number of time steps.
2. Calculate the total and average of each valid profile and store them in separate lists called `totals` and `averages`, r... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import numpy as np
def process_profiles(data: List[List[int]], time_steps: int, names: List[str]) -> (List[List[int]], List[float], List[float]):
"""
Filters and processes profiles based on the specified... |
magic_instruct_75k | 71,409 | Create a Python class `BankAccount` that simulates a simple banking system. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. Additionally, create a subclass `TransferableBankAccount` that inherits from `BankAccount` and adds functionality for transferring funds be... | Here is the Python code to solve the given problem in the markdown block:
```python
class BankAccount:
def __init__(self, account_number, initial_balance):
"""
Initialize a BankAccount with an account number and an initial balance.
Args:
account_number (str): The account number.... |
magic_instruct_75k | 71,419 | Write a Python function to compare two version number tuples. The version numbers are represented as tuples of integers, where each integer represents a different level of the version (e.g., major, minor, patch). The version numbers are compared from left to right, with the most significant level being compared first. ... | Here is the Python code to solve the given problem in the markdown block:
```python
def compare_versions(version1: tuple, version2: tuple) -> int:
"""
Compare two version number tuples.
Args:
version1 (tuple): A tuple of integers representing the first version number.
version2 (tuple): A tu... |
magic_instruct_75k | 71,455 | Write a Python function to process a list of raw field names and return a new list with the field names sorted in ascending order, without any duplicates or empty strings. The function should handle the case where the input list is empty.
The code should start with:
```python
from typing import List
def process_raw_f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_raw_fields(raw_fields: List[str]) -> List[str]:
"""
Processes a list of raw field names and returns a new list with the field names sorted in ascending order,
without any duplicates or em... |
magic_instruct_75k | 71,456 | Write a Python function to extract unique elements from a given list of integers while preserving their original order. The function should not use any built-in Python data structures or libraries for this task. The code should start with:
```python
from typing import List
def get_unique_elements(input_list: List[int]... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def get_unique_elements(input_list: List[int]) -> List[int]:
"""
Extracts unique elements from a given list of integers while preserving their original order.
Args:
input_list (List[int]): T... |
magic_instruct_75k | 71,457 | Write a Python function to update a key binding configuration for a text editor. The function should take a key sequence and an action, and update the key binding configuration accordingly. The function should handle the mapping of key sequences to actions, allowing for efficient lookup and modification of the key bind... | Here is the Python code to solve the given problem in the markdown block:
```python
def bind_key(key_sequence: str, action: str, key_bindings: dict) -> dict:
"""
Updates the key binding configuration by mapping a key sequence to a specific action.
Args:
key_sequence (str): The key sequence to be ma... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.