source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_instruct_75k
18,016
Write a Python function to calculate the adjusted learning rate for a neural network training process based on user inputs for tolerance and precision goal for the loss function. The learning rate is calculated as 10^-3 times the value entered by the user for the precision goal. The code should start with: ```python d...
Here is the Python code to solve the given problem in the markdown block: ```python def apply_parameters(tol: int, ftol: int) -> float: """ Calculate the adjusted learning rate for a neural network training process based on user inputs. Args: tol (int): The user input for tolerance. ftol (i...
magic_instruct_75k
18,018
Write a Python function to find the duplicate and missing numbers in a given array of integers `nums` that represents a permutation of integers from `1` to `n` inclusive. The array contains exactly one duplicate number and one missing number. The function should return a list containing the duplicate number followed by...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def findErrorNums(nums: List[int]) -> List[int]: """ Finds the duplicate and missing numbers in a given permutation array. Args: nums (List[int]): A list of integers representing a permutati...
magic_instruct_75k
18,020
Write a Python function to simulate the behavior of the `dirbuf_add` function described in the given C code snippet. The function should take in parameters representing the directory entry information and add it to a buffer. The buffer should be dynamically resized if necessary to accommodate new entries. The function ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def dirbuf_add(buf: List[Tuple[int, int, int, str]], remain: int, ino: int, off: int, type: int, name: str) -> int: """ Adds a directory entry to the buffer. If the buffer is not large enough to h...
magic_instruct_75k
18,036
Write a Python function to generate n-grams from a given input sequence. An n-gram is a contiguous sequence of n items from a given sample of text or speech. The function should take a list of items and an integer `n` as input and return a list of n-grams. The code should start with: ```python from typing import List,...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def generate_ngrams(sequence: List[int], n: int) -> List[Tuple[int, ...]]: """ Generate n-grams from a given sequence. Args: sequence (List[int]): The input sequence from which to gen...
magic_instruct_75k
18,059
Create a Python class `ContactBook` that represents a simple contact book. The class should allow users to add, remove, and search for contacts by name. Additionally, the class should be able to return the total number of contacts in the book. The class should be implemented with the following methods: 1. `__init__(se...
Here is the Python code to solve the given problem in the markdown block: ```python class ContactBook: def __init__(self): """ Initializes the contact book with an empty list of contacts. """ self.contacts = [] def add_contact(self, name: str) -> None: """ Adds a...
magic_instruct_75k
18,069
Write a Python function to join two datasets, `orders` and `order_items`, based on the `order_id` and return a new dataset containing the following attributes: - `order_id`: The ID of the order - `order_status`: The status of the order - `product_id`: The ID of the product included in the order - `quantity`: The quanti...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def join_datasets(orders: List[Dict[str, any]], order_items: List[Dict[str, any]]) -> List[Dict[str, any]]: """ Joins the `orders` and `order_items` datasets based on the `order_id` and returns a n...
magic_instruct_75k
18,075
Write a Python function to process a labeled image using NumPy operations. The function should take in a labeled image `labeled_im` and a list of labels to keep `keep`, and it should return the modified labeled image. The function aims to retain only the pixels in the labeled image that correspond to the specified labe...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import List def process_labeled_image(labeled_im: np.ndarray, keep: List[int]) -> np.ndarray: """ Processes a labeled image to retain only the pixels corresponding to the specified labels. Ar...
magic_instruct_75k
18,091
Write a Python function to process a dictionary containing various types of data, specifically handling cases where the dictionary values are either `datetime` objects or strings. The function should convert any string values representing dates into `datetime` objects while leaving existing `datetime` objects unchanged...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Union from datetime import datetime def process_data(data: Dict[str, Union[datetime, str]]) -> Dict[str, Union[datetime, str]]: """ Processes a dictionary containing datetime objects or date strings, co...
magic_instruct_75k
18,094
Write a Python function to convert bounding box coordinates from the format `[x1, y1, x2, y2]` (i.e., two opposite corners of the box) to the format `[x, y, w, h]` (i.e., top-left corner coordinates and width/height). The function should take a 2D NumPy array `boxes` as input, where each row represents a bounding box i...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def xyxy_to_xywh(boxes: np.ndarray) -> np.ndarray: """ Convert bounding box coordinates from the format [x1, y1, x2, y2] to the format [x, y, w, h]. Args: boxes (np.ndarray): A 2D NumPy array whe...
magic_instruct_75k
18,115
Write a Python function to generate a text-based menu system for a text-based user interface. The function should take a list of menu items as input, where each menu item is represented as a dictionary with the following keys: - "name": a string representing the name of the menu item - "action": a string representing t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def generate_menu_code(menu_items: List[Dict[str, str]]) -> str: """ Generates Python code for a text-based menu system using the Blender Python API. Args: menu_items (List[Dict[str, s...
magic_instruct_75k
18,117
Create a Python class `EventManager` that manages key press events and their associated actions in a graphical application. The class should allow associating specific actions with key presses and executing the associated action when the corresponding key is pressed. The class should include a method `register_event` t...
Here is the Python code to solve the given problem in the markdown block: ```python class EventManager: def __init__(self): """ Initialize the EventManager with an empty dictionary to store key-action mappings. """ self.key_action_map = {} def register_event(self, key: str, acti...
magic_instruct_75k
18,133
Complete the `merge_sort` function by implementing the merging step of the merge sort algorithm. The function should take an unsorted list of integers as input and return the sorted list. The merging step should combine the sorted left and right subarrays into a single sorted array and return the result. The starter c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_sort(arr: List[int]) -> List[int]: """ Sorts the input list of integers using the merge sort algorithm. Args: arr (List[int]): The unsorted list of integers. Returns: ...
magic_instruct_75k
18,167
Write a Python function to process a list of environment variables and their associated file names. The function should perform the following operations: 1. Repeat the file names and the string 'optional' for each optional environment variable. 2. Sort the optional environment variables. 3. For required environment var...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple from itertools import repeat def process_environment_variables(environment_variables: List[Tuple[str, str, List[str]]]) -> List[Tuple[str, str, str]]: """ Process the list of environment variables...
magic_instruct_75k
18,170
Write a Python function to determine if a character can navigate from a starting point to a destination point in a grid-based world. The grid is represented by a 2D list where each cell can be either empty (denoted by 0) or blocked (denoted by 1). The character can move up, down, left, or right within the grid, but onl...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def navigate_grid(grid: List[List[int]], start: Tuple[int, int], destination: Tuple[int, int]) -> bool: """ Determines if a character can navigate from a starting point to a destination point in a...
magic_instruct_75k
18,190
Write a Python function to find the indices of two numbers in a given list such that they add up to a specified target. Each input will have exactly one solution, and you may not use the same element twice. The function should start with: ```python from typing import List def twoSum(nums: List[int], target: int) -> Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def twoSum(nums: List[int], target: int) -> List[int]: """ Finds the indices of two numbers in the given list such that they add up to the specified target. Args: nums (List[int]): The list ...
magic_instruct_75k
18,198
Write a Python function to simulate the process of indexing a reference genome and aligning DNA sequencing data using the BWA (Burrows-Wheeler Aligner) tool. The function should simulate the steps of loading the BWA module, indexing the reference genome, displaying progress messages, and handling potential conflicts wi...
Here is the Python code to solve the given problem in the markdown block: ```python def simulate_bwa_alignment(ref_genome: str) -> None: """ Simulates the process of indexing a reference genome and aligning DNA sequencing data using the BWA tool. Args: ref_genome (str): The path to the reference ge...
magic_instruct_75k
18,215
Write a Python function to simulate a dice roll and return the result. The function should generate a random number between 1 and 6 (inclusive) to represent the outcome of a single dice roll. The function should return the result of the dice roll as an integer. The code should start with: ```python import random def ...
Here is the Python code to solve the given problem in the markdown block: ```python import random def roll_dice() -> int: """ Simulates a dice roll and returns the result. The function generates a random number between 1 and 6 (inclusive) to represent the outcome of a single dice roll. Returns: ...
magic_instruct_75k
18,228
Write a Bash script to automate the setup and deployment of a Node.js application using Docker. The script should handle the installation of dependencies and starting the application within a Docker container. The script should fulfill the following requirements: 1. The script should be written in Bash. 2. It should s...
Here is the Python code to solve the given problem in the markdown block: ```bash #!/bin/bash # Set the APP_DIR variable to the present working directory APP_DIR="$PWD" # Run the Docker container named "research_share" using the latest Node.js image # Mount the present working directory to /usr/app within the contain...
magic_instruct_75k
18,276
Write a Python function `find_index_of_first_even_number` that takes a list of integers as input and returns the 1-based index of the first even number in the list. If no even number is found, the function should return 0. The function should mimic the functionality of the provided Rust code snippet. The code should s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_index_of_first_even_number(numbers: List[int]) -> int: """ Find the 1-based index of the first even number in the given list of integers. Args: numbers (List[int]): A list of intege...
magic_instruct_75k
18,278
Write a Python function called `generate_mavros_launch_command` that generates a launch command for a MAVLink communication node using ROS (Robot Operating System). The function should take three parameters: - `ros_port` (integer): The port number for the ROS master URI. - `mavros_launcher` (string): The specific MAVRO...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_mavros_launch_command(ros_port: int, mavros_launcher: str, mavlink_port: int) -> str: """ Generates a launch command for a MAVLink communication node using ROS. Args: ros_port (int): The port number for...
magic_instruct_75k
18,286
Create a Python function `format_wikipedia_info(page_title)` that processes data from a Wikipedia API response to extract relevant information and display it in a user-friendly format. The function should take a page title as input and return a formatted message embed as a string. The message embed should include a thu...
Here is the Python code to solve the given problem in the markdown block: ```python class Embed: def __init__(self): self.thumbnail_url = None self.footer_text = None def set_thumbnail(self, url: str): self.thumbnail_url = url def set_footer(self, text: str): self.footer_te...
magic_instruct_75k
18,290
Write a Python function to merge two dictionaries representing file paths, where the keys are file names and the values are file paths. The function should prioritize the values from the first dictionary (`data_runfiles`) if a key exists in both dictionaries. Additionally, implement a function to generate a module map ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def merge_runfiles(data_runfiles: Dict[str, str], default_runfiles: Dict[str, str]) -> Dict[str, str]: """ Merge two dictionaries representing file paths. Args: data_runfiles (Dict[str...
magic_instruct_75k
18,326
Write a Python function to calculate the sum of all even numbers in a given list of integers. If the input list is empty or does not contain any even numbers, the function should return 0. The function should be named `sum_even_numbers` and should accept a single parameter, which is a list of integers. The starter cod...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_even_numbers(nums: List[int]) -> int: """ Calculate the sum of all even numbers in the given list of integers. Args: nums (List[int]): A list of integers. Returns: int: ...
magic_instruct_75k
18,328
Write a Python function to manage and retrieve information about different types of compilers. The function should be able to store and update information about C++ compilers, Dart analyzers, and fake compilers. The function should also provide a method to retrieve the compiler information based on the compiler type. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Optional, Union class CompilerInfoState: def __init__(self): """ Initializes the CompilerInfoState class with empty compiler information. """ self.cxx_compiler_info = None ...
magic_instruct_75k
18,332
Write a Python function to parse a configuration file in the "go_repository" format and extract the name and version of the repository. The configuration file is structured as follows: ``` go_repository( name = "repository_name", version = "repository_version", ... ) ``` Your task is to write a function `...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def parse_go_repository_config(config: str) -> Tuple[str, str]: """ Parses a configuration file in the "go_repository" format and extracts the name and version of the repository. Args: conf...
magic_instruct_75k
18,333
Write a Python function to extract a unique set of build numbers from a list of given ranges. Each range is represented by a dictionary with keys 'start' and 'end', where 'start' is inclusive and 'end' is exclusive. The function should return a set of unique build numbers that fall within any of the provided ranges. T...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Set def get_unique_build_numbers(ranges: List[Dict[str, int]]) -> Set[int]: """ Extracts a unique set of build numbers from a list of given ranges. Args: ranges (List[Dict[str, int]])...
magic_instruct_75k
18,344
Write a Python function to manipulate a list of integers based on a given set of operations. The function should take a list of integers as input and perform the following operations in sequence: 1. Remove all even numbers from the list. 2. Double the value of each remaining number. 3. Sort the list in ascending order...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def manipulate_list(nums: List[int]) -> List[int]: """ Manipulates a list of integers by performing the following operations in sequence: 1. Remove all even numbers from the list. 2. Double the v...
magic_instruct_75k
18,368
Write a Python function to extract and summarize information from a dictionary representing data from two different workflows. Each workflow contains a 'data' key with a nested dictionary of timestamps and corresponding values, a 'tool' key with the name of the tool used, and a 'total avg' key with the average value fo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def workflow_info(data_dict: Dict) -> Dict: """ Extracts and summarizes information from a dictionary representing data from two different workflows. Args: data_dict (Dict): A dictionary whe...
magic_instruct_75k
18,374
Write a Python function to validate the integrity of edges in a graph represented by a list of edges and a set of node IDs. Each edge connects a source node to a target node, and an edge is considered valid if both its source and target nodes exist in the set of node IDs. The function should return `True` if all edges ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Any, Set def validate_edges(edges: List[Dict[str, Any]], nodes_ids: Set[Any]) -> bool: """ Validate the integrity of edges in a graph by checking if both the source and target nodes of each edge e...
magic_instruct_75k
18,375
Write a Python function to simulate the installation and configuration tasks described in the given code snippet. The function should perform the following steps: 1. Install the supervisor package. 2. Remove the cached package files. 3. Create a directory for storing logs at `/srv/logs`. 4. Install the `socket.io` pack...
Here is the Python code to solve the given problem in the markdown block: ```python def setup_environment(): """ Simulates the installation and configuration tasks for setting up a supervisor and a Node.js application. This function prints the actions that would be taken if it were running in a Linux envir...
magic_instruct_75k
18,381
Write a Python function to prepare test documents for a trigger-based document classification system. The function should take in a trigger extractor, trigger generator, parameter file, and word embeddings, and return the prepared test documents. The function should handle the case where the trigger extractor is not sp...
Here is the Python code to solve the given problem in the markdown block: ```python def prepare_test_docs(trigger_extractor, trigger_generator, parameter_file, word_embeddings): """ Prepares test documents for a trigger-based document classification system. Args: trigger_extractor: An object that e...
magic_instruct_75k
18,404
Write a Python function to simulate a simplified version of the `ddg` command, which is used to search the web using the DuckDuckGo search engine. The function should take a search query as an argument and display the search results in the terminal using the `requests` library to fetch the search results and the `Beaut...
Here is the Python code to solve the given problem in the markdown block: ```python import requests from bs4 import BeautifulSoup def ddg_search(query: str) -> None: """ Simulates a simplified version of the `ddg` command to search the web using DuckDuckGo. Args: query (str): The search query to b...
magic_instruct_75k
18,409
Write a Python function to concatenate a list of strings into a single string, with each word modified by removing any leading or trailing whitespace and converting it to lowercase. The function should ignore any empty strings that result from stripping whitespace. The code 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 def concatenate_and_modify(words: List[str]) -> str: """ Concatenates a list of strings into a single string, with each word modified by removing any leading or trailing whitespace and converting it to l...
magic_instruct_75k
18,422
Write a Python function to extract the names of models being created from a list of database migration operations. Each operation is represented as an instance of the `MigrationOperation` class, which can be of different types such as `CreateModel`, `AddField`, `RemoveField`, etc. The function should focus only on the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List class MigrationOperation: pass class CreateModel(MigrationOperation): def __init__(self, name: str): self.name = name def get_created_models(operations: List[MigrationOperation]) -> List[str]: ...
magic_instruct_75k
18,428
Write a Python function to convert a given array of real numbers representing a quantum state to an array of complex numbers. The quantum state is represented by a one-dimensional NumPy array of real numbers, and you need to convert it to a one-dimensional NumPy array of complex numbers. The code should start with: ``...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def convert_to_complex(psi: np.ndarray) -> np.ndarray: """ Converts a one-dimensional NumPy array of real numbers to a one-dimensional NumPy array of complex numbers. Args: psi (np.ndarray): A on...
magic_instruct_75k
18,438
Implement the `xdc_convex_array` and `xdc_convex_focused_array` methods in a Python class for simulating ultrasound transducer arrays. The `xdc_concave` method is already implemented for reference. Each method should simulate a specific type of transducer array and return the simulation result. The code should start w...
Here is the Python code to solve the given problem in the markdown block: ```python class UltrasoundTransducer: def __init__(self, mateng): self._mateng = mateng def xdc_concave(self, radius, focal_radius, ele_size): ret = self._mateng.xdc_concave(radius, focal_radius, ele_size) return ...
magic_instruct_75k
18,459
Write a Python function to flatten a list of options that may contain nested lists. The function should recursively traverse the list and its nested lists, appending each element to a new list. The final result should be a single list containing all the elements in a flattened structure. The code should start with: ``...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def flatten_options(options: List[Any]) -> List[Any]: """ Flattens a list of options that may contain nested lists into a single list. Args: options (List[Any]): The list of options to ...
magic_instruct_75k
18,461
Write a Python function to update a nested dictionary with a new value for a specific key. The function should take in two parameters: `target` and `tmp_pol`. The `target` parameter is a dictionary that contains a nested dictionary under the key `'policy'`, and the `tmp_pol` parameter is a value that will be assigned t...
Here is the Python code to solve the given problem in the markdown block: ```python def update_policy(target: dict, tmp_pol) -> dict: """ Updates the nested dictionary `target` with a new value for the key `'parameter_protection'`. Args: target (dict): The dictionary containing a nested dictionary ...
magic_instruct_75k
18,475
Write a Python function that takes an integer `n` as input and returns the value of a variable `auxi` after assigning `n` to `auxi`. The function should handle the input range of `n` from `-10^9` to `10^9`. The code should start with: ```python def get_auxi(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def get_auxi(n: int) -> int: """ Returns the value of the variable `auxi` after assigning the input integer `n` to it. Args: n (int): The integer to be assigned to `auxi`. Returns: int: The value of `au...
magic_instruct_75k
18,499
Write a Python function to calculate the forecast period based on the length of a given dataset. The forecast period is determined by taking 1% of the dataset length and rounding it up to the nearest integer. The dataset is represented as a list of integers. The code should start with: ```python from typing import Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def calculate_forecast_period(df: List[int]) -> int: """ Calculate the forecast period based on the length of a given dataset. The forecast period is determined by taking 1% of the datase...
magic_instruct_75k
18,531
Write a Python function to count the occurrences of each unique word in a list of anatomy classes, ignoring case sensitivity. The function should return a dictionary where the keys are the lowercase versions of the words and the values are the counts of those words in the list. The code should start with: ```python fr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def count_anatomy_classes(anatomy_classes: List[str]) -> Dict[str, int]: """ Counts the occurrences of each unique word in a list of anatomy classes, ignoring case sensitivity. Args: a...
magic_instruct_75k
18,532
Write a Python function to count the total number of gems collected by a robot after executing a sequence of commands. The robot can execute two types of commands: `moveForward()` to move one step forward and `collectGem()` to collect a gem at its current position. The robot starts at the initial position and follows t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def countGemsCollected(commands: List[str]) -> int: """ Counts the total number of gems collected by a robot after executing a sequence of commands. Args: commands (List[str]): A list of com...
magic_instruct_75k
18,540
Write a Python function to count the occurrences of each unique label type in a given list of label types. The function should return a dictionary where the keys are the unique label types and the values are the counts of each label type in the input list. The function should handle label types case sensitively, meanin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def count_label_types(label_kinds: List[str]) -> Dict[str, int]: """ Counts the occurrences of each unique label type in the given list of label types. Args: label_kinds (List[str]): A...
magic_instruct_75k
18,549
Write a Python function to count the number of nested HTML elements within a given HTML code snippet. The function should only consider the opening tags of HTML elements and ignore any attributes or closing tags. The function should return the count of nested HTML elements. The code should start with: ```python def co...
Here is the Python code to solve the given problem in the markdown block: ```python def countNestedElements(htmlCode: str) -> int: """ Counts the number of nested HTML elements within a given HTML code snippet. Args: htmlCode (str): The HTML code snippet to parse. Returns: int: The cou...
magic_instruct_75k
18,552
Write a Python function to group individuals by their names from a list of dictionaries. Each dictionary contains the keys "name" and "id". The function should return a new dictionary where each key is a unique name from the input list, and the value is another dictionary containing a list of ids associated with that n...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def group_by_name(data: List[Dict[str, any]]) -> Dict[str, Dict[str, List[int]]]: """ Groups individuals by their names from a list of dictionaries. Args: data (List[Dict[str, any]]): ...
magic_instruct_75k
18,585
Write a Python function to refactor a list of class names by replacing any instances of a deprecated class with its updated counterpart. The function should return the updated list of class names. The deprecated class name will always be a standalone word in the array, and the updated class name will be a fully qualifi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def update_class_names(class_names: List[str]) -> List[str]: """ Refactors a list of class names by replacing any instances of a deprecated class with its updated counterpart. Args: class_na...
magic_instruct_75k
18,606
Write a Python script to automate the setup of a DNS deployment environment. The script should perform the following tasks: 1. Clone a Git repository from a specific URL to a local directory. 2. Check if two specific directories exist, and if not, print an error message and exit with a status code of 1. 3. Install thre...
Here is the Python code to solve the given problem in the markdown block: ```python import os import subprocess def setup_dns_environment(repo_url: str, dir1: str, dir2: str, packages: list, link_dirs: list, subdir: str) -> None: """ Automates the setup of a DNS deployment environment. Args: repo_...
magic_instruct_75k
18,607
Write a Python function to automate the installation of Nagios and its plugins on a Linux system. The function should perform the following steps: 1. Set the versions of Nagios and Nagios plugins to be installed (`NAGIOS_VERSION=4.1.1`, `NAGIOS_PLUGINS_VERSION=2.1.1`). 2. Download the source code for Nagios and Nagios ...
Here is the Python code to solve the given problem in the markdown block: ```python import os import subprocess import tarfile import urllib.request def install_nagios(nagios_version: str, nagios_plugins_version: str) -> None: """ Automates the installation of Nagios and its plugins on a Linux system. Arg...
magic_instruct_75k
18,612
Write a Python function to replace placeholders in a given template string with actual values from a dictionary. The placeholders are enclosed in `{{ }}` and can contain any alphanumeric characters and underscores. If a placeholder in the template does not have a corresponding key in the dictionary, it should remain un...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any import re def render_template(template: str, values: Dict[str, Any]) -> str: """ Replaces placeholders in a template string with values from a dictionary. Placeholders are enclosed in `{{ }}` a...
magic_instruct_75k
18,619
Write a Python function to generate a Dockerfile for a Node.js application based on the given requirements. The Dockerfile should set up the Node.js environment and use an `entrypoint.sh` script as the entrypoint for the container. The function should take the Node.js version as an input parameter and return the comple...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_dockerfile(node_version: str) -> str: """ Generates a Dockerfile for a Node.js application based on the given Node.js version. Args: node_version (str): The version of Node.js to use as the base image. ...
magic_instruct_75k
18,664
Write a Python function to determine if a sound wave is valid based on the given conditions. The sound wave is represented by a list `sound_file` containing two integers, where `sound_file[0]` and `sound_file[1]` represent the amplitude values at two different time intervals. The function should check the following con...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def valid_sound_wave(sound_file: List[int], T: int) -> bool: """ Determines if a sound wave is valid based on the given conditions. Args: sound_file (List[int]): A list containing two intege...
magic_instruct_75k
18,673
Write a Python function to find the participant with the highest score from a list of tuples representing the results of a competition. Each tuple contains the participant's name and their score. If there are multiple participants with the same highest score, return the name of the first participant encountered in the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_winner(results: List[Tuple[str, int]]) -> str: """ Find the participant with the highest score from a list of tuples representing the results of a competition. Args: results ...
magic_instruct_75k
18,676
Write a Python function to find the highest score from a list of game scores. If the list is empty, the function should return 0. The function should be efficient and handle edge cases appropriately. The code should start with: ```python from typing import List def highest_score(scores: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def highest_score(scores: List[int]) -> int: """ Find the highest score from a list of game scores. Args: scores (List[int]): A list of integers representing the scores of a game. Retur...
magic_instruct_75k
18,678
Write a Python function to check whether a given string of parentheses is balanced. A string is considered balanced if it consists of only opening and closing parentheses and every opening parenthesis has a corresponding closing parenthesis in the correct order. The input string may contain other characters besides par...
Here is the Python code to solve the given problem in the markdown block: ```python def is_balanced_parentheses(input_string: str) -> bool: """ Checks whether a given string of parentheses is balanced. Args: input_string (str): The string to check for balanced parentheses. Returns: boo...
magic_instruct_75k
18,682
Write a Python function to find the number of days until the next warmer temperature for each day in a given list of daily temperatures. If there is no such day, the output should be 0 for that day. The function should use a stack-based approach to efficiently solve the problem. The code should start with: ```python f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def warmer_days(temperatures: List[int]) -> List[int]: """ Calculate the number of days until the next warmer temperature for each day in the given list of daily temperatures. Args: temperat...
magic_instruct_75k
18,689
Write a Python script to process and filter data from multiple trials using a set of parameters. The script should read in a set of trials, apply a specific key, and filter out any lines containing the strings "VAST" or "Both". The filtered results should be saved to separate files for each trial. The script should st...
Here is the Python code to solve the given problem in the markdown block: ```python import os def process_trials(trials, key, parameters, results_base_name): """ Process and filter data from multiple trials. Args: trials (list): A list of trial names to be processed. key (str): The specifi...
magic_instruct_75k
18,704
Write a Python function to manage the versioning of a software package. The function should take in a new version number and update the package's version accordingly. Additionally, the function should construct and return the application name using the updated version number. The initial version number is provided in ...
Here is the Python code to solve the given problem in the markdown block: ```python def update_version(new_version: str) -> str: """ Updates the package version and constructs the application name using the updated version. Args: new_version (str): The new version number to update the package with....
magic_instruct_75k
18,708
Write a Python function to filter out filenames that end with any of the specified excluded extensions. The function should take two lists as input: one containing filenames and the other containing file extensions to exclude. The function should return a new list of filenames that do not end with any of the excluded e...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_filenames(filenames: List[str], excludes: List[str]) -> List[str]: """ Filters out filenames that end with any of the specified excluded extensions. Args: filenames (List[str]): A...
magic_instruct_75k
18,725
Write a Python function to manage and retrieve settings for various plugins. The function should store settings for multiple plugins and provide a method to retrieve the settings for a specific plugin by its ID. The code should start with: ```python from typing import Dict, Any class PluginSettings: def __init__(...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any class PluginSettings: def __init__(self): """ Initialize the PluginSettings class with an empty dictionary to store plugin settings. """ self.settings: Dict[int, Any] = {...
magic_instruct_75k
18,728
Write a Python function to calculate the sum of all even numbers in a given list of integers efficiently. The function should be optimized for performance, leveraging Python's built-in functions and generators to achieve better efficiency. The code should start with: ```python from typing import List def sum_of_even_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_even_numbers(nums: List[int]) -> int: """ Calculate the sum of all even numbers in the given list efficiently. Args: nums (List[int]): A list of integers from which to calculate t...
magic_instruct_75k
18,747
Create a Python class `Revision` that tracks the details of a revision, such as the number of stars, title, body, and reading status. The class should have the following properties and methods: - `stars` (int): representing the number of stars given to the revision. - `title` (str): representing the title of the revisi...
Here is the Python code to solve the given problem in the markdown block: ```python class Revision: def __init__(self, stars: int, title: str, body: str, readingStatus: bool = False): """ Initializes a Revision instance with the given properties. Args: stars (int): The number of...
magic_instruct_75k
18,748
Write a Python function to process a list of plugins used in a web application configuration. The function should perform the following tasks: 1. Remove any commented-out plugins from the list. A plugin is considered commented-out if it starts with a `#` character. 2. Sort the list of plugins in alphabetical order. 3. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def process_plugins(plugins: List[str]) -> List[str]: """ Processes a list of plugins by removing any commented-out plugins and sorting the remaining plugins in alphabetical order. Args: plu...
magic_instruct_75k
18,767
Write a Python function to calculate the cumulative sum of a given list of integers. The cumulative sum at each index `i` in the output list should be the sum of all elements from index 0 to index `i` in the input list. The function should start with: ```python from typing import List def cumulative_sum(input_list: Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cumulative_sum(input_list: List[int]) -> List[int]: """ Calculate the cumulative sum of a list of integers. Args: input_list (List[int]): The list of integers for which to calculate the ...
magic_instruct_75k
18,769
Write a Python function to manage a collection of windows using a dictionary. Each window is represented by a unique identifier and a corresponding `Window` object. The function should allow creating and accessing windows by their unique identifiers. The function should return a reference to the added window after tran...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any class Window: """ A simple class to represent a window with some data. Attributes: data (Any): The data associated with the window. """ def __init__(self, data: Any): se...
magic_instruct_75k
18,798
Write a Python function to create a dictionary representing a car. The function should take the manufacturer and model of the car as mandatory arguments, and it should also accept any additional information about the car as keyword arguments. The function should then return a dictionary representing the car, including ...
Here is the Python code to solve the given problem in the markdown block: ```python def make_car(manufacturer: str, model: str, **extra_info) -> dict: """ Creates a dictionary representing a car with the given manufacturer, model, and any additional information. Args: manufacturer (str): The manufa...
magic_instruct_75k
18,812
Write a Python function to count the number of unique model unit names from a given list of strings. Model unit names are considered unique if they are case-insensitive equal and after stripping any leading or trailing whitespace. The function should start with: ```python from typing import List def count_unique_model...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_unique_model_units(model_units: List[str]) -> int: """ Counts the number of unique model unit names from a given list of strings. Model unit names are considered unique if they are case-ins...
magic_instruct_75k
18,832
Write a Python function to calculate the sum of elements in each column of a given matrix. The matrix is represented as a list of lists, where each inner list represents a row of the matrix. The function should return a list of integers, where each integer is the sum of the elements in the corresponding column. The co...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_column_sums(mtx: List[List[int]]) -> List[int]: """ Calculate the sum of elements in each column of a given matrix. Args: mtx (List[List[int]]): A matrix represented as a list ...
magic_instruct_75k
18,834
Write a Python function to automate the deployment of a workflow management system. The function should perform the following tasks in the specified order: 1. Enable workflow. 2. Set the admin password. 3. Accept terms and MLSA (Microsoft License Service Agreement). 4. Create an enterprise automate with a specified SSH...
Here is the Python code to solve the given problem in the markdown block: ```python def deploy_workflow_system(admin_password: str, ssh_pub_key_file: str) -> str: """ Automates the deployment of a workflow management system by performing the following tasks in order: 1. Enable workflow. 2. Set the admin...
magic_instruct_75k
18,835
Write a Python function to determine if a vehicle has stopped moving based on its current speed and to decide if a new query should be issued to the GPS system for updated location data based on the distance traveled from the last queried area. The system has two configurable parameters: 1. `MIN_DISTANCE_FOR_NEW_QUERY`...
Here is the Python code to solve the given problem in the markdown block: ```python def is_vehicle_stopped(current_speed: float, full_stop_max_speed: float) -> bool: """ Determines if the vehicle is considered stopped based on its current speed. Args: current_speed (float): The current speed of the...
magic_instruct_75k
18,844
Write a Python function to process a list of "things" where each "thing" is a tuple containing a symbol and a color. The function should perform the following operations: 1. If the list "things" is not empty, it extracts the first element and assigns it to the variable "thing". 2. It then extracts the symbol and color ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def process_things(things: List[Tuple[str, str]]) -> str: """ Process the first element of a list of tuples, where each tuple contains a symbol and a color. If the symbol is one of [symbols.PL...
magic_instruct_75k
18,845
Write a Python function `compute_params` that takes a 2D array or a DataFrame as input and computes the following statistical parameters: 1. Number of rows in the dataset (`n_rows`): The function should calculate and store the number of rows in the dataset. 2. Number of columns in the dataset (`n_cols`): The function s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Union import pandas as pd def compute_params(data: Union[list, pd.DataFrame]) -> dict: """ Computes various statistical parameters from a 2D array or DataFrame. Args: data (Union[list, pd.DataFra...
magic_instruct_75k
18,884
Write a Python function to generate a shell script for installing and configuring CUDA on a Linux system. The function should take the CUDA version as input and produce the necessary shell commands for installation and configuration. The CUDA version will be in the format "X.Y" (e.g., "11.2"). The generated script shou...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_cuda_installation_script(cuda_version: str) -> str: """ Generates a shell script for installing and configuring CUDA on a Linux system. Args: cuda_version (str): The CUDA version in the format "X.Y" (e....
magic_instruct_75k
18,886
Write a Python function to determine if a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, disregarding spaces, punctuation, and capitalization. The function should return `True` if the input string is a palindrome and `False...
Here is the Python code to solve the given problem in the markdown block: ```python def is_palindrome(input_string: str) -> bool: """ Determine if a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, disregardi...
magic_instruct_75k
18,906
Write a Python function `extract_info(code_snippet)` that takes a dictionary `code_snippet` as input and extracts the values associated with the keys 'author_email', 'url', and 'install_requires'. The function should return these values as a tuple in the order: (author_email, url, install_requires). The code should st...
Here is the Python code to solve the given problem in the markdown block: ```python def extract_info(code_snippet: dict) -> tuple: """ Extracts and returns the values associated with the keys 'author_email', 'url', and 'install_requires' from the given code snippet dictionary. Args: code_snippet (d...
magic_instruct_75k
18,925
Write a Python function to create a purchase order (PO) line dictionary based on input data from an API client. The function should extract specific fields from the input data and organize them into a dictionary format. The function should handle cases where the required fields might be missing from the input data. Th...
Here is the Python code to solve the given problem in the markdown block: ```python def create_po_line_dict(api_client: object, po_line_data: dict) -> dict: """ Creates a purchase order line dictionary by extracting specific fields from the input data. Args: api_client (object): An object represent...
magic_instruct_75k
18,944
Write a Python function to process a list of datasets and add non-duplicate elements to a master list. Each dataset is represented as a list of strings, where each string is a unique identifier. The function should take in a master list and a variable number of datasets, and add the non-duplicate elements from each dat...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def add_datasets(master_list: List[str], *datasets: List[str]) -> List[str]: """ Processes a list of datasets and adds non-duplicate elements to a master list. Args: master_list (List[str]):...
magic_instruct_75k
18,950
Write a Python function to parse and organize a list of configuration settings for a software application. Each setting is represented as a string in the format "Category-setting_name-setting_property", where "Category" is the general category of the setting, "setting_name" is the specific name of the setting, and "set...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Tuple def parse_settings(settings_list: List[str]) -> Dict[str, List[Tuple[str, str]]]: """ Parses and organizes a list of configuration settings into a dictionary. Each setting is represente...
magic_instruct_75k
18,955
Write a Python function to process and format data from an organization API. The function should take a dictionary as input, where the keys are department names and the values are the corresponding employee counts. The function should return a formatted string containing the department names and their respective employ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def process_organization_data(data: Dict[str, int]) -> str: """ Processes and formats data from an organization API. Args: data (Dict[str, int]): A dictionary where keys are department names...
magic_instruct_75k
18,960
Write a Python function to calculate the overall health state of an application based on the health states of its individual components. The health states of the components are provided as a dictionary where the keys are component identifiers and the values are the health states (strings: "Ok", "Warning", "Error"). The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def calculate_overall_health_state(component_health_states: Dict[str, str]) -> str: """ Calculate the overall health state of an application based on the health states of its components. The o...
magic_instruct_75k
18,981
Write a Python function to perform element-wise addition and scaling of two lists using a scalar factor. The function should take two input lists `src1` and `src2`, and a scalar `factor`, and return a new list `dst` where each element is calculated as: ``` dst[i] = src1[i] + factor * src2[i] ``` The code should start w...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def elementwise_add_and_scale(src1: List[float], src2: List[float], factor: float) -> List[float]: """ Perform element-wise addition and scaling of two lists using a scalar factor. Args: src...
magic_instruct_75k
18,985
Write a Python function to simulate the behavior of the `CustomError` class in the given C++ code snippet. The function should take two parameters: `error_table` and `error_column`, and return a formatted error message. The formatted error message should be in the format: "Error in table: <error_table>, column: <error_...
Here is the Python code to solve the given problem in the markdown block: ```python def format_custom_error(error_table: str, error_column: str) -> str: """ Formats a custom error message based on the provided error table and column. Args: error_table (str): The name of the table where the error oc...
magic_instruct_75k
19,011
Write a Python function that processes a list of filenames and applies a regular expression pattern to each filename to extract specific information. The function should take a list of filenames and a regular expression pattern as input and return a dictionary where the keys are the filenames and the values are the ext...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict import re def extract_info(files: List[str], pattern: str) -> Dict[str, str]: """ Extracts specific information from a list of filenames using a regular expression pattern. Args: files...
magic_instruct_75k
19,041
Write a Python function to simulate the `popd` command, which removes the top directory from a directory stack and returns the updated stack. The directory stack is represented as a list of strings, where each string represents a directory path. The top of the stack is the last element in the list. If the stack is empt...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def popd(directory_stack: List[str]) -> List[str]: """ Simulates the `popd` command by removing the top directory from the directory stack. Args: directory_stack (List[str]): A list of strin...
magic_instruct_75k
19,077
Write a Python function to sort a list of integers in ascending order using the insertion sort algorithm. The insertion sort algorithm works by iteratively building a sorted portion of the list, one element at a time. The function should take a list of integers as input and return the sorted list. The code should star...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def insertion_sort(arr: List[int]) -> List[int]: """ Sorts a list of integers in ascending order using the insertion sort algorithm. Args: arr (List[int]): The list of integers to be sorted....
magic_instruct_75k
19,113
Write a Python function to handle error messages for a web service. The function should take an error class as input and return the corresponding error message from a predefined map. If the error class is not found in the map, the function should return a generic error message. The code should start with: ```python de...
Here is the Python code to solve the given problem in the markdown block: ```python def get_error_message(error_class: type) -> str: """ Returns the corresponding error message for the given error class from a predefined map. If the error class is not found in the map, returns a generic error message. ...
magic_instruct_75k
19,118
Write a Python function to retrieve a specific attribute from a given model object. The model object is obtained by calling the `get_model()` function, which returns an instance of a model class with various attributes. Your function should take the name of the attribute as a string and return the value of that attribu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any def get_model_attribute(attribute_name: str) -> Any: """ Retrieves the value of a specified attribute from a model object. Args: attribute_name (str): The name of the attribute to retrieve fr...
magic_instruct_75k
19,138
Write a Python function to parse a given software license text and extract the conditions specified in the license. The license text is provided as a string, and the conditions are listed as numbered points followed by a period and space. Your function should return a list of the extracted conditions. The code should ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def parse_license_conditions(license_text: str) -> List[str]: """ Parses a given software license text and extracts the conditions specified in the license. Args: license_text (str): A strin...
magic_instruct_75k
19,140
Write a Python function to manage the startup and shutdown of a system's polybar instances. Polybar is a popular status bar for Linux systems that can be customized and configured to display various system information and notifications. Your function should handle the following requirements: 1. When the function is ca...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess def manage_polybar(): """ Manages the startup and shutdown of polybar instances. This function terminates any existing polybar instances and then starts a new polybar instance named "right". Args...
magic_instruct_75k
19,164
Write a Python function to map a list of class IDs to their corresponding class names using a given dictionary. The function should handle cases where some class IDs might not be present in the dictionary. The code should start with: ```python from typing import List, Dict def getClassNames(classIDs: List[int], class...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def getClassNames(classIDs: List[int], classNames: Dict[int, str]) -> List[str]: """ Maps a list of class IDs to their corresponding class names using a given dictionary. Args: classID...
magic_instruct_75k
19,207
Write a Python function to merge overlapping intervals from a given list of intervals. Each interval is represented as a pair of integers `[start, end]`. The function should return a new list of non-overlapping intervals. The code should start with: ```python from typing import List def merge_intervals(intervals: Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_intervals(intervals: List[List[int]]) -> List[List[int]]: """ Merges overlapping intervals from a given list of intervals. Args: intervals (List[List[int]]): A list of intervals wh...
magic_instruct_75k
19,217
Write a Python function to automate the deployment steps for a web hosting company. The function should perform the following actions in sequence: 1. Create a directory `/var/www/html/storage` if it does not exist. If the directory already exists, the function should not raise an error. 2. Set the owner and group of th...
Here is the Python code to solve the given problem in the markdown block: ```python import os import subprocess def deploy(command: str = None) -> None: """ Automates the deployment steps for a web hosting company. The function performs the following actions in sequence: 1. Creates a directory `/var/w...
magic_instruct_75k
19,236
Write a Python function to sort a list of 2D points based on their x-coordinate in ascending order. If two points have the same x-coordinate, sort them based on their y-coordinate in ascending order. The function should take a list of 2D points as input and return the sorted list of points. The code should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def sort_points_by_x_then_y(points: List[Tuple[int, int]]) -> List[Tuple[int, int]]: """ Sorts a list of 2D points based on their x-coordinate in ascending order. If two points have the same x...
magic_instruct_75k
19,245
Write a Python script that automates the process of extracting a tar.gz file, building a Docker image, and then cleaning up the extracted files. The script should handle any potential errors that may occur during the extraction, building, or cleanup processes. The script should start with: ```python import os import s...
Here is the Python code to solve the given problem in the markdown block: ```python import os import subprocess import tarfile def build_docker_image(tar_gz_file: str, docker_image_tag: str) -> None: """ Automates the process of extracting a tar.gz file, building a Docker image, and cleaning up the extracted f...
magic_instruct_75k
19,277
Write a Python function `validate_form_data(form_data)` that processes a form submission and validates the data based on predefined rules. The form data is represented as a list of dictionaries, where each dictionary contains the ID of a question and the corresponding user input value. The function should return a list...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict import re def validate_form_data(form_data: List[Dict[int, str]]) -> List[Dict[int, bool]]: """ Validates form data based on predefined rules and returns a list of validation results. Args: ...
magic_instruct_75k
19,279
Write a Python function to find the shortest path from a given source node to all other nodes in a graph using Dijkstra's algorithm. The graph is represented as a list of edges, where each edge is a tuple in the format `(source, destination, weight)`. The source and destination are represented as integers, and the weig...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict import heapq def dijkstra_shortest_path(graph: List[Tuple[int, int, int]], source: int) -> Dict[int, int]: """ Find the shortest path from a given source node to all other nodes in a graph u...
magic_instruct_75k
19,281
Write a Python function to find the highest score from a given list of scores. The function should efficiently determine the maximum value in the list. The code should start with: ```python from typing import List def highest_score(scores: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def highest_score(scores: List[int]) -> int: """ Find the highest score from a given list of scores. Args: scores (List[int]): A list of non-negative integers representing the scores. R...
magic_instruct_75k
19,320
Implement a Python function to simulate a data aggregation system for a distributed computing environment. The system consists of an aggregator and multiple worker nodes. The aggregator is responsible for collecting and processing data from the worker nodes. Each worker node runs a specific task and sends its results t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any class Aggregator: def __init__(self, initial_value: Any): """ Initialize the aggregator with an initial value for the aggregation process. Args: initial_value (Any):...
magic_instruct_75k
19,331
Write a Python function to calculate the maximum profit that can be obtained by buying and selling a stock at most once, given a list of daily stock prices. If it is not possible to make any profit, return 0. The code 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 obtained by buying and selling a stock at most once. Args: prices (List[int]): A list of integers repre...
magic_instruct_75k
19,345
Write a Python function `cubic_to_constants(C)` that takes a list `C` of 4 integers as input, representing the coefficients of a cubic equation in the form `ax^3 + bx^2 + cx + d`. The function should return a list of the same 4 integers, representing the constants `[a, b, c, d]` of the cubic equation. The function shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cubic_to_constants(C: List[int]) -> List[int]: """ Converts the coefficients of a cubic equation in the form ax^3 + bx^2 + cx + d into a list of constants [a, b, c, d]. Args: C (List[int...
magic_instruct_75k
19,346
Write a Python function to determine whether a given model output satisfies a specific condition. The function should return `True` if the target class matches the model's highest probability prediction or if the ground truth output matches the target class; otherwise, it should return `False`. The function should sta...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_goal_complete(model_output: List[float], target_class: int, ground_truth_output: int) -> bool: """ Determines whether the given model output satisfies a specific condition. The function retur...