instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Create an array of the first 1000 prime numbers in JavaScript, where the array elements must be sorted in ascending order. | codefeedback |
Create a SQL query to print names starting with a certain letter, but exclude names that contain any special characters or numbers. Additionally, sort the names in descending order based on the length of the name. Letter: A | codefeedback |
Write a recursive algorithm to generate all possible combinations of balanced parentheses given a certain number of pairs, but the parentheses must be balanced not only in terms of count, but also in terms of the position and nesting of the parentheses. | codefeedback |
Create a C++ program that uses command line arguments to print out the argument passed in as a string. The program should also check if the argument is a valid string and display an error message if it is not. Additionally, the program should implement a function that reverses the string and displays the reversed versi... | codefeedback |
Given a sorted array of size n and a target number, find the index of the first occurrence of the target number in Java. The array may contain duplicates.
Please solve the problem with a time complexity of O(log n) and without using any built-in search functions such as indexOf() or any iterative approaches. You can ... | codefeedback |
Calculate the number of valid permutations of length n with respect to a given set of n distinct elements, where each element can only appear once in a permutation and there are certain constraints on the order of elements.
The constraints are as follows:
1. The first element in the permutation can be any of the n dis... | codefeedback |
Create a SQL query to select the maximum salary for each department from the "Salary" table, while also excluding any departments where the maximum salary is below $100,000. Additionally, include the department name and the number of employees in each department. | codefeedback |
Design a data structure to store books that keeps track of page numbers and allows for efficient searching and retrieval of pages based on certain criteria, such as the page number falling within a specific range or the page containing a particular keyword. Additionally, the data structure should support efficient inse... | codefeedback |
Using the given HTML, add the class "container" to the <div> element. Additionally, change the font color of the text inside the <div> to red. However, the class "container" should only be added if the <div> element has a sibling <p> element with the attribute "data-type" set to "special". If the <div> element does not... | codefeedback |
Write code to sort a Python list of tuples based on their second element in the tuple. The second element in each tuple represents the number of occurrences of the first element in a separate list. The tuples should be sorted in ascending order based on the number of occurrences. If two tuples have the same number of o... | codefeedback |
Create a class in Python that represents a binary tree. The class should have the following functions:
1. `insert(value)` - This function should insert a new node with the given value into the binary tree. The value should be an integer between 0 and 1000.
2. `search(value)` - This function should return `True` if th... | codefeedback |
Write a function in Python that takes an integer as an input and prints the number of digits in the integer, without using any built-in string or mathematical functions, and with a time complexity of O(log n), where n is the value of the input integer. | codefeedback |
What data structure can you use to store a set of unique values, where the insertion and retrieval operations have a time complexity of O(1)? Additionally, the data structure must also support constant time deletion of elements. | codefeedback |
Explain the concept of "branching" in version control systems and discuss its differences from "merging". Provide a detailed example scenario where branching and merging would be beneficial in a collaborative software development project. Additionally, include a code snippet showcasing a common mistake made during bran... | codefeedback |
Write a helper function in Haskell that prints out a given string in uppercase and reverses it before printing. The function should also remove any duplicate characters in the string. Additionally, the function should only use recursion to reverse the string instead of built-in functions like `reverse`.
str = "hello" | codefeedback |
Write a C++ program to generate the Fibonacci numbers up to a maximum of n values. However, instead of using an iterative approach, you are required to use a matrix exponentiation approach to calculate the Fibonacci sequence.
The matrix exponentiation approach involves using a matrix multiplication technique to raise... | codefeedback |
What is a concurrent skip list, and how does it differ from a regular skip list? Provide an example of a scenario where a concurrent skip list would be more suitable than a regular skip list. | codefeedback |
You are given two strings, A and B. Write a function to delete the characters in A that also appear in B. Additionally, the function should also delete any characters in A that appear more than once consecutively.
A = 'abcbbdefgghijk'
B = 'abcddcdefgg'
After applying the function, A should be modified to 'ek'. | codefeedback |
Which language is primarily used to develop applications for the Android platform? Provide an example of a common error related to memory management that developers may encounter while using this language, explain the potential impact of this error on the application's performance, and suggest at least two strategies t... | codefeedback |
Write a node.js program to get the name of the day for a given date, considering leap years, accounting for different calendar systems, and implementing a time complexity of O(1). | codefeedback |
Edit a JavaScript program to input a number and output its factorial using a recursive function. The program should also include error handling to check if the input is a positive integer and display an appropriate error message if not. Additionally, the program should be able to handle large inputs up to 1000 and outp... | codefeedback |
Write a code snippet to add two numbers provided in two lists. The length of the lists will always be the same. list1 and list2 will contain integers in the range of 0 to 9. The result should be returned as a new list. The sum of the numbers in the lists can be larger than 9, so the code should handle carrying over the... | codefeedback |
Classify a given paragraph as having a positive or negative sentiment, considering the presence of sarcasm. The customer service was absolutely horrendous, and the wait felt like eternity. Additionally, the algorithm should also detect any contradictory statements within the paragraph and provide a list of specific con... | codefeedback |
Generate a C program to count the frequency of each character in a given string, while also considering uppercase and lowercase characters as the same. The program should not use any built-in functions or libraries for counting the frequency of characters.
String = "aAbBcCabcABC"
Additional requirements:
1. The progr... | codefeedback |
Generate a command to update a folder, but only include files that were modified within the last 6 hours and have a file size greater than 1MB. | codefeedback |
Write a dynamic programming algorithm to solve the following problem:
Given an array of positive integers, find the maximum sum of a subsequence with the constraint that no two numbers in the sequence are adjacent to each other. For example, for the input array [1, 2, 3, 4, 5], the maximum sum of a subsequence would b... | codefeedback |
Retrieve the data stored in a SQL database and perform a join operation between two tables. Implement the join operation using a recursive algorithm with a time complexity of O(nlogn), where n is the total number of rows in the two tables combined. Additionally, ensure that the join operation is executed in parallel ac... | codefeedback |
Implement a function in programming that demonstrates the concept of polymorphism. The function should take in two parameters: a list of shapes (each shape represented as a dictionary with attributes such as "type" and "area") and a string indicating the operation to be performed on the shapes (e.g., "calculate total a... | codefeedback |
Create an XML document with five elements "Company", "Product", "Price", "Quantity", and "Total Price". The "Quantity" element should have a minimum value of 10 and a maximum value of 10000, and it should only accept integer values. The "Total Price" element should be the product of the "Price" and "Quantity" elements,... | codefeedback |
Create a sorting algorithm in Python that will sort an array of numbers in ascending order.
The time complexity of the algorithm should be O(n^2) or better. You are not allowed to use any built-in sorting functions or libraries.
The algorithm should be stable, meaning that the relative order of equal elements should ... | codefeedback |
Provide a MySQL query for selecting all records from a table called "inventory" where the price is greater than 100, the quantity is less than 10, and the product type is "electronics". Additionally, order the results by the price in descending order and limit the output to the first 5 records. | codefeedback |
Write an SQL query to display the 10 most recently added products, but exclude any products that have been marked as discontinued. Additionally, include the average rating for each product, where the rating is calculated as the average of all the ratings given to that product. | codefeedback |
Create an array of length n, containing all prime numbers starting from 2, where each number is the sum of its previous two prime numbers in the array. | codefeedback |
Write a Node.js program to generate a random 10-character string consisting of uppercase letters, lowercase letters, numbers, and special characters (!@#$%^&*). | codefeedback |
Classify the given paragraph into either Affective or Predicate. You should also identify the tense of each sentence and extract the adjectives and adverbs used in each sentence. Additionally, you should determine the subject and object of each sentence, and analyze the sentence structure by identifying any phrases or ... | codefeedback |
Edit the following code so that it prints the first odd number greater than 10 in a given list of positive integers.
nums = [2, 3, 4, 5, 6, 11, 12, 13] | codefeedback |
You need to write a program that performs a specific operation on a given list.
Write a recursive function called `operate` that takes a list of integers `lst` and returns a modified list according to the following rules:
- If the list contains only one element, return the list as it is.
- If the list contains two elem... | codefeedback |
Design a JSON object with three keys: "name", "age", and "address". The value for the "address" key should be another JSON object with two keys: "street" and "city". The value for the "street" key should be a string, and the value for the "city" key should be an array of strings representing different cities the person... | codefeedback |
Train a SVM model on the given input data to classify the output as either "yes" or "no". Each input data point should be represented as a tuple (x1, x2, y) where x1 and x2 are real numbers and y is either "yes" or "no". The SVM model should have a minimum accuracy of 90% on a separate validation dataset of at least 10... | codefeedback |
Create a function in R that will return the maximum number in a given vector, but the vector can contain both numeric and character values. If the vector contains character values, the function should return the maximum number as if the character values were converted to their corresponding ASCII values. If the vector ... | codefeedback |
Create a PHP class called "Person" that has two properties: "id" and "name". Implement a method called "getFullName" that returns the full name of the person. The full name should be a combination of the id and name, separated by a hyphen.
Additionally, create a static variable called "counter" that keeps track of th... | codefeedback |
Create a C# class to serialize a JSON object, but only include properties that have a specific attribute applied to them. Additionally, the serialized JSON object should only include properties with a specific data type and should exclude properties with a specific value. | codefeedback |
Write a JavaScript program to take an array of numbers, where each number is between 1 and 100 (inclusive), and return an array in which each element is the result of squaring the original. The input array will always contain at least one number. The program should also ensure that the output array contains only distin... | codefeedback |
Create an SQL table with five columns called id (int type), name (text type), age (int type), address (text type), and email (text type). The table should also have a primary key constraint on the id column and a unique constraint on the email column.
Additionally, create a trigger that automatically updates the age c... | codefeedback |
Create a MySQL query to select the names and email addresses of all the customers who have made a purchase in the past month and have spent more than $100 in total. Additionally, include the total number of purchases made by each customer and the average amount spent per purchase. | codefeedback |
Write a Bash script to check if a directory exists or not and print the total number of files in the directory if it exists. Additionally, the script should display the total size of the directory in megabytes and print the file names in reverse order. | codefeedback |
Print the largest number in a given array in Python, without using any built-in functions or methods. You are only allowed to use basic arithmetic operations and control structures. The array can contain both positive and negative integers. Additionally, the time complexity of your solution should be O(n), where n is t... | codefeedback |
Create a Python 3 script that prompts the user to enter a month and a year, and then prints out the total number of days in that month and year, taking into account leap years.
The script should validate the input to ensure that the month is a valid integer between 1 and 12, and the year is a valid integer greater tha... | codefeedback |
Create a SQL query to find the total payments made by each customer in the last 30 days, along with the average payment amount, maximum payment amount, and minimum payment amount made by all customers in the last 30 days. Additionally, calculate the total number of payments made by each customer in the last 30 days and... | codefeedback |
Describe the working of a set in Python, including how to implement set operations such as union, intersection, and difference, and provide an example code that demonstrates the usage of sets in a real-life scenario.
Additionally, write a function that takes in two sets and returns a new set that contains the symmetri... | codefeedback |
Create a query to find the total payments from one customer in the last 10 months, while also retrieving the details of each payment including the payment date, amount, and payment method. Additionally, the query should return the total number of payments made by the customer in the last 10 months. The query should als... | codefeedback |
Given a balanced AVL tree, where each node contains a key and a value, provide an algorithm to delete a node with a specific key k from the AVL tree. Additionally, ensure that the algorithm maintains the balance of the tree after deletion. | codefeedback |
Write a function in JavaScript which takes a situation as a parameter and returns the probability of success. The situation includes various factors such as economic indicators, historical data, news sentiment, technical analysis, and social media trends. The function should analyze these factors using machine learning... | codefeedback |
Design a PHP class that can be used to store a user's name, age, gender, and address. The class should have methods to set and get each attribute. Additionally, include a method that can validate the user's age and gender based on certain criteria. The age should be validated based on the user's nationality and the gen... | codefeedback |
Create a HTML page with a form that takes user input and performs some action when the user clicks the submit button. However, the action should involve dynamically generating a graph based on the user input, using a specific JavaScript library such as D3.js or Chart.js. Additionally, the graph should have interactive ... | codefeedback |
Write a SQL query to get all the records from a table if the value in each column is a prime number. Additionally, exclude any records where the value in a specific column named "status" is equal to "inactive". | codefeedback |
Take the following array as an argument and output the sum of all the numbers in the array using Python. However, you are not allowed to use any built-in functions or methods that directly calculate the sum of an array (such as the sum() function or the reduce() method). You must implement your own algorithm to calcula... | codefeedback |
Create an SQL query to search for customer names whose age is greater than 30, whose total purchase amount is more than $1000, and whose purchases include at least one item with a price higher than $500. | codefeedback |
Implement an algorithm to find all the sets of three distinct numbers in an array which adds up to a given number. The array will contain positive integers only and can have duplicate values. The output should be in ascending order and should not contain any duplicate sets. Additionally, the algorithm should have a tim... | codefeedback |
Create an efficient algorithm to find the longest common substring from two given strings. The algorithm should have a time complexity of O(n^3), where n is the length of the longer string. The algorithm should also handle cases where the strings can contain special characters and are case-sensitive. Additionally, the ... | codefeedback |
Extend the following HTML code to include a dropdown list. However, the dropdown list should be dynamically populated with options from a database. The database should be a NoSQL database, specifically MongoDB.
```
<select class="form-control">
<!-- code to populate options dynamically from a MongoDB database -->
</se... | codefeedback |
Visit the official API documentation for a web service of your choice and create a Python code that makes a POST request with a JSON payload. The payload should contain at least five different data fields, with each field having specific requirements. Additionally, the code should handle any possible errors or exceptio... | codefeedback |
Create a visualization to compare the customer preferences of three websites.
Website 1 has 6000 customers and their favorite products are video games and consoles. Each customer has also rated their satisfaction level with the website on a scale of 1 to 10.
Website 2 has 8000 customers and their favorite products are ... | codefeedback |
You need to generate a virtual object with React.js that can be dynamically updated based on user input and automatically refresh every 5 seconds. Additionally, the virtual object should be able to handle multiple user inputs simultaneously and display the updated information for each input separately. | codefeedback |
Develop a program to spell a given word using only vowels, with the constraint that each vowel can only be used once.
For example:
Input: "Hello"
Output: "Eo"
Note: The output should consist of all vowels from the input word, in the same order as they appear, with each vowel used only once. | codefeedback |
Develop a function in Java to display the prime numbers between 0 and 100, but the function should also take into consideration a list of excluded prime numbers that should not be displayed. Additionally, the function should return the sum of all the prime numbers that are displayed. | codefeedback |
Given a number n, print “Hello” n times, each time with a delay of 1 second between each print statement. However, if n is negative or zero, raise an error with a custom error message indicating that n should be a positive integer.
n = -2 | codefeedback |
Determine the longest word in a given string, but exclude any words that contain the letter "e". However, you must implement this functionality using recursion.
sentence = "I am Python Programmer" | codefeedback |
Write a program that takes a string as input and prints it 7 times, each time with an increasing number of exclamation marks at the end. However, you are now allowed to use any built-in functions or libraries for repeating the string. The time complexity of your solution should be O(n), where n is the length of the inp... | codefeedback |
Build a web scraper in Python to fetch the restaurant details from the website.
<uri of the website>
However, the website has implemented advanced anti-scraping measures such as fingerprinting, device recognition, and image-based CAPTCHA. Your task is to find a way to bypass these measures and successfully scrape the ... | codefeedback |
Iterate over a list and count the number of occurrences of each item, without using built-in functions.
Additional requirement: The solution should have a time complexity of O(n) and should be implemented recursively. | codefeedback |
You are given a list of numbers. Count how many of them are prime numbers and contain the digit 3. The time complexity of your solution should not exceed O(n log(log n)), where n is the number of elements in the list. | codefeedback |
Edit the following code so that it prints out the sum of all powers of 2 up to 2^n. Additionally, modify the code to calculate and print the product of all powers of 3 up to 3^n.
n = 5 | codefeedback |
Given two strings, return True if either of the strings appears at the very end of the other string, ignoring upper/lower case differences. The solution should have a time complexity of O(n), where n is the length of the longer string, and a space complexity of O(1).
Example:
str1 = "Strawberry", str2 = "berry"
Output... | codefeedback |
Edit the given code to ensure it outputs appropriate messages for successful and unsuccessful output. The name should not contain any numbers or special characters. If the name is valid, print "Hello, [name]!". If the name is empty or contains invalid characters, print "Invalid name!".
To make the problem more challen... | codefeedback |
Get all unique permutations of a string. A unique permutation is a permutation that does not have any repeated characters.
string = "aabb"
# Erroneous Code #
```python
def get_unique_permutations(string):
if len(string) <= 1:
return [string]
permutations = []
for i in range(len(string)):
... | codefeedback |
Create a JS program that rotates a given string by a random number of characters between 5 and 15. Additionally, ensure that the program handles error cases where the input string is empty or the rotation number is not within the specified range. | codefeedback |
Create a function that reverses a given string without using the built-in reverse method or the use of any additional data structures. The function should also ignore any whitespace characters in the string.
str = 'I am here for the coding challenge'
#Additional Constraints and Requirements#
- The function should hav... | codefeedback |
Modify the following code so that it takes a string as a parameter, reverses it and prints out the reversed string. Additionally, the solution should be implemented using recursion instead of iteration. The input string will always be alphanumeric and can have a maximum length of 100 characters. The solution should hav... | codefeedback |
Implement a function that calculates the power of a number without using the built-in power operator or any multiplication operator.
Signature:
def calculate_power(base: int, exponent: int) -> int:
Example:
calculate_power(3, 4) -> 81
Additional Constraints:
- The base and exponent can be any positive integer.
- The... | codefeedback |
Find a way to get the size of a linked list without traversing it. Additionally, the linked list can contain duplicate values. However, you are not allowed to use any additional data structures or modify the linked list itself. | codefeedback |
Write a SQL query to find the number of customers that have purchased a product more than 10 times, and have a positive balance. The database has four tables:
customer(cust_id, cust_name, balance)
product(prod_id, prod_name, price)
sales(cust_id, prod_id, quantity)
category(cat_id, cat_name)
Note: The category table ... | codefeedback |
Rewrite this code into Python, but ensure that the sum is calculated only for even numbers in the ArrayList. The final sum should be printed out as the result.
```java
import java.util.ArrayList;
public class SumCalculator {
public static void main(String[] args) {
ArrayList<Integer> numbers = new ArrayLi... | codefeedback |
Write a function to find the smallest subarray with a given sum.
The input to the function is an array of positive integers and a target sum. The function should return the length of the smallest subarray in the input array that has a sum greater than or equal to the target sum. If no such subarray exists, the functio... | codefeedback |
Identify the possible output types for the following task.
Task: Write a Spark program to calculate the mean, median, and mode of a set of numbers. Additionally, the program should identify any outliers within the dataset.
In addition to the above requirements, modify the program to handle a large dataset that does no... | codefeedback |
Rewrite this SQL query in Postgres.
You are given two tables: teachers and students.
Teachers table:
- id: integer
- prof_name: string
- rank: string
Students table:
- id: integer
- student_name: string
- teacher_id: integer
Write a query to retrieve the top 5 professors (prof_name) who have the highest number of s... | codefeedback |
Implement a method that reverses a doubly linked list with the constraint that you cannot create any additional nodes or modify the existing nodes' data values.
class Node:
def __init__(self, data=None):
self.data = data
self.next = None
self.prev = None
def reverse_linked_list(head):
... | codefeedback |
You need to create an HTML page containing a table that contains at least 10 columns and 12 rows. Each cell in the table should contain a randomly generated number between 1 and 100. Additionally, the table should have alternating background colors for each row. The page should also include a button that, when clicked,... | codefeedback |
Generate all combinations of the string "abcd" where each combination contains exactly 4 characters. | codefeedback |
Change the last line of the code to assign a nested list value to the variable x, where each nested list contains only integers. Additionally, introduce an error in the code that needs to be fixed.
x = None
x[0] = [1, 2, 3] | codefeedback |
Write an R function to calculate the binomial coefficient of n and k using a recursive approach.
The function should have a time complexity of O(2^n) and a space complexity of O(n). | codefeedback |
Create a function that takes in two strings and determines if the strings are anagrams, but with the additional constraints that:
- The function must be case-insensitive.
- The function should have a time complexity of O(n), where n is the length of the longer string.
- The function should have a space complexity of O(... | codefeedback |
Create a Java class for representing a student object that includes the following:
- The student object should have a unique identifier, which is a combination of their student ID and a randomly generated alphanumeric code.
- The student object should have a first name, last name, and middle name.
- The student object ... | codefeedback |
Build a package and deploy it in the cloud. The package is an API to authenticate users and the API should be able to authenticate users having different types of API keys. The API should also include functionality for user registration and password recovery. Additionally, the API must be able to handle concurrent requ... | codefeedback |
Create a Java program to print out the multiplication table for the first 100 prime numbers, where each row and column should be sorted in ascending order. Additionally, the program should only use a single loop for generating the prime numbers. | codefeedback |
Compare and contrast the fundamental concepts and principles of object-oriented programming (OOP) and procedural programming. Additionally, discuss the advantages and disadvantages of each approach in terms of code organization, reusability, and maintainability. Finally, provide detailed examples of real-world scenario... | codefeedback |
Create a program to split the given string on a specific character and return the resulting list. Additionally, if the character appears multiple times consecutively, treat it as a single delimiter and exclude empty strings from the resulting list. Implement the splitting logic without using any built-in string splitti... | codefeedback |
Create a Python class to hold a student's information: name, age, major, and a list of courses they are currently enrolled in.
Provide a method within the class that allows the user to add a new course to the student's list of enrolled courses.
Additionally, provide a method that allows the user to remove a course fr... | codefeedback |
Change the code to make it an Expression Statement in Python that evaluates the sum of all prime numbers between 1 and 2000. | codefeedback |
Create a JavaScript object that holds the global temperatures for the last 50 years, with each year having temperatures for all 12 months. The temperatures should be randomly generated between a range of -100 to 100 degrees Celsius.
Additionally, implement the following functionalities:
1. Calculate and display the av... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.