source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_instruct_75k | 71,481 | Write a Python function to extract specific information from a given HTML content string. The HTML content contains a snippet of code from a web page, and the function should extract the following information:
1. The number of GitHub stars indicated by the `<gh_stars>` tag.
2. The welcome message for the user, which is... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def extract_information(html_content: str) -> (int, str):
"""
Extracts the number of GitHub stars and the welcome message from the given HTML content.
Args:
html_content (str): The HTML content string fro... |
magic_instruct_75k | 71,482 | Write a Python function to manipulate a list of strings representing output commands for a data processing pipeline. The function should perform the following operations:
1. Create a deep copy of the given list of output commands.
2. Insert a new command at the beginning of the copied list.
3. Remove all elements from ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import copy
def manipulate_output_commands(output_commands: List[str]) -> List[str]:
"""
Manipulates a list of output commands for a data processing pipeline.
Args:
output_commands (List[str... |
magic_instruct_75k | 71,495 | Create a Python function to simulate a simple animation system for a tabbed panel in a game development project. The function should define a class `TabPanel` that includes the following:
- A property `_tabPanelTween` of type `Tween` to handle the animation.
- A method `initTween()` to initialize the `_tabPanelTween` p... | Here is the Python code to solve the given problem in the markdown block:
```python
class Tween:
def __init__(self):
"""
Initialize the Tween object with an inactive state.
"""
self.is_active = False
def start(self):
"""
Start the animation and print a message in... |
magic_instruct_75k | 71,521 | Write a Python function to convert an input value to its string representation in the XSD (XML Schema Definition) format. The function should adhere to the SHACL (Shapes Constraint Language) syntax, which is used for validating RDF (Resource Description Framework) data. The function should take any input value and retu... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_to_xsd_string(input_value) -> str:
"""
Converts an input value to its string representation in the XSD format.
Args:
input_value: The value to be converted to an XSD string.
Returns:
str: Th... |
magic_instruct_75k | 71,525 | Write a Python function to bundle a list of nodes into an assembly and imprint it with metadata. The function should take in the following parameters:
- `nodes`: A list of nodes to be bundled into the assembly.
- `context`: Metadata containing information about the assembly, such as version, author, and origin.
- `load... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Any, Optional
def bundle_and_imprint(nodes: List[Any], context: Dict[str, str], loader: Optional[Any] = None, suffix: str = "CON") -> Any:
"""
Bundle a list of nodes into an assembly and imprint i... |
magic_instruct_75k | 71,567 | Write a Python function to process a list of sequences based on specified criteria. Each sequence is a list of integers. The function should perform the following operations on each sequence:
1. If the length of the sequence exceeds a specified maximum length, it should be truncated to the maximum length.
2. If the seq... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def process_sequences(sequences: List[List[int]], config: Dict[str, int]) -> List[List[int]]:
"""
Processes a list of sequences based on specified criteria.
Args:
sequences (List[List[... |
magic_instruct_75k | 71,600 | Write a Python function to calculate the sum of all even numbers in a given array. The function should take an array of integers as input and return the sum of all the even numbers in the array. The code should start with:
```python
from typing import List
def sum_of_even_numbers(arr: 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(arr: List[int]) -> int:
"""
Calculate the sum of all even numbers in a given array.
Args:
arr (List[int]): The array of integers from which to calculate the sum of ev... |
magic_instruct_75k | 71,610 | Write a Python function to calculate the sum of all even Fibonacci numbers up to a given limit. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. For example, the first few numbers in the Fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13... | Here is the Python code to solve the given problem in the markdown block:
```python
def even_fibonacci_sum(limit: int) -> int:
"""
Calculate the sum of all even Fibonacci numbers up to a given limit.
Args:
limit (int): The upper limit for the Fibonacci numbers to be considered.
Returns:
... |
magic_instruct_75k | 71,617 | Write a Python function to set the compiler flags for C, C++, and Fortran compilers based on the target architecture. The function should return a dictionary containing the compiler flags for each language. If the target architecture is not recognized, the function should return an empty dictionary.
The function shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
def set_compiler_flags(target_architecture: str) -> dict:
"""
Set the compiler flags for C, C++, and Fortran compilers based on the target architecture.
Args:
target_architecture (str): The target architecture for w... |
magic_instruct_75k | 71,623 | Write a Python function to generate command-line options for the Bowtie2 alignment tool based on a given reference genome and number of threads. The function should return a dictionary of options that includes the reference genome and the number of threads. Additionally, it should include some fixed options that are al... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_bowtie2_options(reference: str, threads: int) -> dict:
"""
Generates command-line options for the Bowtie2 alignment tool based on the given reference genome and number of threads.
Args:
reference (str):... |
magic_instruct_75k | 71,635 | Write a Python function to retrieve the corresponding shade of red from a given color code using a provided dictionary. If the color code is not found in the dictionary, the function should return "Unknown color code".
The code should start with:
```python
def get_red_shade(color_codes: dict, color_code: str) -> str:
... | Here is the Python code to solve the given problem in the markdown block:
```python
def get_red_shade(color_codes: dict, color_code: str) -> str:
"""
Retrieves the corresponding shade of red from a given color code using a provided dictionary.
Args:
color_codes (dict): A dictionary containing color... |
magic_instruct_75k | 71,636 | Write a Python function to determine the longest consecutive sequence of successful tests from a given list of test results. Each test result is represented by an integer, where a positive value indicates a successful test and a negative value indicates a failed test. The function should return the length of the longes... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def longest_consecutive_success(test_results: List[int]) -> int:
"""
Determine the length of the longest consecutive sequence of successful tests.
Args:
test_results (List[int]): A list of i... |
magic_instruct_75k | 71,639 | Write a Python function to parse a command string that sets rates for a specific meter array in a network traffic management system. The command string follows the syntax:
```
meter_array_set_rates <meter_array_name> <rate1>:<burst_size1> <rate2>:<burst_size2> ...
```
The function should extract the meter array name an... | Here is the Python code to solve the given problem in the markdown block:
```python
def parse_meter_array_set_rates(command: str) -> dict:
"""
Parses a command string to extract the meter array name and the rates with their corresponding burst sizes.
Args:
command (str): The command string in the f... |
magic_instruct_75k | 71,649 | Write a Python function to generate a package build script for the Termux package manager. The function should take in the package identifier, SHA256 checksum, and a list of dependencies, and return a string that represents the package build script. The script should set the `TERMUX_PKG_SHA256` variable to the provided... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_package_build_script(package_id: str, sha256_checksum: str, dependencies: List[str]) -> str:
"""
Generates a package build script for the Termux package manager.
Args:
package_i... |
magic_instruct_75k | 71,659 | Write a Python function to filter a list of column names in a database table, returning only those that end with the suffix "_modifier". The function should be efficient and handle various edge cases, such as an empty list or a list with no matching column names.
The code should start with:
```python
from typing impor... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_column_names(column_names: List[str]) -> List[str]:
"""
Filters a list of column names to return only those that end with the suffix "_modifier".
Args:
column_names (List[str]): A... |
magic_instruct_75k | 71,672 | Create a Python function that simulates a social media bot's behavior of following pages. The bot may encounter errors or restrictions while trying to follow a page. The function should handle these scenarios by printing appropriate messages and updating a counter variable `F` only when a page is successfully followed.... | Here is the Python code to solve the given problem in the markdown block:
```python
def simulate_follow_bot(gp, F: int) -> int:
"""
Simulates the behavior of a social media bot attempting to follow a page.
Args:
gp: An object representing the social media bot.
F (int): The current count of ... |
magic_instruct_75k | 71,679 | Write a Python function to extract unique layer names from a list of file paths representing the weights and biases of a neural network model. Each file path is in the format "layer_name/parameter_type_index", where "layer_name" is the name of the neural network layer, "parameter_type" is either "w" for weights or "b" ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_layer_names(file_paths: List[str]) -> List[str]:
"""
Extracts unique layer names from a list of file paths representing the weights and biases of a neural network model.
Args:
fi... |
magic_instruct_75k | 71,698 | Create a Python implementation of the Command Pattern for controlling lights. The implementation should include the following components:
1. A `Light` class that represents a light object with methods to turn on, turn off, and dim the light.
2. A base `LightCommand` class that serves as an abstract base class for all l... | Here is the Python code to solve the given problem in the markdown block:
```python
from abc import ABC, abstractmethod
class Light:
"""
Represents a light object with methods to turn on, turn off, and dim the light.
"""
def on(self):
print("Light is ON")
def off(self):
print("Ligh... |
magic_instruct_75k | 71,699 | Write a Python function to check whether all characters in a list of sentences are present in a given character dictionary. The character dictionary provides a mapping of characters to their corresponding integer values. If any character in a sentence is not present in the dictionary, the function should return `False`... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def check_characters_in_dict(sentences: List[str], char_dict: Any) -> bool:
"""
Checks whether all characters in a list of sentences are present in a given character dictionary.
Args:
s... |
magic_instruct_75k | 71,706 | Write a Python function to automate the creation of symbolic links for a set of configuration files. The function should take a single argument, which is the path to the directory where the configuration files are located. The function should then create symbolic links for specific files from the given directory to the... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
def create_config_symlinks(config_dir: str) -> None:
"""
Automates the creation of symbolic links for a set of configuration files from a given directory to the user's home directory.
Args:
config_dir (st... |
magic_instruct_75k | 71,719 | Write a Python function to concatenate two 2D arrays, `p_cols1` and `p_cols2`, along the rows and return the resulting concatenated array. Each array represents columns of a matrix. The function should ensure that the concatenation is done correctly, maintaining the integrity of the matrix structure.
The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def concatenate_columns(p_cols1: List[List[int]], p_cols2: List[List[int]]) -> List[List[int]]:
"""
Concatenates two 2D arrays along the rows and returns the resulting concatenated array.
Args:
... |
magic_instruct_75k | 71,727 | Implement a Python class `HIDParser` that simulates the behavior of a Human Interface Device (HID) parser. The class should provide methods for enumerating and scanning values within the input data. The class should be designed to mimic the functionality described in the given C++ code snippet.
The `HIDParser` class s... | Here is the Python code to solve the given problem in the markdown block:
```python
from enum import Enum
from typing import List, Callable, Optional
class ParserStatus(Enum):
Done = 1
InProgress = 2
Error = 3
class HIDMainItem:
def __init__(self, data: int):
self.data = data
class HIDParser:... |
magic_instruct_75k | 71,732 | Write a Python function to add two positive integers without using the '+' operator. Instead, utilize bitwise operations to achieve the addition. The function should start with:
```python
def add_without_plus(num1: int, num2: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def add_without_plus(num1: int, num2: int) -> int:
"""
Adds two positive integers without using the '+' operator, utilizing bitwise operations.
Args:
num1 (int): The first positive integer.
num2 (int): The s... |
magic_instruct_75k | 71,746 | Write a Python function to calculate the greatest common divisor (GCD) of the coefficients of a given polynomial. The coefficients are provided as a list of integers. The function should use the `math` module to compute the GCD.
The code should start with:
```python
from typing import List
import math
def find_poly_g... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import math
def find_poly_gcd(coefficients: List[int]) -> int:
"""
Calculate the greatest common divisor (GCD) of the coefficients of a polynomial.
Args:
coefficients (List[int]): A list of ... |
magic_instruct_75k | 71,754 | Write a Bash script to automate the reinitialization of containers in an AWS environment. The script should use the AWS CLI to invoke a Lambda function with specific parameters. The script should perform the following steps:
1. Check if the variable `local` is equal to "0".
2. If `local` is equal to "0", create a tempo... | Here is the Python code to solve the given problem in the markdown block:
```bash
#!/bin/bash
local="0" # Example value for the variable local
stack_name="example-stack" # Example value for the stack name
aws_profile="example-profile" # Example value for the AWS profile
# Check if the variable `local` is equal to ... |
magic_instruct_75k | 71,760 | Write a Python function to convert a given decimal number to its octal representation without using built-in functions for decimal to octal conversion. The function should take an integer `n` as input and return a string representing the octal equivalent of the input number.
The code should start with:
```python
def d... | Here is the Python code to solve the given problem in the markdown block:
```python
def decimal_to_octal(n: int) -> str:
"""
Converts a given decimal number to its octal representation.
Args:
n (int): The decimal number to be converted.
Returns:
str: The octal representation of the inp... |
magic_instruct_75k | 71,782 | Write a Python function to process a series of data messages efficiently. Each message contains a timestamp and a payload. The function should store the messages in a dictionary for efficient retrieval based on the timestamp.
The function signature should be:
```python
from typing import List, Tuple, Dict
def process... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def process_messages(num_msgs: int, messages: List[Tuple[int, str]]) -> Dict[int, str]:
"""
Processes a series of data messages and stores them in a dictionary for efficient retrieval.
... |
magic_instruct_75k | 71,793 | Implement a Python class `Matrix` that represents a 2D matrix of integers. The class should have the following methods:
1. `display()`: This method prints the elements of the matrix.
2. `maxRow(row: int, absolute: bool = False) -> int`: This method returns the maximum element in the specified row of the matrix. If the... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import math
class Matrix:
def __init__(self, matrix: List[List[int]]):
"""
Initialize the Matrix object with a 2D list of integers.
Args:
matrix (List[List[int]]): A 2D l... |
magic_instruct_75k | 71,800 | Create a Python function to calculate the area of a given shape (circle, rectangle, or triangle) based on the provided constants and function parameters. The function should be able to handle the following shapes:
- **Circle**: Parameters include the radius.
- **Rectangle**: Parameters include the width and height.
- *... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Union
# Constants
WND_WIDTH = 1000
WND_HEIGHT = 1000
PI = 3.1415926535897932384626
def calculate_area(shape: str, **kwargs) -> Union[float, int]:
"""
Calculate the area of a given shape.
Args:
s... |
magic_instruct_75k | 71,806 | Write a Python function to process a list of dictionaries containing information about reports generated on specific dates. Each dictionary has keys 'date', 'report_name', and 'status'. The function should return a dictionary containing the count of reports for each unique date and the count of reports for each unique ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def process_reports(reports: List[Dict[str, str]]) -> Dict[str, Dict[str, int]]:
"""
Processes a list of report dictionaries to count reports per unique date and per unique status.
Args:
... |
magic_instruct_75k | 71,809 | Write a Python function to convert a given decimal number to its binary representation. The function should take an integer as input and return a string representing the binary equivalent of the input number. The function should handle both positive and negative integers, as well as zero. The code should start with:
``... | Here is the Python code to solve the given problem in the markdown block:
```python
def decimal_to_binary(decimal: int) -> str:
"""
Converts a given decimal number to its binary representation.
Args:
decimal (int): The decimal number to be converted.
Returns:
str: The binary representa... |
magic_instruct_75k | 71,810 | Write a Python function to build a concept dictionary from a given list of concepts and their corresponding details. The function should take a list of tuples as input, where each tuple contains a concept and its details. The function should return a dictionary where the concepts are the keys and the details are the va... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def build_concept_dicts(concepts_and_details: List[Tuple[str, str]]) -> Dict[str, str]:
"""
Builds a concept dictionary from a list of tuples containing concepts and their details.
Args... |
magic_instruct_75k | 71,829 | Write a Python function to increment a given number represented as a string by 1 and return the result as a string. The function should handle both positive and negative integers, as well as zero. The code should start with:
```python
def increment_num(num: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def increment_num(num: str) -> str:
"""
Increments the given number represented as a string by 1 and returns the result as a string.
Args:
num (str): The number to be incremented, represented as a string.
Retur... |
magic_instruct_75k | 71,839 | Write a Python function to parse command-line arguments and extract specific information required for transferring files from a web source to a cloud storage account. The function should handle the command-line arguments in a predefined format and return a dictionary containing the extracted information.
The command-l... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def parse_command_line(args: List[str]) -> Dict[str, str]:
"""
Parses command-line arguments and extracts the necessary information for file transfer.
Args:
args (List[str]): A list of... |
magic_instruct_75k | 71,841 | Write a Python function to update a quota set by removing specific items from the quota set properties and required fields. The quota set is represented as a nested dictionary, and the items to be removed are specified in the `remove_item_list`. Your task is to write a function that takes the original quota set and the... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
import copy
def update_quota_set(original_quota_set: Dict, remove_item_list: List[str]) -> Dict:
"""
Update the quota set by removing specific items from the properties and required fields.
Ar... |
magic_instruct_75k | 71,853 | Write a Python function to calculate the total length of a path based on the given path information. The path information is represented by a data structure `path_info` which contains the number of points in the path and a list of path pieces, each defined by start and end points.
The `path_info` structure has the fol... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
from typing import List, Tuple
def calculate_path_length(path_info: dict) -> float:
"""
Calculate the total length of a path based on the given path information.
Args:
path_info (dict): A dictionary con... |
magic_instruct_75k | 71,873 | Write a Python function to calculate the sum of all even Fibonacci numbers up to a given limit. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. For example, the first few numbers in the Fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13... | Here is the Python code to solve the given problem in the markdown block:
```python
def even_fibonacci_sum(limit: int) -> int:
"""
Calculate the sum of all even Fibonacci numbers up to a given limit.
Args:
limit (int): The upper bound for the Fibonacci numbers to consider.
Returns:
int... |
magic_instruct_75k | 71,879 | Write a Python function to process a list of dictionaries representing configuration settings for a software application. Each dictionary contains key-value pairs representing individual settings. The function should remove any dictionaries that have a key named "preserve_default" with a value of `False`. The function ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def process_configurations(configurations: List[Dict[str, Union[str, bool]]]) -> List[Dict[str, Union[str, bool]]]:
"""
Processes a list of dictionaries representing configuration settings.
... |
magic_instruct_75k | 71,881 | Write a Python function to find the prime factorization of a given integer `m` and return a list of tuples where each tuple contains a prime factor and its multiplicity. The prime factors should be listed in ascending order.
The code should start with:
```python
from typing import List, Tuple
def prime_factorization(... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def prime_factorization(m: int) -> List[Tuple[int, int]]:
"""
Returns the prime factorization of a given integer `m` as a list of tuples.
Each tuple contains a prime factor and its multiplicit... |
magic_instruct_75k | 71,918 | Write a Python function to perform matrix multiplication using the dot product. The function should take two matrices as input and return the result of the dot product operation. The function should handle the case where the number of columns in the first matrix is not equal to the number of rows in the second matrix b... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def dot_product(matrix1: List[List[int]], matrix2: List[List[int]]) -> List[List[int]]:
"""
Perform matrix multiplication using the dot product.
Args:
matrix1 (List[List[int]]): The first ma... |
magic_instruct_75k | 71,953 | Write a Python function to randomly select a specified number of indices from a given total number of stars. The function should ensure that each star has an equal chance of being selected and that the selection process is truly random. The function should handle cases where the number of stars to be selected exceeds t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def select_random_stars(total_stars: int, num_selected: int) -> List[int]:
"""
Randomly selects a specified number of indices from a given total number of stars.
Args:
total_st... |
magic_instruct_75k | 71,954 | Write a Python function to filter out even numbers from a given list of integers while preserving their original order. The function should return a new list containing only the even numbers from the input list.
The code should start with:
```python
from typing import List
def filter_even_numbers(numbers: List[int]) ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_even_numbers(numbers: List[int]) -> List[int]:
"""
Filters out even numbers from a given list of integers while preserving their original order.
Args:
numbers (List[int]): A list ... |
magic_instruct_75k | 72,003 | Create a Python class `Student` with the following properties:
- `Name` of type `FullName` (a class with `FirstName` and `LastName` properties)
- `Type` of type `StudentType` (an enum with values `Real` and `Fake`)
Implement a method `CreateDefaultStudent()` in the `Student` class that returns a new `Student` instance... | Here is the Python code to solve the given problem in the markdown block:
```python
from enum import Enum
class FullName:
"""
Represents a full name with first and last names.
Attributes:
FirstName (str): The first name.
LastName (str): The last name.
"""
def __init__(self, first_n... |
magic_instruct_75k | 72,010 | Write a Python function to process a list of file paths and extract the file names from each path. The function should then sort the file names in lexicographical order and remove any duplicate file names. Finally, the function should return the sorted, unique file names.
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
def extract_and_sort_file_names(file_paths: List[str]) -> List[str]:
"""
Extracts file names from a list of file paths, removes duplicates, and sorts them in lexicographical order.
Args:
fil... |
magic_instruct_75k | 72,030 | Write a Python function to process a list of package names and their corresponding versions, and return a dictionary where the package names are the keys and the corresponding versions are the values. The function should handle the input list of tuples, where each tuple contains a package name (string) and its version ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def process_packages(package_info: List[Tuple[str, str]]) -> Dict[str, str]:
"""
Processes a list of package names and their corresponding versions, and returns a dictionary.
Args:
... |
magic_instruct_75k | 72,042 | Write a Python function to remove all occurrences of a specific name from a list of names, except for the first occurrence. The function should take the list of names and the name to be removed as input and return the modified list. The code should start with:
```python
from typing import List
def remove_duplicates(na... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates(names: List[str], name_to_remove: str) -> List[str]:
"""
Removes all occurrences of a specific name from the list, except for the first occurrence.
Args:
names (List[st... |
magic_instruct_75k | 72,091 | Write a Python function to count the occurrences of unique file extensions in a list of file paths, ignoring case sensitivity. The function should return a dictionary where the keys are the unique file extensions (in lowercase) and the values are the counts of their occurrences. If a file path does not contain a file e... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_file_extensions(file_paths: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of unique file extensions in a list of file paths, ignoring case sensitivity.
Args:
file_... |
magic_instruct_75k | 72,098 | Write a Python function to process a list of integers and return a modified version of the list. The function should perform the following operations on each element:
- If the number is even, it should be multiplied by 2.
- If the number is odd, it should be squared.
The function should start with:
```python
from typi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_data(data: List[int]) -> List[int]:
"""
Process a list of integers by modifying each element based on whether it is even or odd.
If the number is even, it is multiplied by 2. If the numbe... |
magic_instruct_75k | 72,116 | Write a Python function to calculate the highest possible sum of scores from a given list such that no two chosen scores are adjacent in the original list. The function should be named `maxNonAdjacentSum` and should take a list of integers as input, returning an integer representing the maximum sum.
The code should st... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def maxNonAdjacentSum(scores: List[int]) -> int:
"""
Calculate the highest possible sum of scores such that no two chosen scores are adjacent.
Args:
scores (List[int]): A list of integers re... |
magic_instruct_75k | 72,117 | Write a Python function to parse a given code snippet containing route definitions in a Laravel `web.php` file and extract the route paths and associated controller methods. The function should ignore commented routes and return a dictionary where the keys are the route paths and the values are the corresponding contro... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def parseRoutes(code_snippet: str) -> dict:
"""
Parses a given code snippet containing route definitions in a Laravel `web.php` file and extracts the route paths and associated controller methods.
Args:
c... |
magic_instruct_75k | 72,123 | Write a Python function to validate and process grade values entered by users. The grade value should be a floating-point number within the range of 0.0 to 100.0, inclusive. Additionally, the grade value should not contain any non-numeric characters, except for a single decimal point if the grade is a floating-point nu... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_grade(grade_value: str) -> bool:
"""
Validates if the given grade value is a valid floating-point number within the range of 0.0 to 100.0.
Args:
grade_value (str): The grade value to be valid... |
magic_instruct_75k | 72,134 | Write a Python function to perform an inorder traversal of a binary tree iteratively using a stack. The function should return a list of values in the order they are visited. The binary tree node structure is defined as follows:
```python
class TreeNode:
def __init__(self, val=0, left=None, right=None):
sel... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def inorderTraversal(root: TreeNode) -> List[int]:
"""
Pe... |
magic_instruct_75k | 72,136 | Write a Python function to check if a given string of parentheses is balanced. A string is considered balanced if each opening parenthesis has a corresponding closing parenthesis in the correct order. The function should use a stack data structure to achieve this.
The code should start with:
```python
from typing impo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_balanced_parentheses(parentheses: str) -> bool:
"""
Check if a given string of parentheses is balanced.
A string is considered balanced if each opening parenthesis has a corresponding
clo... |
magic_instruct_75k | 72,159 | Write a Python function to analyze cost summaries for various services in an Azure environment. The function should take in a list of report names, start date, and end date as input parameters. It will then retrieve the cost summaries for the specified reports within the given date range and return a dictionary contain... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def retrieve_cost_summaries(report_names: List[str], start_date: str, end_date: str) -> Dict[str, str]:
"""
Retrieves cost summaries for various services in an Azure environment.
Args:
... |
magic_instruct_75k | 72,181 | Write a Python function to calculate the distance a player object will move in a given time interval based on its speed. The function should take the speed of the player object and the time interval as inputs and return the distance the player object will move during that time interval. The movement is calculated using... | Here is the Python code to solve the given problem in the markdown block:
```python
def CalculateDistanceMoved(speed: float, time: float) -> float:
"""
Calculate the distance a player object will move in a given time interval based on its speed.
Args:
speed (float): The speed of the player object i... |
magic_instruct_75k | 72,189 | Write a Python function to process the results of a fitting procedure and return specific values based on the input parameters. The function should handle different scenarios depending on whether a parameter `nH_Gal` is fixed and whether errors need to be calculated. The function should return the values of `kT`, `Z`, ... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_fit_results(fit_result, find_errors, fix_nH_Gal):
"""
Processes the results of a fitting procedure and returns specific values based on the input parameters.
Args:
fit_result (object): An object containi... |
magic_instruct_75k | 72,204 | Write a Python function to monitor the engine speed of a 6-cylinder engine. The engine speed is measured in revolutions per minute (rpm). The function should store and update the engine speed and provide a method to calculate the average engine speed over a given time period.
The function should start with:
```python
... | Here is the Python code to solve the given problem in the markdown block:
```python
from collections import deque
from typing import List
def monitor_engine_speed(speed_updates: List[int], duration: int) -> float:
"""
Monitors the engine speed and calculates the average engine speed over a given time period.
... |
magic_instruct_75k | 72,211 | Write a Python function `process_model_params` that takes a dictionary `bo_dict` as input and performs the following tasks:
1. Extract the value associated with the key 'depth' from the dictionary and store it in a variable `depth_val`.
2. Check if the key 'kldloss' is present in the dictionary. If it is present and it... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_model_params(bo_dict: dict) -> tuple:
"""
Processes the model parameters from a given dictionary and returns specific values.
Args:
bo_dict (dict): A dictionary containing various parameters for a machin... |
magic_instruct_75k | 72,219 | Write a Python function to determine if a specific package is present in a list of device packages. Each device package is represented as a string containing the package name. The function should return `True` if the package is found and `False` otherwise. Additionally, the function should handle cases where the input ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_package_present(packages: List[str], target_package: str) -> bool:
"""
Determines if a specific package is present in a list of device packages.
Args:
packages (List[str]): A list of ... |
magic_instruct_75k | 72,221 | Write a Python function to generate a migration code string for altering a field in a database model. The function should take the model name, field name, and the new field type as input and return a string representing the migration code. The migration code should follow a specific format with proper indentation and i... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_migration_code(model_name: str, field_name: str, new_field_type: str) -> str:
"""
Generates a migration code string for altering a field in a database model.
Args:
model_name (str): The name of the mode... |
magic_instruct_75k | 72,229 | Write a Python function to convert parameter names in a dictionary from one naming convention to another based on a given mapping dictionary. The function should take two dictionaries as input: one containing the parameters in the original naming convention and the other containing the mapping from the original naming ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def convert_parameter_names(input_dict: Dict[str, any], mapping_dict: Dict[str, str]) -> Dict[str, any]:
"""
Converts parameter names in a dictionary from one naming convention to another based on a give... |
magic_instruct_75k | 72,236 | Write a Python function to validate a nested dictionary structure representing a database configuration. The function should ensure that specific keys are present and have the correct data types and values. The configuration dictionary has a specific structure, and the function should validate the presence and correctn... | Here is the Python code to solve the given problem in the markdown block:
```python
def validate_config(config: dict) -> bool:
"""
Validates a nested dictionary structure representing a database configuration.
Args:
config (dict): The configuration dictionary to validate.
Returns:
bool... |
magic_instruct_75k | 72,257 | Write a Python function to group attribute names by their corresponding model names from a list of dictionaries. Each dictionary in the list contains the keys "model_name" and "name", representing the model name and attribute name, respectively. The function should return a new dictionary where the keys are the model n... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def group_attributes(models: List[Dict[str, str]]) -> Dict[str, List[str]]:
"""
Groups attribute names by their corresponding model names from a list of dictionaries.
Args:
models (Lis... |
magic_instruct_75k | 72,263 | Write a Python function to implement an autocomplete feature for a location-based search. The function should take various parameters and return a list of suggested completions based on the input text and other search criteria. The function should utilize the provided parameters to fetch and process relevant data, and ... | Here is the Python code to solve the given problem in the markdown block:
```python
def _autocomplete(client, url_part, input_text, session_token=None,
offset=None, location=None, radius=None, language=None):
"""
Generate autocomplete suggestions based on the input text and search criteria.
... |
magic_instruct_75k | 72,283 | Write a Python function to count the number of unique atoms in each multi-level lattice. Each lattice is represented as a list of lists, where each inner list represents a level of the lattice. The atoms are represented by integers, and the same type of atom is denoted by the same integer value. The function should ret... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_unique_atoms(lattices: List[List[List[int]]]) -> List[int]:
"""
Counts the number of unique atoms in each multi-level lattice.
Args:
lattices (List[List[List[int]]]): A list of lat... |
magic_instruct_75k | 72,284 | Write a Python function `process_data_types` that processes a list of strings, each representing a data type declaration or alias assignment. The function should return a dictionary containing the final data type mappings. The input strings will follow specific formats for data type declarations and alias assignments. ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union, Type
def process_data_types(data_type_strings: List[str]) -> Dict[str, Union[str, Type]]:
"""
Processes a list of strings representing data type declarations and alias assignments.
Retu... |
magic_instruct_75k | 72,319 | Write a Python function to process error messages from a code analysis tool and extract relevant information. The error messages are in the format of `file_path:line_number:column_number - error_message`. Your function should parse these error messages and return a list of dictionaries, where each dictionary contains t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
import re
def process_error_messages(error_messages: List[str]) -> List[Dict[str, str]]:
"""
Processes a list of error messages and extracts relevant information.
Args:
error_messages ... |
magic_instruct_75k | 72,332 | Write a Python function to calculate the final balance of a bank account after processing a list of transactions. Each transaction is represented as a string in the format "action amount", where "action" is either "deposit" or "withdraw" and "amount" is a positive integer representing the transaction amount. The functi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_balance(transactions: List[str]) -> int:
"""
Calculate the final balance of a bank account after processing a list of transactions.
Args:
transactions (List[str]): A list of tr... |
magic_instruct_75k | 72,343 | Write a Python function `process_clients` that processes a list of client names according to the following rules:
1. If a client name contains a forward slash ('/'), truncate the name at the position of the first forward slash.
2. If the resulting client name is found in a predefined dictionary `GO_EXCEPTIONS`, replace... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Set
GO_EXCEPTIONS = {
'client2': 'modified_client2',
'client4': 'modified_client4'
}
def process_clients(client_names: List[str]) -> Set[str]:
"""
Processes a list of client names and returns a... |
magic_instruct_75k | 72,365 | Write a Python function to solve the 0/1 Knapsack problem, which calculates the maximum value that can be obtained by selecting a subset of items such that the total weight does not exceed the given capacity. Each item has a weight and a value, and you can either include an item in the knapsack or exclude it (0/1 prope... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def knapsack_max_value(weights: List[int], values: List[int], capacity: int) -> int:
"""
Calculate the maximum value that can be obtained by selecting a subset of items
such that the total weight doe... |
magic_instruct_75k | 72,389 | Write a Python function to automate the generation of Cardano node VRF (Verifiable Random Function) key pairs for a given number of nodes. The function should execute the command `cardano-cli node key-gen-VRF` to create a verification key file (`node<i>-vrf.vkey`) and a signing key file (`node<i>-vrf.skey`), where `<i>... | Here is the Python code to solve the given problem in the markdown block:
```python
import subprocess
def generate_vrf_key_pairs(n: int) -> None:
"""
Automates the generation of Cardano node VRF key pairs for a given number of nodes.
Args:
n (int): The number of nodes for which VRF key pairs need ... |
magic_instruct_75k | 72,404 | Write a Python function to trace the steps of a search algorithm and provide information about the search process. The function should be able to store the step number and description of each step, and print out the traced steps in the format "Step <step>: <description>".
The code should start with:
```python
from typ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def trace_search_steps(steps: List[Tuple[int, str]]) -> None:
"""
Traces the steps of a search algorithm and prints the steps in the format "Step <step>: <description>".
Args:
steps (... |
magic_instruct_75k | 72,406 | Write a Python function called `square_mapper` that takes a list of integers as input and returns a new list containing the squares of each integer in the original list. The function should adhere to the functional programming paradigm and avoid using explicit loops or list comprehensions. Instead, it should utilize th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def square_mapper(input_list: List[int]) -> List[int]:
"""
Returns a new list containing the squares of each integer in the input list.
This function adheres to the functional programming paradigm b... |
magic_instruct_75k | 72,425 | Write a Python function to add a new URL pattern to an existing list of URL patterns. Each URL pattern is represented as a string and can include placeholders for variable parts of the URL. The function should append the new URL pattern to the list and return the updated list.
The code should start with:
```python
fro... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def add_url_pattern(urlpatterns: List[str], new_pattern: str) -> List[str]:
"""
Adds a new URL pattern to an existing list of URL patterns and returns the updated list.
Args:
urlpatterns (Li... |
magic_instruct_75k | 72,430 | Write a Python function to process escape sequences in a given string. The function should replace escape sequences with their corresponding characters. The escape sequences to be handled are:
- If the character is not a backslash (`\`), it should be returned as is.
- If the character is a backslash followed by three o... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_escape_sequence(input_string: str) -> str:
"""
Processes escape sequences in a given string and returns a new string with the escape sequences replaced by their corresponding characters.
Args:
input_stri... |
magic_instruct_75k | 72,445 | Write a Python function to find the highest score and its corresponding position in a list of integers representing the scores of participants in a competition. The scores are listed in ascending order of the participants' performance. If there are multiple occurrences of the highest score, return the position of the f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_highest_score_position(scores: List[int]) -> Tuple[int, int]:
"""
Find the highest score and its corresponding position in a list of scores.
Args:
scores (List[int]): A list ... |
magic_instruct_75k | 72,450 | Implement a Python class `ProductManager` that manages product information in a GUI application. The class should include methods to update the GUI with product data and calculate the total price of a product based on its quantity and unit price. The `inserir_dados` method should parse the input `dados` and update the ... | Here is the Python code to solve the given problem in the markdown block:
```python
class ProductManager:
def __init__(self, root):
"""
Initialize the ProductManager with the root GUI element.
Args:
root: The root element of the GUI.
"""
# Initialize GUI elements... |
magic_instruct_75k | 72,492 | Write a Python function to format medical eye examination data into an HTML table row. The function should take three parameters: `trans_sphere` (float), `trans_cylinder` (float), and `trans_axis` (int). The function should return a formatted HTML table row with three cells, each containing specific information derived... | Here is the Python code to solve the given problem in the markdown block:
```python
def format_eye_exam_data(trans_sphere: float, trans_cylinder: float, trans_axis: int) -> str:
"""
Formats medical eye examination data into an HTML table row.
Args:
trans_sphere (float): The spherical correction for... |
magic_instruct_75k | 72,508 | Implement a Python class `Builder` that initializes a builder for a test suite management system. The class should be initialized with three services: `resmoke_proxy`, `suite_split_service`, and `evg_config_gen_service`. The class should provide a method `generate_task_options` that takes a `GenTaskOptions` object and ... | Here is the Python code to solve the given problem in the markdown block:
```python
class Builder:
"""
A class to initialize a builder for a test suite management system.
Attributes:
resmoke_proxy (object): Proxy to access resmoke data.
suite_split_service (object): Service to split suites ... |
magic_instruct_75k | 72,513 | Write a Python function to filter a list of shape names based on the number of parts each shape has. The function should take in a dictionary containing the names of shapes as keys and the corresponding number of parts as values, along with minimum and maximum thresholds for the number of parts. The function should ret... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def filter_shapes_by_parts(nparts_dict: Dict[str, int], min_n_parts: int, max_n_parts: int) -> List[str]:
"""
Filters a list of shape names based on the number of parts each shape has.
Args:
... |
magic_instruct_75k | 72,540 | Write a Python function to count the number of clusters in an undirected graph represented by an adjacency list. A cluster is defined as a group of connected vertices within the graph. The function should take the adjacency list as input and return the total number of clusters present in the graph.
The code should sta... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def count_clusters(graph: Dict[int, List[int]]) -> int:
"""
Count the number of clusters in an undirected graph represented by an adjacency list.
Args:
graph (Dict[int, List[int]]): Th... |
magic_instruct_75k | 72,543 | Write a Python function `process_column_descriptions` that processes a list of column descriptions and returns a list of tuples containing specific information about each column. Each tuple should include the following information for each column:
- Column name
- Type code
- Display size (default to `None`)
- Internal ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
class ColumnType:
def __init__(self, type: str, nullable: bool):
self.type = type
self.nullable = nullable
class ColumnDescription:
def __init__(self, col_name: str, col_type: Col... |
magic_instruct_75k | 72,557 | Write a Python function to calculate the fitness evaluation for a given solution to the traveling salesman problem. The function should take a solution (represented as a list of cities) and a dictionary of costs for traveling between pairs of cities. The function should return the total cost of the solution, which repr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def fitness(solution: List[int], cost: Dict[tuple, int]) -> int:
"""
Calculate the fitness evaluation for a given solution to the traveling salesman problem.
The fitness evaluation is based on... |
magic_instruct_75k | 72,568 | Write a Python function to count the occurrences of each unique integer in a given list of integers. The function should return a dictionary where the keys are the unique integers from the input list, and the values are the counts of each unique integer.
The code should start with:
```python
from typing import List, D... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_unique_integers(arr: List[int]) -> Dict[int, int]:
"""
Counts the occurrences of each unique integer in the given list.
Args:
arr (List[int]): The list of integers to count.
... |
magic_instruct_75k | 72,570 | Write a Python function to convert an integer into a list of its individual digits. The function should take an integer as input and return a list of integers, where each integer in the list represents a digit from the input number. The function should handle both positive and negative integers, ensuring that the digit... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def convert_to_digits(number: int) -> List[int]:
"""
Converts an integer into a list of its individual digits.
Args:
number (int): The integer to be converted into a list of digits.
Ret... |
magic_instruct_75k | 72,578 | Write a Python function to determine if a list of operations forms a valid chain of open and close operations. The operations can be of two types: "open" and "close". The function should return a boolean value indicating whether the list of operations forms a valid chain of open and close operations.
The rules for a v... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def chainOpen(operations: List[str]) -> bool:
"""
Determines if a list of operations forms a valid chain of open and close operations.
Args:
operations (List[str]): A list of strings where e... |
magic_instruct_75k | 72,581 | Write a Python function to calculate the total time taken to process a series of requests sequentially. Each request has a specific processing time, and the requests are processed one after another. The function should take a list of request processing times as input and return the total time taken to process all the r... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_total_time(reqs: List[int]) -> int:
"""
Calculate the total time taken to process a series of requests sequentially.
Args:
reqs (List[int]): A list of integers where each integ... |
magic_instruct_75k | 72,601 | Implement a Python function to retrieve the output tensors from a subgraph of a neural network model. The subgraph is represented as a collection of nodes and edges, where each node corresponds to a layer in the neural network model. The function should iterate through the model outputs and populate a dictionary with t... | Here is the Python code to solve the given problem in the markdown block:
```python
from collections import OrderedDict
def get_output_tensors(subgraph):
"""
Retrieve the output tensors from a subgraph of a neural network model.
Args:
subgraph: A collection of nodes and edges representing the subg... |
magic_instruct_75k | 72,610 | Write a Python function to process a list of database migration operations and return a dictionary containing the names of the models being modified and the details of the fields being altered. Each migration operation is represented as a tuple with the following elements:
1. The operation type, which can be 'migration... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def process_migration_operations(operations: List[Tuple[str, str, str, Dict]]) -> Dict[str, List[Tuple[str, Dict]]]:
"""
Processes a list of database migration operations and returns a dicti... |
magic_instruct_75k | 72,612 | Complete the given Python program to print the elements of `MyArray` in reverse order, separated by a space. The program initializes an array `MyArray` with values from 1 to 20 and then enters a while loop. Your task is to add code inside the second while loop to achieve the desired output.
The starter code is as foll... | Here is the Python code to solve the given problem in the markdown block:
```python
i = 0
MyArray = [0] * 20 # Initialize MyArray with 20 elements
while(i < 20):
MyArray[i] = i + 1
i = i + 1
j = 0
i = 19
while(j < 20):
print(MyArray[i], end=" ") # Print the elements of MyArray in reverse order
i = ... |
magic_instruct_75k | 72,615 | Write a Python function to count the number of contigs in a given contig set. A contig is a contiguous sequence of DNA or RNA, typically assembled from sequence reads. The function should take in three parameters: `ctx` (the context object), `workspace_name` (the name of the workspace), and `contigset_id` (the identifi... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_contigs(ctx, workspace_name, contigset_id):
"""
Count the number of contigs in a given contig set.
Args:
ctx: The context object providing access to the workspace.
workspace_name: The name of the w... |
magic_instruct_75k | 72,620 | Write a Python function to generate an HTML page that redirects to a specified URL after a given timeout duration. The function should take two parameters: the URL to redirect to and the timeout duration in seconds. The generated HTML page should include a meta tag for redirection and a message indicating the redirecti... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_redirect_page(url: str, timeout: int) -> str:
"""
Generates an HTML page that redirects to the specified URL after the given timeout duration.
Args:
url (str): The URL to which the page should redirect.... |
magic_instruct_75k | 72,653 | Write a Python function to generate SVG (Scalable Vector Graphics) code for a simple rectangle with specific attributes. The function should take four parameters:
- `x`: The x-coordinate of the top-left corner of the rectangle.
- `y`: The y-coordinate of the top-left corner of the rectangle.
- `width`: The width of the... | Here is the Python code to solve the given problem in the markdown block:
```python
def generateSVGCode(x: int, y: int, width: int, height: int) -> str:
"""
Generates SVG code for a rectangle with the specified position and dimensions.
Args:
x (int): The x-coordinate of the top-left corner of the r... |
magic_instruct_75k | 72,657 | Write a Python function to simulate a system reservation process. The function should take a list of system statuses and return a corresponding list of reservation codes based on the following criteria:
- Return code 0: The system is accessible and available for reservation.
- Return code 1: The system is inaccessible ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reserve_systems(system_statuses: List[str]) -> List[int]:
"""
Simulates a system reservation process by converting system statuses into reservation codes.
Args:
system_statuses (List[str... |
magic_instruct_75k | 72,671 | Write a Python function to calculate the total illumination at a given point in a 3D scene using a simple Lambertian lighting model. The scene contains multiple lights of different types: point lights and directional lights. Each light contributes to the total illumination based on its position or direction and color.
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import math
class LightInterface:
def calculate_illumination(self, point: Tuple[float, float, float]) -> float:
"""
Calculate the illumination at a given point in the scene.
... |
magic_instruct_75k | 72,687 | Write a Python function to parse a code snippet from a test fixture file and extract the test data from the placeholders. The placeholders are represented by `{0}`, `{1}`, `{2}`, `{3}`, and `{4}` and are always separated by tabs (`\t`). The function should return the test data in the order they appear in the code snipp... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def parse_test_case(code_snippet: str) -> List[str]:
"""
Parses a code snippet from a test fixture file and extracts the test data from the placeholders.
Args:
code_snippet (str): The code s... |
magic_instruct_75k | 72,706 | Write a Python function to check for collisions between a player character and a list of enemy characters in a simple game. The function should take in the list of enemy positions, the player's position, and the sizes of both the player and the enemies. The function should return `True` if the player collides with any ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def collision_check(enemy_list: List[Tuple[int, int]], player_pos: Tuple[int, int], player_size: Tuple[int, int], enemy_size: Tuple[int, int]) -> bool:
"""
Checks for collisions between the player... |
magic_instruct_75k | 72,727 | Write a Python function to simulate the system administration tasks described in the given code snippet. The function should:
1. Terminate all instances of the "minecraft-launcher" and "firefox" applications.
2. Display the running processes for "minecraft-launcher" and "firefox" without showing the grep command itself... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def manage_applications(processes: List[Dict[str, str]], minecraft_launcher_path: str) -> None:
"""
Simulates the management of "minecraft-launcher" and "firefox" applications.
Args:
p... |
magic_instruct_75k | 72,730 | Write a Python function to determine the final position on a 2D plane after processing a series of moves represented by a string. The string consists of characters 'U', 'D', 'L', and 'R', which stand for "up", "down", "left", and "right" respectively. Each move brings you one unit in the respective direction. The initi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
def final_position(s: str) -> Tuple[int, int]:
"""
Determine the final position on a 2D plane after processing a series of moves.
Args:
s (str): A string consisting of characters 'U', 'D', ... |
magic_instruct_75k | 72,735 | Write a Python function to analyze and process waveform data generated by a signal processing library. The function should take the measured waveform data as input and perform the following analyses:
1. Calculate the peak-to-peak voltage of the waveform.
2. Determine the average voltage of the waveform.
3. Identify the... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def waveform_analysis(waveform_data: List[float]) -> Dict[str, float]:
"""
Analyzes the given waveform data to calculate the peak-to-peak voltage, average voltage, and frequency.
Args:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.