source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_instruct_75k | 32,408 | Write a Python class `BankAccount` that simulates a simple banking system. The class should be able to create and manage bank accounts, allowing for deposits, withdrawals, and balance inquiries. Each bank account should have a unique account number, and the system should be able to handle multiple accounts.
The class ... | Here is the Python code to solve the given problem in the markdown block:
```python
class BankAccount:
"""
A class to simulate a simple banking system.
Attributes:
total_accounts (int): A static variable to keep track of the total number of bank accounts created.
account_number (int): A uni... |
magic_instruct_75k | 32,411 | Write a Python function to initialize multiple databases concurrently using the `concurrent.futures` module. The databases to be initialized are Cassandra, MongoDB, and Couchbase. Each database has its own initialization function: `init_cassandra`, `init_mongo`, and `init_couchbase` respectively. Your function should e... | Here is the Python code to solve the given problem in the markdown block:
```python
from concurrent.futures import ThreadPoolExecutor
from typing import List
def init_cassandra() -> None:
"""Simulates the initialization of Cassandra database."""
print("Initializing Cassandra...")
# Simulate initialization ... |
magic_instruct_75k | 32,414 | Write a Python function to calculate the value of a variable `cleared` after `n` iterations of a loop, where `cleared` is incremented by 1 in each iteration. The function should take an integer `n` as input and return the final value of `cleared`. Assume that `cleared` is initially set to 0 before the loop starts.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_cleared_value(n: int) -> int:
"""
Calculate the value of `cleared` after `n` iterations of a loop, where `cleared` is incremented by 1 in each iteration.
Args:
n (int): The number of iterations to perf... |
magic_instruct_75k | 32,419 | Write a Python function to calculate the orientation of a geological feature given its strike and dip angles. The function should normalize the strike angle to be within the range [0, 360) degrees and return the orientation in the format "Axis_str_dip(strike, dip)".
The code should start with:
```python
def calculate_... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_orientation(strike: float, dip: float) -> str:
"""
Calculate the orientation of a geological feature based on the provided strike and dip angles.
Args:
strike (float): The strike angle of the geologica... |
magic_instruct_75k | 32,420 | Write a Python function to calculate the time difference between the acquisition time and the injection time for a medical procedure. The function should handle cases where the acquisition time is earlier than the injection time by adjusting the time difference accordingly. The function should return the time differenc... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculateTimeDifference(acquisitionHour: int, acquisitionMinute: int, injectionHour: int, injectionMinute: int) -> str:
"""
Calculate the time difference between the acquisition time and the injection time.
Args:
... |
magic_instruct_75k | 32,426 | Write a Python function to implement a simple factory pattern to create instances of different Lua objects. The Lua objects are defined by a base class `LuaObject` and two derived classes `LuaNumber` and `LuaString`. Your goal is to create a `LuaFactory` class that can produce instances of these Lua objects based on th... | Here is the Python code to solve the given problem in the markdown block:
```python
class LuaObject:
def printType(self):
raise NotImplementedError("Subclasses should implement this method")
class LuaNumber(LuaObject):
def printType(self):
print("LuaNumber")
class LuaString(LuaObject):
def... |
magic_instruct_75k | 32,433 | Write a Python function to count the number of users and staff members in a fictional company's database. The function should take two lists as input: one containing user objects and the other containing staff objects. The function should return a dictionary with the count of users and staff members. The keys of the di... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def get_user_staff_count(user_model: List, staff_model: List) -> Dict[str, int]:
"""
Counts the number of users and staff members in the given lists.
Args:
user_model (List): A list of... |
magic_instruct_75k | 32,465 | Create a Python class `LoginSystem` that simulates a login system interacting with an API service, a mailer, a tracking server, and Google authentication. The class should have the following methods:
1. `authenticate_user_with_google(user_token: str) -> bool`: Authenticates a user using Google authentication.
2. `send_... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
class MockApiService:
def request(self, endpoint: str, data: dict) -> dict:
# Simulate API request
return {"status": "success", "data": data}
class MailerMock:
def send_email(self, ... |
magic_instruct_75k | 32,466 | Write a Python function `generate_macros(gl, wgl, glX)` that takes three input lists `gl`, `wgl`, and `glX`, and returns a string containing the macro definitions as output. Each list contains sublists, where each sublist represents a function and its return type. The return type is stored as the first element of the s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_macros(gl: List[List[str]], wgl: List[List[str]], glX: List[List[str]]) -> str:
"""
Generates macro definitions for the given lists of function return types.
Args:
gl (List[List... |
magic_instruct_75k | 32,486 | Write a Python function to parse a job submission record and extract relevant information. Each record is a string containing various directives and metadata related to a job submission on a high-performance computing (HPC) cluster. The directives include the number of GitHub stars for the project, the job name, resour... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
from typing import Dict
def parse_job_submission(record: str) -> Dict[str, any]:
"""
Parses a job submission record and extracts relevant information.
Args:
record (str): The job submission record contain... |
magic_instruct_75k | 32,487 | Write a Python function to process a list of import statements and return a dictionary containing the imported modules and their corresponding classes or functions. Each import statement follows the format `from <module> import (<class1>, <class2>, ...)`. If a module is imported multiple times, the function should merg... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Set
def process_imports(import_statements: List[str]) -> Dict[str, Set[str]]:
"""
Processes a list of import statements and returns a dictionary containing the imported modules and their correspon... |
magic_instruct_75k | 32,497 | Write a Python function to convert an RGB color represented as an array-like object into its corresponding hexadecimal color code. The RGB color is represented as an array-like object with three elements, each representing the intensity of red, green, and blue, respectively. The function should take the RGB array as in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def rgb_to_hex(rgb: List[int]) -> str:
"""
Converts an RGB color represented as a list of three integers into its corresponding hexadecimal color code.
Args:
rgb (List[int]): A list of three... |
magic_instruct_75k | 32,523 | Write a Python function to count the occurrences of each main data type in a given list of data. The function should handle both exact matches and subtypes of the data types defined in the `MAIN_DATA_TYPES` dictionary. The function should return a dictionary where the keys are the names of the data types and the values... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union, Dict
MAIN_DATA_TYPES = {
'int': int,
'float': float,
'str': str,
'list': list,
'dict': dict,
'tuple': tuple,
'set': set,
}
def count_data_types(data_list: List[Union[int, flo... |
magic_instruct_75k | 32,525 | Write a Python function to determine if a given string representing a pattern of braces, brackets, and parentheses is valid. The pattern is considered valid if every opening brace, bracket, or parenthesis has a corresponding closing one in the correct order.
The function should start with:
```python
def is_valid_patte... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_valid_pattern(pattern: str) -> bool:
"""
Determines if the given pattern of braces, brackets, and parentheses is valid.
Args:
pattern (str): The string representing the pattern to be validated.
Returns:
... |
magic_instruct_75k | 32,538 | Write a Python function to find the maximum sum of a contiguous subarray within a given list of integers. The function should efficiently compute the maximum sum using an optimal algorithm.
The code should start with:
```python
from typing import List
def max_subarray_sum(arr: List[int]) -> int:
```
| 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 a contiguous subarray within the given list of integers.
Args:
arr (List[int]): The list of integers from which to fi... |
magic_instruct_75k | 32,556 | Create a Python class `MessageService` that allows sending and receiving messages between users. The class should have the following methods:
1. `send_message(sender: str, receiver: str, message: str)`: This method should take the sender's name, receiver's name, and the message content as input and store the message in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
class MessageService:
def __init__(self):
"""
Initialize the MessageService with an empty list to store messages.
"""
self.messages = []
def send_message(self, sender: st... |
magic_instruct_75k | 32,561 | Write a Python function to generate a routing configuration for an Angular web application that manages a library of books. The function should take a list of dictionaries representing the existing routes and a list of dictionaries representing the new routes to be added. The function should return the complete routing... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def generate_routing_config(existing_routes: List[Dict[str, str]], new_routes: List[Dict[str, str]]) -> List[Dict[str, str]]:
"""
Generates a complete routing configuration for an Angular web appli... |
magic_instruct_75k | 32,574 | Write a Python function to process a list of transactions and calculate the final account balance. Each transaction is represented as a dictionary with keys 'type' and 'amount'. The 'type' can be either 'deposit' or 'withdrawal', and the 'amount' is a positive integer. The function should iterate through the list of tr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def process_transactions(transactions: List[Dict[str, int]]) -> int:
"""
Process a list of transactions and return the final account balance.
Args:
transactions (List[Dict[str, int]]):... |
magic_instruct_75k | 32,593 | Write a Python function to complete the GUI layout setup for a simple image editing application using a grid system. The function should position the background color picker (`bg_button`), the image picker (`pick_bg`), and the swap button (`swap`) in the appropriate positions within the grid. The grid layout should be ... | Here is the Python code to solve the given problem in the markdown block:
```python
def setup_gui_layout(grid, bg_button, pick_bg, swap):
"""
Sets up the GUI layout for a simple image editing application using a grid system.
Args:
grid: The grid object used to organize the placement of GUI elements... |
magic_instruct_75k | 32,609 | 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 of a company. If it is not possible to make any profit, return 0.
The code should start with:
```python
from typing import List
def max_... | 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 | 32,616 | Write a Python function to validate variable names according to a specific set of rules. The function should take a string as input and return `True` if the string is a valid variable name, and `False` otherwise.
A valid variable name must adhere to the following rules:
1. It can only contain alphanumeric characters a... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_variable_name(name: str) -> bool:
"""
Validate whether a given string is a valid variable name according to specified rules.
Args:
name (str): The string to be validated as a variable name.
... |
magic_instruct_75k | 32,646 | Create a Python class `ContentManager` that represents a simple content management system. The class should include methods for adding new content, retrieving content based on a specified content type, and counting the total number of content items in the system. The class should be implemented as follows:
1. **Constr... | Here is the Python code to solve the given problem in the markdown block:
```python
class ContentManager:
def __init__(self):
"""
Initializes an empty dictionary to store content.
"""
self.content_dict = {}
def add_content(self, content_type, content):
"""
Add ne... |
magic_instruct_75k | 32,663 | Write a Python function to process a dictionary containing model training and testing settings. The function should perform the following tasks:
1. Add a new key-value pair to the dictionary for training settings.
2. Modify the value associated with the 'mode' key in the testing settings.
The function signature is:
``... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_settings(settings: dict) -> dict:
"""
Processes a dictionary containing model training and testing settings.
Args:
settings (dict): A dictionary containing 'train_cfg' and 'test_cfg' keys.
Returns:
... |
magic_instruct_75k | 32,676 | Write a Python function to parse network speed test output and extract the ping time, download speed, and upload speed. The network speed test output is a string containing the ping time, download speed, and upload speed in various formats. The ping time is in milliseconds (ms), and the download and upload speeds are i... | Here is the Python code to solve the given problem in the markdown block:
```python
def parse_output(output: str) -> tuple:
"""
Parses the network speed test output and extracts the ping time, download speed, and upload speed.
Args:
output (str): The network speed test output string.
Returns:
... |
magic_instruct_75k | 32,704 | Write a Python function to perform vector addition for 3D vectors. The function should take two 3D vectors as input and return the resulting vector after adding them together. Each vector is represented as a tuple of three elements, where each element corresponds to the x, y, and z components of the vector.
The code s... | Here is the Python code to solve the given problem in the markdown block:
```python
def add_3d_vectors(vector1: tuple, vector2: tuple) -> tuple:
"""
Perform vector addition for two 3D vectors.
Args:
vector1 (tuple): A tuple of three integers representing the first 3D vector.
vector2 (tuple)... |
magic_instruct_75k | 32,706 | Write a Python function to process a list of database migration operations and extract relevant information from it. The migration operations are represented as a list of tuples, where each tuple contains the name of the app, the migration number, and the specific operation being performed. The operations can include c... | 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[tuple]) -> Dict[str, any]:
"""
Extracts relevant information from a list of database migration operations.
Args:
operations (list): A list o... |
magic_instruct_75k | 32,747 | Create a Python function to generate a histogram visualization based on the input data. The function should take a list of integers as input and return a list of tuples representing the histogram bars, where each tuple contains the value and its frequency. The function should also handle edge cases such as empty input ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
from collections import Counter
def generate_histogram(data: List[int]) -> List[Tuple[int, int]]:
"""
Generates a histogram visualization based on the input data.
Args:
data (List[int... |
magic_instruct_75k | 32,749 | Write a Python function to classify a chess board position by material using one-hot encoding. The chess board is represented as a 1D numpy array where each element corresponds to a piece on the board. Each piece is assigned a unique numerical value based on its type and color. The function should return a dictionary w... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
from typing import Dict, List
def classify_position_by_material(board: np.array) -> Dict[int, List[int]]:
"""
Classify a chess board position by material using one-hot encoding.
Args:
board (np.a... |
magic_instruct_75k | 32,770 | Write a Python function to automate the process of creating multiple directories and files within them. The function should take a list of directory names as input and for each directory, create the directory itself and then create three files within it named "file1.txt", "file2.txt", and "file3.txt". After creating th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import os
def create_directories_and_files(directory_names: List[str]) -> None:
"""
Automates the process of creating multiple directories and files within them.
Args:
directory_names (List[... |
magic_instruct_75k | 32,772 | Write a Python function to compare two version strings and determine their relative order. The function should return:
- `1` if the first version is greater than the second version.
- `-1` if the first version is less than the second version.
- `0` if both versions are equal.
A version string is a series of non-negati... | Here is the Python code to solve the given problem in the markdown block:
```python
def compare_versions(version1: str, version2: str) -> int:
"""
Compare two version strings and return their relative order.
Args:
version1 (str): The first version string.
version2 (str): The second version ... |
magic_instruct_75k | 32,782 | Write a Python function to start a reminder notification based on the configuration setting and the application state. The function should take two parameters: a boolean indicating whether reminder notifications should be displayed, and an enumeration representing the current state of the application. The function shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from enum import Enum
class ConnectedState(Enum):
Connected = 1
Disconnected = 2
def StartReminderNotification(show_reminder_notification: bool, new_state: ConnectedState) -> None:
"""
Starts the reminder notification ... |
magic_instruct_75k | 32,790 | Write a Python function to merge two sets and return the result. The function should handle sets of any size and ensure that the resulting set contains only unique elements. The code should start with:
```python
def merge_sets(set1: set, set2: set) -> set:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def merge_sets(set1: set, set2: set) -> set:
"""
Merges two sets and returns the result. The resulting set contains only unique elements.
Args:
set1 (set): The first set to merge.
set2 (set): The second set ... |
magic_instruct_75k | 32,794 | Write a Python function to simulate a device driver management system. The system has two main operations: adding a new driver and updating an existing driver. The drivers are managed using the `/usr/sbin/add_drv` and `/usr/sbin/update_drv` commands. The drivers are associated with a specific device list, denoted by th... | Here is the Python code to solve the given problem in the markdown block:
```python
def manage_driver(existing: bool, DEVLIST2: str) -> str:
"""
Simulate a device driver management system by constructing and returning the appropriate command.
Args:
existing (bool): A boolean indicating whether the ... |
magic_instruct_75k | 32,835 | Create a Python class `LogEntry` to represent a log entry with the following properties:
- `EntryTime`: a `datetime` object representing the timestamp of the log entry.
- `EntryType`: an enumeration representing the type of log entry (e.g., Information, Warning, Error).
- `Message`: a string representing the log messag... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
from enum import Enum
from typing import List
class EntryType(Enum):
"""
Enum representing the type of log entry.
"""
INFORMATION = 1
WARNING = 2
ERROR = 3
class LogEntry:
"""
... |
magic_instruct_75k | 32,841 | Write a Python function to calculate the area of a rectangle given the coordinates of its bottom-left and top-right corners. The rectangle is aligned with the x and y axes, and its sides are parallel to these axes. The function should take four integer parameters: `x1`, `y1`, `x2`, and `y2`, representing the coordinate... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculateRectangleArea(x1: int, y1: int, x2: int, y2: int) -> int:
"""
Calculate the area of a rectangle given the coordinates of its bottom-left and top-right corners.
Args:
x1 (int): The x-coordinate of the bo... |
magic_instruct_75k | 32,852 | Write a Python function to update a histogram data structure with accuracy values for a given generation. The histogram data is represented as a dictionary where keys are generation numbers and values are lists of accuracy values for each generation. The function should add the accuracy values for the current generatio... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Union
def add_accuracy_to_histogram(histogram_data: Dict[int, List[float]], generation: int, accs: List[float]) -> Dict[int, List[float]]:
"""
Updates the histogram data with accuracy values for a... |
magic_instruct_75k | 32,878 | Write a Python function to map a given string representing a marital status to its corresponding code. The function should return the code as an integer based on the following mapping:
- "SOLTEIRO" should be mapped to 1
- "CASADO" should be mapped to 2
- "DIVORCIADO" should be mapped to 3
- "VIUVO" should be mapped to ... | Here is the Python code to solve the given problem in the markdown block:
```python
def mapMaritalStatus(status: str) -> int:
"""
Maps a given string representing a marital status to its corresponding code.
Args:
status (str): The marital status string to be mapped.
Returns:
int: The c... |
magic_instruct_75k | 32,914 | Write a Python function to generate a list of possible domain names by appending each country code top-level domain (TLD) to a given base domain name. The function should take a string representing the base domain name and a dictionary containing the available TLD options categorized by type. The dictionary has the fol... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_domain_possibilities(domain: str, tld_options: dict) -> list:
"""
Generate a list of possible domain names by appending each country code TLD to the given base domain name.
Args:
domain (str): The base ... |
magic_instruct_75k | 32,917 | Write a Python function to remove specific keys from a given dictionary based on predefined criteria. The function should take a dictionary `param_dict` as input and remove the keys with specific values from it. The keys to be removed are:
- `'nographics'`
- `'save_every'`
- `'print_every'`
- `'verbose'`
- `'quiet'`
- ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def remove_specific_keys(param_dict: Dict[str, any]) -> Dict[str, any]:
"""
Removes specific keys from the given dictionary based on predefined criteria.
Args:
param_dict (Dict[str, any]): T... |
magic_instruct_75k | 32,920 | Write a Python function to perform the following tasks on a list of elements:
1. Print the third element of the list.
2. Print all elements of the list.
The code should start with:
```python
from typing import List
def process_list(elements: List[str]) -> None:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_list(elements: List[str]) -> None:
"""
Processes a list of elements by printing the third element and all elements.
Args:
elements (List[str]): The list of elements to process.
... |
magic_instruct_75k | 32,941 | Write a Python function to process a dictionary containing student scores and return a modified dictionary with the scores sorted in descending order for each student. The original dictionary should not be modified, and the modified dictionary should be returned.
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 sort_student_scores(scores_dict: Dict[str, List[int]]) -> Dict[str, List[int]]:
"""
Processes a dictionary containing student scores and returns a modified dictionary
with the scores sorted... |
magic_instruct_75k | 32,958 | Write a Python function to automate the configuration of Redis server instances on a Linux system. The function should read a list of Redis configuration files from a specified directory and start a Redis server for each configuration file. Additionally, the function should set the maximum number of pending connections... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
import subprocess
from typing import List
def configure_redis_servers(config_dir: str) -> None:
"""
Automates the configuration and startup of Redis server instances on a Linux system.
Args:
config_dir (s... |
magic_instruct_75k | 32,987 | Write a Python function to simulate a database migration process. The function should take a list of alteration operations and apply them to a database schema. Each alteration operation is represented as a dictionary with specific keys. The function should return the final database schema after applying all the operati... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union, Any
def apply_migration(operations: List[Dict[str, Union[str, Dict[str, Union[str, Any]]]]]) -> Dict[str, Any]:
"""
Simulates a database migration process by applying a list of alteration o... |
magic_instruct_75k | 33,014 | Write a Python function to group attribute names by their corresponding model names from a list of dictionaries. Each dictionary contains the keys "model_name" and "name", where "model_name" represents the name of the model and "name" represents the name of an attribute associated with that model. The function should r... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def group_attributes_by_model(models: List[Dict[str, str]]) -> Dict[str, List[str]]:
"""
Groups attribute names by their corresponding model names from a list of dictionaries.
Args:
mo... |
magic_instruct_75k | 33,026 | Write a Python function to categorize a list of software licenses based on their type. Each license is represented as a string, and the function should identify whether the license is an open-source initiative (OSI) approved license, a proprietary license, or an unknown license. The function should return a dictionary ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def categorize_licenses(licenses: List[str]) -> Dict[str, List[str]]:
"""
Categorizes a list of software licenses based on their type.
Args:
licenses (List[str]): A list of strings whe... |
magic_instruct_75k | 33,032 | Write a Python function to match a requested URL against a list of URL patterns and return the corresponding template name based on the first matching pattern. The URL patterns are represented as a list of tuples, where each tuple contains a regular expression pattern and the corresponding template name. If no matching... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Optional
import re
def match_url_pattern(url_patterns: List[Tuple[str, str]], requested_url: str) -> Optional[str]:
"""
Matches a requested URL against a list of URL patterns and returns the corr... |
magic_instruct_75k | 33,038 | Write a Python function to calculate the expanded padding for a given input padding. The expanded padding is a tuple of two integers, where the first integer is the ceiling of the division of the second element of the input padding by 2, and the second integer is the floor of the division of the second element of the i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
import math
def calculate_expanded_padding(padding: Tuple[int, int]) -> Tuple[int, int]:
"""
Calculate the expanded padding for a given input padding.
The expanded padding is a tuple of two integer... |
magic_instruct_75k | 33,062 | Write a Python function `construct_file_paths` that constructs the file paths for different dataset files based on the input parameters and configuration settings. The function should take in the name of the BEIR dataset and the name of the datasets directory, and it should return a dictionary containing the file paths... | Here is the Python code to solve the given problem in the markdown block:
```python
def construct_file_paths(beir_dataset: str, datasets_directory: str, round_num: int, stage_num: int) -> dict:
"""
Constructs the file paths for different dataset files based on the input parameters and configuration settings.
... |
magic_instruct_75k | 33,077 | Write a Python function to map a given order submit status code to its corresponding status description. The function should handle cases where an unknown status code is provided by returning "Unknown status code". The status codes and their descriptions are as follows:
- `ORDER_SUBMIT_STATUS_MODIFY` = '2'
- `ORDER_SUB... | Here is the Python code to solve the given problem in the markdown block:
```python
def get_order_status_description(status_code: str) -> str:
"""
Maps a given order submit status code to its corresponding status description.
Args:
status_code (str): The status code to be mapped.
Returns:
... |
magic_instruct_75k | 33,084 | Write a Python function to count the number of resolving and unresolving URIs from a given list of URI statuses. Each URI status is represented as a tuple containing a URI and its status code. The function should return a tuple containing the counts of resolving and unresolving URIs.
The code should start with:
```pyt... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def count_uri_statuses(vocab_uri_statuses: List[Tuple[str, int]]) -> Tuple[int, int]:
"""
Counts the number of resolving and unresolving URIs from a given list of URI statuses.
Args:
... |
magic_instruct_75k | 33,086 | Write a Python function to perform a depth-first search (DFS) traversal on a graph represented by an adjacency list. The function should return the order in which the nodes are discovered during the DFS traversal starting from a given node.
The code should start with:
```python
from typing import List
def dfs_travers... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def dfs_traversal(start_node: int, graph: List[List[int]]) -> List[int]:
"""
Perform a depth-first search (DFS) traversal on a graph starting from a given node.
Args:
start_node (int): The s... |
magic_instruct_75k | 33,090 | Write a Python function to process a dictionary of package data and return a modified version of the dictionary. The input dictionary contains various package data, and your function needs to modify the dictionary by setting the "include_package_data" key to False if it exists, and adding the key-value pair "author: 'Y... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def process_package_data(input_dict: Dict[str, any]) -> Dict[str, any]:
"""
Processes a dictionary of package data and returns a modified version of the dictionary.
Args:
input_dict (Dict[st... |
magic_instruct_75k | 33,111 | Write a Python function to manage a string table that associates unique integer IDs with string literals. The function should allow setting a string literal for a given ID and retrieving the string literal using its ID. The function should be efficient in both setting and retrieving operations.
The code should start w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Optional
def set_litstr(litstr_table: Dict[int, str], id: int, ret: str) -> None:
"""
Associate a given ID with a string literal in the string table.
Args:
litstr_table (Dict[int, str]): Th... |
magic_instruct_75k | 33,118 | Write a Python function to count the occurrences of each unique permission in a given list of permission strings. Each permission string is in the format "operation_modelname", where "operation" is the type of operation (e.g., "view", "add", "change", "delete") and "modelname" is the name of the model (e.g., "user", "g... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_permissions(permissions: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of each unique permission in a given list of permission strings.
Args:
permissions (List[str... |
magic_instruct_75k | 33,142 | Write a Python function to process an array of integers and return a new array containing the squares of each integer incremented by 1. The function should be optimized for performance and capable of handling large input arrays efficiently. The code should start with:
```python
from typing import List
def find_squares... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_squares_opt(array: List[int]) -> List[int]:
"""
Process an array of integers and return a new array containing the squares of each integer incremented by 1.
Args:
array (List[int]):... |
magic_instruct_75k | 33,151 | Write a Python function to process texture coordinates for a 2D image. The function should take in the minimum and maximum UV coordinates as tuples and return a list containing the UV coordinates in a specific format. The UV coordinates are represented as (x, y) where x and y are floating-point numbers. The function sh... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_texture_coordinates(uv_min: tuple, uv_max: tuple) -> list:
"""
Processes texture coordinates for a 2D image by extracting the x and y components
from the minimum and maximum UV coordinates and returning them in a... |
magic_instruct_75k | 33,180 | Write a Python function to generate a user-agent string for a web browser. The user-agent string should follow the format commonly used by web browsers to identify themselves to web servers. The function should take in a parameter `browser_version` representing the version number of the browser, and it should return a ... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_user_agent(browser_version: int) -> str:
"""
Generates a user-agent string for a web browser based on the given browser version.
The user-agent string follows the format:
"Mozilla/5.0 (platform; security_de... |
magic_instruct_75k | 33,189 | Write a Python function to reverse the order of words in a given message while maintaining the order of characters within each word. A word is defined as a sequence of non-space characters. The function should handle messages of varying lengths, including empty strings.
The code should start with:
```python
def revers... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_words(msg: str) -> str:
"""
Reverses the order of words in a given message while maintaining the order of characters within each word.
Args:
msg (str): The input message containing words to be reversed.
... |
magic_instruct_75k | 33,190 | Write a Python function to compute the sum of all positive integers in a given list. If the input list is empty or does not contain any positive integers, the function should return 0. The function should start with:
```python
from typing import List
def sum_positive_integers(nums: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_positive_integers(nums: List[int]) -> int:
"""
Computes the sum of all positive integers in the given list.
Args:
nums (List[int]): A list of integers.
Returns:
int: The... |
magic_instruct_75k | 33,202 | Write a Python script that parses the output of the command `dui-image/bin/java --list-modules` and extracts the module names that contain the word "client" in their names. The script should then print the count of such modules and their names. The script should start with:
```python
def extract_client_modules(module_l... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_client_modules(module_list: str) -> None:
"""
Extracts and prints the count and names of Java modules that contain the word "client".
Args:
module_list (str): The output of the command `dui-image/bin/jav... |
magic_instruct_75k | 33,212 | Create a Python class `Game` that simulates a simple game between two players. The game involves players moving on a one-dimensional board and scoring points based on their positions. Implement the following methods for the `Game` class:
1. `move_player_one(distance)`: A method that takes an integer `distance` as input... | Here is the Python code to solve the given problem in the markdown block:
```python
class Game:
def __init__(self, player_one_position, player_two_position, max_score, player_one_score, player_two_score):
"""
Initialize the Game class with player positions, maximum score, and initial scores.
... |
magic_instruct_75k | 33,252 | Write a Python function to find the index of the first occurrence of a specific value in a given list of integers. If the value is not found in the list, the function should return -1. The function should be named `find_first_occurrence` and should start with:
```python
from typing import List
def find_first_occurrenc... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_first_occurrence(lst: List[int], value: int) -> int:
"""
Find the index of the first occurrence of a specific value in a list of integers.
Args:
lst (List[int]): The list of integer... |
magic_instruct_75k | 33,271 | Write a Python function to calculate the aliquot sum of a given number. The aliquot sum is defined as the sum of all proper divisors of the number (excluding the number itself). The function should be named `_aliquot` and should take an integer as input and return an integer representing the aliquot sum.
The starter c... | Here is the Python code to solve the given problem in the markdown block:
```python
def _aliquot(number: int) -> int:
"""
Calculate the aliquot sum of a given number.
The aliquot sum is the sum of all proper divisors of the number (excluding the number itself).
Args:
number (int): The number f... |
magic_instruct_75k | 33,296 | Write a Python function `apply_functions` that takes a dictionary `mapping` and a string `input_string` as input. The dictionary `mapping` maps characters to lists of functions. Each character in the `input_string` should have the corresponding functions applied to it in the order they appear in the list. The function ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Callable
def apply_functions(mapping: Dict[str, List[Callable[[], str]]], input_string: str) -> str:
"""
Applies the corresponding functions to each character in the input string based on the prov... |
magic_instruct_75k | 33,303 | Write a Python function `is_hexagon(num)` that determines if a given integer `num` is a hexagonal number. A hexagonal number is a figurate number that extends the concept of triangular and pentagonal numbers to the hexagon. The formula for the nth hexagonal number is given by \( H_n = n(2n - 1) \).
The function should... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_hexagon(num: int) -> bool:
"""
Determines if a given number is a hexagonal number.
A hexagonal number is a figurate number that extends the concept of triangular and pentagonal numbers to the hexagon.
The formula... |
magic_instruct_75k | 33,304 | Write a Python function to generate a setup configuration string for a given project. The function should take a project name and a list of required packages as input and return a string that represents the setup configuration. The setup configuration string should include a `REQUIRES` list containing the required pack... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_setup_config(project_name: str, required_packages: List[str]) -> str:
"""
Generates a setup configuration string for a given project.
Args:
project_name (str): The name of the p... |
magic_instruct_75k | 33,312 | Write a Python function to compare two version strings in the format "x.y.z" where x, y, and z are non-negative integers. The function should return whether the current version is equal to, greater than, or less than the target version.
The code should start with:
```python
def compare_versions(current_version: str, t... | Here is the Python code to solve the given problem in the markdown block:
```python
def compare_versions(current_version: str, target_version: str) -> str:
"""
Compare two version strings in the format "x.y.z" and return whether the current version is equal to,
greater than, or less than the target version.... |
magic_instruct_75k | 33,318 | Write a Python function to generate a list of HTML elements based on a given set of data. The function should take in a list of most active items and return a string containing HTML elements representing each item. Each HTML element should be in the format:
```html
<div class="most-active-item">{item_name}</div>
```
Wh... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_most_active_html(all_most_active: List[str]) -> str:
"""
Generates a string containing HTML elements representing each most active item.
Args:
all_most_active (List[str]): A lis... |
magic_instruct_75k | 33,322 | Write a Python function to simulate a simple dice game where two six-sided dice are rolled, and the sum of the two dice rolls is calculated and displayed. The function should generate random numbers between 1 and 6 to simulate the rolls of the dice, calculate the sum of the two rolls, and return a string that displays ... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
def simulate_dice_game() -> str:
"""
Simulates a simple dice game where two six-sided dice are rolled, and the sum of the two dice rolls is calculated and displayed.
Returns:
str: A string displaying ... |
magic_instruct_75k | 33,369 | Write a Python function to sample patches from a given grayscale image. The function should take as input the image, the size of the patches, and the number of patches to be sampled. The function should return a list of sampled patches, where each patch is represented as a 2D 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
import random
def sample_patches(image: List[List[int]], patch_size: int, n_patches: int) -> List[List[List[int]]]:
"""
Sample patches from a given grayscale image.
Args:
image (List[List[in... |
magic_instruct_75k | 33,374 | Write a Python function `unpack_products` that takes a list of products as input and returns the first four items unpacked into individual variables as a tuple. If the list contains fewer than four items, the function should return `None` for the missing variables.
The function signature should be:
```python
from typi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def unpack_products(products: List[str]) -> Tuple[str, str, str, str]:
"""
Unpacks the first four items from a list of products into individual variables.
If the list contains fewer than four ... |
magic_instruct_75k | 33,402 | Write a Python function to calculate the sum of all even Fibonacci numbers up to a given limit. The Fibonacci sequence starts with 0 and 1, and each subsequent number is the sum of the two preceding ones. The function should take an integer `limit` as input and return the sum of all even Fibonacci numbers that are less... | Here is the Python code to solve the given problem in the markdown block:
```python
def even_fibonacci_sum(limit: int) -> int:
"""
Calculate the sum of all even Fibonacci numbers up to a given limit.
Args:
limit (int): The upper limit for the Fibonacci numbers to be considered.
Returns:
... |
magic_instruct_75k | 33,416 | Write a Python function to simulate a simple UDP server that can receive and process incoming UDP datagrams. The server should perform the following steps:
1. Create a UDP socket for communication.
2. Set the socket options to allow reusing the address and port.
3. Bind the socket to a specific port and address.
4. Rec... | Here is the Python code to solve the given problem in the markdown block:
```python
import socket
def udp_server(host: str, port: int):
"""
Simulate a simple UDP server that receives and processes incoming UDP datagrams.
Args:
host (str): The host address to bind the server to.
port (int):... |
magic_instruct_75k | 33,420 | Write a Python function `apply_operation` that takes an array of integers `input_array` and a string `operation` representing a mathematical operation. The function should return a new array where each element is the result of applying the specified operation to the corresponding element in the `input_array`. The opera... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def apply_operation(input_array: List[int], operation: str) -> List[int]:
"""
Applies a specified mathematical operation to each element of the input array.
Args:
input_array (List[int]): Th... |
magic_instruct_75k | 33,495 | Write a Python function to count the occurrences of unique tags that start with the prefix "project:" from a given list of tags. The function should return a dictionary where the keys are the unique project tags (without the "project:" prefix) and the values are the count of each tag. Tags that do not start with the pr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_project_tags(tags: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of unique project tags from a list of tags.
Args:
tags (List[str]): A list of tags where each tag ... |
magic_instruct_75k | 33,499 | Write a Python function to format a date string in a specific way. The function should take a date string in the format "YYYY-MM-DD" and return a formatted date string in the format "Month Day, Year". The month should be the full name of the month, the day should be the ordinal number with the appropriate suffix (e.g.,... | Here is the Python code to solve the given problem in the markdown block:
```python
def formatDate(date: str) -> str:
"""
Formats a date string from "YYYY-MM-DD" to "Month Day, Year".
Args:
date (str): A date string in the format "YYYY-MM-DD".
Returns:
str: A formatted date string in t... |
magic_instruct_75k | 33,509 | Implement a simple calendar system in Python that allows users to add, remove, and view events for specific dates. Each event will have a title and a description. The program should provide the ability to view all events for a specific date. Complete the implementation of the `Event` and `Calendar` classes by adding ne... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
class Event:
def __init__(self, title: str, description: str):
"""
Initialize an Event object with a title and a description.
Args:
title (str): The title of the ev... |
magic_instruct_75k | 33,555 | Write a Python function to validate registration numbers for a fictional company, H20PRO. The registration number must follow a specific format:
- It starts with the prefix "H20PRO-" followed by a 3-digit number.
- The 3-digit number must be between 001 and 999, inclusive.
The function should return `True` if the inpu... | Here is the Python code to solve the given problem in the markdown block:
```python
def validateRegistrationNumber(registrationNumber: str) -> bool:
"""
Validates if the given registration number follows the specified format for H20PRO.
The format is as follows:
- Starts with the prefix "H20PRO-" follo... |
magic_instruct_75k | 33,563 | Write a Python function to automate the compilation and packaging of C# source code files located in the current directory. The function should perform the following steps:
1. Compile all the C# source code files in the current directory into executable files using the C# compiler (`csc`).
2. Package the compiled execu... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
import subprocess
import zipfile
from typing import List
def compile_and_package_cs_files() -> None:
"""
Automates the compilation and packaging of C# source code files located in the current directory.
Steps:
... |
magic_instruct_75k | 33,568 | Write a Python function to implement the main loop of a reinforcement learning agent that interacts with a game environment. The agent should use a given model to predict actions based on observations received from the environment. The loop should continue until a termination condition is met, and the environment shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
def reinforcement_learning_agent(model, env):
"""
Implements the main loop of a reinforcement learning agent that interacts with a game environment.
Args:
model: An instance of the reinforcement learning model that ... |
magic_instruct_75k | 33,594 | Write a Python function to determine the required scopes for accessing different resources and operations in an API. The function should take in the resource name and operation, and return the expected scopes for accessing that resource and operation. The function should adhere to the following rules:
- If the resource... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def get_expected_scopes(resource: str, operation: str) -> List[Dict[str, List[str]]]:
"""
Determine the required scopes for accessing a specific resource and operation in an API.
Args:
... |
magic_instruct_75k | 33,598 | Write a Python function to aggregate markers from a given list and determine actions based on the aggregated data. The function should return a dictionary of the markers with their counts, an updated list of unique markers, and a dictionary specifying the action to be performed for each marker. The action should be det... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Tuple
def process_markers(marker_list: List[str]) -> Tuple[Dict[str, int], List[str], Dict[str, str]]:
"""
Aggregates markers from a given list and determines actions based on the aggregated data.... |
magic_instruct_75k | 33,605 | Create a Python function to find the longest common subsequence (LCS) between two given strings. The function should return the length of the LCS.
The code should start with:
```python
def longest_common_subsequence(str1: str, str2: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def longest_common_subsequence(str1: str, str2: str) -> int:
"""
Calculate the length of the longest common subsequence (LCS) between two strings.
Args:
str1 (str): The first string.
str2 (str): The second s... |
magic_instruct_75k | 33,614 | Write a Bash script to automate the process of pulling data from a remote server using rsync. The script should continuously attempt to pull data from the specified server, exclude any files with the ".md" extension, and use a password file for authentication. The script should adhere to the following requirements:
1. ... | Here is the Python code to solve the given problem in the markdown block:
```bash
#!/bin/bash
USERNAME="your_username"
SERVER="remote_server"
PORT="remote_port"
PASSWORD_FILE="path_to_password_file"
while true; do
echo "Attempting to pull data from $SERVER..."
rsync --exclude='*.md' --password-file=$PASSWORD_... |
magic_instruct_75k | 33,636 | Create a Python function that simulates the behavior of a smart bulb controller in a home automation system. The function should handle the discovery of smart bulbs and the sending of commands to them. The function should include methods to indicate when a bulb is about to be discovered, when it has been successfully d... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Optional, Any
import random
class SmartBulbController:
def willBulbFound(self):
"""
Method called when a smart bulb is about to be discovered.
"""
print("Smart bulb discovery proce... |
magic_instruct_75k | 33,640 | Write a Python function `generate_inward_payment_report` that processes inward payment data for bookings and generates a report based on the following criteria:
1. For each booking, calculate the total actual amount and total TDS (Tax Deducted at Source) received from all inward payments.
2. Group the inward payments b... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_inward_payment_report(data):
"""
Generates a report based on inward payment data for bookings.
Args:
data (dict): A dictionary containing booking data and inward payments.
Returns:
dict: A ... |
magic_instruct_75k | 33,676 | Write a Python function to calculate the weighted average of term frequencies in a document using inverse document frequency (IDF) values. The function should take a dictionary `document_tokens` where keys are word IDs and values are their respective term frequencies, and a list `data` containing the IDF values. The fu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def calculate_weighted_average(document_tokens: Dict[int, int], data: List[List[int]]) -> List[float]:
"""
Calculate the weighted average of term frequencies in a document using inverse document fr... |
magic_instruct_75k | 33,697 | Write a Python function to parse a custom configuration file format and return a dictionary mapping keys to their corresponding values. The configuration file contains key-value pairs separated by commas, where each key-value pair is separated by a colon. The values can be integers, strings, or enums. Integers are repr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Union
def parse_config_file(content: str) -> Dict[str, Union[int, str, tuple]]:
"""
Parses a custom configuration file format and returns a dictionary mapping keys to their corresponding values.
Ar... |
magic_instruct_75k | 33,713 | Write a Python function to count the occurrences of each unique character in a given string. The function should return a dictionary where the keys are the unique characters and the values are the counts of those characters in the string.
The code should start with:
```python
def count_unique_characters(fruit: str) ->... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_unique_characters(fruit: str) -> dict:
"""
Counts the occurrences of each unique character in the given string.
Args:
fruit (str): The input string for which to count unique characters.
Returns:
... |
magic_instruct_75k | 33,723 | Write a Python function to parse and extract information from a list of Django migration operations. Each operation in the list is represented as a tuple containing the following elements:
1. The operation type, which can be "migrations.AlterField" or "migrations.CreateModel".
2. The model name, which is a string repre... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def parse_migration_operations(operations: List[Tuple[str, str, str, str, str]]) -> Dict[str, List[Tuple[str, str, str]]]:
"""
Parses a list of Django migration operations and extracts infor... |
magic_instruct_75k | 33,724 | Write a Python function named `get_host_devices` that simulates the behavior of a storage connector. The function should take a list of possible devices and a specific logical unit number (LUN) as input, and return a list of device paths that match the given LUN.
The function should have the following signature:
```py... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def get_host_devices(possible_devs: List[Tuple[int, str]], lun: int) -> List[str]:
"""
Filters the list of possible devices to include only those that match the given LUN and constructs their devi... |
magic_instruct_75k | 33,725 | Write a Python function to map source files to their corresponding destination paths. If multiple source files map to the same destination path, the function should append the source files to a list under that destination path in the dictionary. The function should start with:
```python
from typing import List, Tuple, ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict, Union
def map_files(src_list: List[Tuple[str, str]]) -> Dict[str, Union[str, List[str]]]:
"""
Maps source files to their corresponding destination paths. If multiple source files map to the... |
magic_instruct_75k | 33,737 | Write a Python function to count the occurrences of each domain in a list of email addresses. The function should return a dictionary where the keys are domain names and the values are the counts of how many times each domain appears in the list. The domain is defined as the part of the email address after the "@" symb... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_email_domains(emails: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of each domain in a list of email addresses.
Args:
emails (List[str]): A list of email addresse... |
magic_instruct_75k | 33,746 | Write a Python function to check whether a given string contains a valid HTML closing tag that matches a corresponding opening tag. A valid closing tag must start with `"</"` followed by a tag name and end with `">"`. The tag name should consist of only lowercase letters and may contain hyphens. Additionally, the tag n... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_valid_closing_tag(tag: str, opening_tag: str) -> bool:
"""
Checks whether a given string contains a valid HTML closing tag that matches a corresponding opening tag.
Args:
tag (str): The closing tag to be chec... |
magic_instruct_75k | 33,754 | Write a Python function to set up symbolic links for various configuration files in a user's home directory. The function should create symbolic links for the `.clang-format`, `.gdbinit`, `.gitconfig`, and `.bashrc` files from a specified directory (`source_dir`) to the user's home directory. If a symbolic link already... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
def setup_config(source_dir: str) -> None:
"""
Sets up symbolic links for configuration files from a specified directory to the user's home directory.
Additionally, updates the user's .bashrc file to source the .b... |
magic_instruct_75k | 33,767 | Write a Python function to simulate a simplified server group management system. The function should take a server group name and execute all the tests associated with that server group. The function should output the results of the tests in a specific format.
The function signature is:
```python
def run_server_group_... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
def run_server_group_tests(server_group_name: str) -> None:
"""
Simulates the execution of tests for a given server group and prints the results.
Args:
server_group_name (str): The name of the server ... |
magic_instruct_75k | 33,774 | Write a Python function to automate the installation and setup of a Buildkite agent on a Linux system. The function should perform the following tasks:
1. Update the package list using `apt`.
2. Install the `screen` utility using `apt-get`.
3. Set an environment variable `TOKEN` with a specific key.
4. Download and exe... | Here is the Python code to solve the given problem in the markdown block:
```python
import subprocess
import os
def setup_buildkite_agent(token: str) -> None:
"""
Automates the installation and setup of a Buildkite agent on a Linux system.
Args:
token (str): The Buildkite agent token.
Returns... |
magic_instruct_75k | 33,781 | Write a Python function to extract the first three columns from a given NumPy array `dataTraining`, where each row represents a data point and each column represents a feature. The function should return a new array `X` containing only the first three columns of the input array.
The code should start with:
```python
i... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def extract_features(dataTraining: np.ndarray) -> np.ndarray:
"""
Extracts the first three columns from the given NumPy array `dataTraining`.
Args:
dataTraining (np.ndarray): A 2D NumPy array whe... |
magic_instruct_75k | 33,794 | Write a Python function to process a list of parameters and return a modified version of the list. The function should remove any elements that start with an underscore (`_`) and sort the remaining elements in ascending order. If the input list is empty, the function should return an empty list.
The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_params(params: List[str]) -> List[str]:
"""
Processes a list of parameters by removing any elements that start with an underscore (_)
and sorting the remaining elements in ascending order... |
magic_instruct_75k | 33,806 | Write a Python function to process a list of queries and return a list of results based on the specified operations. Each query is represented by a tuple where the first element is the type of query and the second element is the value associated with the query. The types of queries are as follows:
1. **Type 1**: Add an... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
from collections import Counter
def frequency_queries(queries: List[Tuple[int, int]]) -> List[int]:
"""
Processes a list of queries and returns a list of results based on the specified operations.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.