instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a function to calculate the Sinkhorn divergence between clusters of data points. The Sinkhorn divergence is a measure of dissimilarity between two probability distributions, often used in machine learning and data analysis. The function `sinkhorn_divergence` takes as input the weights a...
codefeedback
You are working on a security tool that processes indicators of compromise (IOCs) in JSON format. One of the functions in the tool, `panos_url_formatting`, is responsible for formatting URLs and handling port numbers. The function takes the following parameters: - `iocs_json`: A JSON object containing IOCs in the form ...
codefeedback
You are tasked with creating a function to validate a Sudoku board. The function should take a 9x9 grid representing the Sudoku board as input and return True if the board is valid, and False if it is not. A valid Sudoku board is one where each row, column, and 3x3 subgrid contains the numbers 1 to 9 without repetitio...
codefeedback
You are tasked with implementing a PHP class that parses a given string containing HTML-like tags and their metadata. The class should have a method `parseTags` that takes the input string and returns an associative array where the keys are the tag names (in lowercase) and the values are the corresponding metadata. Th...
codefeedback
You are tasked with creating a function to convert an integer to its base 7 representation. The function should take an integer as input and return a string representing the base 7 equivalent of the input number. The base 7 representation should be in the form of a string. The base 7 representation of a number is obta...
codefeedback
You are tasked with creating a program to calculate the nth Fibonacci number using an efficient algorithm. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The program should take an integer input n and return the nth Fibonacci numbe...
codefeedback
You are working on a software module for tracking particles in a particle physics experiment. The code snippet provided is a part of this module and is responsible for creating a new track, `newTrack`, and populating a vector `componentHits` with hits that fall within the track's tolerance range. The `math::XYZPoint` ...
codefeedback
You are tasked with implementing a class to manage bus information for a transportation company. The class, `LanitBusInfo`, contains a static method `get_nearest_bus` that takes in the user's current location and their destination, and returns the nearest bus to their location. The `Locations` and `Destinations` are e...
codefeedback
You are given a list of tuples, each representing a significant date and its corresponding event. The first element of each tuple is the month (as an integer), the second element is the day (as an integer), and the third element is the event name (as a string). Your task is to write a function that takes this list of t...
codefeedback
You are tasked with creating a Python function that processes images based on their EXIF metadata. The function should take an image object and its corresponding EXIF data as input and apply the necessary transformations to the image based on the orientation tag in the EXIF data. The orientation tag specifies the orien...
codefeedback
You are tasked with creating a program that generates a secure password based on specific criteria. The password must meet the following requirements: 1. Length: The password must be between 8 and 12 characters long, inclusive. 2. Composition: The password must contain a mix of uppercase letters, lowercase letters, num...
codefeedback
You are tasked with creating a script to manage the installation and configuration of dotfiles on a user's system. Dotfiles are configuration files for various programs and tools, typically stored in the user's home directory. The script should support customization of the clone URL and destination path, as well as the...
codefeedback
You are tasked with creating a Python script that processes command-line arguments to output the adjacencies of leaf genomes of a given phylogeny in DeCo format. The DeCo format is a specific format used to represent the genome adjacencies in a phylogenetic tree. Your script should take the following command-line argu...
codefeedback
You are given a code snippet that represents a character literal in the C programming language. Your task is to write a program that takes this character literal as input and converts it to its corresponding ASCII value. Your program should take the character literal as input and output the ASCII value of the characte...
codefeedback
You are working on a project to set up a search system using Terrier, an open-source search engine platform. As part of the setup process, you need to perform several configuration and setup tasks. The given code snippet provides some commands and comments related to this setup process. Your task is to write a script ...
codefeedback
You are tasked with implementing a Python class for a game character that moves within a game map. The class has an `__init__` method that initializes the character's attributes based on the provided parameters. The character's initial position and movement direction are determined by the `moveDir` parameter. The `spee...
codefeedback
You are tasked with creating a class hierarchy for a library management system. The system should be able to handle different types of users, such as librarians and patrons, and store information about the books in the library. Your task is to design and implement the necessary classes to represent users and books, ens...
codefeedback
You are tasked with implementing a function to calculate peri-event time histograms (PETHs) and firing rates for a set of spike data. The spike data consists of spike times and corresponding cluster IDs, and the PETHs and firing rates are calculated with respect to a set of event times. You are given the following inf...
codefeedback
You are tasked with implementing a class for solving 2D linear elasticity problems using the Green strain method. The provided code snippet is the constructor of the `GreenStrain_LIMSolver2D` class, which initializes the variable `Beta` to 100. Your task is to complete the implementation of the `GreenStrain_LIMSolver2D...
codefeedback
You are tasked with implementing a macro in Rust that generates a sequence of durations based on a given input. The macro should take a variable number of expressions representing durations and combine them into a sequence using a specified method. The provided code snippet serves as a starting point for the macro impl...
codefeedback
You are tasked with implementing a function to parse and extract information from a file header in the given format. The file header is a comment block at the beginning of a source file, and it contains metadata such as the file name, author, and copyright information. Your task is to write a function that extracts thi...
codefeedback
You are tasked with implementing a messaging system for a social networking platform. The provided code snippet includes partial implementations of two classes: `BaseMessage` and `FriendRequestMessage`. Your task is to complete the implementation of the `FriendRequestMessage` class by adding necessary methods and attri...
codefeedback
You are tasked with implementing a function to parse and process a set of rules defined in a given code snippet. Each rule is represented by a line of text, and the rules are categorized by prefixes denoting their type. The prefixes are as follows: - `*` for general rules - `#` for utility rules Your task is to create...
codefeedback
You are tasked with implementing a Python class for post-processing soft masks generated by an instance segmentation model. The class should support different post-processing methods and thresholding techniques. Your task is to create the `PostProcessor` class with the specified functionality. Your `PostProcessor` cla...
codefeedback
You are tasked with implementing a device descriptor system for a capture device in a multimedia application. The device descriptor points to a dispatch table and contains a list of filter descriptors that describe the filter types supported by the device. Your goal is to design a data structure and associated function...
codefeedback
You are tasked with creating a Python function that processes a TensorFlow model and exports its weights and biases to a Wolfram Exchange Format (WXF) file. The function should take in the following parameters: - `reader`: An object representing the TensorFlow model reader, which provides access to the model's variable...
codefeedback
You are working on a 3D graphics application and need to implement a function to draw a 3D cube using OpenGL. The cube should be centered at the origin and have a specified size. You are given the following code snippet as a starting point: ```c glVertex3f( WORLD_MAX, 0.0f, WORLD_MAX); glColor3f(0.0f, 0.0f, 0.0f);...
codefeedback
You are tasked with creating a program that processes a list of GitHub repository URLs and checks for the presence of a license file in each repository. If a license file is found, the program should print a formatted message containing the repository ID, name, and the URL to the license file. You are given a code sni...
codefeedback
You are given an array of strings and an integer k. Your task is to find the maximum sum of the lengths of k non-overlapping subarrays, where each subarray contains only distinct elements. If there are multiple possible combinations that result in the same maximum sum, you should return the lexicographically smallest c...
codefeedback
You are tasked with implementing a function to preprocess a set of graphs for a machine learning task. The function takes a list of filenames representing graph data and a set of labels as input. The goal is to normalize the graph data and prepare it for further processing. The provided code snippet shows a part of the...
codefeedback
You are tasked with implementing a neural network model using TensorFlow to classify handwritten digits from the MNIST dataset. The MNIST dataset contains 28x28 pixel grayscale images of handwritten digits (0-9). Your goal is to create a neural network model that can accurately classify these images into their respecti...
codefeedback
You are tasked with creating a program to analyze the coefficients of a transformed target regressor model trained using cross-validation. The transformed target regressor model is a machine learning technique that applies a transformation to the target variable before fitting a regressor model. The code snippet provid...
codefeedback
You are tasked with implementing a basic Flask web application that provides a RESTful API for hashing text. The application should utilize Flask, Flask-SQLAlchemy, and Flask-Login to handle user authentication and store hashed text in a database. Your task is to complete the implementation of the Flask app by adding t...
codefeedback
You are tasked with implementing a volume control system for a device. The system is configured using the following parameters: - `button_down`: The button used to decrease the volume. If set to 0, this functionality is disabled. - `button_mute`: The button used to toggle mute. If set to 0, this functionality is disabl...
codefeedback
You are working on a project that involves evaluating clusters of data points using a specific method. The code snippet provided is part of a larger program that uses the `evaluate_clusters_range` function to assess clusters within a given range of values. Additionally, the code snippet utilizes hierarchical clustering...
codefeedback
You are tasked with creating a function that simulates an asynchronous HTTP request using JavaScript's `Promise` object. Your function should mimic the behavior of the `$.ajax` method from the jQuery library, but without using jQuery itself. The function should take an object as a parameter, which contains the request ...
codefeedback
You are tasked with implementing a thread-safe class for managing aeron subscriptions. The class should provide methods for resetting and stopping the subscriptions, ensuring that these operations are performed in a synchronized manner. Additionally, the class should enforce a specific state before allowing the stop op...
codefeedback
You are tasked with creating a program that processes a given string to extract and manipulate specific information. The input string will contain a series of numbers and characters, and your program should extract the numbers and perform specific operations based on the characters present in the string. You are given...
codefeedback
You are tasked with creating a Rust function that parses command-line arguments and constructs a `SubstrateSyncParams` struct. The `SubstrateSyncParams` struct is used for configuring a synchronization process in a blockchain application. Your task is to complete the implementation of the `substrate_sync_params` functi...
codefeedback
You are working on a system that manages orders for a retail company. The system uses Python and the pytest library for testing. The code snippet provided is part of a test fixture for the order management system. The `order` object represents an order in the system, and it has methods to set items and attributes. The...
codefeedback
You are tasked with implementing a pagination function for a hypothetical AWS client. The function `paginate` takes in various parameters and is responsible for paginating through a list of Fargate profiles. Your goal is to write a function that can paginate through the list of Fargate profiles and return the paginated...
codefeedback
You are tasked with implementing a function that processes a given array of commands and returns the final state of a system. Each command in the array is represented as a string and can be one of the following types: - "add x": Add the value x to the system. - "subtract x": Subtract the value x from the system. - "mul...
codefeedback
You are tasked with creating a Python program that parses the IANA Private Enterprise Numbers registry and extracts relevant information. The IANA Private Enterprise Numbers registry contains a list of assigned enterprise numbers for private use. Each entry in the registry includes the enterprise number, the organizati...
codefeedback
You are tasked with creating a program that simulates a simple file management system. The system should be able to handle basic file operations such as creating, deleting, and listing files and directories. Your program should also support navigating through directories and displaying the current working directory. Y...
codefeedback
You are tasked with implementing a Python class that manages different types of output destinations for a data processing pipeline. The code snippet provided defines a dictionary `OUTS_MAP` that maps output destinations to their respective classes. Each class is responsible for handling the output to a specific destina...
codefeedback
You are tasked with implementing a function to compute the KKT (Karush-Kuhn-Tucker) system for a parallel nonlinear model predictive control (parNMPC) algorithm. The parNMPC algorithm is used to control a group of robots in a parallelized manner. The KKT system is computed for each time step in the algorithm, and the f...
codefeedback
You are tasked with creating a program to manage a library's book inventory. The program should allow users to add new books, remove existing books, and search for books by title or author. Additionally, the program should be able to display the entire inventory of books. You are provided with a partial implementatio...
codefeedback
You are tasked with implementing a Python function that calculates the percentage of occurrences of each unique element in a given list. The function should take a list of elements as input and return a dictionary where the keys are the unique elements from the input list, and the values are the percentages of occurren...
codefeedback
You are given a web page's HTML code snippet that represents a table structure. Your task is to write a program that parses this HTML code and extracts the data from the table. The HTML code snippet is as follows: ``` </div> ...
codefeedback
You are tasked with creating a web application that utilizes a template system to display content. The application uses a popular PHP framework that allows for the creation of reusable templates. The code snippet provided is a simplified representation of a template file in the application. Your task is to implement a...
codefeedback
You are tasked with implementing a learning rate scheduler for a neural network training process. The provided code snippet contains configuration settings for the learning rate schedule. Your task is to write a function that takes these configurations and computes the learning rate for a given epoch during training. ...
codefeedback
You are tasked with implementing a utility function for managing CSS class names in a React application. The function should take in a series of utility functions and return a string of concatenated class names based on the provided utilities. Each utility function corresponds to a specific CSS property and value. You...
codefeedback
You are tasked with creating a function that takes in a JavaScript object representing a style sheet and returns an array of all the unique colors used in the style sheet. Each key in the object represents a style class, and the value is an object containing style properties and their values. For example, given the fo...
codefeedback
You are tasked with creating a Python function that processes a set of IP addresses obtained from a Redis database and returns a list of unique IP addresses along with their corresponding dates. The function should connect to the Redis database, retrieve the IP addresses and dates, and then return the unique IP address...
codefeedback
You are tasked with implementing a Python function to extract radial, sulcal, and gyral orientations from a gyral coordinate NIFTI file. The NIFTI file contains 3D brain images and is commonly used in neuroimaging research. The gyral coordinate NIFTI file represents the gyral pattern of the brain, and the goal is to ex...
codefeedback
You are tasked with creating a Python program that converts RGB color values to CMYK color values. The RGB color model is represented by three values (R, G, B) ranging from 0 to 255, while the CMYK color model is represented by four values (C, M, Y, K) ranging from 0% to 100%. The conversion formulas are as follows: C...
codefeedback
You are tasked with implementing a feature gate mechanism in Rust to conditionally enable or disable certain modules based on a configuration setting. The code snippet provided includes a module `hashing_utils` and a comment indicating the intention to feature gate the `serde_utils` module. Your task is to create a fu...
codefeedback
You are given a list of integers and a target value. Your task is to implement a function `find_target_indices(nums: List[int], target: int) -> List[Tuple[int, int]]` that returns a list of tuples, where each tuple contains the indices of two elements from the input list that sum up to the target value. If no such pair...
codefeedback
You are tasked with creating a function that determines whether a given user belongs to a specific group of students in a database. The database schema includes tables for users, groups, and memberships. The function should take the user ID and the IDs of the student groups as input and return a boolean value indicatin...
codefeedback
You are tasked with creating a Python script that processes a directory of text files and extracts specific information from them. The script should take in a directory path as a command-line argument and then perform the following tasks for each text file in the directory: 1. Extract the file name and creation date o...
codefeedback
You are tasked with creating a function that can determine the longest common prefix among an array of strings. The longest common prefix is the longest string that is a prefix of all strings in the array. If there is no common prefix, the function should return an empty string. Write a function `longestCommonPrefix` ...
codefeedback
You are tasked with implementing a class that manages different modes of operation for an application. The class should handle the selection of an icon to determine the active mode and update the corresponding mode when necessary. You are given a code snippet from the existing application that demonstrates how the ico...
codefeedback
You are tasked with implementing a function to load thermodynamic data from a database and perform specific operations on the data. The thermodynamic data is stored in a database represented by the `thermodb` variable. The `load_thermoDB` function is responsible for loading the thermodynamic data into the `thermodb` va...
codefeedback
You are working on a project that involves managing access control policies using the eXtensible Access Control Markup Language (XACML). As part of this project, you need to develop a Java program that can dynamically load XACML policy files from a specified directory and extract certain information from these policies...
codefeedback
You are tasked with implementing a function to calculate the information gain in a decision tree. Information gain is a measure used in the construction of decision trees to determine the attribute that provides the greatest amount of information about the classification of a set of items. The function `info_gain(prev_...
codefeedback
You are tasked with implementing a caching mechanism for a web application's configuration settings. The application has a class `API` that provides access to various settings, and a class `Cache` that handles caching. The `API` class has a method `GetValueOrDefault` to retrieve settings, and the `Cache` class has a me...
codefeedback
You are given the definition of a singly linked list node and a method to reverse the linked list. Your task is to complete the implementation of the `reverse` method to reverse the given linked list. If the input linked list is empty or has only one node, the method should return the head of the original list. The de...
codefeedback
You are tasked with implementing a function that checks the validity of a given PHP code snippet. The function should determine if the PHP code snippet contains a specific function call and if it is properly terminated. You are given a PHP code snippet as a string. The code snippet may contain various PHP constructs,...
codefeedback
You are given a function `sum(n, k)` that takes in two integers `n` and `k`. The function should return the sum of all integers from `k` to `n` inclusive. However, the function should only be called if `n` is non-negative and `k` is a non-negative integer not exceeding 10^9, and `n` is greater than or equal to `k`. If ...
codefeedback
You are tasked with implementing a constant-time branch operation function in Python. The function should take three parameters: `subject`, `result_if_one`, and `result_if_zero`. The function should return `result_if_one` if `subject` is 1, and `result_if_zero` if `subject` is 0. The catch is that the function should e...
codefeedback
You are tasked with creating a Python function that takes a list of package names and their dependencies as input and returns a valid installation order for the packages. The input will be provided in the form of a dictionary, where the keys are package names and the values are lists of package dependencies. The functi...
codefeedback
You are tasked with implementing a rate limiting system for a web application called BubbleBBS. The application has various actions that need to be rate-limited to prevent abuse and ensure fair usage. The rate limits are defined in the code snippet provided. Each rate limit is specified in terms of a maximum number of ...
codefeedback
You are given a grid of size m x n, where each cell contains a non-negative integer value. You are initially positioned at the top-left cell and are required to reach the bottom-right cell. You can only move either down or right at any point in time. Additionally, you need to find the minimum sum of values along a path...
codefeedback
You are given a code snippet that appears to be part of a merge sort algorithm. Your task is to implement the missing functions and complete the merge sort algorithm to sort an array of integers. The `merge_sort` function takes in an array `nums1`, an auxiliary array `nums0`, and the indices `low` and `high`. It is ex...
codefeedback
You are tasked with implementing a method to determine whether a given attribute is present within a custom data structure representing Swift type attributes. The data structure is defined using an enumeration with associated values, and the method should recursively search through the structure to find the specified a...
codefeedback
You are given a snippet of code representing a set of variables initialized to 0. Your task is to write a function that takes in a list of variable names and returns the sum of the values of these variables. The function should consider only the variables provided in the input list and ignore any other variables. For ...
codefeedback
You are tasked with implementing a function to compare the result of an inverse kinematics (IK) solver with an expected set of joint configurations. The IK solver computes joint configurations for a robotic arm given a desired end-effector pose. The joint configurations are represented by a set of RevoluteJoint objects...
codefeedback
You are working on a medical imaging project and need to process MRI data using Python and R. You have a 3D MRI image stored in the NIfTI format (.nii) and want to perform some statistical analysis on the image data. To achieve this, you need to read the MRI data using Python's nibabel library, convert it to a NumPy ar...
codefeedback
You are tasked with creating a script to automate the setup of a development environment for a specific project. The script should perform the following tasks: 1. Create a folder named "artifact". 2. Navigate into the "artifact" folder. 3. Clone a specific GitHub repository named "foundational_boogie" into the "artifa...
codefeedback
You are tasked with implementing a function that reorders child elements within a rendering hierarchy and removes a specific element. The rendering hierarchy is represented by a tree-like structure, where each node is a `RenderObject`. The function should also update the rendering hierarchy to set a full-screen rendere...
codefeedback
You are given a Python function `simulate(reg_0, find_non_loop)` that takes two parameters: - `reg_0`: An integer representing the initial value of a register. - `find_non_loop`: A boolean flag indicating whether to find the first non-looping value or not. The function simulates a register machine with the following r...
codefeedback
You are tasked with creating a program that parses HTML code to extract specific information. Given an HTML snippet as input, your program should identify and extract all the form IDs present in the code. For example, given the following HTML snippet: ``` <span class="loading"></span> ...
codefeedback
You are tasked with implementing a program to validate a string based on certain criteria. The string should only contain valid letters, and it should have a valid format based on the values assigned to each letter. The program should have the following functionalities: 1. Check if the provided string contains only v...
codefeedback
You are given a string `word` and a character `ch`. Your task is to reverse the substring of `word` starting from the beginning of `word` up to and including the first occurrence of `ch`, and then concatenate the rest of the `word` as is. Write a function `reversePrefix` that takes in the string `word` and the charact...
codefeedback
You are tasked with implementing a custom comparison function for a Rust enum type called `Currencies`. The `Currencies` enum has two variants: `InGame(currencies)` and `Cash(currencies)`. The comparison function should compare two instances of `Currencies` based on the following rules: 1. If both instances are of type...
codefeedback
You are tasked with creating a program to visualize the loss and associated metrics throughout the training process. The program will take the path to a directory for a specific training run as its first argument. The directory will contain the necessary data for plotting the loss and metrics. Your task is to implemen...
codefeedback
You are tasked with implementing a function that processes data from a collection of dictionaries and returns a specific result based on the given criteria. The function should take in a list of dictionaries, each representing a data entry, and return a new list containing specific information extracted from the input ...
codefeedback
You are working on a web application using the Flask framework and SQLAlchemy for database management. You have come across the configuration variable `SQLALCHEMY_TRACK_MODIFICATIONS` set to `True` in the application's configuration file. You are concerned about the potential performance implications of this setting an...
codefeedback
You are tasked with creating a database migration script for a Laravel application that manages user roles, permissions, and their associations. The provided code snippet is a part of the migration script and is responsible for creating foreign key constraints for the `role_id` and `user_id` columns in a table. Your ta...
codefeedback
You are tasked with implementing a library management system that tracks actions performed by students on books. The provided code snippet contains a method signature for connecting an action to its referenced objects and a method signature for retrieving actions by their type. Your task is to implement the `connectAct...
codefeedback
You are working on a bioinformatics pipeline for evaluating the accuracy of variant calls in VCF (Variant Call Format) files. As part of this pipeline, you need to write a script to run the `vcfeval` tool to compare a sample VCF file against a truth VCF file. The `vcfeval` tool is typically used to assess the performan...
codefeedback
You are given a maze represented as a 2D grid of cells. Each cell can be either open or blocked. The objective is to find the shortest path from the start cell to the end cell, where movement is only allowed to adjacent open cells (up, down, left, and right). Write a function `shortestPath` that takes the maze grid, t...
codefeedback
You are tasked with implementing a simplified version of a logging system using C++. The system will utilize a YAML file format to store atomic operations. You are provided with a partial code snippet for the `YamlLogger` class, which uses a private implementation pointer (`_pimpl`) to interact with the underlying impl...
codefeedback
You are tasked with implementing a class `GridWorld` that represents a grid-based world with various features located at different positions. The class should have the following functionalities: 1. `feature_locations`: A method that returns a dictionary where the keys are the features present in the grid and the value...
codefeedback
You are tasked with implementing a genetic algorithm to optimize a specific function. The genetic algorithm involves the use of a fitness function, selection, crossover, and mutation operations. Your goal is to write a Python function that takes in a population of candidate solutions and returns the next generation of ...
codefeedback
You are tasked with creating a Python class to manage time windows for social distancing and travel restrictions during a pandemic. The class should be able to calculate the effectiveness of social distancing measures and the impact of travel restrictions based on the provided time windows. You are given a code snippe...
codefeedback
You are tasked with implementing a gene set z-score calculation method in Python. The gene set z-score is a statistical measure used in bioinformatics to assess the enrichment of a gene set within a larger dataset. You are provided with a class `GeneSetAnalyzer` that contains a method `gs_zscore` for calculating the z-...
codefeedback
You are tasked with implementing a Python function that calculates the unbalanced loss for a given set of masked maps. The function should take into account various parameters such as balance loss, main loss type, negative ratio, and whether to return the unbalanced loss or not. You are given the following function si...
codefeedback
You are tasked with creating a program that simulates a simplified version of an online code submission system. Your program should take a user's code submission, language choice, and problem ID, and then make a POST request to a specified URL with the provided data. You are given the following code snippet as a start...
codefeedback
You are tasked with implementing a custom Metropolis Monte Carlo sampler for a simple 1D Gaussian distribution. The sampler should perform a series of steps to explore the distribution and generate samples. The Gaussian distribution is defined as `f(x) = (1/sqrt(2*pi*sigma^2)) * exp(-(x-mu)^2 / (2*sigma^2))`, where `mu...
codefeedback