instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write an SQL query that displays a table of the ten most commonly used words in the given article, excluding common stop words such as "the", "it", and "and". Additionally, include the count of each word, the average length of the words, and sort the table in descending order based on the word count. | codefeedback |
Create a Javascript function which takes an array as an argument and returns an array with the elements in reverse order. The function should also remove any duplicate elements from the original array and sort the remaining elements in descending order.
Input: [5, 4, 3, 2, 1, 2, 3, 4, 5]
Output: [5, 4, 3, 2, 1] | codefeedback |
Create a while loop to print all elements of a nested array in reverse order, with each element separated by a comma and a space.
Add a constraint: Do not use any built-in functions or methods to reverse the array or join the elements together.
Add a reference code snippet that attempts to reverse the array using a bui... | codefeedback |
Write a Python function that takes in a list of integers and returns a new list containing only the prime numbers from the original list. The function should also sort the prime numbers in ascending order and remove any duplicates from the resulting list. | codefeedback |
Design a Spring Boot class that provides a bean of type String to the application, but the String must be a palindrome and have at least 10 characters. Additionally, the class should implement a custom algorithm to check if the palindrome is a prime number and provide a method to return the prime factors of the number. | codefeedback |
Create a condition statement to check if all elements in a list are unique, are in ascending order, and are even numbers. The time complexity should be less than O(n^2). Additionally, the function should return the total count of unique elements and the sum of all elements in the list. | codefeedback |
Write a function to reverse a doubly linked list in O(n) time complexity. However, you are not allowed to use any additional data structures or modify the values of the nodes. | codefeedback |
Write a query in MySQL to find the particular employee's salary from an employee table, but only for employees who are under the age of 30, have a salary greater than $25,000, and have been working in the company for more than 2 years.
#Reasoning Steps#
1. Select the desired columns (e.g., employee ID, employee name, ... | codefeedback |
Write a Python function that takes the title of a movie as input and returns its IMDB rating. You can assume that the movie title will be a string and the IMDB rating will be a floating-point number. Additionally, you should handle cases where the movie title does not exist in the IMDB database and return an appropriat... | codefeedback |
In Ruby, write a method that finds the sum of all numbers from the given string and returns the sum as an array of digits. The string may contain multiple occurrences of the word "sum" and each occurrence should be treated separately. The method should also handle negative numbers and decimals in the string. The sum sh... | codefeedback |
Create a class in C++ for a circle which includes radius, diameter, circumference, and area as member variables. Implement member functions to calculate and return the diameter, circumference, and area of the circle. Additionally, include a member function to check if a given point (x, y) lies inside the circle. The ci... | codefeedback |
Write a function that takes in an array of positive integers and returns a new array where the elements are reversed, but only for odd integers. If an even integer is encountered, it should remain in its original position. Additionally, the function should sort the resulting array in descending order. The function shou... | codefeedback |
Create a function in JavaScript that finds the maximum number between two given numbers, but without using the built-in Math.max() function or any looping constructs (e.g., for loops, while loops, recursion).
#Updated Test# | codefeedback |
Insert 1000 random unique numbers between 0 and 1000 in a list, without using any built-in functions for random number generation. | codefeedback |
Create a MySQL trigger to store the times for insertion and updating a row in a table. Additionally, ensure that the trigger only captures the time if the inserted or updated row meets the following conditions:
1. The value of a specific column must be greater than a certain threshold.
2. The value of another specific... | codefeedback |
Create a function in python to print all prime numbers between two given values. Do not include the two given values in the output.
Additionally, implement the following optimizations in your solution to increase the difficulty:
1. Use the Sieve of Eratosthenes algorithm to efficiently generate all prime numbers up to... | codefeedback |
Design a data structure in Java to store and sort a list of customers by their age, name, and a randomly generated unique ID. Ensure that the sorting algorithm used has a time complexity of O(n log n) or better. The unique ID should be a combination of alphanumeric characters and should be exactly 10 characters long. A... | codefeedback |
Create a MongoDB query to find all the documents containing the string "Apple" in the field "Company" and the documents must also have a numeric value greater than 100 in the field "Price". Additionally, the query should return the documents sorted in descending order based on the "Price" field. | codefeedback |
Write a JavaScript function that takes an array of sentences and returns an array of the lengths of each word in those sentences. However, the function should also remove any punctuation marks (such as commas, periods, and exclamation marks) from the sentences before calculating the lengths of the words.
#Example Inpu... | codefeedback |
Write a Python program to parse a text string given a regular expression and return the matches. However, you must implement the regular expression parsing algorithm from scratch without using any built-in regular expression libraries or functions. Additionally, the program should handle regular expressions with specia... | codefeedback |
Reset the input fields in a React Native form after submitting the form. The form should also clear any error messages that were displayed. Additionally, implement a loading state to indicate that the form is being submitted and disable the submit button during this time. Ensure that the loading state is accompanied by... | codefeedback |
What type of optimization algorithm is used in the following snippet of code?
weights = np.random.rand(2, 1)
for epoch in range(100):
predictions = predict(x, weights)
gradients = calcluate_gradients(x, predictions, y)
weights -= gradients * learning_rate
Additionally, the learning_rate is updated every 1... | codefeedback |
Write a custom CSS class to add a 5px dashed red border around a button with text size as 24px. Additionally, add a hover effect that changes the border color to green when the button is hovered over.
To increase the difficulty, you can include the following requirements:
1. Make the border animate smoothly when the ... | codefeedback |
Create a TensorFlow neural network model to classify animals into 100 categories, where each category represents a specific species of animal. Additionally, the model should be able to handle real-time video input for animal classification. | codefeedback |
Create a web application that allows users to create an account and log in. Implement server-side validation to check if the email address entered is valid or not. Additionally, implement server-side validation to check if the password entered is strong or not. The password should meet the following criteria:
- At leas... | codefeedback |
Create a program that takes in a numeric value, X, and prints all the positive divisors of that number in ascending order. Additionally, the program should calculate the sum of all the divisors and print it. X will be an integer greater than 1 and less than or equal to 100.
However, your program should also handle the... | codefeedback |
Print out the Fibonacci series up to a given number, but only if the number is both prime and a perfect square.
n = 10 | codefeedback |
Create a function that takes in a positive integer greater than 1 and returns true if the number is a prime number and false if it is not. The function should also check if the input is within the range of 2 to 10^9, inclusive. Additionally, optimize your solution to have a time complexity of O(sqrt(n)) where n is the ... | codefeedback |
Write a function which will print out a given pattern, where each line contains a combination of '#' and '$' characters. The number of '#' characters on each line must be equal to the line number, while the number of '$' characters must be equal to the difference between the total number of lines and the line number. A... | codefeedback |
Create an array of random integers from -100 to 100, ensuring that the array contains at least 100 elements. Implement a sorting algorithm to sort the array in ascending order without using any built-in sorting functions. Finally, calculate the sum of all positive elements in the array. | codefeedback |
Write a class that implements an arithmetic operator and returns the result of the operation. The class should support addition, subtraction, multiplication, and division operations. The input numbers can be positive or negative integers and the result should be an integer as well. Your implementation should include pr... | codefeedback |
Edit the given code to use dynamic programming and memoization to solve the problem. The time complexity should be O(n^2) and the space complexity should be O(n).
def rod_cutting(arr, n):
if n <= 0:
return 0
dp = [-1] * (n+1)
return rod_cutting_helper(arr, n, dp)
def rod_cutting_helper(arr, n, dp)... | codefeedback |
Create a function that takes an array of arrays of numbers, calculates the sum of the numbers across all the arrays, and returns the average of those sums. Each array within the main array can have a different length.
arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12, 13]]
Additional Requirements:
1. The function s... | codefeedback |
What does the "static" keyword do in Java? Explain with examples and provide a detailed explanation of how it works in different scenarios. Additionally, provide the pros and cons of using the "static" keyword in programming and discuss any potential performance implications. | codefeedback |
Describe in detail how a web server handles a request, including the various components, protocols, and processes involved. Additionally, discuss the potential challenges and optimizations that can be implemented to improve the performance and security of the web server. In your implementation, ensure that the web serv... | codefeedback |
Given the following code, find the output. Your solution should have a time complexity of O(n) and a space complexity of O(1), where n is the input number.
def f(x):
if x == 0 or x == 1:
return 1
return f(x-1) + f(x-2)
print(f(10)) | codefeedback |
Create an algorithm in JavaScript to sort an array of numbers in descending order without using any built-in sorting functions or methods. | codefeedback |
Use Python to reverse the order of a string input, while also ensuring that all vowels in the original string are replaced with the corresponding vowel from a given list of replacements. Additionally, the program should ignore any non-alphabetic characters in the string input. | codefeedback |
Create a Flask application to display a web page containing a random quote fetched from an external API. However, the web page should also include a button that, when clicked, fetches and displays a new random quote. Additionally, implement a feature where the web page keeps track of the number of times the button has ... | codefeedback |
Given the following data structure, write a function that takes three arguments: the object, the property name, and a boolean flag. The function should return the value of the specified property from the object only if the boolean flag is set to true. Otherwise, it should return an empty string.
Additional Requirement... | codefeedback |
Write the SQL query to select the second last element of a table where the name column is "John" and the age column is greater than 25, ordered by the salary column in descending order. If there are multiple records with the same salary, consider the one with the earliest date of birth as the second last element.
tabl... | codefeedback |
Create a JSON from a given array that contains objects with the following properties: id (a randomly generated 10-digit number), name (a randomly generated 20-character string), and age (a randomly generated number between 10 and 100). The array should have a length of 10,000.
Additionally, ensure that each id in the ... | codefeedback |
Create a Java class named "MyClass" with three methods - getName(), setName(), and displayName(). Additionally, implement a static variable called "counter" to keep track of the number of instances of "MyClass" that have been created. Increment the counter variable every time a new instance of "MyClass" is created and ... | codefeedback |
Round the number 3.1415 to the nearest hundredth and print it as a fraction, where the numerator and denominator are both integers. Your solution should handle numbers up to 10^6 and return the simplified fraction. | codefeedback |
Create an array with 5 elements, where the first element is the sum of the first and second element of the previous array, the second element is the difference between the first and second element of the previous array, the third element is the product of the first and second element of the previous array, the fourth e... | codefeedback |
Write a SQL query which returns the names, ages, and departments of all employees who have a salary higher than the average salary of all employees in the 'employees' table, and have worked in the company for at least 5 years. | codefeedback |
Use Predicate logic for representing the following statement with the additional requirement:
"An elephant only lives in an African safari, has a lifespan of at least 50 years, and can only eat certain types of plants that are found exclusively in its habitat." | codefeedback |
Write a function that returns the second largest number in the given array without using any built-in sorting or max functions. Additionally, provide a piece of erroneous code that attempts to solve the problem but produces an incorrect output.
[3, 5, 22, 11, 16, 9] | codefeedback |
Create a function in Python which checks if an input value is a prime number or not. The function should return True if the input value is prime, and False otherwise.
Requirements:
- The function should have a time complexity of O(sqrt(n)), where n is the input value.
- The function should have a space complexity of O... | codefeedback |
Design a program to count the total number of even numbers in a given array, but now the program should also output the sum of all the even numbers in the array. Additionally, the program should handle arrays with a size of up to 10^9 elements.
Furthermore, the program should also check for any duplicate even numbers ... | codefeedback |
Design an algorithm in JavaScript to check if a given string consists of only unique characters. The string may contain any printable ASCII characters. The algorithm should have a time complexity of O(n^2) and use constant additional space.
#Solution#
To solve this problem with a time complexity of O(n^2), we can use ... | codefeedback |
Define a function in R which takes two arguments, both of which are positive integers less than 1000, and finds their average. The function should handle cases where the input arguments are not positive integers or are greater than 1000, and should return an error message in such cases. The function should also round t... | codefeedback |
Develop an HTML page in which you can display a message to the user. The message should be centered on the page, with a font size of 20px. The page should also include a button that, when clicked, changes the color of the message to red. Additionally, the page should have a counter that keeps track of the number of tim... | codefeedback |
Convert the given context free grammar to Chomsky Normal Form.
S --> AaBb
A --> aAa | bA | a | b
B --> bBa | aB | a | b
#Revised Test#
Convert the given context free grammar to Chomsky Normal Form. The solution should have a time complexity of O(n^3) or better.
S --> AaBb
A --> aAa | bA | a | b
B --> bBa | aB | a | ... | codefeedback |
Develop a Java code which assigns each element of an array of integers to an individual variable. The code should also calculate the sum of all the elements in the array and display it as output. Additionally, the code should check if any of the elements in the array are negative, and if so, throw an exception with an ... | codefeedback |
Optimizing our data structures through rigorous research and algorithmic analysis allowed us to efficiently utilize our resources and achieve significant performance gains. | codefeedback |
Write a SQL query to find the number of customers who have made more than 10 orders in the last 30 days, while also counting the number of orders made by each customer in the last 30 days. The query should return the customer's state, name, and the count of orders made. Consider only customers who have made orders in t... | codefeedback |
Write a query in PostgreSQL for deleting a table, but before deleting the table, check if it exists in the database. If the table exists, prompt the user to confirm the deletion. If the user confirms, delete the table along with any associated constraints and indexes. Additionally, log the deletion activity in a separa... | codefeedback |
Create HTML code for a responsive web page that has a centered title, a logo, a dynamic colorscheme, and a responsive navigation menu. The navigation menu should have links to at least 5 different pages of the website. The colorscheme should change randomly every time the page is refreshed.
Title: "My Awesome Website... | codefeedback |
Design a C++ class called `AdvancedCalculator` which performs advanced arithmetic operations such as exponentiation and modulus. The class should have the following functionalities:
1. Exponentiation: Implement a method `long long int power(int base, int exponent)` that takes two integers `base` and `exponent` as argu... | codefeedback |
Create a Python program that prints out the sum of all even numbers between 0 and the given number n. The program should also print the count of the even numbers and display the average of the even numbers. Additionally, the program should validate that n is a positive integer greater than 0. | codefeedback |
Write a Python function to create a dictionary with the given list as its keys and values, where each value is a list of integers. The length of the list should be determined by the index of the key in the given list. The function should also handle cases where the list contains duplicate elements, and in such cases, t... | codefeedback |
Rewrite the following instruction to print the binary value it holds using only bitwise operations, without using any loop or conditional statements.
int n = 12; | codefeedback |
When would you use a while-loop in Python? Provide a detailed explanation and give an example of a specific scenario where a while-loop would be necessary and how it would be implemented. Additionally, ensure that the solution includes handling of exceptions and error messages to enhance robustness and error handling i... | codefeedback |
Create a function called "multiply_dict_values" that takes in a dictionary as input and returns a new dictionary where the keys are multiplied by their respective values in the input dictionary. However, if the input dictionary contains any negative values or non-integer values, the function should raise a ValueError w... | codefeedback |
Create HTML code for a table that has 10 columns and 10 rows. Each cell in the table should display the sum of its row and column numbers. Additionally, the background color of each cell should be randomly generated. | codefeedback |
Write a Java method to remove all whitespaces and punctuation marks from a string, reverse the order of the remaining characters, and convert all letters to lowercase. | codefeedback |
Replace a commonly used requirement in the programming task with a less common and more specific one.
You are given two arrays of characters: array1 and array2, both with a length of 10. The goal is to copy the content of array1 to array2 using a recursive function. However, the recursive function must not use any loo... | codefeedback |
Create a shell script that, given a directory as an input, prints out the names of all subdirectories in that directory. However, exclude any subdirectory that contains the word "test" in its name. Additionally, exclude any subdirectory that is empty. Finally, sort the resulting subdirectory names in descending order b... | codefeedback |
How would you create a function in Python to add two lists of numbers element-wise, where each list can have varying lengths?
## Problem Description
You are given two lists, `list1` and `list2`, which contain numbers. The length of `list1` and `list2` may vary. Your task is to create a function `add_lists(list1, list... | codefeedback |
Write a C++ program to find all pairs of prime numbers whose sum is also a prime number, within a given range. | codefeedback |
Write a Python function that takes a list of numbers and returns the mean, median, mode, and standard deviation of that list. Additionally, the function should be able to handle cases where the list contains non-numeric values or is empty.
The mean of a list of numbers is the sum of all the numbers divided by the tota... | codefeedback |
Implement a class hierarchy for a simple banking system. The system should have a base class Account, with subclasses CheckingAccount and SavingsAccount. The Account class should have the following attributes: account_number (string), account_balance (float), and interest_rate (float). The CheckingAccount class should ... | codefeedback |
Write a Java program to get the day of the week from a given Date object, but do not use any built-in date or time libraries or classes. The program should consider leap years and should correctly calculate the day of the week for any given date from January 1, 1900, to December 31, 2100. | codefeedback |
Create a for loop that prints the sum of all odd numbers between 1 and 100. Additionally, implement a nested if statement within the loop to skip the number 57. | codefeedback |
Create a PHP script to calculate and print out the sum of the first 1000 Fibonacci numbers, but without using recursion. | codefeedback |
Design an algorithm to determine if a given string contains a valid email address. Additionally, the algorithm should be able to handle multiple email addresses in the same string and return all valid email addresses found. | codefeedback |
Reverse each word in this sentence and then sort them in alphabetical order: "I can do coding." | codefeedback |
Rewrite the following JavaScript program using ES6 syntax. Additionally, modify the program to only push numbers that are divisible by 3 and have a digit sum greater than 10 into the result array.
let result=[];
for (let i=0;i<array.length;i++) {
let sum = 0;
let num = array[i];
while (num > 0) {
sum += num... | codefeedback |
Please create a class in JavaScript to encapsulate user information. The class should have the following additional requirements:
- The user's email address should be stored as a private property and should be validated to ensure it is in the correct format (e.g., "example@example.com").
- The user's password should be... | codefeedback |
Compute the average of the following ten numbers: 7, 12, 18, 23, 29, 34, 40, 45, 51, and 56. However, you are not allowed to use any arithmetic operators (+, -, *, /) or the built-in average function in your solution. Additionally, your solution must have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Use an object-oriented approach to create a Java class to store the temperature, humidity, and wind speed from a weather forecast. The class should have the following functionalities:
1. Allow the user to set and get the temperature, humidity, and wind speed values.
2. Implement error handling to validate that the tem... | codefeedback |
Create a function called "fizzBuzz" that takes in an integer as an argument and returns a string. The function should print "Fizz" if the number is divisible by 3, "Buzz" if the number is divisible by 5, and "FizzBuzz" if the number is divisible by both 3 and 5. The function should also handle negative numbers and retu... | codefeedback |
Write a C++ program to calculate the shortest path between two points in a weighted directed graph using Dijkstra's algorithm. The graph is represented by an adjacency matrix and each edge has a positive weight associated with it. The program should output the shortest path length, the sequence of vertices visited in t... | codefeedback |
Given the object below, debug the problem to make a valid code in JavaScript. The code should include proper error handling for invalid inputs.
```javascript
let obj = {
name: 'John',
age: 20,
printDetails: () => {
console.log(`The name is ${name} and age is ${age}`);
}
}
```
Additional requir... | codefeedback |
Create an algorithm which is able to sort a given array of integers in descending order. The algorithm should have a time complexity of O(n^2) and should not use any built-in sorting functions or data structures. | codefeedback |
Using the given array, create a function that takes in two arguments, the array and a number, and returns the position of the number in the array. The function should have a time complexity of O(log n) or better, where n is the length of the array. Additionally, the function should use a recursive binary search algorit... | codefeedback |
Substitute the correct data type for each variable in the code below, ensuring that the "name" variable can only store alphabetic characters (with a maximum length of 50 characters), the "age" variable can only store integers greater than or equal to 0, and the "if_married" variable can only store boolean values.
name... | codefeedback |
Construct an SQL query to find the names of all senior developers who have worked at least 5 years and have a salary greater than $100,000, and whose years of experience are evenly divisible by 3. Additionally, the query should only return names in reverse alphabetical order. | codefeedback |
Design a responsive HTML page to display a table of students' grades for multiple subjects. The table should include the following columns: student name, subject name, grade, and date. The page should allow the user to sort the table based on any column in ascending or descending order. Additionally, the page should in... | codefeedback |
Create a MySQL query to select the top 10 sales records from the table "sales", but exclude any records where the sales amount is less than $1000. Additionally, order the results in descending order based on the sales amount and then ascending order based on the sales date. | codefeedback |
Create an input validation function in Python which checks that the input is an integer between 2-6, is divisible by 3, and is not a prime number. | codefeedback |
Implement a method in Java to generate a random float within the given range, rounded to the nearest hundredth. The generated float must be a multiple of 0.01 and not exceed the range of 0.3 to 0.7, inclusive. The method should have a time complexity of O(1) and should not use any built-in random number generator funct... | codefeedback |
Design a class for a user profile with the following additional requirements:
- The profile must have a unique username, which cannot be changed once set.
- The profile must store the user's date of birth, which should be validated to ensure it is in a valid format (e.g., dd/mm/yyyy).
- The profile must have a method t... | codefeedback |
Create a MongoDB query to find all records with a "quantity" field greater than 5, a "price" field less than 10, and an additional condition where the "category" field is either "electronics" or "clothing". | codefeedback |
Make a function in Python that sorts a list of integers in increasing order. The function should not use any built-in sorting functions or methods. Additionally, the function should have a time complexity of O(n^2) and should not use any additional data structures. The input list can contain duplicate integers and may ... | codefeedback |
Construct an SQL query to delete rows from a table that fulfill the following conditions:
Table Name: Customer
Conditions:
(1) Country = 'USA'
(2) Age = 18
(3) Gender = 'Male'
(4) The customer must have made at least 5 purchases in the last month.
(5) The customer's total purchase amount must be greater than $1000.
(6)... | codefeedback |
Create a function that prints out the List of tuples in reverse order and each tuple should be converted to a dictionary with keys 'key' and 'value'. The function should have a time complexity of O(n) and a space complexity of O(n), where n is the length of the input list.
t = [(1, 5), (0, 1), (10, 20)] | codefeedback |
Create a class definition for a Car object with attributes of HP, speed, and fuel efficiency. Implement a method that calculates the distance traveled by the car given the fuel efficiency and speed. Additionally, the car must have a maximum speed limit of 200 mph and a minimum fuel efficiency of 10 miles per gallon. Th... | codefeedback |
Change the case of all alphabetic characters in a string, but leave the punctuation and other non-alphabetic characters unchanged. The input string may contain multiple sentences. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.