instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write a SQL query to find the first ten customers by their joining date, excluding customers who have made more than 3 purchases in the past month. Additionally, the query should only include customers who have made at least 5 purchases in total since they joined. | codefeedback |
Implement a Convolutional Neural Network from scratch using only basic mathematical operations and without using any pre-existing deep learning libraries. The network should have multiple layers including convolutional, pooling, and fully connected layers. However, you are not allowed to use any built-in functions for ... | codefeedback |
What is the time complexity of accessing the third element in the second row of a three-dimensional array in JavaScript? | codefeedback |
Create a function to print out a FizzBuzz pattern for a given number range, but instead of printing "Fizz" for numbers divisible by 3 and "Buzz" for numbers divisible by 5, print "FizzBuzz" for numbers divisible by both 3 and 5. Additionally, for numbers divisible by 7, print "Woof" instead of the number itself. The nu... | codefeedback |
Create a web page that displays a table of 10 employees' information, including their names, phone numbers, email addresses, job titles, and salaries. The table should have alternating row colors and be responsive for both desktop and mobile devices.
Implement a search functionality where the user can enter a keyword ... | codefeedback |
For a given array of integers, write a function to find the mean. However, your solution must have a time complexity of O(n) and a space complexity of O(1). Additionally, you are not allowed to use any built-in functions or libraries to calculate the mean. The input array can contain up to 10^6 integers.
Example:
arr... | codefeedback |
Create a function that takes a string as input and evaluates all the Python code within the string. The string may contain multiple lines of code separated by newlines. Each line of code should be evaluated individually, and the corresponding output should be captured and returned as a list of strings.
Example:
Input... | codefeedback |
Write a function to encode a given string using a modified ROT13 cipher.
The modified ROT13 cipher works as follows:
1. Each letter in the input string is assigned a unique numeric value based on its position in the alphabet. For example, 'a' is assigned a value of 1, 'b' is assigned a value of 2, and so on.
2. The nu... | codefeedback |
Create a Node.js server that responds with "Hello World!" when the URL "/hello" is accessed. Additionally, the server should return a status code of 200 and the response body should include the current date and time in the format "YYYY-MM-DD HH:MM:SS". The server should also log the IP address and user agent of each re... | codefeedback |
Write a function that takes in two integers, `start` and `end`, and returns a list of prime numbers between `start` and `end`. You may assume that `start` and `end` are integers, and that `start` is always less than `end`.
Requirements:
1. The function should not use any built-in functions or libraries that directly d... | codefeedback |
Create an Angular component to display an "about us" page. The component should fetch the about us content from a server using an HTTP request and display it on the page. The content should be formatted using CSS grid and include at least three different sections with different background colors. Additionally, the comp... | codefeedback |
Design a program to find the nth prime number in the fibonacci sequence, where n is between 1000 and 10000.
Note: The program should run within a reasonable amount of time for larger values of n. | codefeedback |
Code a program to display the prime factors of a number. The program should be able to handle very large numbers efficiently, up to 10^15. The time complexity of the program should be less than O(sqrt(n) log(log(n))), where n is the given number. The program should use an optimized algorithm to find the prime factors, ... | codefeedback |
Write a CSS style sheet to change the background color of the webpage to a gradient that transitions from a deep navy blue to a light lavender purple. | codefeedback |
Use SQL to extract the customer name, order date, and price from the following table, but only for orders where the price is above a certain threshold, the order date is within a specific range, and the customer has placed at least two orders.
Table: orders
| order_id | customer_id | product_name | price | order_dat... | codefeedback |
Code a program to delete all occurrences of a given element from an array. The array can contain duplicates. You are not allowed to use any built-in functions or data structures.
Example:
Input: [1, 3, 5, 3, 7, 3], {element: 3}
Output: [1, 5, 7]
Constraints:
- The program should have a time complexity of O(n).
- The... | codefeedback |
Write a SQL query to produce a list of customer names in alphabetical order who have made at least 3 purchases and whose total purchase amount is greater than $100 from the following tables.
Tables:
customers
| customer_id | name |
| --------- | ----- |
| 1 | Bill |
| 2 | Jane |
| 3 | Jo... | codefeedback |
Given a paragraph with a maximum length of 10^6 characters, find the three most frequent words. The paragraph can contain any number of words. The words are case-insensitive and all non-alphabetic characters should be ignored. If two or more words have the same frequency, return them in lexicographically ascending orde... | codefeedback |
Write a function to generate the next line of Pascal's Triangle given the parent line, but with the following additional requirements:
1. The function must use a recursive algorithm to generate the next line.
2. The function must calculate the next line without using any built-in mathematical functions or formulas.
3.... | codefeedback |
Create a function that takes in a list of integers and returns a new list where each element is the product of the previous and next elements in the original list. The first and last elements in the original list should be treated as if they have a previous or next element of 1. The function should have a time complexi... | codefeedback |
Create a function that sorts a list of dictionaries using the values. The dictionaries contain information about various animals, including their name, age, and weight. The list should be sorted based on the animals' ages in ascending order. If two animals have the same age, then they should be further sorted based on ... | codefeedback |
Write a SQL query to output the IDs, names, and salaries of all employees who have a salary greater than the average salary of employees in their respective departments, but only for departments where the average salary is higher than the average salary of all departments in the company. | codefeedback |
Convert this expression in to postfix notation and handle parentheses.
(A + B) * (C / D) | codefeedback |
Suggest a way to identify and remove duplicate elements from the list. The list contains a mixture of integers, strings, and nested lists. You should only consider two elements as duplicates if they have the same value and the same type, and for nested lists, the order of elements should also be considered for duplicat... | codefeedback |
Design a data structure to efficiently store and retrieve a large amount of text data, with the additional requirement of supporting various text manipulation operations.
The data structure should have the following functionalities:
1. Efficiently store a large amount of text data.
2. Retrieve the stored text data qu... | codefeedback |
Create a Java function that converts a string to a decimal, while handling potential errors and misdirection.
String numString = "123.45";
## Additional Instructions ##
1. The function should handle input strings that contain leading or trailing spaces, and remove them before conversion.
2. The function should handle... | codefeedback |
Given a list of integers, design an algorithm to count the number of occurrences of each element in the list, while ensuring that the solution has a time complexity of O(n) and a space complexity of O(k), where n is the number of elements in the list and k is the number of unique elements in the list. Implement the alg... | codefeedback |
Create a class in Java called 'Circle' that stores information about a circle's radius and calculate the area and circumference. The radius should be a positive non-zero integer and the calculated area should be rounded to the nearest whole number. Additionally, implement a method that calculates the circumference of t... | codefeedback |
Identify the output of this snippet of C code.
int x = 10, y = 5;
int z = (x * y) - 15;
int a = x + y;
int b = a * z;
int c = b / 0; // This line contains an error
printf("The value of c is: %d", c); | codefeedback |
Translate this piece of C++ code into Java. The translated code should use recursion instead of a for loop. The input integer should be greater than or equal to 0 and less than or equal to 100. The translated code should handle any input within this range and throw an exception for any input outside this range.
int num... | codefeedback |
Edit this method to return an array of palindromes that are also anagrams of each other. The palindromes should be in ascending order based on their lengths. If two palindromes have the same length, they should be sorted lexicographically.
Provide a piece of erroneous code as a reference to increase misdirection.
pub... | codefeedback |
Write an SQL query to retrieve all records with a salary higher than the average salary of employees who have been with the company for more than 5 years, from a table named “employees”, excluding any records where the employee has been with the company for less than 2 years and their job title is not "Manager". | codefeedback |
Generate a new class from the given prototype. The class should also include a method called "printInfo" that prints out the name, age, and gender of the object in the following format: "Name: [name], Age: [age], Gender: [gender]". Additionally, the class should have a private variable called "id" of type int, which is... | codefeedback |
Write a program in assembly language to calculate the sum of two numbers, where the numbers are stored in memory locations. The program should meet the following requirements:
1. Declare and initialize two variables x and y with the values 27 and 11, respectively.
2. Reserve exactly 10 memory locations to store the va... | codefeedback |
Create a convolutional neural network in Python using the given input and output. The input consists of a 2D array of size 32x32x3 (representing an RGB image) and the output consists of two classes (y1, y2). Additionally, the network should have a maximum of 5 layers and use the ReLU activation function for each layer.... | codefeedback |
Write a program in Python to find the factorial of a non-negative integer using recursion. The program should handle cases where the input is negative or a floating-point number, and display an appropriate error message. Additionally, the program should have a time complexity of O(n), where n is the input number. | codefeedback |
Design an algorithm in Python to detect anomalies in the given data.
Input a dataset containing three columns, temperature, pressure, and humidity.
Additional requirement: The algorithm should be able to handle missing values in the dataset and provide a solution that minimizes the impact of these missing values on an... | codefeedback |
Generate an array of length n with random prime numbers in the range 0 - 100. The array must contain unique elements and must be sorted in descending order. | codefeedback |
Generate a string array of length 10, containing only alphabets in lower case containing 10 random characters. However, each character in the array must be unique, and the order of the characters must be in reverse alphabetical order.
Erroneous Code:
```python
import random
def generate_random_string():
alphabet ... | codefeedback |
Write an SQL query to select all rows from the table "customers" that have the same age and country as the given customer. Also, include an additional condition to only select rows where the customer's first name starts with the letter 'J'. | codefeedback |
Generate a list of 1 million random numbers between -1000000 and 1000000 in Python. Sort the list in ascending order and remove any duplicates. Implement a time-efficient algorithm with a time complexity of O(nlogn) or better. | codefeedback |
How would you write a program to determine the greatest common divisor (GCD) of two non-negative integers, without using any built-in mathematical functions or libraries, with a time complexity of O(log(min(a,b)))? | codefeedback |
What is the value of the expression '(2 + 3) ** 4 - (2 * 3) + 2' ? | codefeedback |
Create a Python function to remove duplicates in a given list, but without using any built-in Python functions or data structures. The function should have a time complexity of O(n^2), where n is the length of the list. The function should not modify the original list, but instead return a new list without any duplicat... | codefeedback |
You are tasked with writing a function that starts a timer with the specified duration and returns a unique identifier for the timer. The timer should accurately track the countdown and perform any necessary actions once it expires.
Additional reasoning steps:
1. Generate a random alphanumeric string to serve as the u... | codefeedback |
How would you sort an array of integers using Merge Sort algorithm? Write a recursive function that sorts the array in descending order, while also keeping track of the number of swaps made during the sorting process.
You are given an array of integers and you need to implement the Merge Sort algorithm to sort the arr... | codefeedback |
Write a SQL query to retrieve the id, name, and salary column from the Employee table, where the salary is above the average salary of all employees and the employee is not a manager. | codefeedback |
Given an arithmetic expression consisting of addition, subtraction, multiplication, and division operations, we want to print the result using Python.
First, we need to parse the arithmetic expression and evaluate the operations in the correct order. The expression can contain parentheses to indicate precedence.
Next... | codefeedback |
Write a lambda expression to select all records from a list of dictionaries with the name "John" and age less than 30. Additionally, the lambda expression should sort the selected records in ascending order based on the age attribute. | codefeedback |
Create a software program that encrypts a text message using a combination of substitution and transposition techniques. The program should prompt the user to enter a plaintext message and a secret key. The program should then perform the following steps:
1. Convert the plaintext message to uppercase and remove any sp... | codefeedback |
Edit the code to extract the data from the given dictionary and calculate the sum of all the numbers found in the dictionary. However, you should only consider numbers that are divisible by 3 and have an even number of digits.
data = {
'name': 'John',
'age': 23,
'address': {
'street': '123 Main Street',
'city': 'L... | codefeedback |
Suggest an algorithm to find the number of leaf nodes in a binary tree, but with the following additional requirement:
- The algorithm should have a time complexity of O(log n), where n is the number of nodes in the binary tree. | codefeedback |
Generate Python code to retrieve a list of tuples from a given string, where each tuple contains a string representing a person's name and an integer representing their age. The string will have the following format: "[('name1', age1), ('name2', age2), ...]".
However, in addition to retrieving the list of tuples, you ... | codefeedback |
Modify the code to create an AI model to classify the given dataset. The model should have an accuracy of at least 95%. Additionally, you are required to implement a cross-validation technique to validate the model's performance. The dataset should be split into 80% training data and 20% testing data. | codefeedback |
Write a predicate to check for valid email syntax. Additionally, ensure that the domain name is a valid and registered domain. Also, validate the username format by ensuring it follows the rules:
- The username can only contain letters (both uppercase and lowercase), numbers, periods, underscores, and hyphens.
- The u... | codefeedback |
Using the below Python code, Write a code snippet to index all the values of an array. However, you cannot use any built-in functions or libraries. Additionally, you must implement your solution using only a single loop and without using any additional variables or data structures.
arr = [3, 8, 2, 5, 1] | codefeedback |
Develop a program to encode and decode a given string using a specific encryption algorithm.
Input a string s to be encoded using the Caesar cipher algorithm.
The Caesar cipher is a substitution cipher where each letter in the plaintext is shifted a certain number of places down or up the alphabet. For example, with ... | codefeedback |
Given a JSON response with an array of objects, each containing a unique id (integer), name (string), and age (integer), parse the response and fetch the name of the person who is both the youngest and has the highest id. | codefeedback |
Generate Python code to extract only the keys from the given dictionary while ignoring any keys that start with the letter 'a' and have a value that is not a string. Additionally, if a nested dictionary is encountered as a value, only extract the keys from the nested dictionary that have values containing at least one ... | codefeedback |
Create a class to represent the given data structure.
Data Structure:
Student:
Id: Integer (unique identifier)
Name: String (should be between 2 and 30 characters long, no special characters allowed)
Age: Integer (should be between 18 and 40)
Please provide the necessary code to validate the input for each pro... | codefeedback |
Write a function that takes in a string of HTML code and returns a modified version of the code that ensures the following:
1. The HTML code is properly indented and formatted.
2. The HTML code includes a meta tag with the following attributes: charset="UTF-8".
3. The HTML code includes a script tag with the following ... | codefeedback |
Trace the given code and explain the operations. Write a function `concatenate_arrays` that takes in two lists `a` and `b`, and concatenates them into a new list `c` using the `+` operator. However, you should not use the built-in `+` operator to concatenate the lists. Instead, you should implement your own algorithm t... | codefeedback |
Given two strings of equal length, write a function to check if one string is a rotation of the other. The function should return True if the strings are rotations of each other and False otherwise. A rotation is defined as moving the characters of a string in a circular manner, such that one or more characters are mov... | codefeedback |
Write a code snippet to check if the following text contains the word 'hello' at least 5 times and is followed by the word 'world' at least once. The text must also not contain any punctuation marks. text = "This is a test message. Hello world! Hello, how are you? Say hello to everyone. Hello, hello, hello!" | codefeedback |
Edit the following code to sort the list of numbers in descending order without using any built-in sorting functions.
let numbers = [3, 1, 2, 5, 4] | codefeedback |
Remove duplicates from the list and sort the list in ascending order. Additionally, you must implement the sorting algorithm using a heap sort.
Input:
list = [9, 4, 2, 6, 9, 3, 7, 1, 4]
Output:
[1, 2, 3, 4, 6, 7, 9]
Explanation:
To solve this problem, we need to remove duplicates from the list and then sort the list... | codefeedback |
Given the following code, write a function to find the sum of all the prime numbers between 0 and n, where n is a positive integer. The function should have a time complexity of O(n log(log n)).
def sum_of_primes(n):
primes = []
is_prime = [True] * (n+1)
is_prime[0] = False
is_prime[1] = False
... | codefeedback |
Write a SQL query to find the number of entries that have a null value in the 'age' column and have a non-null value in the 'city' column, but exclude any entries where the 'name' column starts with the letter 'A'. | codefeedback |
Write a code snippet to calculate the average length of all the elements in an array. The array should have at least 10 elements and cannot exceed a length of | codefeedback |
Create an API using Python which returns the number of unique words in a given string, while also ignoring any common stopwords (such as "the", "and", "is", etc.) and considering words with different capitalization as the same word.
For example, given the string "The sun is shining and the birds are singing", the API ... | codefeedback |
Write an SQL query to find the student's average marks in a particular course, where the average should only include marks obtained within the last 6 months. Additionally, the query should exclude any marks that are lower than 70% of the maximum possible marks for that course. | codefeedback |
Create a Ruby program to display elements of an array in the reverse order, but without using any built-in array reversal methods or loops.
Additionally, you should ensure that your solution has a time complexity of O(n), where n is the number of elements in the array. This means that your solution should not have any... | codefeedback |
Construct an R script that sorts a given list of numbers in descending order. Additionally, implement the sorting algorithm from scratch instead of using a built-in function. | codefeedback |
Construct a SQL query to find all customers with a first name of "John" and a city of "New York", and order the results by their last name in descending order. Additionally, exclude any customers who have made a purchase in the last 30 days from the result set. | codefeedback |
Given a string that represents an HTML document, convert it into well-formed XML by adding closing tags for each opening tag and properly indenting any nested tags.
Input:
- A string representing an HTML document.
Output:
- A string representing a well-formed XML document.
Example:
Input: "<html><head><title>Test</t... | codefeedback |
Implement a function in JavaScript which checks whether a given number is prime or not. The function should only use a maximum of O(sqrt(n)) time complexity and should not use any built-in prime-checking functions or libraries. The function should handle both positive and negative integers as input and return a boolean... | codefeedback |
Write a Python program to create a numerical addition table where the values are multiplied by a random number generated between 1 and 100. Additionally, implement the following requirements:
1. The program should take user input for the size of the table (number of rows and columns).
2. The program should validate th... | codefeedback |
Write a Java program that takes an array of integers and returns the number of zeros in the array. However, you are not allowed to use any loop or recursion to iterate through the array. You must find a way to solve the problem using only one line of code and without using any built-in array functions or methods such a... | codefeedback |
Utilize Python to implement an algorithm which finds the kth largest prime number in an array, where k is given as input.
Additional requirements:
1. The algorithm must have a time complexity of O(n) or better, where n is the size of the array.
2. The algorithm must not modify the original array.
3. You are not allowe... | codefeedback |
Create a program in C++ that converts a given Celsius temperature to Fahrenheit using only bitwise operators and without using any arithmetic operators. Additionally, you should implement error handling to ensure that the user enters a valid temperature input. The program should prompt the user to enter a temperature i... | codefeedback |
Specify the minimum version of the Java platform (JDK 8 or above) and at least two environment variables (JAVA_HOME and PATH) needed to run a Java program, ensuring that the program can only be executed if the specified version is installed, the environment variables are correctly set, and the program is executed from ... | codefeedback |
Implement a function in C# to generate Fibonacci numbers up to a given limit, while ensuring that each generated number is a prime number and is divisible by 5. | codefeedback |
Create a Java program which calculates the area of a circle, but restrict the use of the Math library. Instead, you must implement your own function to calculate the value of pi to at least 100 decimal places.
To calculate the value of pi, you must use a mathematical algorithm such as the Bailey-Borwein-Plouffe formul... | codefeedback |
Why should you use recursion in programming? Provide a solution that includes at least two recursive functions. The program should also handle input validation, ensuring that the user only inputs positive integers. | codefeedback |
Name ten differences between Strings and StringBuffer in Java and provide a detailed explanation for each difference. | codefeedback |
Write a Bash script that performs the multiplication of two numbers entered by the user. Handle the case where one or both of the numbers are negative, and ensure the script displays an error message if non-numeric values are entered.
Additionally, implement input validation to handle cases where non-integer values ar... | codefeedback |
What are the key advantages of utilizing the MapReduce programming model in conjunction with the Hadoop framework? Provide at least three distinct advantages, elaborate on each, and implement a code snippet demonstrating the use of MapReduce in solving a specific problem. | codefeedback |
Write a query to find users who have at least one friend who is exactly 2 years older than them in MongoDB. | codefeedback |
# Rewritten Test #
How can we use the list comprehension method in Python to reverse each word in a given list of strings and return the reversed list, while also ignoring any strings that contain special characters or numbers?
list_of_strings = ["cat", "dog", "rabbit", "1234", "special!"]
# Expected Output
reversed_l... | codefeedback |
Explain the concept of polymorphism and provide an example in Java code. Additionally, the example should demonstrate method overloading and method overriding. | codefeedback |
Given a list of integers, find the numbers which are greater than the given number X and divisible by the given number Z. List: [-3, 0, 3, 5, 9], X = 4, Z = 2 | codefeedback |
How to create an empty data frame in Pandas with a specified shape and index, and then fill it with random values using a specific distribution? | codefeedback |
How can we replace multiple occurrences of a substring in a given string with another substring in JavaScript? Provide the correct code snippet to achieve this. Your solution should have a time complexity of O(n) where n is the length of the string. Additionally, you are not allowed to use any built-in string manipulat... | codefeedback |
How can we use the set() method, ensuring a time complexity of O(n), to find the unique elements in a given list of integers in C# without using any additional data structures, and also without using any built-in methods or libraries? | codefeedback |
Create a function that, given a number, reverses the digits and returns them in an array.
However, there is a small problem in the code provided. Fix the error in the code and make sure the function returns the correct reversed digits in the array.
Additionally, the function should handle negative numbers as well an... | codefeedback |
Edit the following C program to print the sum of the rightmost digit and the leftmost digit of the given number, with the constraint that the program must use only bitwise operators for all calculations and operations. Use only a single variable for computation and ensure that the program can handle numbers up to 10 di... | codefeedback |
Implement a function in Python to find the maximum number from a list of integers. The function should handle cases where the input list is empty or contains non-integer elements. The function should also handle cases where the list contains duplicate maximum numbers. If the list is empty or contains non-integer elemen... | codefeedback |
Create a JavaScript function which takes in an array of numbers and returns the second largest number. The function should also check if the array contains duplicate numbers and return an error message if so. Additionally, the function should only use a single loop for both finding the second largest number and checkin... | codefeedback |
Write a script to launch a web server listening on port 8080, but the web server should only accept incoming requests from a specific IP address range and restrict access to only clients that have a specific user agent string in their HTTP headers. | codefeedback |
Given an array of integers, rewrite the following Python program to sort the numbers in ascending order without using any built-in sorting functions or libraries. Additionally, ensure that the program has a time complexity of O(n log n) and a space complexity of O(1). The array can have duplicate numbers and its length... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.