instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a Python script that analyzes the distribution of programming languages and operating systems in a given dataset of software packages. The dataset is represented as a list of strings, where each string contains metadata information about a software package. The metadata includes details suc...
codefeedback
You are tasked with creating a Python program that generates MIDI music using the `midiutil` library and plays the generated music using the `pygame` library. Additionally, the program should utilize the `timidity` software synthesizer to convert the MIDI file to an audio file and play it using the `mpg123` command-lin...
codefeedback
You are tasked with creating a Rust module that handles HTTP header values for various header types. Your goal is to implement the necessary structs and traits to represent and manipulate these header values. Given the provided code snippet, you need to design and implement the following components: 1. Define a struct...
codefeedback
You are tasked with implementing a Python class that manages a menu system for a restaurant. The class should handle customer requests, maintain a log of orders, and track the presence of staff members. You need to create a class called `Menu` with the following attributes and methods: Attributes: - `Requests`: A lis...
codefeedback
You are tasked with implementing a function that calculates the mean of all possible combinations of perturbations for a given set of numbers. A perturbation of a number is defined as adding or subtracting a small value from the number. The function should take a list of numbers as input and return a list of means for ...
codefeedback
You are tasked with simulating the movement of a character in a 2D grid. The character can move up, down, left, or right within the grid. The grid is represented as a 2D array of integers, where each cell contains a value indicating the cost to move to that cell. The character starts at the top-left corner of the grid ...
codefeedback
You are tasked with implementing a Python function that processes requests based on given keywords. The function should read a key file containing a list of keywords and their corresponding actions, and then handle incoming requests by executing the appropriate action based on the provided keyword. The key file is for...
codefeedback
You are tasked with implementing a memoizing dynamic Fibonacci number generator in Java. The memoizing dynamic Fibonacci number generator should use a cache to store previously computed Fibonacci numbers to improve performance. Your task is to complete the implementation of the `generateFibonacciNumber` method in the ...
codefeedback
You are tasked with implementing a message processing system using Rust's asynchronous programming features. The system will read JSON messages from a stream, deserialize them, and then print the deserialized messages to the standard output. Your goal is to write a function that takes care of this message processing lo...
codefeedback
You are tasked with creating a Java program that processes data from different types of data units. The program should implement a specific interface and handle exceptions appropriately. Your task is to create a Java class that implements the `Component` interface from the LinkedPipes ETL framework. The `Component` i...
codefeedback
You are tasked with implementing a function to find the shortest path between two nodes in a directed graph. The graph is represented using an adjacency list and each edge has an associated weight. Your function should take the graph, the starting node, and the target node as input and return the shortest path from the...
codefeedback
You are tasked with implementing a buffer management system for a microcontroller. The buffer is used to store serialized data, and the system needs to handle different block sizes efficiently. The code snippet provided is from a unit test suite for the buffer management system. The `TEST_F` macro is used to define tes...
codefeedback
You are tasked with implementing a video streaming service that utilizes the HLS (HTTP Live Streaming) protocol to deliver content to users. The service should use the hls.js library to handle the HLS playback. Your goal is to create a function that initializes the HLS player for a given video channel. You are provide...
codefeedback
You are tasked with designing a protocol and a corresponding data structure in Swift to facilitate planned failover operations in a distributed system. The planned failover process involves transitioning the system from its primary state to a secondary state in a controlled manner, typically for maintenance or upgrades...
codefeedback
You are given a game where you need to guess a number chosen by the system. The system will provide feedback on whether your guess is higher or lower than the chosen number. You need to implement a strategy to efficiently guess the number within a given range. You are provided with a pre-defined API `guess(int num)` w...
codefeedback
You are tasked with creating a script that will analyze a given directory structure and list all the components present in the directory. The components are defined as subdirectories within the given directory. Your task is to write a Bash script that will achieve this functionality. Your script should read the absolu...
codefeedback
You are given a list of integers representing the daily stock prices of a company. You need to write a function `maxProfit` to find the maximum profit that can be obtained by buying and selling the stock at most once. If no profit can be made, return 0. The function should take in the following input: ``` maxProfit(pr...
codefeedback
You are tasked with creating a Python program that utilizes the Autobahn library to establish a WebSocket connection between a client and a server. The Autobahn library provides the necessary tools for creating WebSocket clients and servers. Your task is to implement the `startClient` and `startServer` functions using ...
codefeedback
You are tasked with implementing a Python function that calculates the nth Fibonacci number using Cython, a language that makes it easy to write C extensions for Python. Your goal is to create a Cython function that efficiently computes the Fibonacci sequence and then call this function from a Python script. Your task...
codefeedback
You are tasked with creating a program that processes a list of students and their corresponding grades. The program should calculate the average grade for each student and then determine the student with the highest average grade. You are given a snippet of code that represents the end of an HTML form and a PHP cond...
codefeedback
You are tasked with implementing a Python program to perform Principal Component Analysis (PCA) on a given dataset using the `eofs` library. PCA is a statistical method used to reduce the dimensionality of data while retaining trends and patterns. The `eofs` library provides tools for performing EOF (Empirical Orthogon...
codefeedback
You are tasked with implementing a command-line tool that allows users to search and repeat previously executed commands from their shell history. The tool should provide a user-friendly interface for selecting and executing historical commands. Your task is to implement a function `repeat_history` that takes no argum...
codefeedback
You are working on a secure communication application that requires handling digital certificates. You need to implement a method to generate a manifest JSON object and a representation method for a class. The manifest JSON object should contain specific information about the responder, subject certificate, issuer cert...
codefeedback
You are tasked with implementing a class to handle volatile registry keys in a Windows application. The class should provide methods to check for the existence of a volatile key, retrieve the volatile directory, look up a registry key handler, and extract the root from a given directory. You are provided with the foll...
codefeedback
You are tasked with implementing a data pruning algorithm for a system that manages objects with associated creation and last seen timestamps. The algorithm should identify and prune objects that meet specific criteria based on their timestamps. You are given a code snippet from the existing pruning algorithm, which c...
codefeedback
You are tasked with implementing a Swift program that processes outcome values for a healthcare application. The outcome values are represented by the `OutcomeValues` enum, which contains cases for different types of outcomes. Each case has an associated value that represents the actual outcome value. The `OutcomeValu...
codefeedback
You are tasked with creating a program to classify fruits based on their features using a decision tree classifier. The features include the mass, width, and height of the fruits. You are provided with a dataset that has been preprocessed and split into training and testing sets. Your goal is to train a decision tree c...
codefeedback
You are tasked with creating a web application that allows users to edit and update contributor details. The application uses the BForms library, which provides a set of helper methods for generating HTML elements. The code snippet provided is a partial view for displaying contributor details and includes a glyphicon f...
codefeedback
You are given a string. Your task is to write a function to find the index of the first non-repeating character in the string. If there are no non-repeating characters, return -1. For example: - Given the input "leetcode", the output should be 0, as the first non-repeating character is 'l' at index 0. - Given the inpu...
codefeedback
You are tasked with creating a Python function to extract workshop information from a given URL. The function should retrieve specific details about the workshop, such as its name, organizer, description, day, location, and link. Additionally, the function should handle potential connection errors when attempting to ac...
codefeedback
You are given a list of integers representing the daily stock prices of a company. Your task is to write a function to calculate the maximum profit that can be obtained by buying and selling the stock on different days. However, you are only allowed to complete at most two transactions. Create a function `maxProfitTwo...
codefeedback
You are tasked with creating a program that simulates a simplified version of a command-line interface for managing tasks. The program should allow users to add, list, and remove tasks. Additionally, users should be able to set environment variables and execute commands within a specified directory. Your task is to im...
codefeedback
You are tasked with implementing a Python class that simulates a simple text-based adventure game. The game involves navigating through different rooms, picking up items, and using those items to solve puzzles. Your task is to create a class called `AdventureGame` that provides methods for moving between rooms, picking...
codefeedback
You are tasked with implementing a Python function that performs gradient descent optimization to find the minimum of a given function. The function takes as input the initial guess for the minimum, the learning rate, the maximum number of iterations, and the function to be minimized. The function should return the est...
codefeedback
You are tasked with creating a script to validate and retrieve specific properties from configuration files. The script should read a configuration file, remove comments, and extract the value of a specified property. The property name may contain special characters, and the script should handle them appropriately. Add...
codefeedback
You are tasked with creating a program that reads a text file and counts the occurrences of each word in the file. Your program should ignore punctuation and consider words with different capitalizations as the same word. The program should then output the word count for each unique word in alphabetical order. For exa...
codefeedback
You are tasked with implementing a function to parse a raw data stream in a C++ class. The class `req` contains a method `__parse_raw()` which is responsible for parsing the raw data. The method has access to several member variables such as `_raw_len`, `_raw_readed_len`, `_stat`, `_buf_pos`, and `_buf_avail_size`. Add...
codefeedback
You are tasked with creating a program that processes student grades and calculates the average grade for a given set of students. The program should prompt the user to input the grades for each student and then calculate and display the average grade for the entire class. The program should follow these specification...
codefeedback
You are tasked with implementing a Swift extension for the URL type to create a URL safely from a static string. The extension should handle any special characters in the input string and ensure that the resulting URL is valid and properly encoded. Your task is to complete the implementation of the `URL` extension by ...
codefeedback
You are tasked with creating a sentiment analysis tool for stock market data using Python. The sentiment analysis tool will utilize two APIs: `deeptrade.sentiment` for sentiment analysis and `deeptrade.stocks` for accessing stock data. The sentiment analysis API provides functions for analyzing the sentiment of text da...
codefeedback
You are tasked with implementing a file import dispatcher for a contact management system. The system uses a `ContactFileParser` class to determine the appropriate parser for different file types. Your goal is to complete the `dispatch_import_task` function, which takes an import task, a request, a group, and an option...
codefeedback
You are tasked with creating a program that reads a text file and counts the occurrences of each word in the file. Your program should ignore punctuation and consider words with different capitalization as the same word. You should then output the unique words along with their respective counts in alphabetical order. ...
codefeedback
You are tasked with creating a program to validate a binary password. The binary password is represented as a string of 0s and 1s. The validation rules for the binary password are as follows: 1. The length of the binary password must be a multiple of 8. 2. The binary password must contain at least one occurrence of the...
codefeedback
You are tasked with implementing a function that will parse an HTML document and count the number of nested HTML elements within a specific tag. The function should take in the HTML document as a string and the tag name as a parameter, and return the count of nested elements within the specified tag. For example, give...
codefeedback
You are tasked with implementing a function that processes text to resolve coreferences, which are words or phrases that refer to other words or phrases within the same text. The function should take in a text string and an optional boolean parameter `no_detail`, which defaults to `False`. If `no_detail` is `True`, the...
codefeedback
You are working on a web application that involves handling database operations for a multilingual content management system. The code snippet provided represents an array configuration used for managing database fields in different contexts. Each array contains a set of fields relevant to a specific database operation...
codefeedback
You are tasked with implementing a stack-based virtual machine for a simple programming language. The virtual machine has three stacks: `StackStoredLocals`, `Stack`, and `FloatingPointStack`. The `StackStoredLocals` stack is used to store local variables, the `Stack` stack is used for general operations, and the `Float...
codefeedback
You are working on a web application that manages documents and questionnaires. The application uses Django and has a set of URL patterns defined in the `urls.py` file as shown in the code snippet below: ```python path('<int:pk>/document/create/', DocumentCreateView.as_view(), name='document-create'), path('<int:pk>/q...
codefeedback
You are tasked with implementing a token encoding and decoding system for managing attachments in a web application. The system should generate a token based on the user's UUID, customer information, and the type of attachment. Additionally, the system should be able to decode the token and validate its integrity. The...
codefeedback
You are tasked with creating a Python program that utilizes the `infi.systray` library to build a system tray icon application. The program should allow the user to encrypt and decrypt sensitive information using the `traylert.traylert_crypto` module. The encryption and decryption functionality should be accessible thr...
codefeedback
You are tasked with creating a Python program that reads a JSON file containing information about different products and their prices. The program should then calculate the total cost of purchasing a specified quantity of each product and display the overall cost. If any errors occur during the processing of the JSON f...
codefeedback
You are tasked with creating a function to format an address string based on a given data structure. The address data is stored in an object with the following properties: `alamat` (street address), `desa` (village), `kecamatan` (district), `kota` (city), and `kode_pos` (postal code). The address should be formatted in...
codefeedback
You are tasked with implementing a class that simulates a simple banking system. The class should support basic operations such as creating accounts, depositing funds, withdrawing funds, and transferring funds between accounts. Your task is to implement the `Bank` class with the following specifications: - The `Bank` ...
codefeedback
You are tasked with creating a Python function that processes images using a pre-trained deep learning model and returns the top predicted classes for each image. The function should utilize TensorFlow and the Inception-ResNet-v2 model for image classification. Additionally, the function should leverage multiprocessing...
codefeedback
You are working on a project that involves processing large datasets using TensorFlow, a popular open-source machine learning library. As part of the data preprocessing pipeline, you need to parse a dataset using TensorFlow's `tf.io.parse_example` function. The dataset is represented as a collection of serialized examp...
codefeedback
You are tasked with implementing a function to calculate the area of the intersection between a rectangle and a list of rectangles. The rectangles are defined by their top-left and bottom-right coordinates. The function should take the main rectangle and a list of rectangles as input and return the total area of the in...
codefeedback
You are working on a machine learning project that involves training a model to classify images into two categories: "true" and "negative". The model is implemented using TensorFlow, a popular machine learning library. The code snippet provided is part of the training process, where the true labels and negative labels ...
codefeedback
You are tasked with implementing a function that processes a given Rust code snippet to extract and count the number of unique Rust modules being imported. A Rust module is a collection of items, such as structs, enums, traits, functions, and type aliases, that can be used to organize and control the visibility of item...
codefeedback
You are tasked with implementing a program to analyze the frequency of words in a given text. Your program should take a string of text as input and output a list of unique words along with their frequencies, sorted in descending order based on frequency. For the purpose of this problem, a word is defined as a sequen...
codefeedback
You are tasked with implementing a Swift protocol and its associated types to model a simple banking system. The protocol should define the basic functionality required for a bank account, and the associated types should represent the account holder's information. Define a protocol `BankAccount` with the following req...
codefeedback
You are tasked with implementing a Python class that represents a Protocol Buffers message definition. Protocol Buffers is a method of serializing structured data, and it is used for communication protocols, data storage, and more. Your class should have the ability to store various properties of a message definition a...
codefeedback
You are working on a Python package for analyzing and visualizing regret and performance metrics in online learning algorithms. The package contains several modules for computing and plotting different metrics. One of the modules, `n_tree_sensitivity`, focuses on analyzing the sensitivity of performance metrics to the ...
codefeedback
You are tasked with implementing a sorting algorithm for a list of bills based on their introduction dates. The given code snippet is a part of a larger program that manages a list of bills and updates a table view with the sorted data. The `bills` array contains objects with an `introduced_on` property representing th...
codefeedback
You are tasked with creating a script to parse a list of URLs and filter them based on specific criteria. Each URL is a string in the format "http://<hostname>:<port>/<path>". The script should output the URLs that meet the filtering conditions. The filtering conditions are as follows: 1. URLs that contain the substri...
codefeedback
You are tasked with implementing a function that processes a nested dictionary representing a set of filtering conditions for a database query. The dictionary contains column names as keys and filtering conditions as values. The filtering conditions can be simple (e.g., equality, inequality) or complex (e.g., logical A...
codefeedback
You are tasked with implementing a Facebook login feature in an Angular application using the `@ngrx/store` library for state management. The application has a `FacebookLoginComponent` that needs to interact with the Facebook JavaScript SDK to authenticate users and dispatch actions to update the authentication state i...
codefeedback
You are tasked with implementing a generic algorithm for processing and transforming data using a binary operation. The algorithm iterates through two ranges of elements, applies the binary operation to each element in the first range, and stores the results in the corresponding positions of the second range. The binar...
codefeedback
You are tasked with implementing a neural network architecture for an image processing task. The architecture consists of an encoder and a decoder. The encoder takes an input image and produces two sets of intermediate features, denoted as y1, p1, and y2, p2. The decoder then takes these intermediate features along wit...
codefeedback
You are tasked with implementing a method to reverse the order of words in a given string. You need to create a method `ReverseWords` within the `StringExtensions` class, which takes a string as input and returns the string with the order of words reversed. A word is defined as a sequence of non-space characters. The ...
codefeedback
You are given a sorted array of integers where every element appears exactly twice, except for one element that appears only once. Your task is to write a function to find the unique element in the array. The array is guaranteed to be sorted in non-decreasing order. You need to implement the following function: ```ja...
codefeedback
You are tasked with implementing a binary search algorithm to find the index of a given value in a sorted collection. The binary search algorithm compares the target value to the middle element of the collection. If they are not equal, the half in which the target cannot lie is eliminated, and the search continues on t...
codefeedback
You are tasked with creating a Python function to preprocess audio features for a cough detection system. The function should take a file containing cough features as input and perform the necessary preprocessing steps to prepare the data for machine learning classification. The function should perform the following s...
codefeedback
You are tasked with implementing a parallel algorithm for dividing a 2D grid into equal sections based on the number of processes available. The given code snippet is part of a parallel program that aims to divide a 2D grid into sections for parallel processing. The code snippet is responsible for determining the start...
codefeedback
You are working for a telecommunications company that wants to analyze the relationship between the number of customers and the number of cancellations in different categories. The company has a dataset called "tabela" containing information about the categories of customers and their cancellation status. The dataset h...
codefeedback
You are tasked with creating a custom file loader for a specific data format. The data is stored in a NetCDF file, and you need to implement a method to load this data into a 3-dimensional array structure. The NetCDF file contains a variable named "data" which holds the actual data to be loaded. You are provided with a...
codefeedback
You are tasked with creating a program to simulate a simple game of generating and controlling ships using Python's Pygame library. The game will involve the player generating and controlling ships to navigate through obstacles and reach a specific destination. Your task is to implement a function `generate_ships` tha...
codefeedback
You are tasked with implementing a class method that calculates the mutual information for a given band in a histogram. Mutual information is a measure of the mutual dependence between two variables. In this context, the variables are the intensity values in the band and the corresponding pixel positions in the image. ...
codefeedback
You are tasked with creating a Python class that handles incoming HTTP requests and performs asynchronous database insertions. Your class should utilize the Twisted framework for asynchronous event-driven programming. The provided code snippet is a partial implementation of the class, and your task is to complete the i...
codefeedback
You are tasked with implementing a caching mechanism for a database connection in Python. The given code snippet is part of a class that manages the database connection and caching. The `cache_key` is generated from the `filename` and is used as a unique identifier for caching. The class also enables callback traceback...
codefeedback
You are tasked with implementing a simple game logic using Rust. The game involves taking actions based on the outcome of rolling a die. The provided code snippet demonstrates a function `take_action_with_move` that takes a single argument `roll` representing the outcome of rolling a die. The function uses a `match` st...
codefeedback
You are tasked with implementing a simplified version of an offscreen effect player in C++. An offscreen effect player is responsible for applying image processing effects to offscreen render targets and then notifying the caller with the processed results. You are provided with the following code snippet as a startin...
codefeedback
You are tasked with implementing a function to colorize a given string using the Pygments library. Pygments is a syntax highlighting library that supports a wide range of programming languages and file formats. Your task is to create a function `colorize_string` that takes a string as input and returns the colorized ve...
codefeedback
You are tasked with implementing a function to process and validate QR code information related to COVID-19 tests. The function should take a QR code string as input and return the result of the validation process. The QR code information will be in a specific format related to COVID-19 test results. The function shoul...
codefeedback
You are tasked with implementing a reinforcement learning algorithm for a discrete action space using a combined actor-critic network. The actor network is responsible for outputting a probability distribution of actions given a state, while the critic network estimates the value function for the given state. The provi...
codefeedback
You are tasked with implementing a function that generates all possible symmetric strings based on a given input string. A symmetric string is a string that remains unchanged when read backward. For example, "aba" and "1221" are symmetric strings. The function should take a string as input and return a list of all poss...
codefeedback
You are working on a database manipulation system for electronic design automation. The system involves translating between two different representations of pins and nets. Pins are represented by the `Pin` class, and nets are represented by the `Net` class. Additionally, there are two helper functions: `staToDb` and `d...
codefeedback
You are given a C++ class `StringManipulator` with a member function `reverseString` that takes a string `s` as input and reverses it. However, the implementation of the `reverseString` function is missing. Your task is to complete the implementation of the `reverseString` function using C++. Class Definition: ```cpp ...
codefeedback
You are tasked with simulating a simplified version of a disk I/O scheduler. In this scenario, you are given a series of write requests to be performed on a disk. Each write request consists of a buffer to be written, an offset on the disk, and a file descriptor representing the disk. Your goal is to implement a schedu...
codefeedback
You are tasked with implementing a multi-threaded game simulation where two players take turns to make a move. The provided code snippet initializes a boolean variable `yourTurn` which indicates whether it is currently the player's turn to make a move. Your task is to create a Java class `Game` that manages the turn-ba...
codefeedback
You are tasked with creating a Python class method that retrieves and processes new videos from a video feed. The method should interact with a database, call an external feed, and make an API request to retrieve video data. Your task is to complete the implementation of the `get_new_videos` method within the given cla...
codefeedback
You are tasked with implementing a Python class that can parse and extract information from a message structure. The message structure consists of fields and nested messages, and the class should be able to recursively traverse the structure and extract the field names along with their corresponding types. Your task i...
codefeedback
You are tasked with creating a property-based test generator for manipulating text data structures. In this problem, you will be working with ropes, a data structure used for efficiently storing and manipulating large strings. Ropes are particularly useful for operations like concatenation and substring extraction. Yo...
codefeedback
You are given a list of integers representing the scores of a game. The game has a special rule: if the current score is the same as the previous score, the current score is discounted. Your task is to calculate the total score after applying this rule and print the result. Write a Python function `calculate_total_sco...
codefeedback
You are tasked with creating a Python class to handle connections to a DVRIP (Digital Video Recorder Internet Protocol) client. The DVRIPClient class should establish a TCP connection to a specified host and port, and then authenticate using a given username and password. Your task is to implement the DVRIPClient class...
codefeedback
You are tasked with implementing a class that manages a collection of names, their associated contexts, and corresponding file paths. The class should provide methods for adding and retrieving this information. You are given a code snippet that initializes three private arrays within the class: `$names`, `$contexts`, ...
codefeedback
A circular prime is a prime number that remains prime under cyclic shifts of its digits. For example, the number 197 is a circular prime because 197, 971, and 719 are all prime numbers. Your task is to write a program to determine how many circular primes exist below a given limit. Write a function `count_circular_pri...
codefeedback
You are tasked with creating a script to automate the deployment process for a system processor application. The script should perform the following tasks: 1. Check if the executable file `exeSystemProcessor` exists in the `target/debug` directory. 2. If the file exists, display "SYS File found" and proceed to the nex...
codefeedback
You are tasked with creating a form validation function for a user registration page. The function should validate the input fields for telephone number, email, and CPF (Brazilian individual taxpayer registry identification). The validation rules for each field are as follows: 1. Telephone Number (id="telefone"): -...
codefeedback
You are working on a data visualization project and need to create a program to plot time series data. The data is stored in a pandas DataFrame `df` with a column named `cpm` representing counts per minute. You need to create a function to plot the data on a graph using matplotlib. Write a Python function `plot_time_s...
codefeedback
You are tasked with creating a Python function that processes a given text file and extracts the namespaces mentioned in the file. A namespace is a set of symbols that are used to organize objects of various kinds, allowing these objects to be referenced by name. The namespaces in the file are denoted by lines that sta...
codefeedback