source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_instruct_75k
10,089
Write a Python function to simulate rolling a specified number of dice a specified number of times and return the outcomes in a list of lists. Each inner list should represent the outcomes of rolling the dice for a single roll. The function should handle the following: - Ensure that the number of dice and the number of...
Here is the Python code to solve the given problem in the markdown block: ```python import random from typing import List def roll_dice(num_dice: int, num_rolls: int) -> List[List[int]]: """ Simulates rolling a specified number of dice a specified number of times and returns the outcomes. Args: nu...
magic_instruct_75k
10,105
Write a Python function to determine if a given string `s` matches a given pattern `p`, where the pattern can contain wildcard characters `*` and `?`. The function should return `True` if the string matches the pattern, and `False` otherwise. The wildcard `*` matches zero or more of any character, while the wildcard `...
Here is the Python code to solve the given problem in the markdown block: ```python def is_match(s: str, p: str) -> bool: """ Determine if a given string `s` matches a given pattern `p` containing wildcards `*` and `?`. Args: s (str): The string to be matched. p (str): The pattern containin...
magic_instruct_75k
10,154
Write a Python function to apply multiple filters to a given list of results. Each filter is a function that returns `True` or `False` based on whether the result meets certain criteria. The function should return a list containing only the elements from the result list that pass all the filter functions in the filters...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Callable def multifilter(filters: List[Callable[[int], bool]], result: List[int]) -> List[int]: """ Applies multiple filters to a given list of results and returns a list of elements that pass all the f...
magic_instruct_75k
10,164
Write a Python function to group publications by their authors from a given list of publications. Each publication is represented as a string in the format "Title, Author, Journal/Conference Year." The function should return a dictionary where the keys are the unique authors and the values are lists of publications aut...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def group_publications(publications: List[str]) -> Dict[str, List[str]]: """ Groups publications by their authors from a given list of publications. Args: publications (List[str]): A l...
magic_instruct_75k
10,165
Write a Python function to automate the process of enabling and starting the MySQL service on a Linux server and retrieving the temporary password generated during the installation process. The function should perform the following tasks: 1. Enable the MySQL service using the `systemctl` command. 2. Start the MySQL ser...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess import re def automate_mysql_setup(): """ Automates the process of enabling and starting the MySQL service on a Linux server and retrieves the temporary password generated during the installation process. ...
magic_instruct_75k
10,171
Write a Python function to detect circular dependencies in a system of configuration sets. The function should take a dictionary representing the dependencies between configuration sets and return `True` if a circular dependency exists, and `False` otherwise. The `dependencies` parameter is a dictionary where the keys...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def detect_circular_dependency(dependencies: Dict[str, List[str]]) -> bool: """ Detects whether there is a circular dependency in the given configuration sets. Args: dependencies (Dict...
magic_instruct_75k
10,173
Write a Python function to automate the deployment process for a web application. The deployment process involves the following steps: 1. Change directory to `/net/bcoin/explorer`. 2. Pull the latest changes from the Git repository. 3. Change directory to `/net/bcoin/explorer/platform`. 4. Stop the production server by...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess import os def deploy_web_application(): """ Automates the deployment process for a web application by executing a series of shell commands in a specific sequence. Steps: 1. Change directory to /net/bc...
magic_instruct_75k
10,179
Write a Python function `update_maintenance_schedule` that manages tree maintenance schedules. The function should take the type of tree, notes about the maintenance, start and end times for the maintenance (in UTC), and the current count of maintenance tasks. The function should convert the start and end times from UT...
Here is the Python code to solve the given problem in the markdown block: ```python from datetime import datetime, timedelta def update_maintenance_schedule(tree_type: str, note: str, start_time: datetime, end_time: datetime, curr_count: int) -> int: """ Updates the maintenance schedule by converting the start...
magic_instruct_75k
10,187
Write a Python function to calculate the wrapped coordinates of a point within a 2D world grid with given dimensions. The function should handle the wrapping behavior of the point's coordinates when they go beyond the boundaries of the world. Specifically, if the point's x-coordinate becomes negative, it should wrap ar...
Here is the Python code to solve the given problem in the markdown block: ```python def wrap_coordinates(x: int, y: int, dimensions: int) -> tuple: """ Calculate the wrapped coordinates of a point within a 2D world grid with given dimensions. Args: x (int): The current x-coordinate of the point. ...
magic_instruct_75k
10,211
Write a Python function to extract version numbers and their corresponding release dates from a given code snippet. The code snippet contains version information in the format: ``` # Leo 5.7b2: February 12, 2018. # Leo 5.7 final: February 27, 2018. ``` Each line represents a version with its release date. The version n...
Here is the Python code to solve the given problem in the markdown block: ```python import re def extract_versions_and_dates(code_snippet: str) -> None: """ Extracts version numbers and their corresponding release dates from a given code snippet. Args: code_snippet (str): The code snippet containi...
magic_instruct_75k
10,224
Write a Python function to compare two software version numbers represented as strings in the format "x.y.z", where x, y, and z are non-negative integers. The function should return 1 if the first version number is greater, -1 if the second version number is greater, and 0 if they are equal. The version numbers may hav...
Here is the Python code to solve the given problem in the markdown block: ```python def compare_versions(version1: str, version2: str) -> int: """ Compares two software version numbers and returns: - 1 if the first version number is greater, - -1 if the second version number is greater, - 0 if they ...
magic_instruct_75k
10,235
Write a Python function to determine the category of a software change based on its properties. The function should take in the name, description, priority, headings, and severity of the change and return the appropriate category as a string ("EventsObsolete" or "EventsBreakingChange"). The function should also handle ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def determine_category(name: str, description: str, priority: str, headings: List[str], severity: str) -> str: """ Determines the category of a software change based on its properties. Args: ...
magic_instruct_75k
10,249
Write a Python function to generate the complementary DNA sequence for a given DNA sequence. The function should ignore any characters in the input string that are not A, T, C, or G. The complementary bases are as follows: A pairs with T, and C pairs with G. The code should start with: ```python def complementary_sequ...
Here is the Python code to solve the given problem in the markdown block: ```python def complementary_sequence(dna_sequence: str) -> str: """ Generate the complementary DNA sequence for a given DNA sequence. Args: dna_sequence (str): A string representing a DNA sequence containing only the characte...
magic_instruct_75k
10,292
Write a Python function to calculate the total number of stars for each organization from a list of GitHub repositories. Each repository is represented as a string in the format "<organization>/<repository_name>". The function should return a dictionary where the keys are organization names and the values are the total...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def calculate_total_stars(repositories: List[str]) -> Dict[str, int]: """ Calculate the total number of stars for each organization from a list of GitHub repositories. Args: repositori...
magic_instruct_75k
10,293
Write a Python function to create a custom data structure called `GWBUF`. The function `create_gwbuf` takes a string `s` as input and returns an instance of the `GWBUF` class. The `GWBUF` class is a custom buffer or data container that stores the input string `s` in a specific format or structure. Your task is to desig...
Here is the Python code to solve the given problem in the markdown block: ```python class GWBUF: """ A custom data structure to store a string in a specific format or structure. Attributes: data (str): The string stored in the GWBUF object. """ def __init__(self, s: str): """ ...
magic_instruct_75k
10,304
Write a Python function to automate the versioning, committing, and deployment process for a software project. The function should prompt the user for the project version name, then use Git to commit the changes with the provided version name, push the changes to a remote repository, and finally create a zip file of th...
Here is the Python code to solve the given problem in the markdown block: ```python import os import subprocess def automate_versioning_and_deployment(): """ Automates the versioning, committing, and deployment process for a software project. Steps: 1. Prompt the user to input the project version name...
magic_instruct_75k
10,312
Create two Python functions that take in two string parameters, `first_name` and `last_name`, and return the full name in the format "last_name, first_name". The first function, `fullName`, should use an f-string to format the output. The second function, `fullNameAlt`, should use string concatenation to achieve the sa...
Here is the Python code to solve the given problem in the markdown block: ```python def fullName(first_name: str, last_name: str) -> str: """ Returns the full name in the format "last_name, first_name" using an f-string. Args: first_name (str): The first name of the person. last_name (str):...
magic_instruct_75k
10,332
Create a Python class `USB_Camera` that manages USB cameras in a robotics project. The class should provide functionality for setting the maximum number of channels, initializing the USB interface, and generating a unique identifier for each connected device. The class should be designed with appropriate member variabl...
Here is the Python code to solve the given problem in the markdown block: ```python import time import random import string class USB_Camera: def __init__(self): """ Initialize the USB_Camera class with necessary member variables. """ self.max_channels = 0 # Default maximum number ...
magic_instruct_75k
10,365
Write a Python function to reduce a list of groups based on their names and consolidate their permissions. Each group is represented as a dictionary with keys 'group', 'read', 'write', 'delete', and 'change_config'. The function should reduce the groups based on the 'group' key and consolidate the permissions for each ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def reduce_groups(groups: List[Dict[str, any]], group_reduce_idx: Dict[str, int]) -> List[Dict[str, any]]: """ Reduce and consolidate groups based on their names and permissions. Args: ...
magic_instruct_75k
10,385
Write a Python function to combine two code strings based on a given template. The template contains placeholders for the two code strings, which should be replaced by the actual code strings. The function should handle various edge cases, such as empty code strings or templates, and ensure that the placeholders are co...
Here is the Python code to solve the given problem in the markdown block: ```python def combine_two_code_strings(template: str, cs1: str, cs2: str) -> str: """ Combines two code strings based on a given template. Args: template (str): A string representing the template with placeholders for the cod...
magic_instruct_75k
10,401
Write a Python function to implement a simple linked list data structure with basic operations such as insertion, deletion, and traversal. The linked list should support inserting a node at the beginning, deleting a node by value, and printing the list. The code should start with: ```python class Node: def __init__...
Here is the Python code to solve the given problem in the markdown block: : ```python class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def insert_at_beginning(self, data): """ Inserts a ne...
magic_instruct_75k
10,448
Write a Python function to count the total number of files in a given nested dictionary representing a file system structure. Each key in the dictionary represents a directory, and the corresponding value can be either another nested dictionary (representing a subdirectory) or a string (representing a file). The depth ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Union def count_files(file_system: Dict[str, Union[str, Dict]]) -> int: """ Count the total number of files in a nested dictionary representing a file system. Args: file_system (Dict[str, U...
magic_instruct_75k
10,452
Write a Python script to automate the process of updating a version control system and uploading files to a remote server. The script should perform the following steps: 1. Commit a change to the local repository with a message indicating an update to the build log, using the current date as part of the commit message....
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess from datetime import datetime import os def automate_version_control_and_upload(): """ Automates the process of updating a version control system and uploading files to a remote server. Steps: 1. Comm...
magic_instruct_75k
10,458
Write a Python function to validate the correctness of latitude values for a given set of coordinates. The latitude values should not equal zero, as this would indicate an invalid or non-existent location. Your task is to create a function that checks whether the latitude values in a given list are valid or not. The f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def validateLatitude(latitudes: List[float]) -> List[bool]: """ Validates the correctness of latitude values for a given set of coordinates. Args: latitudes (List[float]): A list of latitude...
magic_instruct_75k
10,478
Write a Python function to count the occurrences of each type of database migration operation from a list of operations. Each operation is represented as a tuple where the first element is the model name and the second element is the operation type. The function should return a dictionary where the keys are the operati...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def count_migration_operations(operations: List[Tuple[str, str]]) -> Dict[str, int]: """ Counts the occurrences of each type of database migration operation from a list of operations. A...
magic_instruct_75k
10,484
Write a Python function to find the best feasible value and its corresponding index from a given list of feasible values. The best feasible value is defined as the maximum value in the list. If there are multiple occurrences of the maximum value, the function should return the index of the first occurrence. The code s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_best_feasible_value(feasible_values: List[float]) -> Tuple[int, float]: """ Finds the best feasible value and its corresponding index from a list of feasible values. The best feasibl...
magic_instruct_75k
10,512
Write a Python function to calculate the annual revenue generated by a company based on its marginal costs and electricity demand. The company operates in different load zones (lz) and has multiple time periods (tp) within a year. The function should take into account the electricity demand, marginal costs, and time pe...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_annual_revenue(electricity_demand, electricity_marginal_cost, tp_weight_in_year): """ Calculate the annual revenue generated by a company based on its marginal costs and electricity demand. Args: elect...
magic_instruct_75k
10,513
Write a Python function to process a list of strings and print each element to the standard output. The function should iterate through all the elements of the list and print each element. The code should start with: ```python from typing import List def print_elements(info: List[str]) -> None: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def print_elements(info: List[str]) -> None: """ Prints each element in the given list of strings to the standard output. Args: info (List[str]): The list of strings to be printed. Retu...
magic_instruct_75k
10,521
Write a Python function to simulate a stack allocator that operates on a last-in, first-out (LIFO) basis. The stack allocator should manage a fixed-size memory buffer and provide methods to allocate and deallocate memory. The memory buffer should be of size `SIZE` and should be aligned to the maximum alignment requirem...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def allocate(buffer: List[int], size: int, ptr: int) -> Optional[int]: """ Allocate a block of memory of the specified size from the buffer. Args: buffer (List[int]): The memory bu...
magic_instruct_75k
10,523
Write a Python function `process_data(data)` that processes a list of strings `data` and returns a final result based on the following operations: 1. Strip leading and trailing whitespaces from each string in the list. 2. Skip any empty strings in the list. 3. Construct a final result by concatenating the processed str...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def process_data(data: List[str]) -> str: """ Processes a list of strings and returns a final result based on the following operations: 1. Strips leading and trailing whitespaces from each string. ...
magic_instruct_75k
10,551
Write a Python function `process_submodules` that processes a list of submodule names and generates a dictionary representing the version information for each submodule. The function should take in the list of submodule names and the version string as input and return a dictionary where the keys are the submodule names...
Here is the Python code to solve the given problem in the markdown block: ```python def process_submodules(submodules, version): """ Processes a list of submodule names and generates a dictionary representing the version information for each submodule. Args: submodules (list): A list of submodule n...
magic_instruct_75k
10,556
Write a Python function to simulate the installation process for a machine learning application in a CUDA 11 environment. The function should take several variables as input, including the Python version, package versions, and URLs, and return a string representing the sequence of installation commands and environment ...
Here is the Python code to solve the given problem in the markdown block: ```python def install_cuda11_environment(python_version: str, client_release: str, app_release: str, server_release: str, paddle_version: str, serving_binary_url: str, serving_version: str) -> str: """ Simulates the installation process f...
magic_instruct_75k
10,570
Write a Python function to generate SQL commands that add specified columns back to a given table. The function should take the table name and a list of column names as input and return a string containing the SQL commands for adding these columns to the table. Each column should be added with a specific data type: `BO...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_column_addition_sql(table_name: str, column_names: List[str]) -> str: """ Generates SQL commands to add specified columns back to a given table. Args: table_name (str): The name...
magic_instruct_75k
10,580
Write a Python function to convert error data represented as a dictionary into a compact text format. The error dictionary has the following structure: ```python error = { 'severity': 'error_level', 'type': 'error_type', 'loc': { 'file': 'file_name', 'startLine': 'line_number', 'star...
Here is the Python code to solve the given problem in the markdown block: ```python def to_compact_text(error: dict) -> str: """ Converts error data represented as a dictionary into a compact text format. Args: error (dict): A dictionary containing error data with the following keys: - ...
magic_instruct_75k
10,609
Write a Python function to extract and print the individual file names from a given string containing a list of source files. Each source file is prefixed with a directory path and separated by backslashes and newlines. The function should handle the input string to remove any leading or trailing whitespace and backsla...
Here is the Python code to solve the given problem in the markdown block: ```python import re def extract_and_print_file_names(sources: str) -> None: """ Extracts and prints the individual file names from a given string containing a list of source files. Args: sources (str): A string containing a ...
magic_instruct_75k
10,610
Write a Python function to implement a custom filter that takes a list of values as input and returns a new list where any occurrences of `None` are replaced with an empty string. The function should be named `custom_filter` and should adhere to the following function signature: ```python from typing import List, Optio...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def custom_filter(input_list: List[Optional[str]]) -> List[str]: """ Replaces any occurrences of `None` in the input list with an empty string. Args: input_list (List[Optional[str]...
magic_instruct_75k
10,628
Write a Python function to filter a list of objects based on specific criteria. Each object is represented as a dictionary with attributes such as "name", "type", and "value". The function should return a new list containing only the objects that meet the following conditions: 1. The object's "type" attribute should ma...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def filter_objects(objects: List[Dict[str, any]], obj_type: str, threshold: int) -> List[Dict[str, any]]: """ Filters a list of objects based on the given type and value threshold. Args: ...
magic_instruct_75k
10,645
Write a Python function `process_boolean_equations` that processes a list of Boolean equations in string format. The function should handle both single and multiple Boolean equations and provide the option to display verbose output. The function should take the following parameters: - `equations`: A list of Boolean equ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def process_boolean_equations(equations: List[str], verbose: bool = False) -> List[str]: """ Processes a list of Boolean equations and optionally prints verbose output. Args: equations (List...
magic_instruct_75k
10,650
Write a Python function to calculate the number of unique paths from the top-left corner to the bottom-right corner of a m x n grid, where you can only move right or down. The function should start with: ```python from typing import List def unique_paths(m: int, n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def unique_paths(m: int, n: int) -> int: """ Calculate the number of unique paths from the top-left corner to the bottom-right corner of a m x n grid. Args: m (int): The number of rows i...
magic_instruct_75k
10,657
Write a Python function to simulate the processing of command-line options for a Bash script that installs packages using the YUM package manager. The function should support the following options: - `-h`: Display a help message and exit. - `-v`: Enable verbose mode. - `-y <options>`: Pass additional options to YUM. - ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def simulate_yum_install(args: List[str]) -> str: """ Simulate the processing of command-line options for a YUM package manager installation. Args: args (List[str]): A list of comm...
magic_instruct_75k
10,674
Write a Python function to add a setting change to a list of changes if it is absent. The function should take the name of the setting and its value as input and add the change to the list if it does not already exist. The function should be named `add_setting_if_absent` and should start with: ```python from typing imp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Any def add_setting_if_absent(changes: List[Dict[str, Any]], setting_name: str, setting_value: Any) -> None: """ Adds a setting change to the list of changes if it is absent. Args: ch...
magic_instruct_75k
10,686
Create a Python function `get_articles(category)` that retrieves articles based on the specified category from a predefined dictionary of articles. Additionally, create a sample 'articles.html' template that can display the articles passed to it. The template should iterate through the articles and display their titles...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def get_articles(category: str) -> List[Dict[str, str]]: """ Retrieves articles based on the specified category. Args: category (str): The category of articles to retrieve. Return...
magic_instruct_75k
10,727
Write a Python function to count the occurrences of each type of database migration operation in a given list. Each operation is represented as an instance of a class, and the types of operations include `migrations.CreateModel`, `migrations.AlterField`, and `migrations.DeleteModel`. The function should return a dictio...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict from collections import defaultdict def count_migration_operations(operations: List[object]) -> Dict[str, int]: """ Counts the occurrences of each type of database migration operation in a given li...
magic_instruct_75k
10,777
Write a Python function to process a list of data and transform it based on a given transformation function. The function should take in a list of data and a transformation function, and return a new list of transformed data. The transformation function should be applied to all elements in the data list. The code shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Callable def map_transform(data: List[int], transform_func: Callable[[int], int]) -> List[int]: """ Transforms each element in the given list of data using the provided transformation function. Arg...
magic_instruct_75k
10,793
Write a Python function to calculate the Collatz sequence for a given positive integer `n`. The function should return a list containing the sequence of numbers generated by the Collatz conjecture starting from `n` until it reaches 1. The Collatz conjecture is defined as follows: - Start with any positive integer `n`. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def collatz_sequence(n: int) -> List[int]: """ Calculate the Collatz sequence for a given positive integer `n`. The Collatz sequence is defined as follows: - Start with any positive integer `n`....
magic_instruct_75k
10,795
Write a Python function to perform matrix multiplication on two given 2D matrices. The function should take two matrices `A` and `B` as input and return their matrix product `C`, where `C = A * B`. The matrices will be represented as lists of lists, where each inner list represents a row of the matrix. The number of co...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def matrix_multiply(A: List[List[int]], B: List[List[int]]) -> List[List[int]]: """ Perform matrix multiplication on two given 2D matrices. Args: A (List[List[int]]): The first matrix. ...
magic_instruct_75k
10,804
Write a Python function to calculate the total number of unique words in a given dictionary where keys are words and values are their counts. The function should handle cases where the same word might appear multiple times with different counts, ensuring that each word is counted only once. The code should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def calculate_unique_words_count(word_counts: Dict[str, int]) -> int: """ Calculate the total number of unique words in a dictionary where keys are words and values are their counts. Args: w...
magic_instruct_75k
10,816
Write a Python function to format network speed test results into a readable string. The function should take a dictionary containing the test results as input and return a formatted string. The dictionary will have keys "download", "upload", and "ping", each with corresponding values representing the download speed in...
Here is the Python code to solve the given problem in the markdown block: ```python def format_speed_test_results(result: dict) -> str: """ Formats network speed test results into a readable string. Args: result (dict): A dictionary containing the network speed test results. The diction...
magic_instruct_75k
10,843
Write a Python function to calculate the Euclidean distance between two points in a 2D plane. The function should take the coordinates of the two points as input and return the distance between them. The Euclidean distance is calculated using the formula: \[ \text{distance} = \sqrt{(x2 - x1)^2 + (y2 - y1)^2} \] The c...
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
10,844
Write a Python function to manage a simple Entity-Component-System (ECS) framework. The ECS framework is a design pattern used in game development to manage entities (game objects) and their associated components (data and behavior). Your task is to implement the `ECSManager` class, which will be responsible for creati...
Here is the Python code to solve the given problem in the markdown block: ```python class Entity: """ Represents an entity in the ECS framework. Attributes: entity_id (int): Unique identifier for the entity. components (dict): Dictionary to store components associated with the entity. "...
magic_instruct_75k
10,854
Write a Python function to calculate the "YSI" and "YSI_err" values based on the given conditions. The function should take the exponential mean (`exp_mean`), exponential standard deviation (`exp_std`), a list of regular mean values (`mean`), and a list of regular standard deviation values (`std`). The function should ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Optional def calculate_YSI_values(exp_mean: Optional[float], exp_std: Optional[float], mean: List[float], std: List[float]) -> Dict[str, float]: """ Calculate the "YSI" and "YSI_err" values based ...
magic_instruct_75k
10,859
Write a Python function that processes a JSON object and extracts the key-value pairs from the "default" object. The function should then format and print these key-value pairs in the specified format. The function should use the `jq` command-line tool to perform the JSON processing. The code should start with: ```pyt...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess import json def process_json(json_data: str) -> None: """ Processes a JSON object and extracts the key-value pairs from the "default" object. Prints the key-value pairs in the specified format. Args: ...
magic_instruct_75k
10,865
Write a Python function to retrieve a specific page of results from a leaderboard system. The leaderboard contains a list of player scores, and the function should retrieve a subset of scores based on a given offset and a maximum number of entries per page. If the offset exceeds the length of the queryset, the function...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_leaderboard_page(queryset: List[int], offset: int, LEADERBOARD_MAX_PER_PAGE: int) -> List[int]: """ Retrieves a specific page of results from a leaderboard system. Args: queryset (Li...
magic_instruct_75k
10,880
Write a Python function to calculate the highest possible score by choosing a sequence of non-adjacent numbers from a given list of integers. The function should return the maximum sum of non-adjacent numbers. The function should start with: ```python from typing import List def max_non_adjacent_sum(arr: List[int]) ->...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_non_adjacent_sum(arr: List[int]) -> int: """ Calculate the highest possible score by choosing a sequence of non-adjacent numbers from a given list of integers. Args: arr (List[int]):...
magic_instruct_75k
10,904
Write a Python function to determine whether a given input is a number or not. The function should handle different types of numerical inputs, including integers, floating-point numbers, and scientific notation. The function should return `True` if the input is a number and `False` if it is not. The code should start ...
Here is the Python code to solve the given problem in the markdown block: ```python def is_number(input_value: str) -> bool: """ Determines whether the given input is a number. Args: input_value (str): The input value to check. Returns: bool: True if the input is a number, False otherw...
magic_instruct_75k
10,913
Implement a Python class `ResourceManager` that manages shaders and textures in a game engine. The class should provide the following functionalities: 1. A method `load_shader_from_file` that loads a shader program from specified vertex, fragment, and geometry shader files and stores it in the resource manager. 2. A me...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Optional class Shader: def __init__(self, id: int): self.id = id def delete(self): # Placeholder for actual shader deletion logic print(f"Deleting shader with ID: {self.id}") c...
magic_instruct_75k
10,926
Write a Python function to determine whether a given number is a prime number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The function should be efficient and handle edge cases appropriately. The code should start with: ```python def is_prime(n: int) -> boo...
Here is the Python code to solve the given problem in the markdown block: ```python def is_prime(n: int) -> bool: """ Determine whether a given number is a prime number. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. "...
magic_instruct_75k
10,954
Create a Python function to simulate a simple binary tree and perform various operations on it. The function should support the following functionalities: 1. Inserting a new node into the binary tree. 2. Traversing the tree in three different orders: in-order, pre-order, and post-order. 3. Implementing a static method ...
Here is the Python code to solve the given problem in the markdown block: ```python class Node: def __init__(self, key): """ Initialize a node with a given key. Args: key: The value to be stored in the node. """ self.left = None self.right = None ...
magic_instruct_75k
10,962
Write a Python function to find the maximum sum of a contiguous subarray within a given list of integers. The function should be optimized to achieve a time complexity of O(n), where n is the length of the input list `nums`. The code should start with: ```python from typing import List def max_subarray_sum(nums: List...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_subarray_sum(nums: List[int]) -> int: """ Find the maximum sum of a contiguous subarray within the given list of integers. Args: nums (List[int]): The list of integers from which to ...
magic_instruct_75k
10,963
Write a Python function to analyze the frequency of words in a given text. The function should take a string of text as input and output a dictionary where the keys are the unique words in the text and the values are the frequencies of each word. The input text is case-insensitive, meaning that "Hello" and "hello" shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict import re def word_frequency(text: str) -> Dict[str, int]: """ Analyzes the frequency of words in a given text and returns a dictionary where the keys are the unique words (case-insensitive) and the ...
magic_instruct_75k
10,965
Create a Python class structure to represent an API framework where an `APIRoot` serves as the starting point of the API and can have multiple `APIEndpoint` instances as children. Each `APIEndpoint` can also have child endpoints. Implement the following methods: 1. `add_endpoint` in both `APIRoot` and `APIEndpoint` cla...
Here is the Python code to solve the given problem in the markdown block: ```python class APIRoot: def __init__(self, ref): """ Initialize the APIRoot with a reference and an empty list of endpoints. Args: ref (str): The reference of the API root. """ self.ref = ...
magic_instruct_75k
10,971
Write a Python function to generate a test session report that includes the platform, Python version, pytest version, and the test results for each item collected during the session. The test results should be displayed as a percentage of completion for each item. The function should return a formatted string represent...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_test_report(platform: str, python_version: str, pytest_version: str, test_results: list) -> str: """ Generates a test session report that includes the platform, Python version, pytest version, and the test resul...
magic_instruct_75k
10,981
Write a Python function to find the GitHub repository with the highest number of stars from a given list of repositories. Each repository is represented as a dictionary with keys "name" and "stars_count". Additionally, write a function to determine whether a given string is a valid XPath selector. An XPath selector is ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Any, Optional def find_most_starred_repo(repos: List[Dict[str, Any]]) -> Optional[Dict[str, Any]]: """ Find the GitHub repository with the highest number of stars from a list of repositories. ...
magic_instruct_75k
11,017
Write a Python function to calculate the factorial of a non-negative integer using recursion. The factorial of a non-negative integer \( N \) is the product of all positive integers less than or equal to \( N \). The factorial of 0 is defined to be 1. The code should start with: ```python def factorial(N: int) -> int:...
Here is the Python code to solve the given problem in the markdown block: ```python def factorial(N: int) -> int: """ Calculate the factorial of a non-negative integer N using recursion. The factorial of a non-negative integer N is the product of all positive integers less than or equal to N. The facto...
magic_instruct_75k
11,040
Write a Python function to organize a list of test cases into a hierarchical structure based on their naming convention. Each test case is represented by a string in the format "category.subcategory.test", where "category" and "subcategory" represent the broader categories of the test, and "test" represents the specifi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def organize_test_cases(test_cases: List[str]) -> Dict: """ Organizes a list of test cases into a hierarchical structure based on their naming convention. Args: test_cases (List[str]):...
magic_instruct_75k
11,047
Write a Python function to calculate the score of a dice game based on the given scoring rules. The function should take a list of dice values and return the total score according to the following rules: - A set of three ones is worth 1000 points. - A set of three numbers (other than ones) is worth 100 times the number...
Here is the Python code to solve the given problem in the markdown block: ```python def score(dice: list) -> int: """ Calculate the score of a dice game based on the given rules. Args: dice (list): A list of integers representing the values of the dice rolled. Returns: int: The total s...
magic_instruct_75k
11,052
Write a Python function to update Django admin site configurations based on a given settings object. The function should take a list of dictionaries representing the current admin site configurations and an object containing the settings. Each dictionary in the list should have keys `'site_title'` and `'site_header'`. ...
Here is the Python code to solve the given problem in the markdown block: ```python def update_admin_site_configurations(admin_configs: list, settings_obj: dict) -> list: """ Updates the site title and header in the Django admin site configurations based on the settings object. Args: admin_configs ...
magic_instruct_75k
11,056
Write a Python function to calculate the sum of all even Fibonacci numbers up to a given limit. The Fibonacci sequence starts with 0 and 1, and each subsequent number is the sum of the two preceding ones. The function should take an integer `limit` as input and return the sum of all even Fibonacci numbers that are less...
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
11,062
Write a Python script to automate the process of updating the container image for a specific Kubernetes stateful set and then monitor the rollout status to ensure the update is successful. The script should perform the following steps: 1. Use the `kubectl` command to patch the stateful set named `constellation-app` wit...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess def update_stateful_set(stateful_set_name: str, new_image: str) -> None: """ Updates the container image of a Kubernetes stateful set and monitors the rollout status. Args: stateful_set_name (str)...
magic_instruct_75k
11,078
Write a Python function to validate a given service configuration. The function `valid_discovery_config` should take two parameters: `service`, a string representing the service name, and `config`, a dictionary representing the service configuration. The function should perform the following validations: 1. Check if th...
Here is the Python code to solve the given problem in the markdown block: ```python def valid_discovery_config(service: str, config: dict) -> bool: """ Validate the service name and configuration dictionary. Args: service (str): The service name to validate. config (dict): The configuration...
magic_instruct_75k
11,088
Write a Python function to validate a list of domain names based on specific criteria. Each domain name should be checked for the following conditions: 1. The domain name should not exceed 10 characters in length. 2. The domain name should be in lowercase. 3. The domain name should not contain any special characters or...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def validate_domains(domains: List[str]) -> List[str]: """ Validates a list of domain names based on the following criteria: 1. The domain name should not exceed 10 characters in length. 2. The d...
magic_instruct_75k
11,098
Write a Python function to generate a list of build options based on a given list of software specifications. Each specification in the list represents a feature that can be enabled during the build process. The function should examine the specifications and construct a list of build options accordingly. The function ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_build_options(spec: List[str]) -> List[str]: """ Generates a list of build options based on the given software specifications. Args: spec (List[str]): A list of strings represen...
magic_instruct_75k
11,106
Write a Python function to determine if two instances of a custom class `SomeStruct` are equal based on the value of their `x` attribute. The `SomeStruct` class is defined with a single attribute `x` of type `int`. Your goal is to implement the `is_equal` function that takes two instances of `SomeStruct` and returns `T...
Here is the Python code to solve the given problem in the markdown block: ```python class SomeStruct: def __init__(self, x: int): """ Initialize an instance of SomeStruct with an integer attribute x. Args: x (int): The integer attribute to be stored in the instance. """ ...
magic_instruct_75k
11,127
Write a Python function to simulate the behavior of a `TestNode` class interacting with a `RuntimeRequestsMock` class. The function should set up the necessary environment, execute the test, and validate the expected behavior of the `TestNode`. The function should return a boolean indicating whether the test passed or ...
Here is the Python code to solve the given problem in the markdown block: ```python class RuntimeRequestsMock: def __init__(self): self.requests = [] def add_request(self, request): self.requests.append(request) def get_requests(self): return self.requests class TestNode: def ...
magic_instruct_75k
11,166
Write a Python function to automate the versioning of software releases based on Git tags. The function should extract the latest version number from the Git tags and increment it for the next release. The versioning follows the semantic versioning format, which consists of three numbers separated by dots (e.g., 1.2.3)...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Optional def get_next_version(git_tags: Optional[list] = None) -> str: """ Calculate the next version number based on the latest Git tag. Args: git_tags (Optional[list]): A list of Git tags. Defa...
magic_instruct_75k
11,177
Write a Python function to generate a comprehensive training report for a given phase (e.g., 'train' or 'validation') in a deep learning project. The report should include the following information: - Loss components: Total loss, likelihood, KL divergence for Gaussian distributions, and KL divergence for the inferred G...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_training_report(phase: str, loss_per_epoch: dict, mse_per_epoch: dict, clip_grad_D: float, grad_norm_D: float, clip_grad_S: float, grad_norm_S: float) -> str: """ Generates a comprehensive training report for a give...
magic_instruct_75k
11,180
Write a Python function to perform set operations on three given sets, `set_a`, `set_b`, and `set_c`. The function should return two sets: 1. The intersection of `set_a` with both `set_b` and `set_c`. 2. The elements in `set_a` that are not present in `set_b`. The function 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 Set, Tuple def set_operations(set_a: Set[int], set_b: Set[int], set_c: Set[int]) -> Tuple[Set[int], Set[int]]: """ Perform set operations on three given sets and return the results. Args: set_a (...
magic_instruct_75k
11,191
Write a Python function to process a list of tuples representing file names and their corresponding version numbers. The function should return a dictionary containing the file names as keys and the highest version number for each file as values. The version numbers are strings in the format 'auto_YYYYMMDD_HHMM', where...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def get_latest_versions(files: List[Tuple[str, str]]) -> Dict[str, str]: """ Processes a list of tuples representing file names and their corresponding version numbers. Returns a diction...
magic_instruct_75k
11,197
Write a Python function `replace_and_check` that replaces a placeholder `<NAME>` in a given string with a user-provided name and checks if a specific substring is present in the modified string. The function should return a boolean value based on the presence of the substring. The function should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python def replace_and_check(original_str: str, name: str, substring: str) -> bool: """ Replaces the placeholder `<NAME>` in the `original_str` with the provided `name` and checks if the `substring` is present in the modified string. ...
magic_instruct_75k
11,231
Write a Python function to calculate the sum of the digits of a given positive integer `n` using the following algorithm: 1. Initialize a variable `sum` to 0. 2. While `n` is greater than 0, do the following: - Calculate the remainder when `n` is divided by 10 and store it in a variable `temp`. - Update `n` by di...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_digits(n: int) -> int: """ Calculate the sum of the digits of a given positive integer `n`. Args: n (int): The positive integer whose digits are to be summed. Returns: int: The sum of the dig...
magic_instruct_75k
11,236
Write a Python function to generate the appropriate `KOPS_STORE` value for a given project ID and cluster name. The `KOPS_STORE` value is used by Kops (Kubernetes Operations) to store cluster configuration and state in a Google Cloud Storage (GCS) bucket. The function should take two string parameters: `project_id` and...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_kops_store(project_id: str, cluster_name: str) -> str: """ Generates the KOPS_STORE value for a given project ID and cluster name. Args: project_id (str): A string representing the project ID. c...
magic_instruct_75k
11,241
Write a Python function to flatten a nested dictionary into a single-level dictionary where the keys are concatenated with a specified delimiter to represent the original nested structure. The function should handle arbitrary levels of nesting and should concatenate keys using the specified delimiter. The code should ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def flatten_dict(d: Dict[str, Any], delimiter: str = '.') -> Dict[str, Any]: """ Flattens a nested dictionary into a single-level dictionary. Args: d (Dict[str, Any]): The nested dictio...
magic_instruct_75k
11,246
Write a Python function to calculate the maximum profit that can be obtained by buying and selling a stock on different days. The function should take a list of integers representing the daily stock prices and return the maximum profit. You can only make one transaction (i.e., buy one and sell one share of the stock), ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def maxProfit(prices: List[int]) -> int: """ Calculate the maximum profit that can be obtained by buying and selling a stock on different days. Args: prices (List[int]): A list of integers r...
magic_instruct_75k
11,247
Write a Python function to extract the second last and last subtitles from a given list of subtitles. Each subtitle is represented as a tuple containing the start time and end time of the subtitle. The function should return a tuple containing the second last and last subtitles. If the list contains fewer than two subt...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def extract_last_two_subtitles(subtitle_list: List[Tuple[int, int]]) -> Tuple[Tuple[int, int], Tuple[int, int]]: """ Extracts the second last and last subtitles from a given list of subtitles. ...
magic_instruct_75k
11,250
Write a Python function to determine the best transition sequence for translating a given source sentence based on its tokenized form. The function should take the source sentence and its corresponding tokenized form as input and return the best transition sequence for translation. The transition sequence should be a l...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def best_transition_sequence(input_sentence: str, tokenized_input: List[int]) -> List[int]: """ Determine the best transition sequence for translating a given source sentence based on its tokenized form....
magic_instruct_75k
11,252
Write a Python function to parse a configuration file and extract key-value pairs. The configuration file is in a simple format where each line contains a key-value pair in the form of `key = value`. The keys and values can contain alphanumeric characters and special characters, but they are always separated by an equa...
Here is the Python code to solve the given problem in the markdown block: ```python def parse_config_file(config_content: str) -> dict: """ Parses a configuration file content and extracts key-value pairs. Args: config_content (str): The content of the configuration file as a string. Returns: ...
magic_instruct_75k
11,287
Write a Python function to construct email headers for a multi-part message in MIME format. The function should take in the following parameters: - `smtp_mail_from`: A string representing the email address of the sender. - `to`: A list of strings representing the email addresses of the primary recipients. - `cc`: A lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def construct_email_headers(smtp_mail_from: str, to: List[str], cc: List[str], bcc: List[str]) -> Dict[str, str]: """ Constructs email headers for a multi-part message in MIME format. Args: ...
magic_instruct_75k
11,289
Write a Python function to categorize a list of DNS resource record types into three categories: Standard Types, Obsolete Types, and Reserved Types. The function should take a list of DNS resource record types as input and return a dictionary with the categorized record types. 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, Dict def categorize_dns_records(dns_record_types: List[str]) -> Dict[str, List[str]]: """ Categorizes a list of DNS resource record types into Standard Types, Obsolete Types, and Reserved Types. Ar...
magic_instruct_75k
11,290
Write a Python function to implement a lazy evaluation method for a singleton object. The singleton object represents a service driver for a specific technology integration (TI). The lazy evaluation method should ensure that the singleton object is only created when it is first accessed and then reused for subsequent a...
Here is the Python code to solve the given problem in the markdown block: ```python from threading import Lock class CQCSrvDrvTI_TIImpl: """ Represents the implementation for the technology integration. """ def __init__(self): self.value = "Initialized" class CQCSrvDrvTI_TIServerBase: """ ...
magic_instruct_75k
11,295
Write a Python function to group file names by their extensions and return a dictionary where the keys are the unique extensions and the values are lists of file names with that extension. If a file does not have an extension, it should be grouped under the key "no_extension". 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, Dict def group_by_extension(file_names: List[str]) -> Dict[str, List[str]]: """ Groups file names by their extensions and returns a dictionary where the keys are the unique extensions and the values...
magic_instruct_75k
11,297
Write a Python function to process a list of tuples containing Android OS names and their corresponding version numbers. The function should return a dictionary where the keys are the OS names and the values are lists of version numbers associated with each OS. Each OS name will appear only once in the input list, but ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def process_android_versions(android_versions: List[Tuple[str, str]]) -> Dict[str, List[str]]: """ Processes a list of tuples containing Android OS names and their corresponding version numb...
magic_instruct_75k
11,302
Write a Python function to process a list of strings representing different motion planning algorithms. The function should filter out any duplicate algorithm names, ignore any empty strings, and strip leading/trailing whitespaces from the algorithm names. Finally, the function should return the unique set of algorithm...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_motion_planning_algorithms(algorithms: List[str]) -> List[str]: """ Processes a list of strings representing motion planning algorithms, filters out duplicates, ignores empty strings, and ...
magic_instruct_75k
11,329
Write a Python function to determine if a given integer `x` is a palindrome. An integer is a palindrome when it reads the same backward as forward. The function should not convert the integer to a string to solve the problem. Additionally, consider the case of negative integers and how to handle potential integer overf...
Here is the Python code to solve the given problem in the markdown block: ```python def isPalindrome(x: int) -> bool: """ Determine if a given integer `x` is a palindrome. Args: x (int): The integer to check for palindrome property. Returns: bool: True if `x` is a palindrome, False oth...
magic_instruct_75k
11,330
Write a Python function to filter a dictionary of HTTP content types and their corresponding parameters, retaining only those content types that are of the "application" type. The input dictionary will have content types as keys and their parameters as values. The content types are in the format "type/subtype", and the...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def filter_application_content_types(content_types: Dict[str, Dict[str, str]]) -> Dict[str, Dict[str, str]]: """ Filters the input dictionary to include only content types of the "application" type and t...
magic_instruct_75k
11,332
Write a Python function to calculate the frequency of each word in a given text and return the result as a dictionary. The function should ignore case sensitivity and consider only alphanumeric characters as part of a word. Punctuation and special characters should be disregarded. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict import re def word_frequency(text: str) -> Dict[str, int]: """ Calculate the frequency of each word in the given text and return the result as a dictionary. The function ignores case sensitivity and...
magic_instruct_75k
11,351
Write a Python function to fetch text data from an API in batches of 1000 IDs due to API limitations. The function should take a list of IDs and return a dictionary where the keys are the IDs and the values are the corresponding text data fetched from the API. The function should handle the batching of IDs and make the...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def fetch_text_data(ids: List[int]) -> Dict[int, str]: """ Fetches text data for a list of IDs in batches of 1000 due to API limitations. Args: ids (List[int]): A list of IDs for which...
magic_instruct_75k
11,384
Write a Python function to extract and return a new dictionary containing only the keys related to the device's operating system from a given dictionary. The input dictionary contains various attributes of a device, and the keys are in the format 'DeviceInfo_<Attribute>'. The function should return a new dictionary wit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def extract_os_info(device_info: Dict[str, str]) -> Dict[str, str]: """ Extracts and returns a new dictionary containing only the keys related to the device's operating system. Args: device_...
magic_instruct_75k
11,390
Write a Python function to manage a collection of database rows and their associated content identifiers. The function should provide methods for adding rows and content identifiers, as well as for retrieving specific rows and identifiers. The code should start with: ```python from typing import List, Optional class D...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional class XRow: pass class XContentIdentifier: pass class DatabaseManager: def __init__(self): """ Initialize the DatabaseManager with empty lists for rows and identifiers. ...
magic_instruct_75k
11,392
Write a Python function to calculate the maximum profit that can be achieved by making a single buy and sell transaction in a given list of stock prices. The buy must occur before the sell. The function should start with: ```python from typing import List def max_profit(prices: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_profit(prices: List[int]) -> int: """ Calculate the maximum profit that can be achieved by making a single buy and sell transaction. Args: prices (List[int]): A list of integers repr...
magic_instruct_75k
11,400
Write a Python function to calculate the position of a reflected wave given the position of the original wave, the velocity of the wave, and the time it takes for the wave to reach the reflecting surface and return. The formula to calculate the position of the reflected wave is given by: \[ \text{reflected\_position} ...
Here is the Python code to solve the given problem in the markdown block: ```python def reflected_wave(original_position: float, velocity: float, tinterp: float) -> float: """ Calculate the position of a reflected wave given the position of the original wave, the velocity of the wave, and the time it takes ...