instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a function to calculate the total number of lines of code in a Python file, excluding comments and empty lines. The function should take the file path as input and return the total number of lines of executable code.
You are given a Python file named `example.py` as an example input. T... | codefeedback |
You are tasked with implementing a user search feature in a web application using Django. The provided code snippet includes a template loading and a view function for user search. Your task is to complete the implementation of the user search functionality by creating a view that handles the search query and returns t... | codefeedback |
You are tasked with implementing a simplified version of a UUID (Universally Unique Identifier) generator. A UUID is a 128-bit number used to uniquely identify information. It is typically represented as a 32-character hexadecimal string, such as "550e8400-e29b-41d4-a716-446655440000".
Your task is to create a functio... | codefeedback |
You are tasked with automating the deployment and configuration of Apache Kafka and Apache Flink on a server. Your goal is to write a Bash script that performs the following tasks:
1. Extracts the Kafka and Flink tarballs.
2. Starts the Zookeeper server for Kafka.
3. Starts the Kafka server.
4. Creates two Kafka topic... | codefeedback |
You are tasked with implementing a feed simulation system for a social media app. The system should handle the display of images in a feed and simulate the loading of new images as the user scrolls through the feed. You are given a partial implementation of the `FeedViewController` class and the `simulateFeedImageViewN... | codefeedback |
You are tasked with implementing a Swift protocol to create a filter for drawing crosshatch shadows. The protocol, `C7FilterProtocol`, is used to define the structure for various filters in the ATMetalBand framework. Your goal is to complete the implementation of the `C7Crosshatch` struct, which conforms to the `C7Filt... | codefeedback |
You are tasked with implementing a news processing system that handles the retrieval and processing of news articles. The system should be designed to handle various types of news articles and perform specific actions based on the type of news. You are provided with a PHP code snippet that represents the constructor an... | codefeedback |
You are tasked with implementing a cache management system for a mobile application. The cache should support inserting, deleting, and retrieving items efficiently. Your task is to design and implement a cache system that satisfies the following requirements:
1. The cache should be able to store key-value pairs, where... | codefeedback |
You are tasked with designing a Java class for managing items in a shopping cart system. The class should represent an item that can be added to a shopping cart, and it should contain various attributes and annotations for database mapping.
Your task is to create a Java class named `CartItem` that includes the followi... | codefeedback |
You are tasked with implementing a Python function that interacts with a RESTful API for user authentication. The function should handle the retrieval of an access token, use it to fetch user data, and update the client's headers for subsequent requests. You are provided with a code snippet that demonstrates the usage ... | codefeedback |
You are tasked with creating a navigation system for a mobile application. The application uses a navigation service to move between different views. The snippet provided is a part of the code that handles the navigation logic.
The `_navigationService.NavigateTo` method is used to navigate to a specific view, in this ... | codefeedback |
You are tasked with creating a program that analyzes the frequency of words in a given text file. Your program should read a text file and output the frequency of each word in the file, sorted in descending order based on their frequency. For the purpose of this problem, a word is defined as a sequence of alphanumeric ... | codefeedback |
You are tasked with implementing a network serialization configuration system. The system should allow users to define and configure the serialization format for network communication. The serialization configuration should support various data formats such as JSON, XML, and binary, and it should be extensible to accom... | codefeedback |
You are tasked with creating a web application for managing job categories. The application has a page that displays a table of existing job categories and a form to add new job categories. The table is populated with data from a backend server and allows users to delete existing job categories. The frontend code snipp... | codefeedback |
You are tasked with implementing a function to parse and extract specific information from a given data structure representing an SVG image. The data structure is represented as an array in a specific format. The array contains the SVG tag followed by its attributes and nested elements represented as arrays. Each neste... | codefeedback |
You are given a partially obfuscated C code snippet that contains some variables and random characters. Your task is to reverse engineer the code and identify the variables and their types, and then write a function to perform a specific operation using those variables.
The variables in the code snippet are:
- ab
- Pg... | codefeedback |
You are working on a geographic information system (GIS) project and need to develop a function to calculate the area of overlap between two raster images. The raster images are represented as grids of pixels, and each pixel has a geographic location defined by its latitude and longitude coordinates. Your task is to wr... | codefeedback |
You are given a Python class `PuzzleSolver` with a method `solve(self)`. The `solve` method is intended to solve a puzzle, but it currently lacks the implementation for solving the puzzle when it is not already solved. Your task is to complete the `solve` method by implementing the puzzle-solving logic.
The `PuzzleSol... | codefeedback |
You are tasked with creating a Python class that parses and processes data from two different types of MINIDUMP files. The MINIDUMP files contain information about a process, including its ID, creation time, user time, kernel time, and, in the case of the second type of file, the maximum processor frequency.
Your task... | codefeedback |
You are tasked with implementing a data structure that can efficiently store and retrieve key-value pairs. The data structure should have the ability to keep a strong reference to the data source, ensuring that the data is not prematurely deallocated. Your task is to design and implement a class that fulfills these req... | codefeedback |
You are tasked with creating a Python class that implements a simple version of a priority queue using a list. The priority queue should support the following operations:
1. `insert(value, priority)`: Insert a value into the priority queue with the given priority.
2. `pop()`: Remove and return the value with the highes... | codefeedback |
You are tasked with implementing a simple text-based game where the player navigates through a maze. The maze is represented as a 2D grid, where each cell can be either a wall ('#') or an empty space ('.'). The player starts at the top-left corner of the maze and must reach the bottom-right corner. The player can move ... | codefeedback |
You are given a program that checks whether a given number is divisible by 4, 3, or 2. The program prints a message based on the divisibility of the number. Your task is to complete the program by writing a function that takes an integer as input and returns a message based on the divisibility of the number.
The funct... | codefeedback |
You are working on a ticket management system for a customer support application. The system uses Laravel framework, and you are responsible for implementing access control using Laravel's Gate feature. The `Ticket` model is located in the `App\Model\Customer` namespace. The `Ticket` model has various attributes such a... | codefeedback |
You are tasked with optimizing the performance of a data loading operation in a reading list application. The application uses an object store to manage the reading list data. The provided code snippet includes two test functions: `testLoadData` and `testLoadDataPerformance`. The `testLoadData` function initializes the... | codefeedback |
You are tasked with implementing a text formatting function for a styling language. The function should take an array of styling tokens and produce a formatted text output based on the token types and content. The styling tokens consist of three types: `StyleTokenType.TEXT`, `StyleTokenType.STYLE`, and `StyleTokenType.... | codefeedback |
You are tasked with creating a program that analyzes the frequency of words in a given text file. Your program should read a text file and output the top N most frequently occurring words along with their frequencies. For the purpose of this problem, a word is defined as a sequence of characters separated by spaces or ... | codefeedback |
You are tasked with implementing a custom iterator for a simplified version of the `SmallIndexMap` data structure. The `SmallIndexMap` is a map that stores key-value pairs in insertion order and provides constant-time access to its elements. Your goal is to create an iterator that allows for iterating over the key-valu... | codefeedback |
You are tasked with implementing a traffic simulation system using object-oriented programming in Python. The system will model the movement of vehicles on a road and will utilize simulation parameters to control the behavior of the simulation.
You are provided with a code snippet that includes a reference to a `vehic... | codefeedback |
You are given a code snippet that uses a custom programming language called "Ath" and its interpreter "TildeAthInterp". Your task is to understand the given code and answer a question related to its behavior.
The code snippet initializes a statement list `stmts` and contains a series of Ath statements and loops. The s... | codefeedback |
You are working on a project to develop a federated learning system using TensorFlow Federated (TFF). In this system, you need to calculate aggregates per client and build an aggregation function. The code snippet provided is a part of this project. Your task is to complete the aggregation function and ensure that it c... | codefeedback |
You are tasked with implementing a Base64 encoding and decoding algorithm. Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format by translating it into a radix-64 representation. The encoding process involves taking a sequence of bytes and converting it into a string of ASCII ... | codefeedback |
You are given a string containing a license text. Your task is to write a program to extract the license information from the text and display it in a structured format.
Your program should extract the following information:
1. License type (e.g., MIT, Apache 2.0, GPL)
2. License text (the actual license terms and con... | codefeedback |
You are given two binary trees `s` and `t`. Write a function `isSubtree` to determine if `t` is a subtree of `s`.
A subtree of a tree `s` is a tree consisting of a node in `s` and all of this node's descendants. The tree `s` could also be considered as a subtree of itself.
The `TreeNode` class is defined as follows:
... | codefeedback |
You are tasked with implementing a 2D point class in C++ to represent coordinates on a map. The class should have the following functionalities:
1. A constructor that takes x and y coordinates as input and initializes the point.
2. Methods to get and set the x and y coordinates.
3. A method to calculate the distance be... | codefeedback |
You are tasked with implementing a function that takes a string as input and performs a specific set of operations on it. The function should first check if the input string contains only alphabetic characters. If the string passes this check, the function should then convert all the lowercase letters to uppercase and ... | codefeedback |
You are tasked with implementing a version comparison algorithm that compares two version strings and determines which one is greater. A version string consists of a series of dot-separated numeric components, followed by an optional series of dot-separated alphanumeric pre-release identifiers. The comparison should fo... | codefeedback |
You are tasked with implementing a class-validator for the given TypeScript class. The class represents a location with a title, description, and address. Your goal is to use class-validator to ensure that the provided properties meet specific criteria.
The TypeScript class is as follows:
```typescript
import { ApiPr... | codefeedback |
You are given a stack data structure and are required to implement a function that sorts the stack in ascending order using only one additional stack. The original stack should be modified to be sorted without using any other data structures such as arrays or lists.
You need to implement the following function:
```cp... | codefeedback |
You are tasked with simulating a simple URL producer-consumer system using Python's threading module. The system consists of a producer thread and multiple consumer threads. The producer thread generates URLs and adds them to a shared queue, while the consumer threads retrieve URLs from the queue and process them.
You... | codefeedback |
You are tasked with implementing a class for managing players in a multiplayer game. The provided code snippet is a part of the class that retrieves the players present in a specific game room. The `getPlayersInRoom` method takes a room as a parameter and is expected to return a list of players currently in that room. ... | codefeedback |
You are tasked with implementing a program to perform 2D Delaunay triangulation on a set of points. Delaunay triangulation is a method for creating a triangulated irregular network (TIN) from a set of points in the plane, such that no point is inside the circumcircle of any triangle in the network. The program should t... | codefeedback |
You are tasked with implementing a URL routing system for a web application using Python's Django framework. The given code snippet represents a list of URL patterns and their corresponding view functions. Each URL pattern is associated with a specific view function and has a unique name.
Your task is to create a func... | codefeedback |
You are tasked with creating a Python program that processes a given C++ header file and generates a modified version with specific annotations. The program should read the input C++ header file, identify certain elements, and apply the required annotations before writing the modified content to a new file.
Your task ... | codefeedback |
You are tasked with implementing a rotary encoder class in Python. A rotary encoder is an electromechanical device used to convert the angular position of a shaft or axle to an analog or digital code. The provided code snippet is a part of the rotary encoder class and includes some initialization and a method for obtai... | codefeedback |
You are given a Python class `SegmentTree` that implements a segment tree data structure. The segment tree is represented as an array `SEG` of size `2*n-1`, where `n` is the number of elements in the input array. The class also contains a method `func` that takes two arguments and performs a specific operation on them.... | codefeedback |
You are tasked with implementing a simplified version of the Bitcoin block header validation algorithm. The Bitcoin block header contains several fields, including the extended private key prefix, the maximum target, the genesis block hash, and the genesis block bits.
The extended private key prefix is a hexadecimal v... | codefeedback |
You are given a code snippet in Swift that defines a generic class `A` and a protocol `B`. The class `A` has a weak reference to an object of type `T`, where `T` must be a subclass of `AnyObject`. The protocol `B` is defined as a class protocol. The code then attempts to print the value of the weak reference `a` of the... | codefeedback |
You are tasked with implementing a function that calculates the size of a given data type in bytes. The function should take a single argument representing the data type and return the size of that data type in bytes. You are provided with a code snippet that includes a match arm for the `f64` data type, which returns ... | codefeedback |
You are tasked with implementing a simple 2D rendering system for a game engine. The provided code snippet is part of the rendering pipeline and involves the functions `Begin2D`, `DrawRateStuff`, `GLRenderer->Flush`, and `Swap`.
The `Begin2D` function is used to initialize the 2D rendering context, and it takes a boo... | codefeedback |
You are tasked with implementing a parser for numerical expressions with signed numbers. Your task is to create a class that can parse and evaluate expressions containing signed integers. The class should handle both positive and negative integers and perform the necessary operations based on the signs.
Your task is t... | codefeedback |
You are working on a Java application that utilizes the Gson library for JSON serialization and deserialization. The given code snippet is part of a utility class that manages Gson instances and type adapters. Your task is to implement a method to unregister a type adapter from the Gson builder and provide a new method... | codefeedback |
You are tasked with implementing a class hierarchy for light transformers in a home automation system. The provided code snippet is a part of the implementation of the `LightOutput` class, which is responsible for creating default transitions for light effects. Your task is to design and implement the necessary classes... | codefeedback |
You are tasked with implementing a function that removes all occurrences of a specific character from a given string. Your function should take in the original string and the character to be removed, and then return the modified string with all instances of the specified character removed.
You are to write a function ... | codefeedback |
You are tasked with implementing a Particle Swarm Optimization (PSO) algorithm to optimize a given graph. The PSO algorithm maintains a population of particles, each representing a potential solution. The particles move through the search space, adjusting their positions based on their own best position and the best po... | codefeedback |
You are tasked with implementing a logging system for a Python application. The code snippet provided is a part of a logging function that calculates the time taken by a specific method and stores it in a dictionary. The `kw` dictionary contains various logging parameters, and the `te` and `ts` variables represent the ... | codefeedback |
You are tasked with creating a middleware function for a Redux store in a React application. The middleware should handle routing, state persistence, and action whitelisting. Your task is to implement the middleware function using the provided code snippet as a reference.
The middleware function should perform the fol... | codefeedback |
You are tasked with implementing a user throttling mechanism for an API using Python and Django Rest Framework. The provided code snippet includes the definition of a custom user throttle class called `OncePerDayUserThrottle`, which inherits from `UserRateThrottle` and sets the throttling rate to '1/day'. Additionally,... | codefeedback |
You are tasked with creating a Python function that processes HTML content and extracts specific information using BeautifulSoup and requests libraries. The function should take a URL as input, navigate to a specific link within the page, retrieve the content of that link, and then switch to using BeautifulSoup version... | codefeedback |
You are tasked with implementing a logging system for a distributed database management system. The system consists of multiple nodes, each running a MariaDB instance. The goal is to create a centralized logging mechanism that captures important events and status updates from each node.
You are provided with a Python ... | codefeedback |
You are tasked with implementing a Python code analyzer that can traverse and process different types of nodes in an abstract syntax tree (AST). Your goal is to extend the functionality of the existing code analyzer by implementing specific visit methods for different types of nodes.
You are provided with a partial co... | codefeedback |
You are working on a data processing task involving astronomical data. You have been given a file containing records of stars, each identified by a Hipparcos Catalogue number (HIP). The records are stored in a dictionary called `data`, where the keys are HIP numbers and the values are corresponding star records. Each r... | codefeedback |
You are tasked with implementing a simple interpreter for a custom programming language. The interpreter is responsible for processing lines of code and storing the results in memory. The code snippet provided is a part of the interpreter's logic for processing and storing values in memory.
The interpreter has a `memo... | codefeedback |
You are tasked with creating a custom exception class in C# that extends the functionality of the base Exception class. Your custom exception, named `KuttException`, should have the following features:
- It should inherit from the base Exception class.
- It should have a constructor that takes a string message as a par... | codefeedback |
You are tasked with creating a Swift function that interacts with the Uniswap V2 API to retrieve token information based on a given array of token addresses. The Uniswap V2 API uses GraphQL for querying data. Your function should take an array of token addresses as input, construct a GraphQL query, send a request to th... | codefeedback |
You are tasked with implementing a function that can parse and extract information from a given JavaScript code snippet. The code snippet represents a React component and includes a call to `getStaticProps` function. Your task is to extract the name of the function being exported and the name of the function being pass... | codefeedback |
You are tasked with creating a program to process user input for a mode menu in a game using Python and the Pygame library. The mode menu consists of four input fields labeled 'mode_input_1', 'mode_input_2', 'mode_input_3', and 'mode_input_4'. When the user types in the input boxes and presses the Enter key, the progra... | codefeedback |
You are tasked with implementing a simple command-line argument parser in C++ to parse and process user input. The parser should support parsing both options with values and standalone arguments.
Your task is to write a function `parseArguments` that takes a vector of strings representing command-line arguments and re... | codefeedback |
You are tasked with implementing a simplified version of a live auction system in Swift. The system involves creating a view model for auctions and defining a default auction view model creator function. The provided code snippet includes a class and a function related to this task. Your goal is to complete the impleme... | codefeedback |
You are tasked with creating a Python function that processes an audio file to calculate the Root Mean Square (RMS) amplitude of the audio signal. The RMS amplitude is a measure of the power of the signal and is commonly used in audio processing applications.
You are provided with a code snippet that loads an audio fi... | codefeedback |
You are tasked with implementing a custom list class in C# that extends the functionality of the built-in `List<T>` class. The custom list class, named `CustomList`, should have additional methods for sorting and filtering elements based on certain criteria.
Your task is to implement the `CustomList` class with the fo... | codefeedback |
You are tasked with creating a function that processes a given HTML code snippet and extracts the labels of all the form fields present in the snippet. The HTML code snippet will contain various form elements such as input fields, checkboxes, radio buttons, and select dropdowns, each wrapped in their respective form fi... | codefeedback |
You are tasked with creating a Python class that can parse a YAML file and provide specific functionality for accessing and manipulating the data within it. Your class should be able to load the YAML file, retrieve specific values, update existing values, and save the modified data back to the file.
Your task is to i... | codefeedback |
You are tasked with creating a function that processes an input array and returns a modified array or a null value. Your task is to implement the `foo` function in PHP, which takes an array as input and returns either a modified array or null. The function signature is as follows:
```php
function foo($x) : ?array {
... | codefeedback |
You are tasked with creating a program that analyzes the frequency of words in a given text file. Your program should read a text file and output the top N most frequently occurring words along with their frequencies. The program should ignore common stop words (e.g., "the", "and", "is") and should be case-insensitive ... | codefeedback |
You are tasked with simulating a simple booking system for rooms in a building. The building has multiple floors (referred to as "geschosses"), and each floor contains multiple rooms. The goal is to create a program that can efficiently manage the booking of rooms on each floor.
You are given a code snippet that initi... | codefeedback |
You are tasked with creating a Rust program that utilizes WebAssembly to implement asynchronous functions. Your goal is to write an asynchronous function in Rust and then call it from JavaScript using WebAssembly.
Your task is to complete the Rust function and the JavaScript code to properly handle the asynchronous b... | codefeedback |
You are tasked with implementing a pagination service for a user profile system. The system contains a list of recommended users, and the goal is to create a function that returns a paginated list of these recommended users. The function should take into account the page number, page size, and any optional filtering cr... | codefeedback |
You are tasked with implementing a function that takes a list of ranges and returns a list of all the numbers within those ranges. The ranges are represented as tuples, where each tuple contains two integers representing the start and end of the range (inclusive). If a range contains only one number, that number should... | codefeedback |
You are tasked with creating a Python function that simulates the process of adding a user to a group. The function should take two parameters: a username and a group name. The function should then return a string indicating the success or failure of adding the user to the group.
The function signature should be:
```p... | codefeedback |
You are tasked with implementing a simplified version of a batch call system for asynchronous operations. The system should allow adding calls to a batch and then executing them concurrently, returning a future that resolves once all the batched calls have been executed.
You are provided with a partial code snippet fo... | codefeedback |
You are tasked with implementing a simplified version of a message bus system using Rust. The message bus will be used to facilitate communication between different components of a system. The bus will support sending and receiving messages, and it will be thread-safe to allow concurrent access from multiple threads.
... | codefeedback |
You are tasked with implementing a file processing system that involves a `FileHelper` and a `StarsHelper`. The `FileHelper` interface provides methods for reading and writing files, while the `StarsHelper` interface offers functionality related to star ratings. You are given a code snippet that declares two variables:... | codefeedback |
You are tasked with creating a Python function that downloads a function file from an API and saves it to a specified output path. The function will take in the function name, function ID, version ID, and output path as parameters. You need to implement the function to perform the following steps:
1. Construct a notic... | codefeedback |
You are working on a project that involves processing stellar abundance data. You have been given a code snippet that contains a function `_prepare_pdf_data` which is responsible for preparing probability density function (PDF) data based on the means, standard deviations, and range of the stellar abundances. The funct... | codefeedback |
You are tasked with implementing a modified binary search algorithm to find the index of a target element in a rotated sorted array. The array has been rotated at an unknown pivot point, and it may contain duplicate elements. Your task is to write a function `search_in_rotated_array` that takes an array of integers `ar... | codefeedback |
You are tasked with implementing a custom data structure in Rust that simulates a fixed-size circular buffer. A circular buffer is a data structure that uses a single, fixed-size buffer as if it were connected end-to-end. When the buffer is full and a new element is inserted, it overwrites the oldest element. The circu... | codefeedback |
You are tasked with implementing a function that executes a specified callback within a transaction on a given IndexedDB store. IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs. The provided code snippet contains a helper function that wraps the trans... | codefeedback |
You are tasked with creating a program that processes a list of GitHub repositories and calculates the average number of stars for repositories within a specified range.
You are given a list of GitHub repositories in the following format:
```
<gh_stars>10-100
export * from './has-class';
```
Each line represents a Git... | codefeedback |
You are tasked with implementing a function to calculate the contour plots for a specific engineering analysis. The function `contour_2d` takes three arguments: a dictionary of parameters, a string specifying the type of analysis, and a subplot axis for visualization. The parameters in the dictionary include "plate_imp... | codefeedback |
You are tasked with implementing a function that processes time series data to calculate quantiles. The function takes an InstantVector representing the time series data, an optional Aggregate label, and a parameter of type f64. The function should return an InstantVector representing the quantile calculation based on ... | codefeedback |
You are given an array `input` of stock prices for a particular stock, where `input[i]` represents the price of the stock on the `i`-th day. Your task is to write a function to determine the maximum profit that can be obtained by buying and selling the stock at most once.
You need to implement the function `int maxPr... | codefeedback |
You are tasked with creating a database schema for a company's employee management system. The schema should include a table for employees with specific fields and constraints.
Create an SQL schema for the employee table with the following fields and constraints:
- id: an auto-incrementing primary key
- nome: a string... | codefeedback |
You are tasked with implementing a function to update an invoice with new line items. The function will take in the following parameters:
- `$invoiceId` (integer): The ID of the invoice to be updated.
- `$lineItems` (array): An array of line items to be added to the invoice. Each line item is represented as an associat... | codefeedback |
You are working on a natural language processing (NLP) project and need to implement a function that processes entity and relation vectors to create a graph vector. The function takes in entity vectors, relation vectors, and a case ID, and returns a graph vector.
You are given the following code snippet as a starting ... | codefeedback |
You are given a list of integers representing the scores of a game. The game has a rule that a player's score is the sum of the scores of the last two turns. However, if the player's score exceeds a certain threshold, the score for that turn is reduced to the threshold value. Write a function to calculate the final sco... | codefeedback |
You are tasked with implementing a simple text-based user interface for displaying data. The provided code snippet is a part of a Python class that manages the display of data in a text-based window. The class has a method `draw` that is responsible for rendering the data in the window. If the data is not available, it... | codefeedback |
You are given a set of asteroids in a 2D plane, each represented by its coordinates (x, y). The goal is to determine the 200th asteroid to be vaporized when a laser starts at a specific location and rotates around the asteroids in a clockwise direction.
Write a function `find_200th_vaporized` that takes in a dictionar... | codefeedback |
You are tasked with creating a whitelist filter for function names based on a given set of rules. The rules are defined using regular expressions, and any function name that matches the whitelisted patterns should be included in the final whitelist.
Write a function `filterFunctionNames` that takes a list of function ... | codefeedback |
You are given a 2D array representing a matrix of integers. Your task is to write a function that rotates the matrix 90 degrees clockwise.
For example, given the input matrix:
```
[[1, 2],
[3, 4]]
```
The function should return:
```
[[3, 1],
[4, 2]]
```
You need to implement a function `rotateMatrix(matrix)` that t... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.