source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_instruct_75k
58,671
Write a Python function to relocate a specific directory to a new location within each file path in a given list of file paths. The function should handle the relocation efficiently and return the updated list of file paths. The code should start with: ```python from typing import List def relocate_directory(file_pat...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def relocate_directory(file_paths: List[str], old_dir: str, new_dir: str) -> List[str]: """ Relocates a specific directory to a new location within each file path in a given list of file paths. Args...
magic_instruct_75k
58,701
Write a Python function to simulate a deployment script for a software distribution system. The script should transfer executable files and their associated manifests to multiple servers, and deploy specific files based on platform file masks. The function should perform the following actions: 1. Transfer the `test_sta...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def deploy_software(PLATF_DIR: str, PLATF_SERVERS: List[str], PLATF_NCBI_BIN_DIRS: List[str], PLATF_FILE_MASKS: List[str], EXE: str, CGI_BIN_DIR: str) -> None: """ Simulates a deployment script for...
magic_instruct_75k
58,713
Write a Python function `process_entries` that processes a list of entries from a geographic information system (GIS) database and returns two lists: one containing vector layer entries and another containing vector field entries. Each entry is represented as a dictionary with the keys "layer_id", "name", and "type". T...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Tuple def process_entries(entries: List[Dict[str, str]]) -> Tuple[List[Dict[str, str]], List[Dict[str, str]]]: """ Processes a list of GIS entries and returns two lists: one for vector layer entri...
magic_instruct_75k
58,720
Write a Python function `process_bigwig_names` that processes a list of `bigwig_names` and performs the following operations: 1. Check if all the names in the list are unique. If not, raise a `ValueError` with the message "Duplicate names found in the list". 2. Create a dictionary where the keys are the indices of the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def process_bigwig_names(bigwig_names: List[str]) -> Dict[int, str]: """ Processes a list of bigwig file names and returns a dictionary mapping indices to names. Args: bigwig_names (Li...
magic_instruct_75k
58,743
Write a Python function to calculate the Commodity Channel Index (CCI) signal indicator for a trading platform. The function should determine the buy and sell signals based on the given conditions and return the final signal as an integer. The conditions for buy and sell signals are derived from the logical OR of three...
Here is the Python code to solve the given problem in the markdown block: ```python def signal_cci(cross_up: float, cross_md: float, cross_dn: float) -> int: """ Calculate the Commodity Channel Index (CCI) signal indicator for a trading platform. The function determines the buy and sell signals based on th...
magic_instruct_75k
58,784
Write a Python function that converts a list of tuples into a dictionary. Each tuple in the list contains two elements: the first element is the key, and the second element is the value. The function should return a dictionary where the keys are the first elements of the tuples, and the values are lists of the second e...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Any, Dict def tuple_list_to_dict(input_list: List[Tuple[Any, Any]]) -> Dict[Any, List[Any]]: """ Converts a list of tuples into a dictionary where the keys are the first elements of the tuples ...
magic_instruct_75k
58,806
Write a Python function to convert a given `datetime` object into two different date formats: an HTTP header date format and an AMZ date format. The function should return a dictionary with two key-value pairs: 'http_header' and 'amz_date', where the values are the datetime object converted into the respective formats....
Here is the Python code to solve the given problem in the markdown block: ```python from datetime import datetime def convert_to_date_formats(datetime_obj: datetime) -> dict: """ Converts a given datetime object into two different date formats: HTTP header date format and AMZ date format. Args: da...
magic_instruct_75k
58,808
Write a Python function to calculate the default number of concurrent links based on given parameters. The function should take three input parameters: `per_link_gb`, `reserve_gb`, and `secondary_per_link_gb`. The function should return the calculated default number of concurrent links using the formula: ``` default_co...
Here is the Python code to solve the given problem in the markdown block: ```python def get_default_concurrent_links(per_link_gb: float, reserve_gb: float, secondary_per_link_gb: float) -> float: """ Calculate the default number of concurrent links based on the given parameters. Args: per_link_gb (...
magic_instruct_75k
58,820
Write a Python function to simulate a simple library management system. The system should allow users to add, remove, and display books in the library. Each book has a title, author, and unique identification number. Additionally, the program should be able to search for a book by its title or author. The code should ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional class Book: def __init__(self, title: str, author: str, id: int): """ Initialize a Book object with title, author, and unique id. Args: title (str): The title o...
magic_instruct_75k
58,860
Write a Python script to automate the deployment of a firmware file to a remote embedded system. The script should securely copy the firmware file "ch.bin" from the local "build" directory to the remote system at the address specified by the variable `REMOTE_ADDR` and the username specified by the variable `REMOTE_USER...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess def deploy_firmware(firmware_file: str, remote_user: str, remote_addr: str) -> None: """ Automates the deployment of a firmware file to a remote embedded system. This function securely copies the firmware...
magic_instruct_75k
58,862
Write a Python function to calculate the area of a rectangle given the coordinates of two opposite corners. The function should handle any valid input coordinates and return the correct area. The code should start with: ```python def calculate_rectangle_area(x1: float, y1: float, x2: float, y2: float) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_rectangle_area(x1: float, y1: float, x2: float, y2: float) -> float: """ Calculate the area of a rectangle given the coordinates of two opposite corners. Args: x1 (float): The x-coordinate of the first...
magic_instruct_75k
58,885
Write a Python function to automate the setup process for a software-defined radio (SDR) device by creating a configuration file and adding a specific line to it. The function should simulate the creation of the configuration file and the addition of the line, and it should return the content of the configuration file ...
Here is the Python code to solve the given problem in the markdown block: ```python def setup_sdr_configuration() -> str: """ Simulates the creation of a configuration file for a software-defined radio (SDR) device. This function creates a configuration file named `rtlsdr.conf` and adds the line `black...
magic_instruct_75k
58,906
Write a Python function to process a list of migration operations and extract specific information from each operation. Each operation in the list is represented as a dictionary containing details about a migration operation. The function should extract the model name, field name, field type, and default value for each...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def extract_migration_info(operations: List[Dict]) -> List[Dict]: """ Extracts specific information from a list of migration operations. Args: operations (List[Dict]): A list of dictio...
magic_instruct_75k
58,928
Write a Python function to parse command-line arguments and return a formatted output based on certain conditions. The function should take in the number of command-line arguments and the list of command-line arguments. If the number of arguments is greater than 2, the function should perform specific operations and re...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cmdline(argc: int, argv: List[str]) -> str: """ Parses command-line arguments and returns a formatted output based on certain conditions. Args: argc (int): The number of command-line arg...
magic_instruct_75k
58,931
Write a Python function to calculate the sum of the digits of 2 raised to the power of a given integer `n`. The function should efficiently handle large values of `n`. The code should start with: ```python def sum_of_digits_of_power_of_2(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_digits_of_power_of_2(n: int) -> int: """ Calculate the sum of the digits of 2 raised to the power of a given integer `n`. Args: n (int): The exponent to which 2 is raised. Returns: int: The s...
magic_instruct_75k
58,940
Write a Python function to implement a role-based access control system for a web application. The system should allow users with different roles to access specific parts of the application. The roles are defined as an enum called `Roles`, which includes the following values: `Admin`, `Supplier`, `Customer`, and `Emplo...
Here is the Python code to solve the given problem in the markdown block: ```python from enum import Enum class Roles(Enum): Admin = 1 Supplier = 2 Customer = 3 Employee = 4 def get_permissions_for_role(role: Roles) -> list[str]: """ Returns a list of permissions associated with the given role...
magic_instruct_75k
58,942
Write a Python function to calculate the maximum number of digits in a list of integers. The function should take a list of integers as input and return the maximum number of digits present in any of the integers in the list. For example, if the input list is `[12, 345, 6789, 4]`, the function should return `4`, as `67...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_digits_count(numbers: List[int]) -> int: """ Calculate the maximum number of digits in a list of integers. Args: numbers (List[int]): A list of integers. Returns: int: T...
magic_instruct_75k
58,950
Write a Python function to convert a given chess board index position to its corresponding chess notation. The chess board is represented by an 8x8 grid, and the indices are zero-based, with the top-left corner being (0, 0) and the bottom-right corner being (7, 7). The chess notation uses a combination of a letter and ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def index_to_notation(position: Tuple[int, int]) -> str: """ Converts a given chess board index position to its corresponding chess notation. Args: position (Tuple[int, int]): A tuple repre...
magic_instruct_75k
58,951
Write a Python function to convert network statistics data from a dictionary format into a string format compatible with InfluxDB. The input data is a dictionary `netstat_data` containing statistics for various network parameters. The function `points_to_influx` should iterate through the `netstat_data` and convert the...
Here is the Python code to solve the given problem in the markdown block: ```python def points_to_influx(netstat_data: dict) -> str: """ Converts network statistics data from a dictionary format into a string format compatible with InfluxDB. Args: netstat_data (dict): A dictionary containing networ...
magic_instruct_75k
58,954
Write a Python function to calculate the average number of datapoints for each classifier and experiment combination from a list of result rows. Each result row contains the following information in order: classifier name, result quality (RQ), experiment ID, iteration, number of datapoints, and number of features. The ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def average_datapoints_per_experiment(result_rows: List[List[any]]) -> Dict[tuple, float]: """ Calculate the average number of datapoints for each classifier and experiment combination. Args: ...
magic_instruct_75k
58,958
Write a Python function to calculate the sum of five given integer variables. The function should take five separate integer arguments and return their sum. The code should start with: ```python def calculate_sum(T__1: int, T__2: int, T__3: int, T__4: int, T__5: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_sum(T__1: int, T__2: int, T__3: int, T__4: int, T__5: int) -> int: """ Calculate the sum of five given integer variables. Args: T__1 (int): The first integer value. T__2 (int): The second integ...
magic_instruct_75k
58,960
Write a Python function to find the longest common directory path shared by all the given file paths. Each file path consists of a list of directories separated by slashes ("/"). If there is no common directory path, the function should return an empty string. The code should start with: ```python from typing import L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def longest_common_directory_path(paths: List[str]) -> str: """ Find the longest common directory path shared by all the given file paths. Args: paths (List[str]): A list of file paths, each...
magic_instruct_75k
58,966
Write a Python function `check_winner(board)` that takes a 3x3 list representing a Tic-Tac-Toe game board as input and returns a boolean value indicating whether there is a winner or not. Additionally, handle the scenario where the game ends in a draw (i.e., no winner). The function should return `True` if there is a w...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def check_winner(board: List[List[str]]) -> bool: """ Check if there is a winner in a Tic-Tac-Toe game represented by a 3x3 board. Args: board (List[List[str]]): A 3x3 list representing the ...
magic_instruct_75k
58,986
Write a Python function to find and return the unique amino acids present in a given list of amino acids represented by their one-letter codes. The function should take a list of amino acids as input and return a list of unique amino acids in the same order of their first appearance in the input list. The code should ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_unique_amino_acids(amino_acids: List[str]) -> List[str]: """ Finds and returns the unique amino acids present in the given list, preserving the order of their first appearance. Args: ...
magic_instruct_75k
58,990
Write a Python function to filter a list of items based on a specific condition and perform certain actions based on the filtered items. The function should take in a list of items and a filtering condition as input and return the filtered list. Additionally, it should perform the following actions: - If any items are ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Callable def filter_and_update(items: List, condition: Callable) -> List: """ Filter the list of items based on the given condition and perform specific actions. Args: items (list): The lis...
magic_instruct_75k
58,992
Write a Python function to manage the download and update process of artifacts. The function should check for the existence of a folder and a file, and take appropriate actions based on their presence. The function should follow the logic outlined in the provided code snippet. Given the following parameters: - `artifa...
Here is the Python code to solve the given problem in the markdown block: ```python import os def manage_artifacts(artifact_folder: str, artifact_file: str) -> None: """ Manages the download and update process of artifacts by checking for the existence of a folder and a file. Args: artifact_folder...
magic_instruct_75k
58,997
Write a Python function to debug and fix a test case that checks the content type of a response in a web application framework. The test case is designed to ensure that the content type of the response is 'image/gif', but it currently fails due to an incorrect assertion. The function should identify the issue and corre...
Here is the Python code to solve the given problem in the markdown block: ```python def fix_test_case(headers: dict, default_mimetype: str, env: dict) -> str: """ Debugs and fixes a test case that checks the content type of a response in a web application framework. Args: headers (dict): A dictiona...
magic_instruct_75k
59,011
Implement a simple observer pattern in Python using the provided code snippet as a starting point. The code snippet includes the definition of a `MutableProperty` class and the declaration of three properties: `userSessionEndedProperty`, `userSessionStartedProperty`, and `viewDidLoadProperty`. Additionally, there are t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Callable, Dict class MutableProperty: def __init__(self, value=None): self._value = value self._observers = [] @property def value(self): return self._value @value.setter ...
magic_instruct_75k
59,014
Write a Python function to convert an array of vehicle information into a dictionary. Each element in the array is a list containing two integers: the first integer represents the vehicle's ID, and the second integer represents the device ID. The function should return a dictionary where the vehicle ID is the key and t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def create_vehicle_dictionary(vehicles_info_array: List[List[int]]) -> Dict[int, int]: """ Converts an array of vehicle information into a dictionary. Args: vehicles_info_array (List[L...
magic_instruct_75k
59,027
Write a Python function to determine if a given Spatial Reference ID (SRID) uses the meter unit for measuring distances. The function should take an integer `srid` as input and return `True` if the SRID uses the meter unit, and `False` otherwise. The function should be able to handle various SRID values commonly encoun...
Here is the Python code to solve the given problem in the markdown block: ```python def check_srid_has_meter_unit(srid: int) -> bool: """ Determines if the given Spatial Reference ID (SRID) uses the meter unit for measuring distances. Args: srid (int): The Spatial Reference ID to check. Return...
magic_instruct_75k
59,039
Write a Python function to calculate the frequency of each unique element in a given list and return the result as a dictionary. The function should take in a list of elements and return a dictionary where the keys are the unique elements from the input list and the values are the frequencies of those elements in the i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def calculate_frequency(input_list: List[int]) -> Dict[int, int]: """ Calculate the frequency of each unique element in the given list. Args: input_list (List[int]): The list of elemen...
magic_instruct_75k
59,042
Write a Python function to manage a user list database by adding new users to a file and storing their information in an array. The function should append the username to a file named "user-list.db" with each username separated by a new line character and push the username into an array named `data` to keep track of al...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List data: List[str] = [] def addUser(username: str) -> None: """ Adds a new user to the user list database. This function appends the given username to a file named "user-list.db" and also stores t...
magic_instruct_75k
59,064
Create a Python function to determine the minimum number of operations required to transform a given string into another string by performing insertions, deletions, and substitutions. The function should use dynamic programming to efficiently compute the minimum edit distance. The code should start with: ```python fro...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def min_edit_distance(source: str, target: str) -> int: """ Calculate the minimum number of operations (insertions, deletions, substitutions) required to transform the source string into the target s...
magic_instruct_75k
59,077
Write a Python function to simulate a division operation without using the division operator. The function `spam(divideBy)` takes an integer `divideBy` as input and should return a list of integers that are the result of dividing 42 by the input integer using subtraction only. If the input integer is 0, the function sh...
Here is the Python code to solve the given problem in the markdown block: ```python def spam(divideBy: int) -> list[int] | str: """ Simulates a division operation of 42 by the input integer using subtraction only. Args: divideBy (int): The integer to divide 42 by. Returns: list[int] | ...
magic_instruct_75k
59,080
Write a Python function to calculate the amount of water that can be trapped between walls represented by a list of integers. Each integer in the list represents the height of a wall. The function should return the total amount of water that can be trapped between the walls. The code should start with: ```python from ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def trapped_water(walls: List[int]) -> int: """ Calculate the amount of water that can be trapped between walls. Args: walls (List[int]): A list of integers representing the heights of the w...
magic_instruct_75k
59,101
Write a Python function to generate post-build steps for deprovisioning remote hosts. The function should take a list of remote host names and return a list of tasks, where each task is a dictionary containing the title, command, and output format for deprovisioning a single remote host. The function should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def generate_deprovision_tasks(remote_hosts: List[str]) -> List[Dict[str, str]]: """ Generates post-build steps for deprovisioning remote hosts. Args: remote_hosts (List[str]): A list ...
magic_instruct_75k
59,114
Write a Python function to simulate a system reboot notification. The function should check if a reboot is needed based on a boolean variable and display a message accordingly. The function should return the message as a string. The code should start with: ```python def system_reboot_notification(reboot_needed: bool) ...
Here is the Python code to solve the given problem in the markdown block: ```python def system_reboot_notification(reboot_needed: bool) -> str: """ Simulates a system reboot notification based on whether a reboot is needed. Args: reboot_needed (bool): A boolean indicating whether a reboot is requir...
magic_instruct_75k
59,125
Write a Python function to extract date and time information from a list of file paths and return a sorted list of tuples containing the date and time information. Each file path is in the format '/home/nww/ASICAP/tmp/ASICAP_YYYY-MM-DD_HH_MM_SS_MS.SER', where YYYY-MM-DD represents the date, HH_MM_SS represents the time...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import re def extract_date_time(file_paths: List[str]) -> List[Tuple[int, int, int, int, int, int, int]]: """ Extracts date and time information from a list of file paths and returns a sorted list...
magic_instruct_75k
59,130
Write a Python function to simulate a simplified version of a database migration system. The function should take a list of migration operations and execute them in the specified order. Each migration operation is represented as a dictionary with 'code' and 'reverse_code' keys, where the values are functions to be exec...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Callable def execute_migrations(operations: List[Dict[str, Callable]]) -> bool: """ Simulates a simplified version of a database migration system. Executes a list of migration operations in t...
magic_instruct_75k
59,164
Write a Python function to parse a configuration file that maps PHP packages to their associated directories. The configuration file follows a specific format where each line consists of the package name followed by its associated directories. The directories are separated by spaces. Additionally, some directories may ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List import re def parse_package_directories(config_file: str) -> Dict[str, List[str]]: """ Parses a configuration file that maps PHP packages to their associated directories. Args: config_...
magic_instruct_75k
59,169
Write a Python function to validate a coupon form based on specific criteria. The function should take a dictionary as input and return a boolean value indicating whether the form is valid or not. The dictionary will contain a key-value pair representing a coupon code. The key will always be 'code', and the value will ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def validate_coupon_form(data: Dict[str, str]) -> bool: """ Validates a coupon form based on specific criteria. Args: data (Dict[str, str]): A dictionary containing a key 'code' with a strin...
magic_instruct_75k
59,176
Write a Python function to find the maximum sum of any contiguous subarray within a given list of integers. The function should be named `max_subarray_sum` and should take a single parameter: `arr`, a list of integers. The function should return an integer representing the maximum sum of any contiguous subarray within ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_subarray_sum(arr: List[int]) -> int: """ Find the maximum sum of any contiguous subarray within the given list of integers. Args: arr (List[int]): A list of integers from which to fi...
magic_instruct_75k
59,193
Implement a Python function to retrieve a flag indicating whether a single loop should be used for generating a suite of OperatorInfos. The function should be part of a context handler class and should raise a `ValueError` if the context handle is `None`. The function should return the flag value if the context handle ...
Here is the Python code to solve the given problem in the markdown block: ```python class ContextHandler: def __init__(self, context_handle): self._context_handle = context_handle def get_dp_algo_single_loop(self): """ Get the flag of whether or not generating a single suite of Operator...
magic_instruct_75k
59,196
Write a Python function to count the number of unique years present in a list of dates. Each date in the list is represented as a string in the format "MM/DD/YYYY". The function should ignore duplicate years and only consider unique years present in the list. The code should start with: ```python from typing import Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_unique_years(dateList: List[str]) -> int: """ Counts the number of unique years present in a list of dates. Args: dateList (List[str]): A list of date strings, each in the format "...
magic_instruct_75k
59,210
Write a Python function to process a list of user names and output the number of users and their names in a specific format. The function should take a space-separated string of user names as input and transform it into a comma-separated string. Then, it should return a formatted string displaying the total number of u...
Here is the Python code to solve the given problem in the markdown block: ```python def process_user_names(user_names: str) -> str: """ Processes a space-separated list of user names and returns a formatted string. Args: user_names (str): A space-separated string of user names. Returns: ...
magic_instruct_75k
59,215
Write a Python function to calculate the `ccs_marker_lower` value based on the given `scan_lower` value and the `ccs_marker_each` interval. The `ccs_marker_lower` value is obtained by rounding the `scan_lower` value to the nearest multiple of `ccs_marker_each`. The function should start with: ```python def calculate_c...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_ccs_marker_lower(scan_lower: int, ccs_marker_each: int) -> int: """ Calculate the ccs_marker_lower value by rounding the scan_lower value to the nearest multiple of ccs_marker_each. Args: scan_lower (i...
magic_instruct_75k
59,232
Write a Python function to extract information about the fields being added to a specific model from a list of Django migration files. Each migration file is represented as a string containing Python code. The function should extract the model name, field name, and field type for each field being added to the specified...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import re def extract_migration_fields(migration_files: List[str], model_name: str) -> List[Tuple[str, str, str]]: """ Extracts information about the fields being added to a specific model from a ...
magic_instruct_75k
59,247
Create a Python function to simulate a simple event notification system. The system should allow observers to subscribe to specific events and receive notifications when those events occur. The system should also support unsubscribing from events. The code should start with: ```python from typing import List, Callable ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Callable class SceneNotify: OPEN_HOME = "OPEN_HOME" CLOSE_HOME = "CLOSE_HOME" class SceneObserver: def __init__(self, name: str): self.name = name def notify(self, event: str): ...
magic_instruct_75k
59,256
Write a Python function to calculate the sum of all even numbers in a given list of integers. The function must adhere to the following constraints: 1. It should not use any conditional statements (if, else). 2. It should not use any loops (for, while). 3. It should use only Python's built-in higher-order functions and...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List from functools import reduce def sum_even_numbers(numbers: List[int]) -> int: """ Calculate the sum of all even numbers in the given list of integers. Args: numbers (List[int]): A list of in...
magic_instruct_75k
59,261
Write a Python function to calculate the difference between two lists of integers. The function should take two lists as input and return a new list containing the differences between the elements at the corresponding indices. If the lists are of different lengths, the function should consider the shorter list as if it...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_difference(list1: List[int], list2: List[int]) -> List[int]: """ Calculate the difference between two lists of integers. The function takes two lists as input and returns a new list co...
magic_instruct_75k
59,301
Write a Python function to manage the `/etc/hosts` file on a Linux system. The function should check if a specific line already exists in the file and add it if it does not. The function should handle this task efficiently and provide appropriate feedback to the user. The function should start with: ```python def mana...
Here is the Python code to solve the given problem in the markdown block: ```python def manage_hosts_file(hostline: str) -> None: """ Manages the /etc/hosts file by checking if a specific line exists and adding it if it does not. Args: hostline (str): The line to be checked and added to the /etc/ho...
magic_instruct_75k
59,303
Write a Python function to simulate the progression of the "Jouer" game through a given number of generations. The game is based on a grid of cells, each of which can be in one of two states: alive (1) or dead (0). The state of each cell in a generation is determined by the state of its neighboring cells in the previou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def jouer(grid: List[List[int]], generations: int) -> List[List[int]]: """ Simulate the progression of the "Jouer" game through a given number of generations. Args: grid (List[List[int]]): A...
magic_instruct_75k
59,346
Write a Python function to perform a binary search on a sorted array of distinct integers to find a target value. If the target value is found in the array, return its index; otherwise, return -1. The function should use the binary search algorithm, which involves dividing the array into halves and narrowing down the s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def binary_search(nums: List[int], target: int) -> int: """ Perform a binary search on a sorted array to find the target value. Args: nums (List[int]): A sorted list of distinct integers. ...
magic_instruct_75k
59,372
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 integers representing the daily stock prices. If it is not possible to make any profit, return 0. The function should start with: ```python from typing import List def max_profit(pr...
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
59,394
Write a Python function to parse a list of software packages and their version numbers in the format `package_name:version`. Each package may have multiple versions listed. The function should return a dictionary where the keys are the package names and the values are lists of corresponding version numbers. The code s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def parse_packages(packages: List[str]) -> Dict[str, List[str]]: """ Parses a list of software packages and their version numbers in the format `package_name:version`. Returns a dictionary wher...
magic_instruct_75k
59,397
Write a Python function to update a configuration dictionary based on a list of parameter-value pairs. The configuration dictionary is represented as a dictionary where keys are parameter names and values are the corresponding parameter values. The list of parameter-value pairs to update is provided as a list of tuples...
Here is the Python code to solve the given problem in the markdown block: ```python def update_config(config: dict, update_params: list) -> dict: """ Updates a configuration dictionary based on a list of parameter-value pairs. Args: config (dict): The original configuration dictionary. upda...
magic_instruct_75k
59,402
Create a Python class `Library` that manages data for a library system. The class should have the following methods: 1. `data`: Returns a dictionary containing information about the books available in the library. Each book is represented by a dictionary with keys "title", "author", and "genre". 2. `add_book`: Takes in...
Here is the Python code to solve the given problem in the markdown block: ```python class Library: def __init__(self): self.books = [] def data(self): """ Returns a dictionary containing information about the books available in the library. Each book is represented by a dictiona...
magic_instruct_75k
59,431
Write a Python function to generate a development tag for a given Docker image name. The development tag is created by appending `":dev"` to the original image name. If the input image name is empty or `None`, the function should return `"Invalid image name"`. The function should start with: ```python def get_dev_tag(...
Here is the Python code to solve the given problem in the markdown block: ```python def get_dev_tag(image_name: str) -> str: """ Generates a development tag for a given Docker image name. Args: image_name (str): The original Docker image name. Returns: str: The development tag for the ...
magic_instruct_75k
59,451
Write a Python function to automate the installation of dependencies for a PHP project using Composer. The function should navigate to the project directory and execute the `composer install` command to install all the required packages. The function should handle potential errors and provide appropriate feedback to th...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess import os def install_composer_dependencies(clone_dir: str) -> None: """ Automates the installation of Composer dependencies for a PHP project. Args: clone_dir (str): The path to the project direc...
magic_instruct_75k
59,457
Write a Python function to calculate the total volume of liquid in a set of bottles given an array of integers representing the labels on the bottles. Each label is a positive integer indicating the volume of the corresponding bottle. The labels on the bottles are not necessarily in ascending order, and some labels may...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_total_volume(labels: List[int]) -> int: """ Calculate the total volume of liquid in the bottles given an array of integers representing the labels on the bottles. Args: labels ...
magic_instruct_75k
59,476
Create a Python function to manage and sort file paths based on their likelihood. The function should take a list of tuples, where each tuple contains a file path (string) and its associated likelihood (float). The function should return a sorted list of file paths based on their likelihood, limited by a specified limi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def get_sorted_paths(paths: List[Tuple[str, float]], limit: int) -> List[str]: """ Returns a sorted list of file paths based on their likelihood, limited by the specified limit. Args: ...
magic_instruct_75k
59,482
Write a Python function to identify and return a list of keys that are not present in a given configuration dictionary. The function should take in a list of keys and the current configuration dictionary as input and return the list of keys that are not found in the configuration dictionary. The code should start with...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def find_missing_keys(keys: List[str], curr_config: Dict[str, any]) -> List[str]: """ Identify and return a list of keys that are not present in the given configuration dictionary. Args: ...
magic_instruct_75k
59,547
Write a Python function to determine whether a given string is a palindrome. A palindrome is a sequence of characters that reads the same forward and backward, disregarding spaces, punctuation, and capitalization. The function should take a string as input and return `True` if the string is a palindrome, and `False` ot...
Here is the Python code to solve the given problem in the markdown block: ```python def is_palindrome(s: str) -> bool: """ Determine whether a given string is a palindrome. A palindrome is a sequence of characters that reads the same forward and backward, disregarding spaces, punctuation, and capitaliz...
magic_instruct_75k
59,563
Write a Python function to rotate a given list of integers to the right by a specified number of steps. The function should handle cases where the number of steps is greater than the length of the list by taking the modulo of the steps with the length of the list. The function should start with: ```python from typing i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def rotate_list(l: List[int], n: int) -> List[int]: """ Rotates the given list of integers to the right by `n` steps. Args: l (List[int]): The list of integers to be rotated. n (int)...
magic_instruct_75k
59,591
Write a Python function to filter a dictionary of module names and their corresponding file paths based on a specified prefix. The function should return a new dictionary containing only the module names that start with the given prefix. If no module names match the prefix, the function should return an empty dictionar...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def filter_modules_by_prefix(module_dict: Dict[str, str], prefix: str) -> Dict[str, str]: """ Filters a dictionary of module names and their corresponding file paths based on a specified prefix. Arg...
magic_instruct_75k
59,593
Write a Python function to determine the number of candles that are tallest in a given array of integers representing the heights of candles. The function should take in the array of candle heights and return the count of the tallest candles. The code should start with: ```python from typing import List def count_tal...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_tallest_candles(candles: List[int]) -> int: """ Counts the number of candles that are tallest in a given array of integers. Args: candles (List[int]): An array of integers represen...
magic_instruct_75k
59,600
Write a Python function to filter out specified fields from different types of data records based on a given dictionary of ignored fields. The function should take in a dictionary `IGNORE` and a list of data records, and return the filtered records with the specified fields removed. The `IGNORE` dictionary contains th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def filter_ignored_fields(IGNORE: Dict[str, List[str]], data_records: List[Dict[str, str]]) -> List[Dict[str, str]]: """ Filters out specified fields from different types of data records based on a...
magic_instruct_75k
59,603
Implement a custom data structure called `CustomStack` in Python. The `CustomStack` should have the following functionalities: 1. `push`: Add an element to the top of the stack. 2. `pop`: Remove and return the top element from the stack. 3. `peek`: Return the top element of the stack without removing it. 4. `is_empty`:...
Here is the Python code to solve the given problem in the markdown block: ```python class CustomStack: def __init__(self): """ Initialize an empty stack. """ self.elements = [] def push(self, element: int) -> None: """ Add an element to the top of the stack. ...
magic_instruct_75k
59,604
Write a Python function to sort a list of authors based on their last update date in ascending order. Each author is represented as a dictionary with keys `"name"` and `"update_date"`. The `"update_date"` values are in the format "Month. Year" (e.g., "May. 2020"). The function should return a new list of authors sorted...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict from datetime import datetime def sort_authors_by_update_date(authors: List[Dict[str, str]]) -> List[Dict[str, str]]: """ Sorts a list of authors based on their last update date in ascending order....
magic_instruct_75k
59,609
Write a Python function to extract the file type from each file name in a given dictionary and store the information in a new dictionary. The file type is defined as the characters following the last period (.) in the file name. If a file name does not contain a period, the file type should be considered as "unknown". ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def extract_file_types(file_dict: Dict[str, str]) -> Dict[str, str]: """ Extracts the file type from each file name in the given dictionary and returns a new dictionary with the file names as keys an...
magic_instruct_75k
59,635
Create a Python class `NamespaceManager` that manages namespaces and identifiers within them. The class should support the following operations: 1. `add_identifier(namespace_name, identifier)`: Add an identifier to the specified namespace. 2. `get_identifier(namespace_name, identifier)`: Retrieve an identifier from the...
Here is the Python code to solve the given problem in the markdown block: ```python class NamespaceManager: def __init__(self): """ Initialize the NamespaceManager with an empty dictionary to store namespaces. """ self.namespaces = {} def add_identifier(self, namespace_name: str...
magic_instruct_75k
59,675
Write a Python function `parse_urlpatterns` that simulates a URL routing system similar to Django's URL patterns. The function should take a list of URL patterns and return a dictionary mapping the URL patterns to their corresponding view functions. Each URL pattern consists of a path, a view function, and a name. The ...
Here is the Python code to solve the given problem in the markdown block: ```python def parse_urlpatterns(urlpatterns): """ Parses a list of URL patterns into a dictionary mapping URL patterns to their corresponding view functions. Args: urlpatterns (list): A list of tuples where each tuple contain...
magic_instruct_75k
59,680
Write a Python function to parse and process a BOOTP (Bootstrap Protocol) packet. The function should take a raw BOOTP packet as input and extract relevant information such as the client's IP address, server's IP address, and other configuration parameters. If an exception occurs during the parsing process, the functio...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any # Mock logging function for demonstration purposes def log_debug(level: int, message: str) -> None: """ Mock logging function to log messages. Args: level (int): The log level. ...
magic_instruct_75k
59,700
Write a Python function to find the index where a target value should be inserted into a sorted list of integers to maintain the sorted order. If the target value is already present in the list, the function should return the index of the leftmost occurrence of the target value. The function should use the `bisect` mod...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import bisect def binary_search_insert_index(arr: List[int], target: int) -> int: """ Find the index where the target value should be inserted into a sorted list of integers to maintain the sorted order....
magic_instruct_75k
59,702
Write a Python function to generate a unique file name for saving a model's optimizer state based on the given model name and accuracy. The function should take in the model name, accuracy, and the directory path where the file will be saved. The file name should follow a specific format and include the model name, acc...
Here is the Python code to solve the given problem in the markdown block: ```python import os def generate_optimizer_file_name(model_name: str, accuracy: float, model_dir: str) -> str: """ Generates a unique file name for saving a model's optimizer state based on the given model name and accuracy. Args: ...
magic_instruct_75k
59,705
Write a Python function to process a dictionary containing information about user-agent strings and return a modified dictionary based on specific requirements. The function should update the "Value" key in the dictionary according to the following rules: 1. If the "Required" key is set to `True`, the "Value" key shoul...
Here is the Python code to solve the given problem in the markdown block: ```python def process_user_agent(input_dict: dict) -> dict: """ Processes a dictionary containing information about user-agent strings and returns a modified dictionary. The function updates the "Value" key in the dictionary based on...
magic_instruct_75k
59,724
Write a Python function to remove extra arguments from a query argument map based on a given set of argument names. The query argument map is a dictionary where the keys are strings representing the argument names and the values are strings representing the argument values. The function should remove any key-value pair...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Set def remove_extra_arguments(query_args: Dict[str, str], set_name: Set[str]) -> None: """ Removes any extra arguments from the query argument map based on the given set of argument names. Args: ...
magic_instruct_75k
59,730
Write a Python function `apply_rules` that takes a list of integers as input and applies the following rules to modify two variables `rule1` and `rule2`: 1. For each positive integer in the input list, increment `rule1` by the value of the integer. 2. For each negative integer in the input list, decrement `rule2` by th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def apply_rules(input_list: List[int]) -> Tuple[int, int]: """ Applies specific rules to a list of integers and returns the modified values of `rule1` and `rule2`. Args: input_list (L...
magic_instruct_75k
59,734
Write a Python function to construct a valid API endpoint URL for retrieving weather forecast data. The function should take in the following parameters: - `api_host`: A string representing the base URL of the API host. - `city`: A string representing the name of the city for which the weather forecast is requested. - ...
Here is the Python code to solve the given problem in the markdown block: ```python def construct_api_url(api_host: str, city: str, country: str, units: str, api_key: str) -> str: """ Constructs a valid API endpoint URL for retrieving weather forecast data. Args: api_host (str): The base URL of the...
magic_instruct_75k
59,736
Write a Python function to compile a list of instructions into machine code. Each instruction is represented as a string and consists of an operation followed by operands. The operations supported are "ADD", "SUB", "MUL", and "DIV", and the operands are integers. The function should concatenate all instructions into a ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def compile_instructions(instructions: List[str]) -> str: """ Compiles a list of instructions into machine code. Args: instructions (List[str]): A list of instruction strings, where each ins...
magic_instruct_75k
59,743
Write a Python function to sanitize and validate a deployment name for a Java client. The function should ensure that the deployment name adheres to the following rules: 1. The name should not contain any special characters or spaces. 2. The name should be at least 3 characters long. 3. If the name is not provided or d...
Here is the Python code to solve the given problem in the markdown block: ```python import re def validate_deployment_name(name: str) -> str: """ Validates and sanitizes a deployment name for a Java client. Args: name (str): The deployment name to be validated and sanitized. Returns: ...
magic_instruct_75k
59,744
Write a Python function to find all unique pairs of integers from a given set that sum up to a specified target value. Each pair should be represented as a tuple and the pairs should be sorted in ascending order. If there are no such pairs, the function should return an empty list. The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_pairs_with_sum(nums: List[int], target: int) -> List[Tuple[int, int]]: """ Find all unique pairs of integers from a given list that sum up to a specified target value. Args: ...
magic_instruct_75k
59,753
Write a Python function to retrieve the allowed actions for a given role within a specified organization and application. The function should simulate the retrieval of allowed actions based on the input parameters. The function signature should be: ```python def get_allowed_actions(role_id: str, organization_id: str, ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_allowed_actions(role_id: str, organization_id: str, application_id: str) -> List[str]: """ Retrieves the allowed actions for a given role within a specified organization and application. Arg...
magic_instruct_75k
59,757
Write a Python function to generate an HTML caption for an audio segment based on the provided `segmentMeta` dictionary. The `segmentMeta` dictionary contains the following keys: - `"finalAudioFilename"`: a string representing the filename of the audio segment. - `"segmentStartUTC"`: a `datetime` object representing th...
Here is the Python code to solve the given problem in the markdown block: ```python import datetime def generate_caption(segmentMeta: dict) -> str: """ Generates an HTML caption for an audio segment based on the provided segmentMeta dictionary. Args: segmentMeta (dict): A dictionary containing the...
magic_instruct_75k
59,768
Write a Python function to manage a virtual register system. The function should allow initializing a set of virtual registers, retrieving a pointer to the virtual registers array, retrieving the total number of virtual registers, and selecting a specific register for modification. Ensure that the selected register ind...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional class VirtualRegs: def __init__(self, num_regs: int): """ Initialize the virtual registers with a specified number of registers. Args: num_regs (int): The numbe...
magic_instruct_75k
59,796
Write a Python function to calculate the synthetic aperture duration for a given desired azimuth resolution using satellite orbit data. The function should take the desired azimuth resolution in meters, an orbit object, and a time `t` as inputs, and return the synthetic aperture duration in seconds. The orbit object ha...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def calculate_synthetic_aperture_duration(azimuth_resolution: float, orbit, t: float) -> float: """ Calculate the synthetic aperture duration for a given desired azimuth resolution using satellite orbit data....
magic_instruct_75k
59,801
Write a Python function to calculate the width of a shape based on its normal width and a depth multiplier. The width is calculated by multiplying the normal width by the depth multiplier and then converting the result to an integer. The function should handle both positive and negative values for the normal width and ...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_width(normal_width: int, depth_multiplier: float) -> int: """ Calculate the width of a shape based on its normal width and a depth multiplier. Args: normal_width (int): The normal width of the shape. ...
magic_instruct_75k
59,845
Write a Python function to monitor the resolution of ARP (Address Resolution Protocol) for a given IPv4 gateway using the Snappi API. The function should take the maximum number of attempts for timeout and the interval in seconds for polling as parameters. The function should return the number of attempts made to resol...
Here is the Python code to solve the given problem in the markdown block: ```python import time def monitor_arp_resolution(snappi_api, max_attempts: int, poll_interval_sec: int) -> int or str: """ Monitors the ARP resolution for a given IPv4 gateway using the Snappi API. Args: snappi_api: An insta...
magic_instruct_75k
59,846
Implement a Python class `ResourceBundleSourceMap` that manages resources from a given resource bundle. The class should have the following functionalities: 1. Store the provided resource bundle. 2. Provide a method to retrieve a specific resource from the resource bundle based on a given key. 3. Ensure efficient resou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, Dict class ResourceBundleSourceMap: """ A class to manage resources from a given resource bundle. Attributes: resource_bundle (Dict[str, Any]): A dictionary containing resources with keys as...
magic_instruct_75k
59,886
Create a Python function to simulate a Markov Decision Process (MDP) state transition. The function should take a current state, an action, and a transition probability matrix, and return the next state based on the given action and probabilities. The transition probability matrix is a 2D list where each element `trans...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def mdp_state_transition(current_state: int, action: int, transition_probabilities: List[List[float]]) -> int: """ Simulate a Markov Decision Process (MDP) state transition based on the giv...
magic_instruct_75k
59,901
Write a Python function to simulate the behavior of a queue after a series of operations. The function should take an initial queue and a list of operations, where each operation is a tuple specifying the type of operation ('append' or 'pop') and the value to be appended or popped (if applicable). The function should r...
Here is the Python code to solve the given problem in the markdown block: ```python from collections import deque from typing import List, Tuple def simulate_queue_operations(initial_queue: List[int], operations: List[Tuple[str, int]]) -> List[int]: """ Simulate the behavior of a queue after performing a serie...
magic_instruct_75k
59,905
Create a Python class `Trip` that represents a trip and its status. The class should have the following methods: 1. A constructor that initializes the trip status to 'is_active' by default. 2. A method named `update_status` that takes a new status as a parameter and updates the trip status if the new status is valid. 3...
Here is the Python code to solve the given problem in the markdown block: ```python class Trip: """ A class representing a trip and its status. Attributes: TRIP_STATUS (tuple): A tuple of valid trip statuses. status (str): The current status of the trip. Methods: __init__(): In...
magic_instruct_75k
59,906
Write a Python function to determine the compliance of a list of software licenses with the Apache License, Version 2.0. The function should take a list of license strings as input and return two lists: one containing the compliant licenses and the other containing the non-compliant licenses. A license is considered co...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import re def check_compliance(licenses: List[str]) -> Tuple[List[str], List[str]]: """ Determines the compliance of a list of software licenses with the Apache License, Version 2.0. Args: ...
magic_instruct_75k
59,915
Write a Python function to calculate the total price of items in a shopping cart. The function should take a dictionary `cart_items` as input and return the total price of all items in the cart, considering the quantity of each item. The `cart_items` dictionary contains the following key: - `CTX_CART_ITEMS`: A list of...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def calculate_total_price(cart_items: Dict) -> float: """ Calculate the total price of all items in the shopping cart. Args: cart_items (Dict): A dictionary containing the cart items. The di...
magic_instruct_75k
59,918
Write a Python function to generate HTML code for rendering a checkbox item. The function `render_item` should take two parameters: `caption`, a string representing the label for the checkbox, and `checked`, a boolean indicating whether the checkbox should be initially checked. The function should return a string conta...
Here is the Python code to solve the given problem in the markdown block: ```python def render_item(caption: str, checked: bool) -> str: """ Generates HTML code for rendering a checkbox item. Args: caption (str): The label for the checkbox. checked (bool): Indicates whether the checkbox sho...
magic_instruct_75k
59,953
Write a Python function to analyze a hand of cards and determine the type of poker hand it represents, along with the highest card in the hand. The hand of cards is represented by two lists: `color_all` containing the colors of the cards and `size_all` containing the sizes of the cards. The colors are represented by st...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def analyze_poker_hand(color_all: List[str], size_all: List[int]) -> Tuple[str, int]: """ Analyzes a hand of cards to determine the type of poker hand and the highest card in the hand. Args: ...
magic_instruct_75k
59,955
Write a Python function to determine whether a given positive integer `n` is a prime number. The function should return `True` if the input number `n` is a prime number, and `False` otherwise. A prime number is a positive integer greater than 1 that has no positive divisors other than 1 and itself. The function should ...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_prime(n: int) -> bool: """ Determine whether a given positive integer `n` is a prime number. Args: n (int): The positive integer to check for primality. Returns: bool: True if `n` is...
magic_instruct_75k
59,957
Write a Python function to process a list of convolutional and pooling layers represented as dictionaries. Each dictionary contains information about the layer's type, input channels, output channels, kernel size, stride, and padding. The function should return the total number of convolutional layers, the total number...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Tuple def process_layers(layers: List[Dict[str, int]]) -> Tuple[int, int, int]: """ Processes a list of convolutional and pooling layers to return the total number of convolutional layers, the...
magic_instruct_75k
59,974
Write a Python function to summarize the total income for each form of income from a list of income records. The income records are provided as a list of tuples, where each tuple contains the following fields: `id`, `data_receita`, `amount`, and `forma_receita`. The `forma_receita` field is an integer that corresponds ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def income_summary(income_records: List[Tuple[int, str, int, int]]) -> Dict[str, int]: """ Summarizes the total income for each form of income from a list of income records. Args: ...
magic_instruct_75k
59,988
Write a Python function to filter a list of integers and return a new list containing only the elements that are less than or equal to a given target value. The function should handle edge cases such as an empty input list or a target value that is smaller than any element in the list. The code should start with: ```py...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_elements_by_target(input_list: List[int], target: int) -> List[int]: """ Filters a list of integers and returns a new list containing only the elements that are less than or equal to a giv...