instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Generate a concise summary of an article containing more than 500 words, while ensuring that the summary is at least 90% accurate in terms of capturing the key information and ideas. Additionally, the summary should be generated within a time limit of 5 seconds for every 100 words in the article. The program should als... | codefeedback |
Develop a program that finds the second highest value from a list of positive integers. The program should also handle negative integers and zero values in the list and should return -1 if there is no second highest value. | codefeedback |
Given the following Python code, identify if it is syntactically correct or not. The code should also return the sum of the elements in a given list, with the additional requirement that the code must use recursion to calculate the sum.
def sum_list_recursive(lst):
if len(lst) == 0:
return 0
else:
... | codefeedback |
Implement an algorithm to subtract two strings, represented as linked lists, in the order they appear and return the result as a linked list.
The linked lists may contain digits from 0 to 9. You can assume that the input strings are well-formed and do not contain leading zeros, except for the number zero itself.
For ... | codefeedback |
Design a function to find the Fibonacci sequence numbers given n. The function should only use a single loop and no recursion. The function should also handle the edge case when n is negative or zero by returning an empty list. n = -5
#Erroneous Code#
def fibonacci(n):
if n <= 0:
return []
elif n == 1:... | codefeedback |
Write an SQL query to find the top 5 users with the highest average number of logins per day in the last 7 days. | codefeedback |
Given an array of integers, remove any duplicate numbers and sort the remaining elements in descending order. The final array should also include the count of each unique element. Additionally, the solution should be implemented in a time complexity of O(nlogn) or better.
Example:
Input: arr = [3, 9, 8, 4, 6, 7, 5, 4]... | codefeedback |
Design a function to compute the sum of the squares of the first n even numbers. | codefeedback |
Compute the sum of all even integers from 1 to the given number n, while ensuring that the time complexity of the solution is O(1). | codefeedback |
Please create a Java program that takes a list of integers as an argument and computes the longest increasing subsequence. The longest increasing subsequence is a sequence of integers in the original list that are in strictly increasing order, and no other sequence in the list is longer.
Example input: [8, 10, 1, 4, 1... | codefeedback |
Create a program that outputs a spiral array from the given input of a 2D array. The program should take into consideration that the input array can have any number of rows and columns. The program should also handle cases where the input array contains negative numbers. Additionally, the program should only use a sing... | codefeedback |
Create a Python script to find all prime numbers within a given range [m, n], where 1 ≤ m ≤ n ≤ 10^9, with the additional requirement that the script must have a time complexity of O(n log log n).
Note: You are not allowed to use any external libraries or built-in functions that directly solve this problem. You must i... | codefeedback |
Use PHP to create a web page redirect script that includes the following requirements:
- The script should only redirect users who are accessing the web page from a specific IP address range.
- The script should log the IP address, timestamp, and redirect destination for each redirected user in a database.
- The redire... | codefeedback |
Implement the algorithm to reverse a singly linked list in-place without using any additional data structures. The algorithm should have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Create a script in Bash to print the 1st, 3rd, and 5th program arguments in reverse order, while ignoring any empty arguments. Additionally, the script should check if the 2nd argument is a valid file path and if so, append the contents of that file to the output. The script should handle any errors that may occur duri... | codefeedback |
Edit the following CSS class to display a square box with a border-radius of 10px and a background gradient from top left to bottom right, with colors ranging from red (#FF0000) at the top left corner to blue (#0000FF) at the bottom right corner. Additionally, add a hover effect that changes the background color to gre... | codefeedback |
Write a script that prints out the current value of environment variables, but only for variables that contain the word "secret" in their name. Additionally, the script should also check if the value of each secret variable is encrypted. If it is encrypted, the script should decrypt the value before printing it. | codefeedback |
Convert the following string "The quick brown fox jumps over the lazy dog" to an array of words, where each word is a separate element in the array. The solution should be implemented using only a single loop and should have a time complexity of O(n), where n is the length of the input string. | codefeedback |
Compute the sum of all the prime numbers and Fibonacci numbers in an array of numbers, while excluding any negative numbers.
For example, given the array [2, 3, -1, 5, -3, 7, 8, 13], the result should be 30 (2 + 3 + 5 + 7 + 13). | codefeedback |
Design an algorithm that computes the minimum number of moves required to sort an array of integers, where a move is defined as swapping two adjacent elements. The algorithm should have a time complexity of O(n^2) and a space complexity of O(1). Additionally, the algorithm should be able to handle arrays with duplicate... | codefeedback |
Design a function to parse the given URL and return its components. The function should handle URL encoding and decoding. The URL may contain special characters and non-ASCII characters. The function should also validate the URL format and throw an error if it is not a valid URL. Additionally, the function should suppo... | codefeedback |
Use the reduce function to calculate the product of elements in an array, but ensure that the product is calculated correctly even if the array contains negative numbers. The product should also be calculated using the modulo operator, with the result being the remainder when dividing the product by a specific number. ... | codefeedback |
Increase the difficulty by adding additional variables and nested logical conditions:
Rewrite the following PHP code to JavaScript:
$someNumber = 10;
$anotherNumber = 5;
$thirdNumber = 8;
$fourthNumber = 12;
$fifthNumber = 15;
if ($someNumber > $anotherNumber && $anotherNumber < $thirdNumber) {
if ($fourthNumber >... | codefeedback |
Write a SASS mixin that accepts parameters for the color, size, blur radius, and position of a shadow, and applies the shadow style to multiple elements. The position parameter should accept values such as "top-left", "top-right", "bottom-left", "bottom-right", "top", "bottom", "left", "right", and "center". The mixin ... | codefeedback |
Create a JSON object with the key 'name' and the value 'John'. The value must be an array of strings with a length between 2 and 5 characters. Additionally, the JSON object must contain two more keys: 'age' with the value 25, and 'hobbies' with the value of an array containing at least three elements, each of which mus... | codefeedback |
Modify the following code segment to add multiple values in an array while ensuring that each value is unique and the array does not exceed a length of 100. Use a loop to prompt the user to enter a value, check if it already exists in the array, and only add it if it is unique. Additionally, display an error message if... | codefeedback |
Generate a secure web service function in Python to return the current date and time in the format "YYYY-MM-DD HH:MM:SS". The function should only allow authenticated users with valid API keys to access the service. Additionally, the function should limit the number of requests to 100 per hour for each user. | codefeedback |
Write a code to delete white space from this sentence, while also keeping track of the number of words in the sentence. The sentence should be reversed after removing white space. Additionally, your code should handle punctuation marks and special characters in the sentence. This is a sentence with extra white space, p... | codefeedback |
Generate a dictionary with 10 elements, where each element should be a tuple consisting of a string key and a list value. The key should be a palindrome and the list value should contain only prime numbers. Display the dictionary. | codefeedback |
Design a JavaScript class to instantiate objects for student records.
The student records should store the student name, age, and scores of multiple tests.
In addition to the above requirements, the class should also include the following functionalities:
1. A method to calculate the average score of all the tests ... | codefeedback |
Write code to create an SQLite table called "Students" with 5 columns: student_id, name, age, class, and grade.
The student_id column should be a primary key with auto-increment functionality, ensuring each student has a unique identifier.
The name column should be limited to a maximum of 50 characters.
The age c... | codefeedback |
Given an array of positive integers, find the two elements that have the largest sum. The array may contain duplicates and can have a maximum length of 10^6.
Additional Information:
- The array may not be sorted.
- If there are multiple pairs with the same maximum sum, return any one of them.
- You are not allowed to... | codefeedback |
Create a function in JavaScript which prints out squares of all numbers from 1 to a given number, where the given number can be up to 10^6. The function should have a time complexity of O(n), where n is the given number. Additionally, the function should only use a single loop and should not use any built-in JavaScript... | codefeedback |
Discover and remove redundant code from this C++ program, while also ensuring that the code uses a maximum of three variables, does not use any loops or conditional statements, and has a time complexity of O(nlogn), where n is the size of the input. | codefeedback |
Write a SQL query to get the names of all customers who have placed orders that have a total cost greater than $100 and were placed within the last 7 days. Additionally, exclude any customers whose names contain the letter 'e'.
Table names: customers, orders
Table columns: customers(customer_id, customer_name), order... | codefeedback |
Describe in English the function of this Javascript code. The function addUser takes two parameters: username (a string) and age (a number). It creates a new object called user with two properties: name (assigned the value of username) and age (assigned the value of age). The function then returns the user object. Addi... | codefeedback |
Rewrite the following recursive algorithm in Java.
Implement a function named "recursive" that takes an integer input "n" and returns the sum of all numbers from 1 to "n". The function should handle negative numbers as well, and in such cases, it should return the sum of all numbers from "n" to 1 (inclusive). The func... | codefeedback |
Propose an algorithm in Python for sorting a given list of numbers in descending order, without using any built-in sorting functions or libraries. Additionally, ensure that your algorithm has a time complexity of O(n log n) and a space complexity of O(log n). | codefeedback |
Given a 2D array in Python, find the maximum value in each column and return a new 2D array where each element is replaced by its corresponding column's maximum value. The input array can have any number of rows and columns.
Write a function called "find_column_max" that takes in the following parameters:
- "array", a... | codefeedback |
Explain in plain English the difference between the set() and list() methods in Python. Additionally, write a Python function that takes in a list of integers and returns a set containing only the even numbers. The function should also validate that the input list is not empty and contains only positive integers, other... | codefeedback |
Propose a C++ program to calculate the average price of a product given its list of purchased items, while also implementing error handling for invalid inputs such as non-numeric values, negative prices, and prices exceeding a certain threshold.
The program should:
1. Prompt the user to enter the number of purchased i... | codefeedback |
Write a script in PHP for generating a random alphanumeric string of length 10. The generated string should not contain any repeated characters. Additionally, the generated string should always start with a letter and end with a number. | codefeedback |
Create a C++ class called "HelloPrinter" that has a private member variable called "name" and a public member function called "printHello" that prints the "Hello World!" string followed by the value of the "name" variable. The "printHello" function should also have a parameter called "numTimes" that specifies the numbe... | codefeedback |
Write a class in Ruby that implements the following methods: `add`, `subtract`, `multiply`, and `divide`. The class should handle both integer and floating-point numbers, and should round the result to the nearest whole number when using the `divide` method. The class should also keep track of the total number of opera... | codefeedback |
Use HTML and CSS to create a responsive webpage which features a table with at least 10 columns and 20 rows. The table should have alternating row colors and a header that remains fixed when scrolling. Additionally, implement a search functionality where the table dynamically filters based on user input.
In the search... | codefeedback |
Create a function in Python to find all pairs of distinct integers from two given lists that sum up to k, where the absolute difference between the integers in each pair should be greater than or equal to a given threshold value. Additionally, the function should return the pairs in ascending order based on the sum of ... | codefeedback |
Create a sorting algorithm to order a given array of integers in descending order, without using any built-in sorting functions or libraries. The algorithm should have a time complexity of O(n log n) and should be implemented using a variation of the quicksort algorithm. Additionally, the algorithm should be able to ha... | codefeedback |
Write a query to list the names, total order amount, and order date of customers who have purchased any item from the Items table. The results should be ordered by the total order amount in descending order, and should only include customers who have made purchases within the last 30 days. Additionally, the query shoul... | codefeedback |
How can you use a function to determine whether a given array is strictly increasing, strictly decreasing, non-decreasing, non-increasing, or unordered, without using any comparison operators or sorting algorithms? | codefeedback |
Write a Python function to remove all vowels from a given sentence, while also converting all remaining letters to uppercase. The function should also count and return the total number of consonants in the modified sentence. The quick brown fox jumps over the lazy dog! | codefeedback |
Write a SQL query to find the count of all customers whose age is more than 20 and have made at least 3 purchases in the last month. Additionally, exclude any customers whose total purchase amount is less than $100 in the last month. | codefeedback |
## Updated Test ##
Write a C++ program that reads in a series of integers and prints out the most frequent, but with the following additional constraints:
1. The program should handle negative integers as well as positive integers.
2. The program should handle floating-point numbers as well as integers.
3. The program... | codefeedback |
Create an API in Go that takes a string and returns the amount of unique words present in the given string. However, the API should also be able to handle large strings with millions of words efficiently. Ensure that the solution can handle strings with a maximum length of 1 GB and has a time complexity of O(n) and a s... | codefeedback |
Create a mySQL script to create a table called "User" with columns user_id, name, mobile_number, and date_of_birth. The mobile_number column should be unique and have a format of "+[country code]-[mobile number]" (e.g. "+1-1234567890"). The date_of_birth column should have a default value of the current date, but shoul... | codefeedback |
Write a Python function to generate a list of Fibonacci numbers up to the given limit n, where the time complexity of the function should be O(n).
Additional Constraints:
1. The function should be implemented using recursion.
2. The function should not use any loops or iteration.
3. The function should handle negative... | codefeedback |
Write a Python script that takes a list of integers as input and returns a new list that contains only the unique elements from the input list. The elements in the output list should be in the same order as they appear in the input list. You are not allowed to use any built-in functions or libraries to solve this probl... | codefeedback |
Implement a function that takes in a string and returns a dictionary where each character in the string is a key and the corresponding value is a list of indices where the character appears in the string. The dictionary should be sorted in descending order by the characters. | codefeedback |
Please write a function that takes in a list of positive integers and returns the maximum possible sum that can be obtained by adding a subset of the integers. The subset must meet the following conditions:
- The sum of the integers in the subset must be divisible by a given divisor.
- The subset must not contain any t... | codefeedback |
Create a SQL query to join three tables based on their common fields. The tables are:
Table1 (field1, field2, field3)
Table2 (field2, field4, field5)
Table3 (field2, field6, field7)
The query should return the combined rows where the field2 values match in all three tables. Additionally, the query should also include ... | codefeedback |
Create a dynamic and responsive UI in HTML/CSS for a shopping cart website that allows users to add, remove, and update items in the cart. Implement a search feature that filters products based on user input, with a time complexity requirement of O(log n) for searching. Additionally, display the total price of all item... | codefeedback |
Create a GUI that displays a dynamically changing text and multiple buttons, where each button triggers a different action when clicked. The dynamically changing text should be fetched from a remote server and updated every 5 seconds. Additionally, implement error handling to gracefully handle any unexpected user input... | codefeedback |
Write a Java program to print out the lyrics of the song "Mary Had a Little Lamb", ensuring that each line of the lyrics is reversed before being printed out. Additionally, the program should capitalize the first letter of each word in the reversed line. However, the program should also handle the case where the lyrics... | codefeedback |
Convert the given code in Java to an equivalent expression in Python. In addition, modify the code to prompt the user to enter a value for x and then print the square of x. Also, handle the case where the user enters a non-numeric value.
Original code in Java:
int x = 10;
Modified code in Python:
try:
x = int(inp... | codefeedback |
Create a MySql query to find all the students who have obtained a grade above 8 in both their math and science subjects. The query should display the student's name, grade, and the subjects in which they achieved the high grades. Additionally, the query should only include students who have also achieved a grade above ... | codefeedback |
How would you design the data structure to store and process results from a 5-choice multiple choice test, where each question can have multiple correct answers and there is a time limit of 30 seconds for answering each question? Additionally, the system should also be able to handle multiple different types of questio... | codefeedback |
Given a list of positive integers, write a program to find four elements whose sum equals a given target value. Additionally, the program should return all possible combinations of these four elements.
For example, given the list [1, 2, 3, 4, 5, 6] and the target value of 10, the program should return the following co... | codefeedback |
Create a program that prints out a list of all prime numbers from 0 to 100, except for two, five, and any prime number that contains a digit '3'. | codefeedback |
You need to write a function to check if the given input is a palindrome string. The function should ignore any punctuation marks, spaces, and special characters in the string. The function should also be case-insensitive, meaning that "Level" should be considered a palindrome.
Additionally, the function should have a... | codefeedback |
Design a MongoDB schema for a collection to store books with fields for title, author, ISBN, publication date, genre, and a list of reviews. Each review should have fields for reviewer name, rating, and comments. Additionally, the schema should allow for tracking the number of times a book has been viewed and the avera... | codefeedback |
Generate an HTML list with the following entries, but ensure that each entry is a hyperlink that redirects to a different webpage. The URLs should be dynamically generated based on the entry's index in the list:
- Apple (redirects to "https://www.example.com/1")
- Banana (redirects to "https://www.example.com/2")
- Che... | codefeedback |
Create a function that compares two strings and returns a boolean value depending on their equality or inequality. However, you cannot use any built-in string comparison methods or operators such as '=='. Instead, you must implement your own algorithm to compare the strings character by character. Additionally, you are... | codefeedback |
Design a data structure in Java to store student records which includes Roll Number (must be a positive integer), Name (must be a non-empty string), Grade (must be a character from A to F), and a unique Student ID (must be an alphanumeric string of length 10 characters). Additionally, each student record should also in... | codefeedback |
A function needs to be created that will take a list of strings and return a list of the same strings without duplicates. The function should also ignore case sensitivity when checking for duplicates. Additionally, the function should remove any leading or trailing whitespace from each string in the input list before c... | codefeedback |
Implement a Class in Java that creates a new array of integers with a dynamic size determined by the user and allows the user to set and get the values of the array. Additionally, the Class should include a method to calculate the sum of all the elements in the array and a method to find the maximum value in the array.... | codefeedback |
Use CSS to style an HTML table with a heading and 50 rows and 15 columns. Additionally, add alternating background colors to the rows. Add a hover effect to the table cells so that when a cell is hovered over, its background color changes. Implement a functionality that allows the user to sort the table data in ascendi... | codefeedback |
Write a program to generate the Fibonacci sequence up to a given number n. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. For example, the sequence up to 1000 would be: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 9... | codefeedback |
Create a program to find the largest prime number that is a factor of two numbers within a given range.
The program should take three inputs: the two numbers (N1 and N2), and the range (R).
The program should find the largest prime number that is a factor of N1 and N2 and is within the range of 1 to R.
If there is no p... | codefeedback |
Please write a Python program to analyze the sentiment of a given text.
The program should take as input a list of text sentences and return a sentiment score for each sentence. The sentiment score should range from -1 to 1, where -1 indicates a negative sentiment, 0 indicates a neutral sentiment, and 1 indicates a po... | codefeedback |
Write a function that will format a given string in proper title case. The string may contain multiple sentences and punctuation marks. The function should correctly capitalize the first letter of each word in the string, except for certain words that should be lowercase (e.g., articles, prepositions, conjunctions). Th... | codefeedback |
In Python, write a script that prints out the elements of a list in reverse order, without using the built-in reverse function or any additional data structures. The list should be modified in-place. The time complexity of the algorithm should be O(n), where n is the length of the list. Additionally, the script should ... | codefeedback |
Describe the data structures used to implement a stack data structure and explain how to implement a method that retrieves the minimum element in logarithmic time complexity. Additionally, provide an optimized solution that retrieves the minimum element in constant time complexity. | codefeedback |
Design a network for sending data from a server to multiple clients simultaneously, ensuring efficient data transmission by implementing a messaging protocol that supports asynchronous communication. Additionally, enforce strict security measures by integrating end-to-end encryption and two-factor authentication mechan... | codefeedback |
Write a C# program that connects to a PostgreSQL database, retrieves data from multiple tables using a join operation, applies sorting and filtering conditions on the retrieved data, and then displays the results in a console application. Additionally, the program should implement pagination functionality to display th... | codefeedback |
Write a SQL statement to select the names, IDs, and addresses of customers from the customers table that live in California, have made at least 3 purchases in the past month, and have an average purchase amount of more than $500. | codefeedback |
Create a Java program that implements an AVL tree, which is a self-balancing binary search tree. The program should include methods for inserting a new node, deleting a node, and searching for a specific value. Additionally, the program should provide methods for performing an in-order traversal, pre-order traversal, a... | codefeedback |
Describe the step-by-step process of debugging a complex code that involves multiple modules and libraries, where you must identify and fix logical errors, memory leaks, and race conditions, while adhering to strict performance requirements and minimizing downtime during the debugging process. Additionally, provide an ... | codefeedback |
Create a SQL query that counts the number of active users in a given table, but exclude any users whose registration date is before 01/01/20 and whose email address does not end with '.com'. | codefeedback |
Write a program that takes a URL as input and extracts all the links present on the webpage. The program should then display the number of internal links (links pointing to the same domain) and external links (links pointing to other domains). Additionally, the program should only consider links that are within a speci... | codefeedback |
Write a C program that declares a 2D array of size 5x5 and initializes each element of the array with a unique prime number. The program should also find and print the sum of all prime numbers in the array. | codefeedback |
Please create a function that will validate if a given date is in the correct format and also checks if the date is a valid date in the Gregorian calendar. The function should meet the following requirements:
1. The function should return a boolean value indicating whether the date is valid or not.
2. The function sho... | codefeedback |
Write a function in a programming language of your choice that takes a list of strings as input and returns a string of HTML code to create an ordered numbered list. Each string in the input list should be a separate bullet point in the output HTML code. The function should properly handle any special characters in the... | codefeedback |
Write a SQL query to count the number of customers who have made at least 3 purchases in each country, and whose total purchase amount exceeds a certain threshold, in the 'customers' table. | codefeedback |
Write a bash script to print all processes currently running on the system, but exclude any processes with a specific word in their command line arguments. Additionally, exclude any processes that have been running for less than 1 hour. | codefeedback |
Calculate the sum of the cube of prime numbers from 1 to n, where n is a positive integer. | codefeedback |
Given a string of integers, create a method to generate an array in which each integer is added to the sum of its neighbors. However, the sum of the neighbors should only include integers that are divisible by 2. The resulting array should be sorted in ascending order.
Additionally, the method should handle the case w... | codefeedback |
Create a method that deletes all the empty elements from a given array of strings. The method should not use any built-in array manipulation methods such as `filter`, `reduce`, or `map`. The method should have a time complexity of O(n), where n is the length of the input array.
arr = ["a", "", "b", "", "c"]
# Example... | codefeedback |
Implement a JavaScript function to print all the leap years between 1900 and 2100 that are divisible by both 4 and 400, but not divisible by 100 or 200.
Requirements:
1. The function should have a time complexity of O(n).
2. The function should have a space complexity of O(1).
Note: Leap years are years that are divi... | codefeedback |
Write a program to convert a given 2D matrix into a 1D array. Your program should handle error cases where the input matrix is not a valid 2D matrix. The input matrix will have at most 100 rows and 100 columns. Each element in the matrix will be an integer between -100 and 100, inclusive.
matrix = [[1,2,3],[4,5,6]]
Ou... | codefeedback |
Write a program in Python that simulates a file system with permission levels. The program should have the following requirements:
1. Define a class named "File" with the following attributes:
- "name" (string): representing the name of the file.
- "permission" (integer): representing the permission level of the... | codefeedback |
Parse this JSON data using JavaScript and return an array of all the unique keys in the JSON object, excluding any keys that start with the letter "a". | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.