instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
Given an array of integers, find the top k maximum values in the array and output them in descending order in JavaScript. However, you are not allowed to use any built-in JavaScript functions or methods that directly solve this problem, such as Math.max() or Array.prototype.reduce(). You must implement your own solutio... | codefeedback |
You are tasked with implementing a function that calculates the size of an icon for a React component based on the provided input. The function should handle both numeric and string inputs and should fall back to a default size if the provided size is not valid.
You are given the following code snippet as a starting p... | codefeedback |
You are tasked with creating a Python function that validates and processes database configuration settings for a Django application. The function should take a dictionary representing the database configuration and perform the following tasks:
1. Check if the 'default' key exists in the dictionary.
2. If the 'default'... | codefeedback |
Create an artificial neural network to recognize handwritten digits from MNIST dataset. | codefeedback |
from account import Account
import pandas
print("welcome to Ot's Bank App.\n")
new_account = Account()
print(new_account.account_details())
# 2. Store details in a csv file.
def csv_data_operations():
df = pandas.DataFrame.from_dict(new_account.account_details(), orient="index")
try:
user_data = ... | codefeedback |
Design an advanced alert system that continuously monitors a Kafka stream with relentless precision. When a new data event is detected, the system should adeptly utilize the capabilities of the Twilio API to send a corresponding SMS alert to a predefined mobile number. This will guarantee instant communication and swif... | codefeedback |
Design a Python program that examines a set of numerical values. The program should not only determine if each and every individual number in the set is a prime number, but also calculate the cumulative total of the prime numbers' digits. Furthermore, identify the highest prime number present in the set, and return a d... | codefeedback |
Write Python code to store odd numbers from the given list in a separate list. Additionally, the code should also remove any duplicate odd numbers from the new list. The code should not use any built-in functions or libraries to remove duplicates from the list, and it should also be implemented in a way that has a time... | codefeedback |
Has anybody got any kind of experience with dynamic programming using WCF. By dynamic programming I mean runtime consumption of WSDL's.
I have found one blog entry/tool:
[http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx](http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-prog... | codefeedback |
Generate a random string of length 10 made up of characters ‘a’ to ‘e’. Additionally, the string must contain at least two occurrences of the character 'a', exactly one occurrence of the character 'b', and the character 'c' must appear before the character 'd'. The characters 'b' and 'd' must not be adjacent to each ot... | codefeedback |
What is the largest factor of the prime factorization of 54,321 that is less than 54,321 and how would you calculate it? | codefeedback |
Create an Angular application for managing customer profiles. The application should consist of a form for collecting customer information, a page for displaying customer profiles, and a page for editing customer profiles. | codefeedback |
You need to design a database for a school where multiple students can have multiple tutors for multiple subjects. Additionally, each tutor can have multiple students for each subject they teach. However, there is a new requirement that each student can only have one tutor for a particular subject. What is the best way... | codefeedback |
Classify each word in this sentence into its specific part of speech, while also considering the tense and form of verbs, degrees of adjectives and adverbs, and distinguishing between common and proper nouns. Proper nouns must be capitalized. Additionally, implement a feature to detect and classify compound words as a ... | codefeedback |
You are tasked with creating a Rust function that simulates the behavior of the `fs::create_dir_all` function. The `fs::create_dir_all` function creates a new directory and all its parent components if they are missing. Your task is to implement a similar function called `custom_create_dir_all` that takes a path as an ... | codefeedback |
Create a sonnet that demonstrates the complexity of sibling rivalry through the depiction of a younger brother's poetic mastery and the older brother's crippling self-doubt. The sonnet should contain multiple instances of metaphorical imagery, one of which must portray the elder brother's writing as incoherent and unre... | codefeedback |
Create a React Native application for a shopping cart. This application should contain components for viewing the cart and adding items to the cart. | codefeedback |
You are tasked with implementing a Python class that manages a process and its associated PID file. The given code snippet is part of a class method that handles the reloading of the process. Your task is to complete the implementation of the `ProcessManager` class by adding the necessary methods to manage the PID file... | codefeedback |
Write a function which takes a list of lists, each containing floating point numbers, and returns the median value for each list as a tuple. The function should also handle cases where the lists contain erroneous data types and return an error message for those specific lists.
Additionally, below is a piece of code t... | codefeedback |
Complete the following C++ code to sort a two-dimensional array in ascending order based on the sum of each inner array.
int[][] arr = {{4, 9}, {2, 8}, {3, 1}};
Note: The sorting should be done using any sorting algorithm of your choice. | codefeedback |
Increase the difficulty of the given programming test question:
Remove the boilerplate code from the program for printing 10 random numbers. Instead, write a function that generates a sequence of n random numbers, where n is the input to the function. The function should return the sequence of random numbers.
The fun... | codefeedback |
Consider a scenario where a car travels along n different points at different speeds. The car starts from point A and travels to point n, then it returns back to the starting point A at a different speed. These various speeds are not uniform, they form an array of speeds both to and from the destination. The task is to... | codefeedback |
Implement an efficient sorting algorithm with a time complexity of O(n log n) to sort the given array in ascending order. You are not allowed to use any built-in sorting functions or libraries. | codefeedback |
Find the frequency of a given phrase in the text, considering case sensitivity and punctuation marks.
text = "This is a phrase that I want to find the frequency of. The phrase, phrase, is important!"
phrase = "phrase" | codefeedback |
Write an algorithm that finds the longest palindromic substring of a given input string. Additionally, the algorithm should have a time complexity of O(n) and should not use any extra space other than a constant amount of additional memory. The input string will have a length of at most 10^5.
# Difficulty Increase #
T... | codefeedback |
You are tasked with implementing a Python class that generates a sequence of dates based on a given start year. The class should have a method to initialize a dictionary with specific key-value pairs and another method to generate dates based on the start year.
You need to implement the following class:
```python
cla... | codefeedback |
Increase the complexity of the given programming task.
Revise and correct the erroneous code below, by including uncommon situations where elements are not integers or floating-point numbers:
def advanced_monotonic(l: list, strict: bool = False):
"""
Return True if list elements rise or fall monotonically, while con... | codefeedback |
Modify the following SQL statement to select only the rows with prices greater than 100 and quantities less than 50. Ensure that the result is ordered by the product name in descending order. However, the table "products" has been changed to "items" and the column "product_name" has been renamed to "name". SELECT * FRO... | codefeedback |
Create an HTML form that, when submitted, displays all the user input on the same page. Additionally, implement client-side form validation to ensure that all required fields are filled out before submitting the form. The form should also include a password field that must meet the following criteria: minimum length of... | codefeedback |
Construct a program that finds all prime numbers between 1 and 1000 in Python.
#Instructions#
Write a program in Python that finds and prints all prime numbers between 1 and 1000.
A prime number is a whole number greater than 1 that is divisible by only 1 and itself. For example, 2, 3, 5, 7, 11, and 13 are all prim... | codefeedback |
Write an R program to find the unique values in a vector and return them in descending order. | codefeedback |
You are tasked with writing a program to compare two sets of pixel data from two images and identify the differences between them. Each image is represented as a 2D array of pixel data, where each pixel is represented by a tuple of RGB values. Your task is to implement a function that takes in the pixel data before and... | codefeedback |
Create a function to format a given phone number in the format "123-456-7890" and output a string with the canonical format of "+1-123-456-7890". The function should also handle cases where the phone number is passed in as a string or with additional characters such as spaces or parentheses. | codefeedback |
Suggest a suitable algorithm for solving this problem efficiently.
An array of positive integers is given. Find the highest sum that can be obtained by including at most three different members from the array, such that no two members have the same index and the sum should be divisible by 4. Additionally, the algorithm... | codefeedback |
Develop a function to remove vowels from a given text. Additionally, the function should also handle edge cases such as punctuation, special characters, and numbers. The function should also be case-insensitive.
Here is a piece of erroneous code for reference:
```python
def remove_vowels(text):
vowels = ['a', 'e... | codefeedback |
| | Club | Played | Won | Drawn | Lost | Points for | Points against | Tries for | Tries against | Try bonus | Losing bonus | Points |
|---:|:-------------------|:---------|:------|:--------|:-------|:-------------|:-----------------|:------------|:----------------|:------------|:... | codefeedback |
Implement a modified version of the insertion sort algorithm that sorts an array of integers in descending order. The array should be sorted using the modified algorithm.
Input:
[3, 4, 8, 1, 5, 7, 2, 9, 6, 0]
Output:
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
Explanation:
In this modified version of the insertion sort algorithm... | codefeedback |
Invent a tertiary operator that generates distinctive color codes based on the humidity readings, specifically designed for a hydrological scenario.
var humidity = 45; | codefeedback |
Given a list of emails and corresponding info, write a code to keep only the emails and transform the list into a dictionary of emails and corresponding info. Each email must be validated to ensure it is in the correct format of [username]@[domain].[extension]. The dictionary should also include the length of each emai... | codefeedback |
Devise a function capable of mutating a given multidimensional list, to result in a new construct which encompasses elements that are essentially twofold of each numerical value constituting the original list.
original_list = [1, 2, [3, 4], 5] | codefeedback |
You are working on a web development project and need to create a component for displaying project items. The component should include various elements such as project item header, image wrapper, overlay, technology pills, and a "See More" link. You have been provided with the code snippet for the styled components use... | codefeedback |
I have an API Gateway resource which calls a Dynamodb post request to query a table. I'm trying to call the API within my React app using Axios. The API is working, returning the data as expected (console log) but I'm getting errors if I try to use @aws-sdk/util-dynamodb (unmarshall) to convert the api data.items res... | codefeedback |
Can you elucidate the concept of abstraction in the context of computer programming with a focus on its significance and contributions to program efficiency? Please include an explanation of data abstraction in object-oriented programming (OOP). For a more practical aspect, kindly debug the following code that was desi... | codefeedback |
You are tasked with creating a Python program to control a robot's movements using the `rosebot` library. The robot is equipped with a camera and can perform various actions based on the data it captures. Your goal is to implement a program that utilizes the robot's capabilities to perform specific movements and action... | codefeedback |
Reverse the words of a given sentence but keep the order of the words intact.
I am a programmer | codefeedback |
Given a 2D matrix of integers, retrieve the maximum sum submatrix. The matrix may contain negative integers. If the matrix is empty, return 0 as the maximum sum. If multiple submatrices have the same maximum sum, return any one of them.
Example:
Input: [[2,-2,3,4],[-4,-3,1,1],[-1,5,5,-3]]
Output: 14
Input: [[-1,-2],... | codefeedback |
You are tasked with implementing a simplified version of a messaging system using Python. Your goal is to create a class that manages users and allows sending messages to specific users. The provided code snippet includes a method for sending messages to users and the beginning of a class for managing Line users.
Your... | codefeedback |
You have been given a list of user details (Names, Addresses etc) along with their occupations. Write a code to filter out the users whose age is more than 21 and whose occupations are not 'Engineer'. Additionally, you need to sort the filtered users by their addresses in ascending order. The filtered list should only ... | codefeedback |
Recreate this nested for loop in a single line of code, using list comprehension. The final list should only contain even numbers and each number should be multiplied by 2. Additionally, the final list should be sorted in descending order. Final_list = [2*(i+j) for i in range(10) for j in range(10) if (i+j)%2 == 0]. Th... | codefeedback |
Employing the cryptographic method known as a monoalphabetic substitution cipher, encode the following string to enhance its security profile:
thisisasupersecurestring | codefeedback |
Create a computer program that takes a string as an input and builds a dictionary of words and their respective frequencies. The program should also ignore any punctuation marks and convert all words to lowercase before counting their frequencies. Additionally, the program should remove any stop words from the input st... | codefeedback |
You are given a code snippet that defines a custom comparison function and a function to create a priority queue using this comparison function. Your task is to implement a function that uses this priority queue to find the minimum spanning tree (MST) of a given graph.
You are provided with the following structures:
`... | codefeedback |
Write a PHP function that takes an array of integers as input and returns a new array containing only the prime numbers from the input array. The function should also remove any duplicates in the input array before checking for prime numbers. Additionally, the function should utilize a multithreading approach to improv... | codefeedback |
Write a Python function that takes a positive integer as an argument and returns the square of that number, using only bitwise operations and without using the multiplication operator.
However, you are not allowed to use any looping constructs or conditional statements. You can only use bitwise operations such as bit ... | codefeedback |
Remove all the elements from a given 2D array which are prime numbers. Additionally, provide a function in your solution that generates the 2D array with random integers ranging between 1 and 100, and implements a control structure that minimizes the possibility of creating prime numbers. Demonstrate your solution with... | codefeedback |
You are tasked with implementing a function to simulate a changepoint process for a time series dataset. The function should accept the following parameters:
- `data`: A 1D array representing the time series data.
- `num_changepoints`: An integer specifying the number of changepoints to simulate.
- `nu`: A float repres... | codefeedback |
Implement Naive Bayes for classification considering Laplace smoothing and missing values.
Consider the provided piece of code with an error as a reference:
```python
def naive_bayes(train_data, test_data, label_col, classes=[0, 1]):
train_data[label_col] = train_data[label_col].fillna(-1)
test_data[label_col... | codefeedback |
Could you delve into the mechanism of hoisting in JavaScript, elucidating its process, and subsequently illustrate its potential pitfalls by showcasing a scenario where its operation might result in unanticipated outcomes? | codefeedback |
Design an algorithm to find the longest increasing subsequence in an array.
input = [9, 8, 4, 12, 2, 10, 6, 14, 1, 16, 3, 11, 5, 15, 7] | codefeedback |
Given an unsorted array of integers, implement a function to insert a new element at the beginning of the array without using any built-in array functions or methods. The function should have a time complexity of O(1) and space complexity of O(n), where n is the number of elements in the array.
#Reasoning Steps#
1. De... | codefeedback |
You are tasked with implementing a function that performs authenticated encryption using a specific set of parameters. The function takes in a message, its length, additional data, and the length of the additional data. Your goal is to write a function that encrypts the message and authenticates the additional data usi... | codefeedback |
Given an integer array, output the largest sum of all the possible subarray sums. The subarray must have a length of at least 3 and cannot include adjacent elements. Additionally, the subarray must be a contiguous subarray, meaning all the elements are adjacent to each other in the original array. Use Python for the so... | codefeedback |
Create a function that ingests a list with sublists of integers, calculates the product for each sublist, then returns the median value of those products. Treat your input list like mat = [[2, 3, 4], [5, 6, 7], [8, 9, 10]]. | codefeedback |
Debug and optimize the following JavaScript code. Your solution should include error handling, potential edge case considerations, and performance improvements. Implement an efficient way to isolate and test each modification you propose.
```javascript
function greetPlanet() {
document.write('Greetings, ' + 'Earth')... | codefeedback |
Calculate the Hamming distance of two binary strings, where the length of the strings can be up to 10^6. | codefeedback |
Create a function "calculate_area" which calculates the area of a polygon with n sides. The function should take in a list of tuples representing the coordinates of the vertices of the polygon. The function should return the area of the polygon.
For example, given the list of tuples [(0, 0), (0, 1), (1, 0)], the funct... | codefeedback |
Write a CSS rule that changes the color of all the links in a webpage to blue, but only if they are within a specific div with the class "menu". Additionally, the CSS rule should only apply to the links that have a specific data attribute called "data-custom-link". | codefeedback |
Let's build an advanced backend system that can handle an inventory of medical products, with an additional requirement to track the expiration dates of each product. You can use any programming language to complete this task, and we kindly request that you spend two to four hours on it (you may split this time up over... | codefeedback |
You are tasked with implementing a class for registering auxiliary data types in a data processing system. The system should prevent registering two auxiliary data types with the same name but incompatible types. Your task is to design and implement the registration mechanism and ensure that attempting to register a du... | codefeedback |
Can you help me resize this SVG to fit a 500x500 canvas?
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14.3675 5.87431L10.6615 3.30015C10.2652 3.02489 9.72534 3.12861 9.44275 3.51981L1.77125 14.5646C1.496 14.9609 1.59462 15.5081 1.99091 15.7833L5.69698 18.3575... | codefeedback |
I'm looking for a way to set the default language for visitors comming to a site built in EPiServer for the first time. Not just administrators/editors in the backend, people comming to the public site. | codefeedback |
Construct a dynamic HTML document incorporating a complex search engine interface with real-time auto-suggestion and pagination features. Include an option to filter results based on multiple parameters. Integrate this with an existing SQL database through Ajax calls. This must be done in pure JavaScript. | codefeedback |
You are tasked with implementing a constraint satisfaction problem (CSP) solver in Rust. A CSP consists of a set of variables, each with a domain of possible values, and a set of constraints that specify the allowable combinations of values for different variables. Your task is to implement the `Constraint` struct and ... | codefeedback |
Construct an interactive HTML structure with form functionalities permitting the end-user to proactively input and transmit their personal contact information. | codefeedback |
Given a list containing strings, write a Python program to filter out unique strings and return them in descending order based on their lengths. However, if a string starts with a vowel, it should not be included in the output. The output list should also be sorted alphabetically if multiple strings have the same lengt... | codefeedback |
Write a python function to find the sum of xor of all pairs of numbers in the given list. Additionally, implement a second function that calculates the sum of the bitwise AND operation for all pairs. Compare the results of both functions and discuss the differences in their outputs. | codefeedback |
You are tasked with implementing a Python class that simulates a heart rate monitor. The class should send heartbeat messages to a flight controller at a specific frequency using the rospy library for ROS (Robot Operating System).
Your task is to complete the `send_heartbeat` method of the `HeartRateMonitor` class. Th... | codefeedback |
Write a function to check if a number is a power of 2, using bitwise operations.
The function should have a time complexity of O(1) and a space complexity of O(1).
The number should be represented in binary and have exactly one '1' bit set. | codefeedback |
Increase the difficulty of the given programming test question by adding additional features and complexity:
Create a class in Java which stores the details of a book (title, author, ISBN, publication year) and also keeps track of the number of times the book has been borrowed.
Implement a method to calculate the ave... | codefeedback |
Swap the values of two given variables without using a temporary variable. Additionally, ensure that the solution works for variables of any data type.
You are given two variables, `x` and `y`, with the following initial values:
```
x = 10
y = "hello"
```
Write a program to swap the values of `x` and `y` without usin... | codefeedback |
Given a 2D array, implement a function `count_integers(arr: List[List[int]]) -> int` that counts the number of integers in the 2D array. The 2D array may contain lists of different lengths, negative integers, and duplicate integers. Additionally, count and return the number of distinct integers in the given 2D array. Y... | codefeedback |
Write a function in Python to sort this dictionary by values in descending order.
my_dict = {"Jerry": 10, "Marcus": 3, "Hanna": 5} | codefeedback |
You are tasked with implementing a method to manage electric cables in a virtual world. The method `breakBlock` is responsible for removing electric cables when a block is broken in the world. The method takes in the world, position, and block state as parameters. If the block at the given position has a corresponding ... | codefeedback |
You are tasked with implementing a custom model in a Django application for managing events. The provided code snippet is the beginning of the `Event` model class, which inherits from the `GeneralModel` class in the `eventup.utils.models` module. Your task is to complete the implementation of the `Event` model by addin... | codefeedback |
I am faced with this challenge: Identify the Central Node of a Star Graph
The details are as follows: You are presented with a star graph, an undirected graph that consists of `n` nodes, each distinctly labeled from `1` to `n`. A star graph is characterized by a single central node that is directly connected to the rem... | codefeedback |
Construct a for loop in Python to find the sum of all prime numbers between 50 and 100 (inclusive). | codefeedback |
You are given a Python code snippet that processes an image to create a heat map. The code uses nested loops to iterate over the pixels of the image and applies a distance-based calculation to update the heat map. Your task is to implement a function that encapsulates this image processing logic.
Write a function `gen... | codefeedback |
Augment the provided coding challenge to incorporate the task of pinpointing the fitting swap candidates to rectify a given sequence:
Fill in the missing part for the following function:
def find_swap_pairs(sequence):
"""Devise a function that generates a dictionary comprising of the maximal index of
a compo... | codefeedback |
Write a CSS code to align the text within a `<div>` element horizontally to the right. The code should not use the `text-align` property, the `float` property, or any other CSS properties or attributes to achieve the desired result. Additionally, the code should only use pure CSS and not rely on any JavaScript or other... | codefeedback |
Given a piece of erroneous code below:
```
def distinct_characters(phrases):
for phrase in phrases:
distinct_chars = len(set(phrase))
return distinct_chars
```
This function currently just returns the number of distinct characters in the last phrase it operates on, instead of each phrase individually.... | codefeedback |
You are tasked with implementing a program to calculate the value of a specific variable based on given input. The program should take into account the provided code snippet and additional context.
Context:
The given code snippet is part of a larger program that performs calculations based on certain input parameters.... | codefeedback |
Construct a programming function capable of determining whether a given word exhibits palindromic characteristics.
Word: racecar | codefeedback |
Write a program that accepts a series of hexadecimal values of uppercase letters as input. Convert these values to their corresponding ASCII characters and also provide an option to switch to conversion from ASCII characters to hexadecimal values of corresponding uppercase letters. The program should handle invalid inp... | codefeedback |
Create an SQL table to store information about books, authors, and publishers. Additionally, ensure that the table has proper constraints to enforce referential integrity, such as foreign key relationships between the books and authors, as well as books and publishers. Implement a trigger that automatically updates the... | codefeedback |
Write a python code to generate all possible permutations of an input string with duplicate characters.
For example, given the input string "aba", the expected output should be ["aab", "aba", "baa"]. | codefeedback |
I have this problem : Minimum Number of Steps to Make Two Strings Anagram with Constraints
Description are as below: Given two equal-size strings `s` and `t`. In one step you can choose any character of `t` and replace it with another character. Additionally, you are given a third string `p` which contains the only cha... | codefeedback |
Write a program that takes a sentence as input and determines the syntactic structure of each word in the sentence. The program should identify the part of speech (noun, verb, adjective, etc.) for each word, including specific subcategories such as transitive or intransitive verbs, countable or uncountable nouns, and c... | codefeedback |
Write a function that takes a string and prints every character in a single line. The string should only contain lowercase letters. Additionally, the function should return the number of vowels and consonants present in the string. | codefeedback |
Explain in detail what type hints are in Python and how they can be used in function definitions and variable declarations. Additionally, elaborate on the benefits of using type hints for static type checking and provide specific examples of how type hints can be used effectively in different scenarios. | codefeedback |
How can you reverse a given string using a while loop, without using any built-in string reversal functions? Additionally, you are not allowed to use any additional variables to store the reversed string.
string = "hello"
*Rewritten test with increased difficulty:*
How can you reverse a given string using a while lo... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.