source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_instruct_75k | 24,383 | Write a Python function to identify the position where a missing opening brace `{` should be inserted in a given code snippet. The code snippet is a string that is syntactically correct except for a single missing opening brace. The function should return the index where the missing opening brace should be inserted. If... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_missing_brace(code_snippet: str) -> int:
"""
Finds the position where a missing opening brace '{' should be inserted in a given code snippet.
Args:
code_snippet (str): The code snippet as a string.
Ret... |
magic_instruct_75k | 24,430 | Implement a binary search tree (BST) in Python with the following methods:
1. `add(self, value: int)`: This method should add a new node with the given value to the binary search tree. If the tree is empty, the new node becomes the root. Otherwise, the `add` method of the `BinaryTreeNode` class should be called to recu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Optional
class BinaryTreeNode:
def __init__(self, value: int):
"""
Initialize a new BinaryTreeNode with the given value.
Args:
value (int): The value to be stored in the node.... |
magic_instruct_75k | 24,450 | Write a Python function to count the number of unique IDs in a given list of integers. The function should remove any duplicate IDs and then return the count of the remaining unique IDs. The code should start with:
```python
from typing import List
def count_unique_ids(ids: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_unique_ids(ids: List[int]) -> int:
"""
Counts the number of unique IDs in a given list of integers.
Args:
ids (List[int]): A list of integers representing IDs.
Returns:
... |
magic_instruct_75k | 24,463 | Create a Python class-based solution to manage toggable productions in a university system. Each toggable production is associated with a specific type of production, such as generating students or scientists. Implement the following classes and methods:
1. **`TogableProduction` class**:
- Properties:
- `name`... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
class TogableProduction:
"""
Represents a toggable production with a name, associated productions, and an active status.
Attributes:
name (str): The name of the toggable production.
... |
magic_instruct_75k | 24,469 | Write a Python function to determine if a given list of integers contains any duplicates. The function should return `True` if there are any duplicates in the list, otherwise it should return `False`. The function should have a time complexity of O(n) and a space complexity of O(n).
The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def contains_duplicate(nums: List[int]) -> bool:
"""
Determines if the given list of integers contains any duplicates.
Args:
nums (List[int]): A list of integers where 1 <= len(nums) <= 10^5... |
magic_instruct_75k | 24,476 | Write a Python function to calculate the sum of values associated with specific keys in a dictionary. If a key is not present in the dictionary, its associated value should be considered as 0. The function should handle any potential `KeyError` exceptions by setting the missing value to 0.
The function signature is:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
def sum_values(dictionary: dict, keys: list) -> int:
"""
Calculate the sum of values associated with specific keys in a dictionary.
If a key is not present in the dictionary, its associated value is considered as 0.
Arg... |
magic_instruct_75k | 24,494 | Write a Python function to compare the number of tags obtained from an API call with the number of tags in the tag history of a repository. The function should return `True` if the number of tags in both lists match, and `False` otherwise. The function should be named `compare_tags` and should take two parameters: `tag... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compare_tags(tags: List[str], history: List[str]) -> bool:
"""
Compares the number of tags obtained from an API call with the number of tags in the tag history.
Args:
tags (List[str]): A... |
magic_instruct_75k | 24,509 | Write a Python function to extract the author's name from a given code snippet that contains metadata information. The code snippet is formatted with specific tags for the IDE, project name, user, file, and author. The function should parse the code snippet and return the author's name as a string.
The code should sta... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_author_name(code_snippet: str) -> str:
"""
Extracts the author's name from a given code snippet containing metadata information.
The code snippet is formatted with specific tags for the IDE, project name, user, ... |
magic_instruct_75k | 24,543 | Write a Python function to transform bounding box coordinates for object detection tasks. The function should take the coordinates of a bounding box (`bbox_xmin`, `bbox_xmax`, `bbox_ymin`, `bbox_ymax`) and the dimensions of the image (`img_width`, `img_height`) as inputs, and return the transformed coordinates `x`, `y`... | Here is the Python code to solve the given problem in the markdown block:
```python
def transform_bbox(bbox_xmin: float, bbox_xmax: float, bbox_ymin: float, bbox_ymax: float, img_width: int, img_height: int) -> tuple:
"""
Transforms the bounding box coordinates into a normalized format.
Args:
bbox_... |
magic_instruct_75k | 24,544 | Write a Python function to determine if an exception was hit during the execution of a program based on a given backtrace. The backtrace is a list of strings where each string represents a frame in the backtrace. The function should return `True` if an exception was raised, and `False` otherwise. The backtrace will alw... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def check_exception_hit(backtrace: List[str]) -> bool:
"""
Determines if an exception was hit during the execution based on the given backtrace.
Args:
backtrace (List[str]): A list of string... |
magic_instruct_75k | 24,574 | Write a Python function to extract all comments from a given code file. The function should identify and return all comments present in the code as a list of strings. A comment is defined as any text following a `#` symbol until the end of the line. The function should handle both single-line and inline comments.
The ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_comments(code: str) -> List[str]:
"""
Extracts all comments from a given code file.
Args:
code (str): The code file as a string.
Returns:
List[str]: A list of string... |
magic_instruct_75k | 24,590 | Write a Python function to simulate a database cursor's fetch operations. The function should take a list of tuples representing rows of a database table and an integer `n` representing the number of rows to fetch at a time. The function should return the rows fetched in each operation based on the specified `n`.
The ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def simulate_fetch(rows: List[Tuple], n: int) -> List[List[Tuple]]:
"""
Simulates a database cursor's fetch operations by fetching `n` rows at a time.
Args:
rows (List[Tuple]): A list... |
magic_instruct_75k | 24,609 | Write a Python function `parse_package_config` that takes a dictionary representing the package configuration and returns a tuple containing the classifiers and dependencies. The input dictionary will have the following structure:
```python
{
"classifiers": List[str],
"keywords": str,
"packages": List[str],... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Tuple
def parse_package_config(package_config: Dict[str, any]) -> Tuple[List[str], List[str]]:
"""
Parses a package configuration dictionary and extracts the classifiers and install dependencies.
... |
magic_instruct_75k | 24,621 | Write a Python function to simulate a deck of playing cards with the following functionalities:
1. **Initialization**: Create a deck with 52 standard playing cards (4 suits: hearts, diamonds, clubs, spades; 13 ranks: 2-10, J, Q, K, A).
2. **Shuffle**: Shuffle the deck of cards.
3. **Draw Card**: Draw the top card from ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional, Tuple
import random
def initialize_deck() -> List[Tuple[str, str]]:
"""
Initialize a standard 52-card deck.
Returns:
List[Tuple[str, str]]: A list of tuples representing the deck,... |
magic_instruct_75k | 24,622 | Write a Python function `createList` that processes a list of parameters according to the following rules:
1. If the parameter is a positive integer, add it to the new list.
2. If the parameter is a string, add its length to the new list.
3. If the parameter is a list, recursively apply the above rules to its elements ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def createList(params: List[Union[int, str, List]]) -> List[int]:
"""
Processes a list of parameters and returns a new list based on the following rules:
1. If the parameter is a positive inte... |
magic_instruct_75k | 24,625 | Write a Python function to construct a URL for Alexa's country ranking pages based on a given country code and page number. The URL should follow the format 'http://alexa.chinaz.com/Country/{country_code}_{page_number}.html'. The function should validate the inputs to ensure the country code is exactly two characters l... | Here is the Python code to solve the given problem in the markdown block:
```python
def construct_alexa_url(country_code: str, page_number: int) -> str:
"""
Constructs a URL for Alexa's country ranking pages based on the given country code and page number.
Args:
country_code (str): A two-letter cou... |
magic_instruct_75k | 24,631 | Write a Python function to remove duplicates from a list while preserving the original order of the elements. The function should take a list of objects as input and return a new list with all duplicates removed. The input list may contain objects of any type, and the function should handle an empty list by returning a... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates(representedObjects: List[object]) -> List[object]:
"""
Removes duplicates from a list while preserving the original order of elements.
Args:
representedObjects (List[ob... |
magic_instruct_75k | 24,639 | Write a Python function to calculate the impact score of an opponent in a game scenario. The impact score is determined based on the size and position of both the player and the opponent. The function `compute_opponent_impact` takes in four parameters: `our_size`, `opponent_size`, `our_position`, and `opponent_position... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
def compute_opponent_impact(our_size: int, opponent_size: int, our_position: Tuple[int, int], opponent_position: Tuple[int, int]) -> int:
"""
Calculate the impact score of an opponent based on the relat... |
magic_instruct_75k | 24,652 | Write a Python function to calculate the sum of all even numbers in a given list of integers. The function should take a list of integers as input and return the sum of all even numbers in the list. The code should start with:
```python
from typing import List
def sum_of_even_numbers(nums: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_of_even_numbers(nums: List[int]) -> int:
"""
Calculate the sum of all even numbers in a given list of integers.
Args:
nums (List[int]): A list of integers.
Returns:
int:... |
magic_instruct_75k | 24,682 | Write a Python function to find a resource file within a given directory structure. The function should take a directory path and a file name as input and return the full path to the file if it exists, or an empty string if the file is not found. The directory structure is represented as a tree, where each node can hav... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def find_resource_file(directory_structure: Dict[str, Union[str, Dict]], file_name: str) -> str:
"""
Find a resource file within a given directory structure and return its full path.
Ar... |
magic_instruct_75k | 24,692 | Write a Python function to process a list of experiments and return a dictionary containing the results of each experiment. Each experiment is represented as a tuple containing the experiment name, a function to run, optional window parameters, and keyword arguments for the function. The function should take in the lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict, Any, Optional
def process_experiments(experiments: List[Tuple[str, Any, Optional[Dict[str, Any]], Dict[str, Any]]], gamma: Any, window: Optional[Any] = None) -> Dict[str, Any]:
"""
Process ... |
magic_instruct_75k | 24,699 | Write a Python function to manage a NAT gateway in a cloud environment. The function should validate the specification and status of the NAT gateway, update the tags if an upgrade is required, and return the current status of the NAT gateway. The function should start with:
```python
def manage_nat_gateway(resource_gro... | Here is the Python code to solve the given problem in the markdown block:
```python
def manage_nat_gateway(resource_group_id: str, specification: str = 'Small', status: str = 'Available', tags: dict = {}) -> str:
"""
Manages a NAT gateway in a cloud environment by validating the specification and status,
up... |
magic_instruct_75k | 24,700 | Write a Python function to extract unique function names from a list of strings representing functions related to neuroimaging data analysis. The function names are enclosed within single quotes. The function should return a sorted list of these unique function names.
The code should start with:
```python
from typing ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_function_names(function_list: List[str]) -> List[str]:
"""
Extracts unique function names from a list of strings representing functions related to neuroimaging data analysis.
The function... |
magic_instruct_75k | 24,734 | Write a Python function to find the common key-value pairs between two dictionaries. The function should return a new dictionary containing only the key-value pairs that are present in both input dictionaries and have the same values. If there are no such pairs, the function should return an empty dictionary.
The code... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def find_shared_items(dict1: Dict[str, int], dict2: Dict[str, int]) -> Dict[str, int]:
"""
Finds and returns a dictionary containing the key-value pairs that are common to both input dictionaries and hav... |
magic_instruct_75k | 24,751 | Write a Python function to set the flash voltage for an ESP (Embedded Systems Processor) based on the provided efuse values. The function should take three parameters: `esp` (an ESP object), `efuses` (a dictionary containing the efuse values), and `args` (additional arguments). The efuse values are retrieved using the ... | Here is the Python code to solve the given problem in the markdown block:
```python
def set_flash_voltage(esp, efuses, args):
"""
Sets the flash voltage for an ESP based on the provided efuse values.
Args:
esp: An ESP object with a method `set_flash_voltage` to set the flash voltage.
efuses... |
magic_instruct_75k | 24,755 | Write a Python function to construct a sequence of operations for processing input data in a deep learning project. The sequence should include adding a temporary variable, generating noise, performing convolution, applying normalization, and activating the output based on given conditions. The function should return t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def construct_sequence(seq: List, tmp, fill_noise: bool, inp, conv, GenNoise, conv_num, pad, normalization, act) -> List:
"""
Constructs a sequence of operations for processing input data in a deep learn... |
magic_instruct_75k | 24,776 | Write a Python function `map_not` that takes a single argument `process`, which is another function. The `map_not` function should return a modified version of the `process` function that applies the logical NOT operation to the result of the original function. Additionally, implement the `map_if` function that takes a... | Here is the Python code to solve the given problem in the markdown block:
```python
def map_not(process):
"""
Returns a modified version of the input function that applies the logical NOT operation to the result.
Args:
process: A function that returns a boolean value.
Returns:
A function that ... |
magic_instruct_75k | 24,778 | Write a Python function to perform element-wise addition of two lists and return the result as a new list. The function should handle lists of arbitrary length and ensure that the addition is performed correctly. The code should start with:
```python
from typing import List
def element_wise_addition(list1: List[int], ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def element_wise_addition(list1: List[int], list2: List[int]) -> List[int]:
"""
Perform element-wise addition of two lists and return the result as a new list.
Args:
list1 (List[int]): The f... |
magic_instruct_75k | 24,782 | Write a Python function to find the nearest smaller element to the right for each element in a given array of integers. The function should return a new array where each element at index `i` represents the nearest smaller element to the right of `arr[i]`. If there is no smaller element to the right of `arr[i]`, the val... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def nearest_smaller_to_right(arr: List[int]) -> List[int]:
"""
Find the nearest smaller element to the right for each element in the given array.
Args:
arr (List[int]): The input array of in... |
magic_instruct_75k | 24,783 | Write a Python function to find the maximum sum of a contiguous subarray within a given string of comma-separated integers. The function should take a string as input and return the maximum sum of any contiguous subarray.
The code should start with:
```python
def maxSubarraySum(arr: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def maxSubarraySum(arr: str) -> int:
"""
Find the maximum sum of a contiguous subarray within a given string of comma-separated integers.
Args:
arr (str): A string containing comma-separated integers.
Returns:
... |
magic_instruct_75k | 24,785 | Write a Python function to check if an email link has expired based on the time it was sent and the current time. The email link expires after a fixed duration of 2 hours. The function should take two parameters: `email_sent_time` (in seconds since epoch) and `current_time` (in seconds since epoch). The function should... | Here is the Python code to solve the given problem in the markdown block:
```python
def check_email_expiration(email_sent_time: int, current_time: int) -> bool:
"""
Check if an email link has expired based on the time it was sent and the current time.
Args:
email_sent_time (int): The time when the ... |
magic_instruct_75k | 24,791 | Write a Python function to determine if a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, ignoring spaces, punctuation, and capitalization.
The function should start with:
```python
def is_palindrome(s: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome(s: str) -> bool:
"""
Determine if a given string is a palindrome.
A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward,
ignoring spaces, punc... |
magic_instruct_75k | 24,816 | Write a Python function to validate the setup information for a Python package. The setup information is provided as a dictionary with keys 'name', 'version', and 'author'. The function should check if the dictionary contains all three keys and if their corresponding values are non-empty strings. If any of the conditio... | Here is the Python code to solve the given problem in the markdown block:
```python
def validate_setup_info(info: dict) -> bool:
"""
Validates the setup information for a Python package.
The setup information is provided as a dictionary with keys 'name', 'version', and 'author'.
The function checks if ... |
magic_instruct_75k | 24,841 | Write a Python function to filter a list of GitHub repository information based on specific criteria. Each repository is represented as a dictionary with the following keys: "reponame" (the name of the repository), "filename" (the name of the file), and "gh_stars" (the number of stars the repository has).
The function... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def filter_repositories(repositories: List[Dict[str, Union[str, int]]], keyword: str, min_stars: int) -> List[Dict[str, Union[str, int]]]:
"""
Filters a list of GitHub repository information... |
magic_instruct_75k | 24,847 | Write a Python function to resolve module dependencies and return the order in which the modules should be imported to satisfy all dependencies. The function should take a dictionary where the keys are module names and the values are lists of modules that the key module depends on. The function should return a list of ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def resolve_dependencies(module_dependencies: Dict[str, List[str]]) -> List[str]:
"""
Resolve the dependencies of Python modules and return the order in which they should be imported.
Args:
... |
magic_instruct_75k | 24,850 | Write a Python function to process a list of database migration operations and return a dictionary containing the model names as keys and the corresponding field names as values. Each migration operation is represented as a tuple containing the model name, field name, and field type. 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, Dict
def extract_migration_fields(migrations: List[Tuple[str, str, str]]) -> Dict[str, List[str]]:
"""
Processes a list of database migration operations and returns a dictionary
containing th... |
magic_instruct_75k | 24,871 | Write a Python function to calculate the sum of all even numbers in a given list of integers. The function should handle any exceptions that may occur during the processing of the list. If an exception occurs, the function should print the exception and continue processing the remaining elements in the list. If no exce... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_even_numbers(numbers: List[int]) -> int:
"""
Calculate the sum of all even numbers in a given list of integers.
If an exception occurs during the processing of any element in the list,
th... |
magic_instruct_75k | 24,907 | Write a Python function to count the occurrences of each distinct character in a given string and return the results in the order they appear in the string. The function should return a list of strings, where each string contains a character followed by a space and its count.
The code should start with:
```python
from... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_distinct_characters(s: str) -> List[str]:
"""
Counts the occurrences of each distinct character in the given string and returns the results in the order they appear.
Args:
s (str):... |
magic_instruct_75k | 24,915 | Write a Python script to automate the build process for a TypeScript project. The script should perform the following tasks:
1. Determine the directory in which the script is located.
2. Set the project directory as the parent directory of the script directory.
3. Change the current working directory to the project dir... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
import subprocess
def automate_typescript_build():
"""
Automates the build process for a TypeScript project.
The script performs the following tasks:
1. Determines the directory in which the script is located... |
magic_instruct_75k | 24,935 | Write a Python function to generate a list of commands to install specified software packages on a Linux system using the `apt` package manager. The function should take a string of package names separated by spaces and return a list of commands in the format `sudo apt install <package_name>`.
The code should start wi... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_install_commands(packages: str) -> list[str]:
"""
Generates a list of commands to install specified software packages using the `apt` package manager.
Args:
packages (str): A string containing package n... |
magic_instruct_75k | 24,938 | Write a Python function to parse a given license file and extract the license information from it. The license file is in the format of a comment block at the beginning of a source code file, similar to the provided code snippet. The license information is enclosed within the comment block and contains details about th... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def parseLicense(source_code: str) -> dict:
"""
Parses a given source code file to extract license information from a comment block.
Args:
source_code (str): The source code file content as a string.
... |
magic_instruct_75k | 24,941 | Write a Python function to simulate the behavior of the given Bash script for managing a PostgreSQL database. The function should handle the following scenarios:
1. If the PostgreSQL data directory (`PGDATA`) does not contain a file named `PG_VERSION` or if the file is empty, the function should simulate initializing a... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
import sys
def manage_postgres(action: str, pgdata: str) -> None:
"""
Simulate managing a PostgreSQL database based on the given action and PGDATA directory.
Args:
action (str): The action to perform ('in... |
magic_instruct_75k | 24,948 | Write a Python function to process a list of classifiers and return a dictionary containing the count of each unique classifier category. Each classifier is a string that represents a category for a Python package. The function should ignore any classifiers that are not properly formatted.
The `classifiers` parameter ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_classifiers(classifiers: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of each unique classifier category from a list of classifiers.
Args:
classifiers (List[str])... |
magic_instruct_75k | 24,951 | Create a Python class `SolverSelection` that manages the selection of advection and diffusion solvers based on provided settings. The class should have the following methods:
1. `SetAdvectionSolver`: This method takes the settings, an advection solver object, and the advection type as input and sets the advection solve... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
class SolverSelection:
"""
A class to manage the selection of advection and diffusion solvers based on provided settings.
Methods:
SetAdvectionSolver(settings: Dict[str, Any], advection... |
magic_instruct_75k | 24,979 | Write a Python function `buildSystem(commands)` that simulates a simplified build system. The function should take a list of commands as input and return a list of files generated after processing all the commands in the correct order. Each command has a specific action associated with it, and the program should execut... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def buildSystem(commands: List[str]) -> List[str]:
"""
Simulates a simplified build system by processing a list of commands and generating the necessary files.
Args:
commands (List[str]): A ... |
magic_instruct_75k | 24,982 | Write a Python function to process a list of integers according to specific rules. The function should take a list of integers as input and return a modified list based on the following rules:
1. If the input list is empty, the function should return an empty list.
2. If the input list contains only one element, the fu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_list(nums: List[int]) -> List[int]:
"""
Processes a list of integers according to specific rules.
Args:
nums (List[int]): The list of integers to be processed.
Returns:
... |
magic_instruct_75k | 25,011 | Write a Python function to extract specific key-value pairs from a given dictionary based on certain criteria. The function should take a dictionary as input and return a new dictionary containing only the key-value pairs where both the key and the value are of type `str`.
The code should start with:
```python
def ext... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_key_value_pairs(input_dict: dict) -> dict:
"""
Extracts key-value pairs from the input dictionary where both the key and the value are of type `str`.
Args:
input_dict (dict): The input dictionary from wh... |
magic_instruct_75k | 25,034 | Write a Python function to format package information from a given dictionary into a specific string format. The input dictionary contains details about the package maintainer, their email, the list of packages, package data, and supported platforms. The function should return a string that includes the maintainer's na... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def format_package_info(package_info: Dict[str, any]) -> str:
"""
Formats the package information from a dictionary into a specific string format.
Args:
package_info (Dict[str, any]): A dict... |
magic_instruct_75k | 25,037 | Write a Python function to perform a scan operation on a database using given predicates and return the number of matching records. The function should filter the records based on the predicates and return the count of matching records.
The code should start with:
```python
from typing import List, NamedTuple
class P... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, NamedTuple
class Predicate(NamedTuple):
column: str
value: str
operator: str
class Record(NamedTuple):
columns: List[str]
values: List[str]
def scan(predicates: List[Predicate], records: L... |
magic_instruct_75k | 25,050 | Write a Python function to convert a given time in seconds to minutes and seconds. The function should return a tuple `(minutes, seconds)` where `minutes` is the whole number of minutes and `seconds` is the remaining seconds after converting from the input time `t`. Ensure the function handles edge cases properly, such... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_time(t: int) -> tuple:
"""
Convert a given time in seconds to minutes and seconds.
Args:
t (int): The time in seconds to be converted.
Returns:
tuple: A tuple (minutes, seconds) where minute... |
magic_instruct_75k | 25,054 | Write a Python function to perform a character rotation on a given string. The rotation involves shifting each character in the string by a specified number of positions in the alphabet. The rotation should preserve the case of the characters, i.e., uppercase letters should remain uppercase, and lowercase letters shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
def rotate(input_string: str, shift: int) -> str:
"""
Rotates each character in the input string by the specified number of positions in the alphabet.
Args:
input_string (str): The string to be rotated.
shif... |
magic_instruct_75k | 25,058 | Write a Bash script to parse and extract the value of the "nTuplesSubmitted" parameter from the 234th line of a log file. The log file contains lines of data, and each line is formatted such that the "nTuplesSubmitted" parameter is the 3rd token on the 234th line.
The script should:
1. Read each line of the log file.
... | Here is the Python code to solve the given problem in the markdown block:
```bash
#!/bin/bash
# Initialize line counter and variable to store the previous token
line_number=0
ntuples_submitted_previous_token=""
# Read each line of the log file
while IFS= read -r line; do
# Increment the line counter
((line_nu... |
magic_instruct_75k | 25,077 | Write a Python function to generate a Docker build command string based on the provided microservice name and Git commit hash. The function should format the Docker build command according to the specified format and return the complete command as a string.
The code should start with:
```python
def build_docker_image(... | Here is the Python code to solve the given problem in the markdown block:
```python
def build_docker_image(microservice_name: str, git_commit_hash: str) -> str:
"""
Generates a Docker build command string based on the provided microservice name and Git commit hash.
Args:
microservice_name (str): Th... |
magic_instruct_75k | 25,092 | Write a Python function to find all unique triplets in a given array of integers that sum up to zero. Each triplet should be represented as a list of three integers, and the same triplet should not be repeated in the output. The function should return a list of all unique triplets that sum up to zero.
The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_triplets(nums: List[int]) -> List[List[int]]:
"""
Find all unique triplets in the array that sum up to zero.
Args:
nums (List[int]): The input array of integers.
Returns:
... |
magic_instruct_75k | 25,102 | Write a Python function to track the number of wins and losses for a player and calculate the win percentage. The function should have methods to update the win and loss counts, as well as a method to calculate the win percentage.
The code should start with:
```python
class GameStats:
def __init__(self):
s... | Here is the Python code to solve the given problem in the markdown block:
```python
class GameStats:
def __init__(self):
"""
Initialize the GameStats class with wins and losses set to 0.
"""
self.wins = 0
self.losses = 0
def record_win(self):
"""
Incremen... |
magic_instruct_75k | 25,133 | Create a Python function to determine the sex of an individual based on genetic data analysis. The function should take in various parameters to customize its behavior and return the sex of the individual. The parameters include `data_source`, which represents the genetic data source, and `array_type`, which specifies ... | Here is the Python code to solve the given problem in the markdown block:
```python
def get_sex(data_source: str, array_type: str = None, verbose: bool = False, plot: bool = False, save: bool = False, on_lambda: bool = False, include_probe_failure_percent: bool = False, return_fig: bool = False, return_labels: bool = F... |
magic_instruct_75k | 25,181 | Complete the `except` block to handle the `ValueError` exception and print the error message in the correct format: "This failed for particle [particle_id]".
The code should start with:
```python
import gc
def extract_particle_id_from_exception(e: ValueError) -> int:
# This function is a placeholder and should be... | Here is the Python code to solve the given problem in the markdown block:
```python
import gc
def extract_particle_id_from_exception(e: ValueError) -> int:
# This function is a placeholder and should be implemented to extract the particle ID from the exception
# For the purpose of this task, we will assume it ... |
magic_instruct_75k | 25,204 | Write a Python function to generate the sequence of numbers obtained by repeatedly applying the following steps to a given integer input until the input becomes 1:
1. If the input is even, divide it by 2.
2. If the input is odd, multiply it by 3 and add 1.
The function should return the sequence of numbers generated d... | Here is the Python code to solve the given problem in the markdown block:
```python
def step_5_sequence(n: int) -> list:
"""
Generate the sequence of numbers obtained by repeatedly applying the following steps to a given integer input until it becomes 1:
1. If the input is even, divide it by 2.
2. If th... |
magic_instruct_75k | 25,216 | Write a Python function to calculate the Euclidean distance between two points in a 2D plane. The function should take in the coordinates of the two points and return the distance between them. The Euclidean distance between two points \((x1, y1)\) and \((x2, y2)\) is given by the formula:
\[ \text{distance} = \sqrt{(... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def calculate_distance(x1: float, y1: float, x2: float, y2: float) -> float:
"""
Calculate the Euclidean distance between two points (x1, y1) and (x2, y2) in a 2D plane.
Args:
x1 (float): The x-coordina... |
magic_instruct_75k | 25,244 | Write a Python function `play_rock_paper_scissors()` that simulates a simple game of rock-paper-scissors. The function should take the user's choice (rock, paper, or scissors) as input and return the result of the game. The function should randomly generate a choice for the computer and determine the winner based on th... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
def play_rock_paper_scissors(user_choice: str) -> str:
"""
Simulates a game of rock-paper-scissors between the user and the computer.
Args:
user_choice (str): The user's choice, which can be "rock", "... |
magic_instruct_75k | 25,250 | Implement a Python class `DropTargetManager` that manages a collection of drop targets for a user interface. The class should include methods to add a new drop target to the collection and to retrieve the total count of drop targets currently managed. The collection should have a maximum capacity defined by `MAX_DROPTA... | Here is the Python code to solve the given problem in the markdown block:
```python
class DropTargetManager:
"""
A class to manage a collection of drop targets for a user interface.
Attributes:
MAX_DROPTARGETS (int): The maximum number of drop targets that can be managed.
drop_targets (list... |
magic_instruct_75k | 25,257 | Write a Python function `remove_even_numbers` that takes a list of integers as input and returns a new list with all the even numbers removed. Additionally, the function should print the removed even numbers in the following format: "Removed: num1, num2, ...".
The code should start with:
```python
from typing import L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_even_numbers(nums: List[int]) -> List[int]:
"""
Removes all even numbers from the given list and prints the removed even numbers.
Args:
nums (List[int]): The list of integers from... |
magic_instruct_75k | 25,264 | Write a Python function to create a time-locked transaction for a cryptocurrency project. The function should take in various parameters and generate the necessary data for the time-locked transaction. The function should return a dictionary containing all the input parameters as well as the `protocol_version` key with... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
PROTOCOL_VERSION = '0.12'
def create_timelock_transaction(message_id: str, oracle_fees: float, miners_fee_satoshi: int, return_address: str, locktime: int, pubkey_list: List[str], req_sigs: int) -> dict:
""... |
magic_instruct_75k | 25,269 | Write a Python function to process a dictionary representing a tracklist for multiple artists and their albums. The function should return a new dictionary containing the albums as keys and the number of tracks in each album as values.
The tracklist dictionary will be structured as follows:
```python
tracklist = {
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def album_track_count(tracklist: Dict[str, Dict[str, List[str]]]) -> Dict[str, int]:
"""
Processes a tracklist dictionary and returns a new dictionary containing the albums as keys and the number o... |
magic_instruct_75k | 25,281 | Write a Python function to calculate the sum of all even numbers in a given list. The function should take a list of integers as input and return the sum of all the even numbers in the list. The code should start with:
```python
from typing import List
def sum_even_numbers(numbers: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_even_numbers(numbers: List[int]) -> int:
"""
Calculate the sum of all even numbers in a given list of integers.
Args:
numbers (List[int]): A list of integers from which to calculate ... |
magic_instruct_75k | 25,282 | Write a Python function to create an embed for a Discord bot that displays information about a climbing route. The function `create_selection_embed` should take in the name of a climbing route, a list of routes, and the name of the user making the request. The function should create and return an embed with information... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def create_selection_embed(route_name: str, routes: List[dict], requestor: str) -> Optional[dict]:
"""
Creates an embed for a Discord bot that displays information about a climbing route.
... |
magic_instruct_75k | 25,283 | Write a Python function to extract the author and the quote from a given dictionary containing details of quotes and their authors. The function should return the extracted details as a tuple in the format `(author, quote)`.
The input dictionary will have the following structure:
```python
quote_details_response = {
... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_quote_details(quote_details_response: dict) -> tuple:
"""
Extracts the author and the quote from the input dictionary and returns them as a tuple.
Args:
quote_details_response (dict): A dictionary contai... |
magic_instruct_75k | 25,297 | Write a Python function to determine if a player can navigate from a starting point 'S' to an exit point 'E' in a 2D grid representing a mysterious abyss. The player can move in four directions: up, down, left, and right. Each cell in the grid represents a different location within the abyss, and the player must naviga... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def explore_abyss(abyss: List[List[str]]) -> bool:
"""
Determines if the player can navigate from the starting point 'S' to the exit point 'E' in a 2D grid.
Args:
abyss (List[List[str]]): A ... |
magic_instruct_75k | 25,302 | Create a Python class `ReportExportServiceProvider` that supports exporting reports to various file formats such as PDF, CSV, and Excel. The class should be designed to be extensible, allowing for the addition of new file formats in the future without modifying the existing codebase. The class should include methods to... | Here is the Python code to solve the given problem in the markdown block:
```python
class ReportExportServiceProvider:
"""
A service provider class for exporting reports to various file formats.
This class supports exporting reports to PDF, CSV, and Excel formats. It is designed to be extensible,
allow... |
magic_instruct_75k | 25,305 | Write a Python function to extract the names of items from a list of dictionaries. Each dictionary in the list contains a key "Name" which represents the name of the item. The function should return a list of these names.
The code should start with:
```python
from typing import List, Dict
def extract_item_names(items... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def extract_item_names(items: List[Dict[str, str]]) -> List[str]:
"""
Extracts the names of items from a list of dictionaries.
Args:
items (List[Dict[str, str]]): A list of dictionarie... |
magic_instruct_75k | 25,330 | Write a Python function to calculate the time needed for all employees to be informed if the head employee informs all employees in a company. Each employee has a unique ID from 0 to n-1, and the head of the company is identified by `headID`. The direct manager for each employee is given in the `manager` list, and the ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def numOfMinutes(n: int, headID: int, manager: List[int], informTime: List[int]) -> int:
"""
Calculate the time needed for all employees to be informed if the head employee informs all employees.
Ar... |
magic_instruct_75k | 25,336 | Write a Python function to process a list of image filenames and extract specific views from each image. The function should take in the list of filenames and extract the front, front-left, side-left, front-right, and side-right views from each image. The image extraction process is performed by the `image_extractor` f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def image_processor(path: List[str]) -> List[str]:
"""
Processes a list of image filenames and extracts specific views from each image.
Args:
path (List[str]): A list of image filenames to p... |
magic_instruct_75k | 25,347 | Write a Python function to find the game environment with the highest score from a list of dictionaries. Each dictionary contains two key-value pairs: 'env-title' representing the name of the game environment, and 'score' representing the score achieved in that environment. The function should return the name of the ga... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def highest_score_env(data: List[Dict[str, float]]) -> str:
"""
Find the game environment with the highest score from a list of dictionaries.
Args:
data (List[Dict[str, float]]): A lis... |
magic_instruct_75k | 25,352 | Write a Python function to process a list of URL redirection configurations and return a dictionary mapping the regex patterns to their corresponding view names. Each configuration is represented as a tuple containing the regex pattern, the view, the kwargs, and the name.
The function should start with:
```python
from... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def extract_redirections(configurations: List[Tuple[str, str, Dict[str, str], str]]) -> Dict[str, str]:
"""
Processes a list of URL redirection configurations and returns a dictionary mappin... |
magic_instruct_75k | 25,359 | Write a Python function `isPalindrome` that takes in two strings `s1` and `s2` and returns `True` if either `s1` or `s2` is a palindrome, and `False` otherwise. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalizat... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def isPalindrome(s1: str, s2: str) -> bool:
"""
Determine if either of the two input strings is a palindrome.
Args:
s1 (str): The first input string.
s2 (str): The second input string.
Return... |
magic_instruct_75k | 25,360 | Write a Python function to find the extreme points associated with the maximum distance from a given list of distances and a list of extreme points. The extreme points are represented as a list of tuples. The function should return the tuple of extreme points corresponding to the maximum distance.
The code should star... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import numpy as np
def find_max_distance_points(distances: List[float], extreme_points: List[Tuple[int, int]]) -> Tuple[Tuple[int, int], Tuple[int, int]]:
"""
Finds the extreme points associated w... |
magic_instruct_75k | 25,369 | Write a Python function to abstract a dictionary obtained from a JSON message into a list of predicates. The JSON message contains various data points related to distances and target grasping. The function should extract specific values from the JSON message and update the predicates accordingly.
The function `abstrac... | Here is the Python code to solve the given problem in the markdown block:
```python
import json
def abstract_message(message: dict) -> dict:
"""
Abstracts a JSON message into a dictionary of predicates based on specific rules.
Args:
message (dict): A dictionary representing the JSON message contai... |
magic_instruct_75k | 25,373 | Write a Python function to simulate the joint stock price movements of two correlated stocks over a given number of time steps using a bivariate geometric Brownian motion model. The function should take the risk-free rate, correlation coefficient, volatilities of the two stocks, number of time steps, and the number of ... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def simulate_stock_prices(r, rho, sigma1, sigma2, nSteps, nSimulation):
"""
Simulate the joint stock price movements of two correlated stocks over a given number of time steps using a bivariate geometric Brow... |
magic_instruct_75k | 25,428 | Write a Python function `compare_lists(l1: List[int], l2: List[int]) -> int` that compares two lists `l1` and `l2` lexicographically after ensuring they have the same length by appending zeros to the shorter list. The function should return:
- `1` if `l1` is lexicographically greater than `l2`,
- `-1` if `l1` is lexico... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compare_lists(l1: List[int], l2: List[int]) -> int:
"""
Compares two lists lexicographically after ensuring they have the same length by appending zeros to the shorter list.
Args:
l1 (Li... |
magic_instruct_75k | 25,454 | Write a Python function to generate a request body for a user by including the user's permissions. The function `get_request_body_from_user` takes a `User` object as input and returns a dictionary representing the request body. The `User` object has a method `to_dict()` that returns a dictionary representation of the u... | Here is the Python code to solve the given problem in the markdown block:
```python
class User:
def __init__(self, username, email, permissions):
self.username = username
self.email = email
self.permissions = permissions
def to_dict(self):
return {
"username": self.u... |
magic_instruct_75k | 25,464 | Create a Python function to simulate a logging system that supports different types of log appenders and layouts, as well as different report levels. The function should append messages to a log and return a summary of the appender's properties.
The code should start with:
```python
from typing import List, Dict, Unio... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def log_appender(layout: str, report_level: str, messages: List[str]) -> Dict[str, Union[str, int]]:
"""
Simulates a logging system with different types of log appenders and layouts.
Ar... |
magic_instruct_75k | 25,479 | Write a Python function to generate a formatted Markdown list of required documentation tools from a given list of strings. Each string in the list represents a tool required for a documentation project. The list may contain duplicate entries, and the order of the tools should be preserved in the output. The function s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_documentation_list(doc_requires: List[str]) -> str:
"""
Generates a formatted Markdown list of required documentation tools from a given list of strings.
Args:
doc_requires (Lis... |
magic_instruct_75k | 25,484 | Create a Python decorator that logs the arguments and return value of a given function. The decorator should be named `log_arguments_and_return`. Additionally, write a function `multiply` that takes two arguments `x` and `y` and returns their product. Decorate the `multiply` function with the `log_arguments_and_return`... | Here is the Python code to solve the given problem in the markdown block:
```python
def log_arguments_and_return(func):
"""
A decorator that logs the arguments and return value of a given function.
Args:
func (function): The function to be decorated.
Returns:
function: The wrapper func... |
magic_instruct_75k | 25,534 | Write a Python function to find the highest score achieved in a series of games given a list of integers representing the scores. The function should efficiently determine the maximum value in the list.
The code should start with:
```python
from typing import List
def find_highest_score(scores: List[int]) -> int:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_highest_score(scores: List[int]) -> int:
"""
Find the highest score achieved in a series of games.
Args:
scores (List[int]): A list of integers representing the scores of the games.... |
magic_instruct_75k | 25,537 | Write a Python function to find the corresponding view name for a given URL name in a Django URL routing system. If the URL name is not found in the provided configuration, the function should return "Not Found". The function should start with:
```python
def find_view_name(url_name: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_view_name(url_name: str) -> str:
"""
Finds the corresponding view name for a given URL name in a Django URL routing system.
Args:
url_name (str): The name of the URL pattern to look up.
Returns:
... |
magic_instruct_75k | 25,538 | Write a Python function to construct and return a formatted HTTP header for a given set of parameters. The function should take a dictionary of header parameters as input and return a string representing the formatted HTTP header. Each key-value pair from the input dictionary should be represented on a new line in the ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def construct_http_header(header_parameters: Dict[str, str]) -> str:
"""
Constructs and returns a formatted HTTP header from a given dictionary of header parameters.
Args:
header_parameters ... |
magic_instruct_75k | 25,551 | Write a Python function to filter medical procedures based on the selected clinic department. The function should take a list of dictionaries representing available medical procedures and a string representing the selected clinic department. Each dictionary in the list contains the following key-value pairs:
- "name": ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def filter_procedures(procedures: List[Dict[str, str]], selected_department: str) -> List[Dict[str, str]]:
"""
Filters a list of medical procedures based on the selected clinic department.
Arg... |
magic_instruct_75k | 25,555 | Write a Python function to extract titles and URLs from a list of links formatted as `[Title][URL]`, where each link is separated by a newline character. The function should return a dictionary where the keys are the titles and the values are the corresponding URLs.
The code should start with:
```python
from typing im... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
import re
def extract_links(input_str: str) -> Dict[str, str]:
"""
Extracts titles and URLs from a list of links formatted as `[Title](URL)`.
Args:
input_str (str): A string containing the l... |
magic_instruct_75k | 25,558 | Write a Python function to determine the number of days you would have to wait until a warmer temperature for each day in a given list of daily temperatures. If there is no future day for which this is possible, the function should return 0 for that day.
The function should start with:
```python
from typing import Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def daily_temperatures(T: List[int]) -> List[int]:
"""
Calculate the number of days to wait for a warmer temperature for each day in the given list of daily temperatures.
Args:
T (List[int])... |
magic_instruct_75k | 25,584 | Write a Python function to synchronize a Configuration Management Database (CMDB) with the latest data from various sources. The function should take in the current state of the CMDB and the latest data from the sources, and update the CMDB accordingly. The function should update the attributes of existing CIs in the C... | Here is the Python code to solve the given problem in the markdown block:
```python
def sync_cmdb(current_cmdb: dict, latest_data: dict) -> dict:
"""
Synchronize the current Configuration Management Database (CMDB) with the latest data from various sources.
Args:
current_cmdb (dict): A dictionary r... |
magic_instruct_75k | 25,596 | Write a Python function to process a dataset containing three columns: an integer ID, a float value, and another integer. The function should perform the following operations:
1. Calculate the average of the float values for all data points with an odd ID.
2. Find the maximum float value for all data points with an eve... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def process_dataset(data: List[Tuple[int, float, int]]) -> Tuple[float, float, int]:
"""
Process a dataset to calculate the average of float values for data points with odd IDs,
find the maxim... |
magic_instruct_75k | 25,611 | Write a Python function to load gold labels from a label matrix using the provided code snippet as a reference. The function should take in a session, annotator name, and additional keyword arguments, and return the loaded gold labels. The function should utilize the `load_matrix` function, which takes in a label matri... | Here is the Python code to solve the given problem in the markdown block:
```python
def load_gold_labels(session, annotator_name, **kwargs):
"""
Load gold labels from a label matrix using the provided session and annotator name.
Args:
session: The session object used to load the labels.
ann... |
magic_instruct_75k | 25,635 | Write a Python function to generate a command for training a Neural Machine Translation (NMT) model using the `nmt.nmt` module. The function should accept various parameters related to the training process and construct a command string that can be executed to start the training. The parameters include source and targe... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_nmt_training_command(src: str, tgt: str, vocab_prefix: str, train_prefix: str, dev_prefix: str, test_prefix: str, out_dir: str, num_train_steps: int, steps_per_stats: int, num_layers: int, num_units: int, dropout: float, me... |
magic_instruct_75k | 25,638 | Implement a `NotificationManager` class that manages user subscriptions to topics and sends notifications to the appropriate users. The class should support the following functionalities:
1. `subscribe(topic: str, phoneNumber: str) -> None`: This method should allow a user to subscribe to a specific topic by providing ... | Here is the Python code to solve the given problem in the markdown block:
```python
class NotificationManager:
def __init__(self):
"""
Initialize the NotificationManager with an empty dictionary to store subscriptions.
"""
self.subscriptions = {}
def subscribe(self, topic: str, ... |
magic_instruct_75k | 25,644 | Write a Python function to parse a file path and extract specific information from it. The file path follows a specific format, and your function should be able to extract the filename, directory path, and the number of stars associated with the file from the given input.
The file path format is as follows:
```
<filen... | Here is the Python code to solve the given problem in the markdown block:
```python
def parse_file_path(file_path: str) -> dict:
"""
Parses a file path and extracts the filename, directory path, and the number of GitHub stars associated with the file.
Args:
file_path (str): The file path string to ... |
magic_instruct_75k | 25,664 | Write a Python function `extract_conversation_info(data)` that processes conversation data represented as a dictionary and extracts specific information from it. The function should return a tuple containing the participant ID, conversation ID, and modality of the conversation item. If any of these fields are missing i... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_conversation_info(data: dict) -> tuple:
"""
Extracts and returns the participant ID, conversation ID, and modality from the given conversation data.
Args:
data (dict): A dictionary representing the conve... |
magic_instruct_75k | 25,665 | Write a Python function to determine whether a given location is inside, outside, or overlapping a specified region. The region is defined by its start and end points, and the location is represented by a single point. The function should return one of the following values: `RegionPlace.inside`, `RegionPlace.outside`, ... | Here is the Python code to solve the given problem in the markdown block:
```python
from enum import Enum
class RegionPlace(Enum):
inside = 1
outside = 2
overlapping = 3
class Location:
def __init__(self, start: int):
self.start = start
class Region:
def __init__(self, start: int, end: in... |
magic_instruct_75k | 25,668 | Write a Python function to determine the winner of a game between two players, Takahashi and Aoki, based on the given integer `n` and the total number of turns `row`. The game proceeds in turns, with Takahashi and Aoki taking alternate turns. The winner is determined by comparing `n` with a critical value calculated by... | Here is the Python code to solve the given problem in the markdown block:
```python
def game_winner(n: int, row: int) -> str:
"""
Determine the winner of the game between Takahashi and Aoki based on the given integer n and the total number of turns row.
Args:
n (int): The initial value for the game... |
magic_instruct_75k | 25,683 | Write a Python function to determine the frequency of each word in a given string. The function should take a string as input and return a dictionary where the keys are the unique words in the input string, and the values are the frequencies of those words. The function should handle case sensitivity and punctuation.
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
import string
def wordFrequency(s: str) -> Dict[str, int]:
"""
Calculate the frequency of each word in a given string.
Args:
s (str): The input string from which to calculate word frequencie... |
magic_instruct_75k | 25,685 | Implement a simple Observer pattern in Python. The Observer pattern is a behavioral design pattern that defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. In this problem, you will create a basic implementation of the Observ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Any, List, Protocol
class Observer(Protocol):
"""
Interface for an Observer.
"""
def next(self, value: Any) -> None:
"""
Method called by the subject to provide the observer with a new... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.