source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_instruct_75k
29,868
Write a Python function to find the highest version number from a given list of version number strings. Each version number string is in the format "VX", where X is a non-negative integer. The function should return the highest version number string. The code should start with: ```python from typing import List def f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_highest_version(version_list: List[str]) -> str: """ Find the highest version number from a list of version number strings. Args: version_list (List[str]): A list of version number ...
magic_instruct_75k
29,883
Write a Python function to determine whether a given point lies inside or outside a given polygon in a 2D space. The polygon is represented as a list of points in the order they are connected. The point is represented as a tuple `(x, y)` where `x` and `y` are the coordinates of the point. 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 point_in_poly(point: Tuple[float, float], polygon: List[Tuple[float, float]]) -> bool: """ Determine whether a given point lies inside or outside a given polygon. Args: point (Tup...
magic_instruct_75k
29,897
Write a Python function to calculate the total cost of shipping a package based on its weight and a flat rate. The shipping cost is calculated using the formula: `total_cost = weight * 12.0 + flat`. The function should take the weight of the package and the flat rate as input and return the total shipping cost. The co...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_shipping_cost(weight: float, flat: float) -> float: """ Calculate the total cost of shipping a package based on its weight and a flat rate. The total cost is calculated using the formula: total_cost = weight *...
magic_instruct_75k
29,900
Write a Python function to calculate the average R&D spend for companies located in a specific state from a given dataset. The dataset is represented as a 2D list where each row contains the company's financial details (R&D spend, Administration spend, Marketing spend) and the company's location (state). The function s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def average_rd_spend(dataset: List[List[Union[float, str]]], state: str) -> float: """ Calculate the average R&D spend for companies located in a specific state. Args: dataset (List[L...
magic_instruct_75k
29,904
Write a Python function to process a list of `pacman` package installation commands and return a dictionary containing the packages to be installed for each command. Each command is a string representing a `pacman` package manager command with various options and package names. The function should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def process_install_commands(install_commands: List[str]) -> Dict[str, List[str]]: """ Processes a list of `pacman` package installation commands and returns a dictionary containing the package...
magic_instruct_75k
29,907
Write a Python function to manipulate a list of strings based on specific requirements. The function should take a list of strings as input and perform the following operations: 1. Join the strings in the list using a comma (`,`) and store the result in a variable `result1`. 2. Join the strings in the list using an amp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def manipulate_strings(lst: List[str]) -> Tuple[str, str]: """ Manipulates a list of strings by joining them using a comma and an ampersand. Args: lst (List[str]): A list of strings t...
magic_instruct_75k
29,910
Write a Python function `process_text_features(text_features_list)` that processes a list of text features and organizes them into a dictionary. The function should identify and handle duplicate text features within the same canonical document ID, and then serialize the resulting dictionary into a list of examples. The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def process_text_features(text_features_list: List[Tuple[int, str]]) -> List[Dict[str, any]]: """ Processes a list of text features and organizes them into a dictionary. Identifies and h...
magic_instruct_75k
29,912
Write a Python function to parse a limited JSON string and provide methods to access the parsed data. The JSON format will be limited to objects (key-value pairs) and arrays (lists of values). The parser should be able to handle nested objects and arrays. The function should have the following methods: 1. `parse(json_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, Dict, List, Union import json class JsonParser: def __init__(self): self.data = {} def parse(self, json_str: str) -> None: """ Parse a JSON string and store the parsed data inter...
magic_instruct_75k
29,934
Write a Python function to count the occurrences of major versions from a list of strings representing programming language versions. Each string in the list follows the format "Programming Language :: Python :: X.Y", where X is the major version and Y is the minor version. The function should return a dictionary where...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def count_major_versions(versions: List[str]) -> Dict[str, int]: """ Counts the occurrences of major versions from a list of strings representing programming language versions. Args: v...
magic_instruct_75k
29,937
Create a Python class `VendingMachine` that simulates a simple vending machine. The vending machine should have the following functionalities: 1. Initialize with a set of available items, each with a unique identifier, name, and price. 2. Allow users to insert coins into the machine, which adds to the current balance. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Tuple class VendingMachine: """ A class to simulate a simple vending machine. Attributes: available_items (Dict[int, Tuple[str, float]]): A dictionary mapping item IDs to tuples containing ...
magic_instruct_75k
29,939
Write a Python function `extract_build_info(config_data)` that processes a given dictionary `config_data` representing an Android application's build configuration in the GYP format. The function should extract and return specific pieces of information from the configuration data. The extracted information should inclu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def extract_build_info(config_data: Dict) -> Dict[str, str or List[str]]: """ Extracts specific information from a given build configuration dictionary. Args: config_data (dict): A dic...
magic_instruct_75k
29,958
Write a Python function to generate HTML script tags for a list of JavaScript file paths. The function should produce the script tags in the format `{!! HTML::script('path/to/file.js')!!}`, where each script tag is on a new line. The function should handle an empty list by returning an empty string. The code should st...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generateScriptTags(file_paths: List[str]) -> str: """ Generates HTML script tags for a list of JavaScript file paths. Args: file_paths (List[str]): A list of file paths to JavaScript fil...
magic_instruct_75k
29,977
Write a Python function to process a list of image URLs using a set of pre-trained models for image detection and classification. The function should take a dictionary of models and a list of image URLs as input and return a dictionary containing the results of processing each image URL using the corresponding model. T...
Here is the Python code to solve the given problem in the markdown block: ```python def process_images(models: dict, img_urls: list) -> dict: """ Processes a list of image URLs using a set of pre-trained models for image detection and classification. Args: models (dict): A dictionary where keys are...
magic_instruct_75k
29,983
Write a Python function to process a list of tweets and generate a summary of actor information. The function should return a list of tuples, where each tuple contains the following information in the given order: actor ID, actor link, preferred username, display name, retweet count, and share count. The retweet count ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def process_tweets(tweets: List[dict]) -> List[Tuple[str, str, str, str, int, int]]: """ Processes a list of tweets and generates a summary of actor information. Args: tweets (list): ...
magic_instruct_75k
29,985
Write a Python function to round a given floating-point number represented as a string to the nearest integer and return the result as a string. The function should handle various edge cases, such as negative numbers, numbers with a fractional part exactly equal to 0.5, and invalid input strings. The code should start...
Here is the Python code to solve the given problem in the markdown block: ```python def round_float_to_nearest_integer(line: str) -> str: """ Rounds a given floating-point number represented as a string to the nearest integer and returns the result as a string. Args: line (str): A string representi...
magic_instruct_75k
29,995
Write a Python function to adjust the learning rate of an optimizer based on a provided schedule. The schedule is a list of tuples, where each tuple contains an epoch number and the corresponding new learning rate. The function should update the learning rate of the optimizer if the current epoch matches any of the sch...
Here is the Python code to solve the given problem in the markdown block: ```python def adjust_learning_rate(optimizer, epoch, args): """ Adjust the learning rate of the optimizer based on the provided schedule. Args: optimizer: An instance of the optimizer used for training the model. epoc...
magic_instruct_75k
30,000
Write a Python function `get_seat_info` that takes a boarding pass string as input and returns a dictionary containing the row, column, and seat ID. The boarding pass string consists of characters 'F', 'B', 'L', and 'R', where 'F' and 'B' determine the row, and 'L' and 'R' determine the column. The row and column are t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def get_seat_info(boarding_pass: str) -> Dict[str, int]: """ Calculate the row, column, and seat ID from a boarding pass string. Args: boarding_pass (str): The boarding pass string con...
magic_instruct_75k
30,001
Write a Python function to determine if a given package exists based on a list of rules. Each rule is a string of the form "CONDITION=PACKAGE", where CONDITION is a logical condition and PACKAGE is the name of the package. The logical condition can be either a negated condition (starting with "!") or a regular conditio...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def package_exists(rules: List[str], package: str) -> bool: """ Determine if a given package exists based on a list of rules. Args: rules (List[str]): A list of rules where each rule is a st...
magic_instruct_75k
30,018
Write a Python function to manage virtual machine snapshots based on predefined quotas and warning thresholds. The function should take a team number as input and perform the following steps: 1. Validate if the input team number is a valid integer. If not, raise a `ValueError` with an appropriate error message. 2. Cons...
Here is the Python code to solve the given problem in the markdown block: ```python def manage_vm_snapshots(team_number: int) -> None: """ Manages virtual machine snapshots based on predefined quotas and warning thresholds. Args: team_number (int): The team number for which to manage the snapshots....
magic_instruct_75k
30,029
Write a Python function to find the length of the longest continuous increasing subsequence (LCIS) within a given list of integers. The function should return the length of the longest subsequence where each element is greater than the previous element. The code should start with: ```python from typing import List de...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_lcis_length(nums: List[int]) -> int: """ Find the length of the longest continuous increasing subsequence (LCIS) in a list of integers. Args: nums (List[int]): A list of integers. ...
magic_instruct_75k
30,031
Write a Python function to process a list of waffle resources and return a modified list based on the specified target state. Each resource is represented as a dictionary with the keys "name", "state", and "type". The function should take the list of resources and a target state as input, and return a new list with the...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def process_resources(resources: List[Dict[str, str]], target_state: str) -> List[Dict[str, str]]: """ Processes a list of waffle resources and returns a modified list based on the specified target...
magic_instruct_75k
30,038
Write a Python function to process a list of tuples representing database migration records and return the latest migration for each app. Each tuple contains two elements: the app name and the migration identifier. The migration identifier consists of a numeric part and a timestamp part in the format "auto_YYYYMMDD_HHM...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def latest_migrations(migration_records: List[Tuple[str, str]]) -> Dict[str, str]: """ Processes a list of tuples representing database migration records and returns the latest migration for...
magic_instruct_75k
30,045
Write a Python function to calculate the sum of all even Fibonacci numbers up to a given limit. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. For example, the first few numbers in the Fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13...
Here is the Python code to solve the given problem in the markdown block: ```python def even_fibonacci_sum(limit: int) -> int: """ Calculate the sum of all even Fibonacci numbers up to a given limit. Args: limit (int): The upper limit for the Fibonacci numbers to be considered. Returns: ...
magic_instruct_75k
30,073
Write a Python function to implement a sorting algorithm that repeatedly swaps adjacent elements in a list if they are in the wrong order until the list is fully sorted. The function should start with: ```python from typing import List def mysteryAlgorithm(lst: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def mysteryAlgorithm(lst: List[int]) -> List[int]: """ Sorts a list of integers by repeatedly swapping adjacent elements if they are in the wrong order. Args: lst (List[int]): The list of in...
magic_instruct_75k
30,081
Write a Python function `extract_manual_hour(event_time, time_zone)` that processes time zone information and extracts the manual hour informed in an event. The function should handle invalid time zone strings and raise a `ValueError` with an appropriate message. The function should take two parameters: - `event_time`:...
Here is the Python code to solve the given problem in the markdown block: ```python import re def extract_manual_hour(event_time: str, time_zone: str) -> int: """ Extracts the manual hour from the event time based on the provided time zone. Args: event_time (str): The time of the event in the form...
magic_instruct_75k
30,103
Write a Python function to simulate the message processing logic for a robotic arm control system. The function should handle three types of messages: `SetPose`, `CustomPose`, and `EmergencySignal`. Each message type has a specific structure and processing logic. The function should be able to process a list of message...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Union def process_messages(messages: List[Dict[str, Union[str, Dict[str, Union[float, List[float], bool]]]]]) -> Dict[str, int]: """ Process a list of messages for a robotic arm control system and...
magic_instruct_75k
30,144
Write a Python function to extract specific information from a setup configuration dictionary for a package and return it as a formatted string. The setup configuration dictionary contains various attributes related to the package, such as its name, version, author, and description. The function should ensure that the ...
Here is the Python code to solve the given problem in the markdown block: ```python def extract_package_info(setup_config: dict) -> str: """ Extracts and formats specific information from a setup configuration dictionary for a package. Args: setup_config (dict): A dictionary containing the setup co...
magic_instruct_75k
30,156
Write a Python function to create a new work item in a project management system. The function should take a list of child work item IDs, an ID for the new work item, and a title for the new work item. The function should create the new work item with the given ID and title, and then associate it with the child work it...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def create_work_item(child_work_item_ids: List[int], id: int, title: str) -> str: """ Creates a new work item in a project management system and associates it with the specified child work items. Ar...
magic_instruct_75k
30,162
Write a Python function to filter a list of dataset names based on a given keyword. The function should return a new list containing only the dataset names that include the specified keyword. The function should be case-insensitive, meaning it should match the keyword regardless of the case of the letters in the datase...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_datasets(dataset_names: List[str], keyword: str) -> List[str]: """ Filters a list of dataset names based on a given keyword. Args: dataset_names (List[str]): A list of dataset nam...
magic_instruct_75k
30,190
Write a Python function `process_list` that takes a list of integers as input and returns a new list containing the unique elements from the input list, preserving their original order. The function should ensure that each element appears only once in the output list, and the order of elements in the output list should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def process_list(input_list: List[int]) -> List[int]: """ Returns a new list containing the unique elements from the input list, preserving their original order. Args: input_list (List[int])...
magic_instruct_75k
30,197
Write a Python function `get_bet_rate` that takes an integer `trios_quatre_cinq` as input and returns the corresponding betting rate. The betting rates are stored in a dictionary where the keys are the values of `trios_quatre_cinq` and the values are the respective betting rates. If the input value is not found in the ...
Here is the Python code to solve the given problem in the markdown block: ```python def get_bet_rate(trios_quatre_cinq: int) -> float: """ Returns the betting rate corresponding to the given integer input. The betting rates are stored in a dictionary where the keys are the integer values and the values...
magic_instruct_75k
30,201
Write a Python function to remove consecutive duplicate characters from a given string containing only lowercase English letters. The function should return the modified string with all consecutive duplicates removed. The code should start with: ```python def remove_consecutive_duplicates(s: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def remove_consecutive_duplicates(s: str) -> str: """ Removes consecutive duplicate characters from the given string. Args: s (str): The input string containing only lowercase English letters. Returns: ...
magic_instruct_75k
30,203
Write a Python function to filter a list of student records based on specific criteria. Each student record is represented as a dictionary with keys "name", "age", "grade", and "school". The function should take a list of student records and a filter condition as input and return a list of student names that satisfy th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Union def filter_students(students: List[Dict[str, Union[str, int]]], filter_condition: str) -> List[str]: """ Filters a list of student records based on the given filter condition and returns a l...
magic_instruct_75k
30,205
Implement a simple key-value store using a hash map in Python. The key-value store should support the following operations: 1. `put(key, value)`: Insert a new key-value pair into the store. If the key already exists, update the corresponding value. 2. `get(key)`: Retrieve the value associated with the given key. If th...
Here is the Python code to solve the given problem in the markdown block: ```python class Node: def __init__(self, key, value): self.key = key self.value = value self.next = None class KeyValueStore: def __init__(self, capacity): """ Initialize the KeyValueStore with a g...
magic_instruct_75k
30,212
Write a Python function to generate an HTML error page based on the given HTTP status code and error message. The function should dynamically insert the status code and error message into the HTML template. The HTML template should include a container div, centered content, and a horizontal rule. The code should start...
Here is the Python code to solve the given problem in the markdown block: ```python def generateErrorPage(statusCode: int, errorMessage: str) -> str: """ Generates an HTML error page based on the given HTTP status code and error message. Args: statusCode (int): The HTTP status code to be displayed ...
magic_instruct_75k
30,213
Write a Python function to determine the actions that should be added to an alert dialog based on the availability of specific features on a user's device. The function should take four boolean parameters indicating whether the device supports accessing the camera, photos, videos, and files, respectively. The function ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def getActions(getCamera: bool, getPhotos: bool, getVideos: bool, getFiles: bool) -> List[str]: """ Determine the actions that should be added to an alert dialog based on the availability of specific fea...
magic_instruct_75k
30,219
Write a Python function to simulate a simplified version of a message processing system. The system consists of a task queue, a task execution function, and a socket client that submits tasks for processing. Implement the task execution function and the task submission logic based on the given code snippet. The task e...
Here is the Python code to solve the given problem in the markdown block: ```python def execute_task(task_id: str, user_id: str, code: str, inputs: str) -> str: """ Executes a task based on the provided code and inputs. Args: task_id (str): The ID of the task. user_id (str): The ID of the u...
magic_instruct_75k
30,255
Write a Python function to calculate the length of a singly linked list. The linked list is represented by the `ListNode` class, which has an `__init__` method to initialize the node with a value and a reference to the next node. The function should take the head of the linked list as input and return the length of the...
Here is the Python code to solve the given problem in the markdown block: ```python class ListNode: def __init__(self, val, next=None): self.val = val self.next = next def length_of_linked_list(head: ListNode) -> int: """ Calculate the length of a singly linked list. Args: head...
magic_instruct_75k
30,266
Write a Python function to perform a scaling operation on a given value using a global scaling factor. The function should take an input value `val` and return the result of scaling `val` by the global scaling factor `scale`. The scaling factor is represented as a percentage, and the function should return the integer ...
Here is the Python code to solve the given problem in the markdown block: ```python def scale_value(val: int) -> int: """ Perform a scaling operation on the given value using a global scaling factor. The scaling factor is represented as a percentage and is stored in the global variable `scale`. The fun...
magic_instruct_75k
30,277
Write a Python function `binary_to_decimal_memoized(masked_value)` that takes a binary string `masked_value` as input and returns its decimal equivalent using memoization to store previously calculated values. The function should be efficient and avoid redundant calculations by leveraging a memoization technique. The ...
Here is the Python code to solve the given problem in the markdown block: ```python def binary_to_decimal_memoized(masked_value: str) -> int: """ Converts a binary string to its decimal equivalent using memoization to avoid redundant calculations. Args: masked_value (str): A binary string represent...
magic_instruct_75k
30,282
Write a Python function to implement a simple recording state machine for a voice recorder application. The state machine has three states: Idle, Recording, and Paused. The function `start_recording` should transition the recorder to the Recording state when called, but only if the recorder is currently in the Idle sta...
Here is the Python code to solve the given problem in the markdown block: ```python from enum import Enum class RecorderState(Enum): Idle = 1 Recording = 2 Paused = 3 def start_recording(current_state: RecorderState) -> RecorderState: """ Transition the recorder to the Recording state if it is cur...
magic_instruct_75k
30,302
Write a Python function to construct a URL for a specific API endpoint based on the given information. The function should take in the endpoint details and return the complete URL. The function should handle the parameters and append them to the URL in the correct format. The code should start with: ```python from typ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def constructURL(method: str, base_url: str, endpoint_path: str, service_name: str, parameters: Dict[str, Dict[str, str]]) -> str: """ Constructs a complete URL for an API endpoint based on the given inf...
magic_instruct_75k
30,306
Write a Python function to count the occurrences of each unique programming language mentioned in a list of classifiers. The classifiers are strings in the format "Category :: Subcategory :: Subsubcategory" or "Category :: Subcategory". The function should return a dictionary where the keys are the unique programming l...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def count_programming_languages(classifiers: List[str]) -> Dict[str, int]: """ Counts the occurrences of each unique programming language mentioned in a list of classifiers. Args: clas...
magic_instruct_75k
30,321
Write a Python function to calculate the factorial of a given non-negative integer `n` using an iterative approach. The factorial of a non-negative integer `n` is the product of all positive integers less than or equal to `n`. The function should handle large factorials efficiently and accurately. The code should star...
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 given non-negative integer n using an iterative approach. Args: n (int): The non-negative integer for which to calculate the factorial. Returns: ...
magic_instruct_75k
30,327
Write a Python function to calculate the sum of all even Fibonacci numbers up to a given limit. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, typically starting with 0 and 1. The function should take an integer `limit` as input and return the sum of all even Fibon...
Here is the Python code to solve the given problem in the markdown block: ```python def evenFibonacciSum(limit: int) -> int: """ Calculate the sum of all even Fibonacci numbers up to a given limit. Args: limit (int): The upper limit for the Fibonacci numbers to be considered. Returns: ...
magic_instruct_75k
30,350
Write a Python function to process configuration settings for a data loading application. The function should take in an argument object containing various parameters and a configuration dictionary. The function should then determine the appropriate settings for loading data based on the input parameters and the config...
Here is the Python code to solve the given problem in the markdown block: ```python def process_config_settings(arg_obj, config): """ Processes configuration settings for a data loading application based on the provided argument object and configuration dictionary. Args: arg_obj (dict): A dictionar...
magic_instruct_75k
30,354
Write a Python function to count the number of integers in a given list that are multiples of 100 and 1000. The function should return a tuple where the first element is the count of numbers that are multiples of 100 and the second element is the count of numbers that are multiples of 1000. 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 count_hundreds_thousands(numbers: List[int]) -> Tuple[int, int]: """ Counts the number of integers in the given list that are multiples of 100 and 1000. Args: numbers (List[int]):...
magic_instruct_75k
30,358
Write a Python function to automate the installation and setup of the JAGS (Just Another Gibbs Sampler) software on a Linux system. The function should perform the following steps: 1. Install the LAPACK library and its development files using the `yum` package manager. 2. Download the JAGS source code from a specified ...
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 setup_jags(lapack_package: str, jags_url: str, jags_archive_name: str, jags_directory_name: str) -> None: """ Automates the installation and setup of the JAGS...
magic_instruct_75k
30,362
Write a Python function to generate CSS code for styling radio buttons based on the provided input parameters. The function should take the size of the radio button, the color palette, and a boolean indicating whether the radio button is checked or unchecked. The generated CSS code should include the width, height, bor...
Here is the Python code to solve the given problem in the markdown block: ```python def generateRadioButtonCSS(size: int, colorPalette: str, checked: bool) -> str: """ Generates CSS code for styling a radio button based on the provided input parameters. Args: size (int): The size of the radio butto...
magic_instruct_75k
30,381
Write a Python function to determine the winning candidate based on a majority voting rule from a given list of votes. If there is no clear winner (i.e., no candidate has more than half of the total votes), the function should return "No winner". The code should start with: ```python from typing import List def find_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_winner(votes: List[str]) -> str: """ Determine the winning candidate based on a majority voting rule. Args: votes (List[str]): A list of strings where each string represents a vote ...
magic_instruct_75k
30,384
Write a Python function to categorize a list of file extensions into three groups: "debpackage" for Debian package files, "file" for regular files, and "unknown" for any other file extensions. The function should return a dictionary containing the counts of each file type. The keys of the dictionary should be the file ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def categorize_file_extensions(file_extensions: List[str]) -> Dict[str, int]: """ Categorizes a list of file extensions into three groups: "debpackage", "file", and "unknown". Args: fi...
magic_instruct_75k
30,387
Write a Python function to implement a module loader for a social media API library. The module loader should dynamically load and execute the appropriate function based on the user's request. The function should accept a function name as input and return the result of executing the corresponding function from the libr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, Callable, Dict # Mock functions for the social media API library def get_countries() -> str: return "List of countries" def get_media_by_location(location: str) -> str: return f"Media from {location}" ...
magic_instruct_75k
30,407
Write a Python function to calculate the average score of a game, excluding the highest and lowest scores from a given list of integers. The function should handle lists with at least two elements and up to 100 elements. The average score should be rounded to the nearest integer. The code should start with: ```python ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_average_score(scores: List[int]) -> int: """ Calculate the average score of a game after excluding the highest and lowest scores. Args: scores (List[int]): A list of integers r...
magic_instruct_75k
30,415
Write a Python function to perform a byte swap operation on a given NumPy array and return both the original and the byte-swapped arrays. The function should handle both in-place and non-in-place byte swapping. The code should start with: ```python import numpy as np from typing import Tuple def byte_swap_arrays(arr: ...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import Tuple def byte_swap_arrays(arr: np.ndarray, inplace: bool = False) -> Tuple[np.ndarray, np.ndarray]: """ Perform a byte swap operation on a given NumPy array and return both the original an...
magic_instruct_75k
30,435
Write a Python function to automate the deployment of a Hugo website. The function should simulate the execution of a Bash script that starts the Hugo server with specific options. The function should take a dictionary of options as input and return a string representing the Bash command that would be executed. The opt...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def generate_hugo_command(options: Dict[str, bool]) -> str: """ Generates a Bash command to start the Hugo server with specified options. Args: options (Dict[str, bool]): A dictionary where ...
magic_instruct_75k
30,459
Write a Python function to parse a configuration dictionary for a keypoint detection module in a deep learning model. The function should extract specific settings related to the keypoint detection module and return them in a new dictionary. The input dictionary may contain commented-out keys and nested dictionaries. I...
Here is the Python code to solve the given problem in the markdown block: ```python def parse_keypoint_config(config: dict) -> dict: """ Parses the configuration dictionary for a keypoint detection module and extracts relevant settings. Args: config (dict): The configuration dictionary containing s...
magic_instruct_75k
30,472
Write a Python function called `organize_imports` that takes a list of module imports as input and returns a hierarchical representation of the imports as a dictionary. The keys of the dictionary should be the top-level segments of the import paths, and the values should be dictionaries representing the next level of t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def organize_imports(imports: List[str]) -> Dict: """ Organizes a list of module imports into a hierarchical dictionary structure. Args: imports (List[str]): A list of module import st...
magic_instruct_75k
30,477
Write a Python function to perform a merge sort on a given list of integers. Merge sort is a divide-and-conquer algorithm that recursively divides the input list into smaller sublists until each sublist contains only one element. It then merges these sublists in a sorted manner to produce the final sorted list. The co...
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 a list of integers using the merge sort algorithm. Args: arr (List[int]): The list of integers to be sorted. Returns: List...
magic_instruct_75k
30,496
Write a Python function to determine if a given string is a palindrome. A palindrome is a sequence of characters that reads the same forward and backward, ignoring spaces, punctuation, and capitalization. The function should be case-insensitive and should handle various edge cases, such as empty strings and strings wit...
Here is the Python code to solve the given problem in the markdown block: ```python def is_palindrome(s: str) -> bool: """ Determine if a given string is a palindrome, ignoring spaces, punctuation, and capitalization. Args: s (str): The input string to check. Returns: bool: True if the...
magic_instruct_75k
30,500
Write a Python function to process a given string according to a specific set of rules. The function should take a string as input and return a modified version of the string based on the following rules: 1. If the input string starts with "--", it should be replaced with "dashdash_". 2. If the input string ends with "...
Here is the Python code to solve the given problem in the markdown block: ```python def process_string(input_str: str) -> str: """ Processes the input string according to a specific set of rules. Args: input_str (str): The input string to be processed. Returns: str: The modified string...
magic_instruct_75k
30,542
Write a Python function to select a random action from a list of available actions. The function should take a list of strings representing the available actions and return a randomly chosen action from the list. The function should be efficient and handle cases where the list of available actions is empty. The code s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def select_random_action(available_actions: List[str]) -> str: """ Selects a random action from a list of available actions. Args: available_actions (List[str]): A list of stri...
magic_instruct_75k
30,545
Write a Python function to find the maximum sum of a subarray within a given array of integers. A subarray is defined as a contiguous block of elements within the original array. The function should efficiently handle large arrays and return the maximum sum. 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 def maxSubarraySum(arr: List[int]) -> int: """ Calculate the maximum sum of a subarray within the given array. Args: arr (List[int]): The input array of integers. Returns: int: ...
magic_instruct_75k
30,549
Write a Python function to determine whether a given node should be formatted in its parent context based on certain conditions. The function should take two parameters: `state` and `config`. The `state` parameter represents the current state of the node, including its parent, and the `config` parameter contains config...
Here is the Python code to solve the given problem in the markdown block: ```python def should_format_in_parent_context(state: dict, config: dict) -> bool: """ Determines whether a given node should be formatted in its parent context based on the configuration options. Args: state (dict): The curre...
magic_instruct_75k
30,555
Write a Python function to find the missing integer in a list of n-1 integers, where each integer is in the range 1 to n inclusive. The function should return the missing integer. The code should start with: ```python from typing import List def find_missing_integer(nums: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_missing_integer(nums: List[int]) -> int: """ Finds the missing integer in a list of n-1 integers, where each integer is in the range 1 to n inclusive. Args: nums (List[int]): A list...
magic_instruct_75k
30,585
Create a Python decorator that intercepts the input and output of a function named `decorator_protocol` without modifying the original function. The decorator should not affect another function named `non_decorator_protocol`. The decorator should print messages before and after the `decorator_protocol` function is call...
Here is the Python code to solve the given problem in the markdown block: ```python def decorator_protocol_decorator(func): """ A decorator that intercepts the input and output of the `decorator_protocol` function. Args: func (function): The function to be decorated. Returns: function:...
magic_instruct_75k
30,594
Write a Python function to extract the table constraints that are being dropped during the upgrade process from a given Alembic migration script. The function should return a list of tuples, where each tuple contains the name of the constraint being dropped, the table it belongs to, and its type. The code should start...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import re def extract_dropped_constraints(migration_script: str) -> List[Tuple[str, str, str]]: """ Extracts the table constraints that are being dropped during the upgrade process from a given Al...
magic_instruct_75k
30,610
Write a Python function to parse the "EtaRegion" parameter and return the corresponding value for "myEtaRegion". If the input parameter is not recognized, the function should log a warning message and return the default value "Central". The possible values for "EtaRegion" and their corresponding "myEtaRegion" values ar...
Here is the Python code to solve the given problem in the markdown block: ```python import logging def parse_eta_region(eta_region: str) -> tuple: """ Parses the "EtaRegion" parameter and returns the corresponding "myEtaRegion" value. If the input parameter is not recognized, logs a warning message and ret...
magic_instruct_75k
30,625
Write a Python function to determine the directory path for each user's uploaded files in a Django model. The directory path should be based on the user's username. The function should take two parameters: - `instance`: An instance of the model where the file is being attached. - `filename`: The original filename of th...
Here is the Python code to solve the given problem in the markdown block: ```python def user_directory_path(instance, filename): """ Determine the directory path for each user's uploaded files in a Django model. Args: instance: An instance of the model where the file is being attached. file...
magic_instruct_75k
30,639
Write a Python function to count the number of valid image IDs in a given list. An image ID is considered valid if it is a non-empty string consisting only of digits. The function should ignore any non-string elements in the input list. The code should start with: ```python from typing import List def count_valid_ima...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_valid_image_ids(image_ids: List[str]) -> int: """ Counts the number of valid image IDs in a given list. An image ID is considered valid if it is a non-empty string consisting only of digit...
magic_instruct_75k
30,668
Write a Python function to extract metadata from a Markdown file's content. The metadata is located at the beginning of the file and consists of key-value pairs formatted as `key: value`. Each key-value pair is separated by a newline character. The function should ignore any non-metadata content in the file. The code ...
Here is the Python code to solve the given problem in the markdown block: ```python def extract_metadata(markdown_content: str) -> dict: """ Extracts metadata from the beginning of a Markdown file's content. The metadata is assumed to be located at the beginning of the file and consists of key-value pairs ...
magic_instruct_75k
30,683
Write a Python function to count the total number of uploads made by each unique uploader from a list of upload records. Each upload record is represented as a dictionary with the keys "uploader_id" and "upload_id". The function should return a dictionary where the keys are unique uploader IDs and the values are the to...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def count_uploads_by_uploader(upload_records: List[Dict[str, any]]) -> Dict[int, int]: """ Counts the total number of uploads made by each unique uploader from a list of upload records. Args: ...
magic_instruct_75k
30,697
Create a Python class `MediaSegment` that manages a library of various media segments for a video streaming service. The class should handle serving rules, tags, variations, and variation maps for each segment. The class should have the following functionalities: 1. Initialize the `MediaSegment` class with a unique ide...
Here is the Python code to solve the given problem in the markdown block: ```python class MediaSegment: """ A class to manage media segments for a video streaming service. Attributes: identifier (str): A unique identifier for the media segment. serving_rules (list): A list of serving rules ...
magic_instruct_75k
30,700
Write a Python function `process_relationships` that takes a list of relationships as input and returns a modified list of parameter dictionaries based on the following conditions: 1. For each relationship, if the 'end_taxid' is '9606' (indicating a specific taxonomic identifier), add a new key-value pair to the 'prope...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Union def process_relationships(relationships: List[Dict[str, Union[int, str, Dict[str, str]]]]) -> List[Dict[str, Union[int, str, Dict[str, str]]]]: """ Processes a list of relationships and upda...
magic_instruct_75k
30,730
Write a Python function to reverse the keys and values of a given dictionary where the keys are state abbreviations and the values are the corresponding full state names. The function should return a new dictionary with the full state names as keys and the state abbreviations as values. 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 reverse_state_dict(state_dict: Dict[str, str]) -> Dict[str, str]: """ Reverses the keys and values of a given dictionary where the keys are state abbreviations and the values are full state names. ...
magic_instruct_75k
30,738
Create a Python class `LogEvent` that represents a log event with a timestamp and associated data. The class should provide functionality to compare two log events based on their timestamps. Additionally, implement a function `make_next_log_events_test_pair` that creates a pair of `LogEvent` objects for testing purpose...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple class LogEvent: """ Represents a log event with a timestamp and associated data. Attributes: _timestamp (int): The timestamp of the log event. _data (str): The associated data of th...
magic_instruct_75k
30,740
Write a Python function to calculate the Mean Average Precision (MAP) for search results from two different sources: CodeCatch and Google. The MAP is a measure of the quality of search results, considering both the relevance and the ranking of the retrieved documents. The MAP is calculated by taking the average of the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict class SearchResult: def __init__(self, is_relevant: bool): self.is_relevant = is_relevant def average_precision(results: List[SearchResult], cutoff: int) -> float: """ Calculate the av...
magic_instruct_75k
30,761
Write a Python function `parse_metadata` that takes in a dictionary `pages` as input. The `pages` dictionary contains page names as keys and their corresponding metadata as values. The metadata is represented as a dictionary with keys "category", "title", and "description". However, not all pages have all three metadat...
Here is the Python code to solve the given problem in the markdown block: ```python def parse_metadata(pages: dict) -> dict: """ Parses and retrieves metadata from a collection of web pages. Args: pages (dict): A dictionary where keys are page names and values are dictionaries containing metadata. ...
magic_instruct_75k
30,765
Write a Python function `matchNames` that takes in three parameters: - `ID_name`: A string representing the name of the ID to be matched. - `ID`: Either a string or an integer representing the ID to look for. If it is an integer, it will be considered as the ID to look for, except for sizes as these can sometimes be in...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def matchNames(ID_name: str, ID: Union[str, int], data: List[dict]) -> List[int]: """ Matches the given ID or string with the ID_name in the data and returns a list of matched IDs. Args: ...
magic_instruct_75k
30,767
Write a Python function to calculate the sum of the products of adjacent pairs of integers in a given list. If the last integer is reached, the "next" integer will be the first integer in the list. The function should handle lists with a length between 2 and 1000. The code should start with: ```python from typing impo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_adjacent_products(puzzle_input: List[int]) -> int: """ Calculate the sum of the products of adjacent pairs of integers in a circular list. Args: puzzle_input (List[int]): A list o...
magic_instruct_75k
30,784
Write a Python function to calculate the R1 regularization penalty for a discriminator in a generative adversarial network (GAN). The R1 penalty is used to regularize the discriminator's gradients with respect to real samples. The function should take in the gradients of the discriminator with respect to real samples a...
Here is the Python code to solve the given problem in the markdown block: ```python import torch def calculate_r1_penalty(real_grads: torch.Tensor) -> float: """ Calculate the R1 regularization penalty for a discriminator in a GAN. The R1 penalty is used to regularize the discriminator's gradients with re...
magic_instruct_75k
30,788
Write a Python function to automate the versioning and iteration of a software project. The version number is stored in a file named `build.sbt` in the format `version := "x.y.z"`, where `x.y.z` represents the major, minor, and patch version numbers. The iteration number is a combination of the Jenkins build number and...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_iteration_number(build_file: str, build_number: int, additional_string: str) -> str: """ Generate an iteration number for a software project by combining the version number from a build file, the Jenkins build n...
magic_instruct_75k
30,797
Write a Python function to calculate the sum of all even numbers in a given list of integers. The function should take a list of integers as input and return the sum of all the even numbers in the list. The function should be efficient and handle various edge cases, such as an empty list or a list with no even numbers....
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_even_numbers(nums: List[int]) -> int: """ Calculate the sum of all even numbers in a given list of integers. Args: nums (List[int]): A list of integers from which to calculate the...
magic_instruct_75k
30,822
Write a Python function to initialize a list of lists based on the given paths and number of classes. Each inner list in the resulting list should correspond to a path, and each inner list should contain `ncls` empty sublists. The function should start with: ```python from typing import List def initialize_fname(path...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def initialize_fname(path: List[str], ncls: int) -> List[List[List[None]]]: """ Initializes a list of lists based on the given paths and number of classes. Args: path (List[str]): A list of ...
magic_instruct_75k
30,831
Write a Python function to calculate the sum of all even numbers in a given list of integers. The function should take a list of integers as input and return the sum of all even numbers in the list. The function should be efficient and handle various edge cases, such as an empty list or a list with no even numbers. Th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_even_numbers(arr: List[int]) -> int: """ Calculate the sum of all even numbers in a given list of integers. Args: arr (List[int]): A list of integers from which to calculate the s...
magic_instruct_75k
30,845
Write a Python function to process a list of FBX files in a resource manager module. The function should iterate through the list of FBX files and perform a specified processing step for each file. The processing step is not specified and can be left as a placeholder. The function should start with: ```python from typi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def process_fbx_files(fbx_list: List[str], index: int) -> None: """ Process a list of FBX files by iterating through each file and performing a specified processing step. Args: fbx_list (Lis...
magic_instruct_75k
30,846
Create a Python class `NamedUser` that represents a user on a version control platform like GitHub. The class should have attributes for user type, company, location, contributions, public repositories, and followers. Additionally, implement a method `contribution_ratio` that calculates the user's contribution ratio, d...
Here is the Python code to solve the given problem in the markdown block: ```python class NamedUser: """ Represents a named user on a version control platform like GitHub. Attributes: type (str): The type of the user (e.g., "Developer", "Contributor"). company (str): The company the user is...
magic_instruct_75k
30,849
Write a Python function to count the number of ways to decode a given encoded message string `s` containing digits from '0' to '9'. Each digit can be mapped to a character using the following mapping: - '1' -> 'A' - '2' -> 'B' - ... - '26' -> 'Z' The function should take a string `s` as input and return the total num...
Here is the Python code to solve the given problem in the markdown block: ```python def numDecodings(s: str) -> int: """ Count the number of ways to decode a given encoded message string `s`. Args: s (str): The encoded message string containing digits from '0' to '9'. Returns: int: The...
magic_instruct_75k
30,875
Create a Python function to manage and log messages to different channels, similar to the C++ logging system described. The function should allow for defining new log channels, logging messages to specific channels, and enabling or disabling specific log channels. The code should start with: ```python from typing impor...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def log_message(channel: str, message: str, log_channels: Dict[str, bool]) -> None: """ Logs a message to a specific channel if the channel is enabled. Args: channel (str): The name of...
magic_instruct_75k
30,884
Write a Python function to count the number of digits in a given string. The function should iterate through each character in the string and count how many of them are digits. The function should be named `count_digits` and should start with: ```python def count_digits(s: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def count_digits(s: str) -> int: """ Counts the number of digits in a given string. Args: s (str): The input string to count digits from. Returns: int: The number of digits found in the string. """ ...
magic_instruct_75k
30,889
Write a Python function to generate commands for creating user accounts in a Hadoop environment. Each user account is associated with a specific UID and primary group. The function should take a base UID and a list of Hadoop ecosystem components as input and return a list of strings, where each string represents a comm...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_user_creation_commands(uid_base: int, components: List[str]) -> List[str]: """ Generates commands to create user accounts for Hadoop ecosystem components. Args: uid_base (int): ...
magic_instruct_75k
30,892
Write a Python function to convert a given Unicode string into its corresponding code point values. The function should handle both regular characters and Unicode escape sequences (e.g., `\uXXXX`). The code should start with: ```python def unicode_to_code_points(input_str: str) -> list: ```
Here is the Python code to solve the given problem in the markdown block: ```python def unicode_to_code_points(input_str: str) -> list: """ Converts a given Unicode string into its corresponding code point values. Args: input_str (str): The Unicode string to be converted. Returns: list...
magic_instruct_75k
30,896
Write a Python function to process Wikipedia article titles according to specified transformations. The function should handle various string replacements and optionally retain underscores in the title. The function should start with: ```python import re def process_wiki_title(title: str, is_train: bool = True, keep_u...
Here is the Python code to solve the given problem in the markdown block: ```python import re def process_wiki_title(title: str, is_train: bool = True, keep_underscore: bool = False) -> str: """ Process a Wikipedia article title by performing specified string replacements and optionally retaining underscores. ...
magic_instruct_75k
30,909
Write a Python function to calculate the elastic constants \( C_{11} \), \( C_{12} \), and \( C_{44} \) for a batch of materials based on the given equilibrium lattice parameter \( \text{sws0} \) and bulk modulus \( B_0 \). The function should return the calculated elastic constants as a tuple. The elastic constants c...
Here is the Python code to solve the given problem in the markdown block: ```python def elastic_constants_batch_calculate(sws0: float, B0: float) -> tuple: """ Calculate the elastic constants C11, C12, and C44 for a batch of materials based on the given equilibrium lattice parameter (sws0) and bulk modulus (B0)...
magic_instruct_75k
30,959
Write a Python function to simulate the removal of a specific file named `footer.h2m` from a list of file names. If the file `footer.h2m` is present in the input list, it should be removed, and the updated list of files should be returned. If the file `footer.h2m` is not present, the function should return the original...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def simulate_file_removal(file_list: List[str]) -> List[str]: """ Simulates the removal of the file 'footer.h2m' from a list of file names. Args: file_list (List[str]): A list of strings rep...
magic_instruct_75k
30,963
Write a Python function to simulate a simple audio oscillator that generates a waveform with a random amplitude and frequency for a given duration. The function should return an array of waveform samples representing the oscillator output for the specified duration. The code should start with: ```python import math im...
Here is the Python code to solve the given problem in the markdown block: ```python import math import random from typing import List def generateOscillatorWaveform(duration: float) -> List[float]: """ Generates a waveform for a simple audio oscillator with random amplitude and frequency. Args: du...
magic_instruct_75k
30,972
Write a Python function to construct the output file path and prefix based on the given data type (`dtype`) and model name (`model`). The function should also ensure that the output directory exists, creating it if necessary. The function should return the constructed output file prefix. The code should start with: ``...
Here is the Python code to solve the given problem in the markdown block: ```python import os def construct_output_file_prefix(dtype: str, model: str, output_path: str) -> str: """ Constructs the output file prefix based on the given data type and model name, and ensures that the output directory exists. ...
magic_instruct_75k
30,981
Write a Python function to calculate the overall average of statistical measures from a list of dictionaries. Each dictionary contains keys "min_rank", "max_rank", "avg_rank", "stddev", and "variance", with corresponding values representing statistical measures for a dataset. The function should return a new dictionary...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def calculate_statistical_average(data: List[Dict[str, float]]) -> Dict[str, float]: """ Calculate the overall average of statistical measures from a list of dictionaries. Args: data (...
magic_instruct_75k
31,003
Write a Python function to automate the process of setting up a development environment for a mobile app using the Ionic framework. The function should perform the following tasks: 1. Add the iOS platform to the project using the command `ionic platform add ios`. 2. Generate app icon and splash screen resources using t...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess def setup_ionic_environment(): """ Automates the setup of a development environment for an Ionic mobile app. This function performs the following tasks: 1. Adds the iOS platform to the Ionic project. ...
magic_instruct_75k
31,022
Write a Python function `draw_on_screen` that updates a 2D grid (representing a screen) by setting specified coordinates to corresponding colors. The function should take three parameters: 1. `screen`: A 2D list representing the screen, where each element is a string representing a color. 2. `coordinates`: A list of tu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def draw_on_screen(screen: List[List[str]], coordinates: List[Tuple[int, int]], colors: List[str]) -> List[List[str]]: """ Updates the screen grid by setting the specified coordinates to the corre...
magic_instruct_75k
31,042
Write a Python function to implement a custom linked list data structure. The linked list should support inserting a new node at the end of the list. The function should start with: ```python class ListNode: def __init__(self, data): self.data = data self.next = None class LinkedList: def __ini...
Here is the Python code to solve the given problem in the markdown block: ```python class ListNode: def __init__(self, data): """ Initialize a new ListNode with the given data. Args: data: The value to be stored in the node. """ self.data = data self.next...