instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Create a relational database schema to store data of products sold in an e-commerce store, while considering the following additional requirements:
1. Each product can belong to multiple categories.
2. Each product can have multiple images associated with it.
3. Each product can have multiple variants (e.g., different... | codefeedback |
Create a HTML page which includes two input fields and a button that generates output field that should contain the sum of the two numbers given in the two input fields. Additionally, the sum should be calculated in a way that only allows the use of bitwise operations, such as bit shifting and bitwise logical operation... | codefeedback |
Calculate the Hamming distance of two binary strings, where the length of the strings can be up to 10^6. | codefeedback |
Create a for loop to print all the prime numbers between 1 and 100 (including 1 and 100). | codefeedback |
Write a SQL query to find the employee numbers, names, and salaries of all the employees who work in a department with ID 10 and have a salary greater than $50,000. | codefeedback |
Generate a Delete API endpoint in Python Flask for a user to delete their data from a specific table in a database. The user should only be able to delete their own data and not data belonging to other users. Additionally, the endpoint should require authentication using JWT (JSON Web Tokens) to ensure that only authen... | codefeedback |
Generate code to create a PDF report from a given dataset.
The dataset contains information about customer orders.
1. The code should prompt the user to enter the file path of the dataset.
2. The code should validate if the file exists and if it is in the correct format (e.g., CSV, JSON, Excel).
3. If the file is not ... | codefeedback |
Read the following JSON object and print the "name" corresponding to the "id" 2. However, instead of using a JSON parsing library, you must implement your own JSON parsing algorithm from scratch. | codefeedback |
Compose a SQL query that returns the names, cities, and phone numbers of customers from the Customer table whose last name starts with the letter "L" and their corresponding orders from the Order table, including the order date and total amount. Additionally, the query should only include customers who have made at lea... | codefeedback |
Generate a logic for a regex expression to detect a valid email address with the following requirements:
- The email address must start with an alphanumeric character.
- The domain name must contain at least one period.
- The domain name must be at least two characters long.
- The email address must end with a valid to... | codefeedback |
Create a loop in Python that prints the prime numbers between 1 and 1000. | codefeedback |
Design a JavaScript class for a bank account with one private variable, account_balance. The class should have three public functions: deposit(amount), withdraw(amount), and getBalance().
The deposit(amount) function should add the given amount to the account_balance variable and print the updated balance.
The with... | codefeedback |
Modify the following SQL query so that it only returns the customers from the city "New York" and have made a purchase in the last 30 days.
SELECT *
FROM Customer
WHERE City = 'New York'
AND PurchaseDate >= DATEADD(DAY, -30, GETDATE()) | codefeedback |
Design a function in Java that takes in two integer arguments, a and b, and returns the result of a*b. However, you are not allowed to use the multiplication operator (*) to perform the multiplication. You should instead implement the multiplication logic using only addition, subtraction, and bit shifting operations. | codefeedback |
Write a function in Python to move the second-to-last element of a given list to the beginning of the list. | codefeedback |
Reverse the order of the values in the input list without using any built-in Python functions or methods. Your solution should have a time complexity of O(n) and a space complexity of O(1). The input list will always contain at least one element. You are not allowed to use any additional data structures to solve this p... | codefeedback |
Query all values from the table "users" in a MySQL database and sort them by descending order of the column "age". Additionally, filter the results to only include users whose age is greater than 30 and whose username contains the letter "a". | codefeedback |
Create a function to calculate the sum of the first n prime numbers using JavaScript. | codefeedback |
Construct a PHP function to log the user out of the system and securely destroy all session data. | codefeedback |
Create a React component to render a table with data from an API. The API returns an array of objects, each representing a person's information. Each person has the following properties: name (a string), age (a number), and job (a string).
The table should display the following columns: Name, Age, and Job. The data fr... | codefeedback |
Create a web page with a JavaScript function to search for a product in a product inventory using user input. The user should be able to search for a product by either its name or price.
The web page should display the list of products in a table format, with each row showing the name and price of a product. The user ... | codefeedback |
Construct a program that determines the sign of a given number using a nested conditional statement. The program should handle decimal numbers as well.
Constraints:
- The program should be written in a programming language of your choice.
- The program should not use any built-in functions or libraries for determining... | codefeedback |
Create a JS object property with a string value that is encrypted using a custom encryption algorithm. | codefeedback |
Create a responsive web page with a React component to fetch data from a RESTful API and display it in a sortable and searchable table. Implement client-side pagination for the table, with a maximum of 10 rows per page. Add a loading indicator while fetching the data and handle error cases gracefully by displaying an e... | codefeedback |
Create a JavaScript object with a number property and a string property. Add a method to the object that takes in two parameters (a number and a string) and returns the concatenation of the number property and the string property. | codefeedback |
Given a database with multiple tables, write a SQL query to list the name, column names, and data types of all tables in the database. Additionally, order the list of tables by the number of columns in each table in descending order. | codefeedback |
Write a Java program to read the following text and count the number of words in the given sentence. However, the program should ignore any words that are enclosed within quotation marks.
For example, if the input sentence is:
This is a "sample" sentence.
The program should count only the words "This", "is", "a", and... | codefeedback |
Write a SQL query that selects the first name, last name, and the full name (concatenation of first and last name) of all users in a customer table, where the last name must be in uppercase and the full name should only include alphabetic characters. | codefeedback |
Create a class in C++ to store the rolling average of a stream of numbers. The class should also provide a method to calculate the standard deviation of the numbers in the stream. Additionally, the class should implement a method to remove outliers from the stream before calculating the rolling average and standard dev... | codefeedback |
How would you create a CSS style for alternating the background color of table rows, with the following additional conditions:
1. The alternating background colors should start with a different color than the default background color of the table.
2. The alternating background colors should be applied to only a specifi... | codefeedback |
Given a binary search tree and a target value, write a python function to search for the closest node value to the target. The binary search tree is not guaranteed to be balanced. The time complexity of the solution should be O(log n) on average, where n is the number of nodes in the tree. The space complexity should b... | codefeedback |
Write a Python function that takes in a sentence and reverses the order of the words, while keeping the order of the characters within each word intact. The function should handle punctuation marks and multiple whitespaces between words appropriately.
Example:
Input: "Hello world! This is a sentence."
Output: "senten... | codefeedback |
Write a code that prints all the possible outcomes of rolling three dice. | codefeedback |
Explain what the following Python code prints out, but without using the range() function or any other looping construct.
i = 0
while i < 10:
print(i**2)
i += 1 | codefeedback |
Write a Python code to find all the prime numbers below a given number and store them in a list. The code should also determine the sum of the digits of each prime number and only include prime numbers whose digit sum is a prime number itself. | codefeedback |
How would you improve the efficiency of the following code snippet?
def get_total(list):
total = 0
for item in list:
total -= item
return total | codefeedback |
Change the For loop statement below to a While loop statement:
i = 0
while i < 5: | codefeedback |
Convert the given for loop code to a functional programming approach. Implement the solution without using any built-in functions or libraries, and ensure that the solution is a pure function. The input list should not be modified, and the result should be stored in a new list named "new_list". | codefeedback |
Write a JavaScript function that takes in an array and returns an array of objects containing the original array elements and their frequency. The function should also sort the objects in the output array based on the frequency of each element in descending order.
For example, given the input array [3, 4, 3, 4, 5, 3],... | codefeedback |
Write a function to reverse the contents of a stack without using any additional data structures. | codefeedback |
How would you print the sum of all elements in a 2-dimensional array, where each element is a list of integers? The array has dimensions n x m, where n is the number of rows and m is the number of columns. Each row may have a different number of columns.
#Additional Requirements:
- You cannot use any built-in function... | codefeedback |
Create a Bash script that takes in a single argument and prints it in reverse order. The script should also check if the argument is a valid file path and, if so, display the contents of the file instead of just printing the argument itself. | codefeedback |
Design an efficient algorithm for sorting a large array of integers in ascending order using the selection sort technique, ensuring that the time complexity is less than O(n^2) and the space complexity is less than O(n). | codefeedback |
Write a SQL statement to query the names and ages of all employees from the Employees table whose salary is less than 3000, and whose age is greater than or equal to 25. | codefeedback |
Explain a scenario where you need to use mySQL COUNT function to retrieve the number of unique customers who have made at least 5 purchases within the last month, excluding any cancelled orders. | codefeedback |
In C++, write a code snippet to print "Welcome to GeeksforGeeks" 10 times using a for loop, but ensure that each time the phrase is printed, the words "GeeksforGeeks" are printed in reverse order. | codefeedback |
Write a SQL query to find the customer id, name, and salary of the customers whose salary is in the range 2000-6000, and have made at least 5 purchases in the last month. | codefeedback |
Edit the given code snippet to generate a table in HTML with four columns and three rows. Each cell in the table should contain a randomly generated number between 1 and 100. | codefeedback |
Visualize the following dataset using a bar chart in matplotlib. The bars should be color-coded based on the value range they belong to. The labels should be displayed in descending order of their values. Additionally, the chart should have a title, x-axis label, and y-axis label. Use a different color for the bars tha... | codefeedback |
Create a function in JavaScript that takes in two arrays of integers and returns an object. The object should contain elements where the two arrays have coinciding elements. Additionally, the function should only consider coinciding elements that are prime numbers. | codefeedback |
Write a program to calculate the Fibonacci sequence up to a given number. | codefeedback |
Create a function in Javascript that validates a user input as a valid email address, ensuring that it meets the following additional requirements:
1. The email address must contain at least one uppercase letter.
2. The email address must contain at least one lowercase letter.
3. The email address must contain at leas... | codefeedback |
Develop a program in Java that prints out the following star pattern. The program should take an input from the user to determine the number of rows in the pattern. The number of rows should be between 3 and 10 (inclusive). If the user enters an invalid input, the program should display an error message and ask for inp... | codefeedback |
What are the key differences between a software engineer and a software developer, both in terms of their roles and responsibilities? Provide specific examples to support your answer. Additionally, include a piece of erroneous code that demonstrates a common mistake made by software engineers or developers, and explain... | codefeedback |
Construct a switch-case statement in JavaScript to print the day of the week, but with the added requirement that the program should also display a message if the day_index value is invalid (i.e. not within the range of 1-7). | codefeedback |
Construct a class in Python named "Person" which stores first name and last name in instance variables. Implement a method called "get_full_name" which returns the full name in the format "Last Name, First Name". The first name and last name should be between 2 and 20 characters long. The class should also have a metho... | codefeedback |
Find the nth prime number, where n is a positive integer greater than 100. | codefeedback |
Calculate the sales tax given a price and a tax rate, but the tax rate must be rounded to the nearest hundredth decimal place. The price should be a positive integer between 1 and 1000, and the tax rate should be a positive decimal number between 0.01 and 0.1. | codefeedback |
Write a program to estimate the value of pi to ten decimal places using the Monte Carlo method. | codefeedback |
Create a Java class to represent a point in 2D space using two fields, x and y. The x and y values should be restricted to integers between -100 and 100, inclusive. Additionally, the class should have a method to calculate the distance between two points in 2D space. | codefeedback |
Write a MySQL query to select all customers who have a birthday in the month of May and have made at least 3 purchases in the last 6 months. | codefeedback |
Create a RNN model to predict the next character in a given string, taking into account not only the previous characters but also the context and meaning of the entire sentence. Additionally, incorporate the ability to generate coherent and meaningful sentences based on the learned patterns from the training data. | codefeedback |
Given a 2-d array of integers, write a method to flatten the array while removing all duplicate elements. The flattened array should be sorted in ascending order.
Additional Constraint: Your solution should have a time complexity of O(nlogn), where n is the total number of elements in the 2-d array.
[[1, 2, 3], [4, 5,... | codefeedback |
Sort all strings in a list alphabetically, using Python.
Time Complexity: O(nlogn)
Space Complexity: O(1)
["apple", "dog", "cat", "banana"]
Please rewrite the given test question to increase the difficulty. | codefeedback |
Write a bash script to find the sum of two integers, but the integers must be inputted by the user and the script must handle cases where the input is not a valid integer. | codefeedback |
What is the value of Dirac's constant in Planck units and rounded to the nearest integer? | codefeedback |
Using Java, create a program to compute the area and circumference of a circle given the radius. Implement the following requirements:
1. The program should prompt the user to enter the radius of the circle.
2. Validate the user input to ensure that it is a positive integer.
3. Calculate and display the area of the cir... | codefeedback |
Using C++, create a program to calculate the volume of a rectangular prism given the length, width, and height. However, you are not allowed to use the multiplication operator (*) or any built-in math functions. | codefeedback |
Write a function in C++ to find the sum of all prime numbers between 1 and 100. | codefeedback |
Write a code in C# to create a ranking system for 10 players based on their scores.
Player1: 53
Player2: 45
Player3: 37
Player4: 66
Player5: 22
Player6: 19
Player7: 43
Player8: 31
Player9: 57
Player10: 12
The ranking system should sort the players in descending order based on their scores and assign a rank to each pla... | codefeedback |
Create a function that returns the first non-repeating character in a given string.
string = 'This is a sample string'
The function should return 'T' as it is the first character that does not repeat in the string. | codefeedback |
Create a relational database with the following table structure, ensuring that each table has a primary key and at least one foreign key constraint. | codefeedback |
Create an array with 10 elements, each element must be a randomly generated positive integer between 1 and 1000 inclusive. The array must be sorted in descending order. | codefeedback |
Given a string consisting of lowercase and uppercase letters, spaces, and punctuation marks, parse the string and reverse the order of words, while maintaining the capitalization of the first letter of each word. The string may contain multiple consecutive spaces and trailing spaces. | codefeedback |
Write a multithreaded class in Java to submit a form, ensuring that each form submission is unique and includes a captcha verification. | codefeedback |
Design an algorithm in C to find all palindromic substrings of a given string. | codefeedback |
Write an Angular component to display a list of books with the following functionalities:
1. Sort the books alphabetically by the book name.
2. Filter the books based on the author's name. Provide an input field where the user can enter the author's name, and display only the books written by that author.
3. Allow the... | codefeedback |
Using a for loop and an if statement, count how many prime numbers are in the given array. The array can contain both positive and negative integers. | codefeedback |
Write a code that sorts an array in descending order, but do not use any built-in sorting functions or methods. You can only use basic operations such as loops, conditional statements, and variable assignments. The input array will contain integers ranging from -1000 to 1000, and its length will be between 1 and 1000. | codefeedback |
Create a function that takes an integer as input and returns the sum of the squares of all the numbers between 1 and the input number, excluding any multiples of 3. | codefeedback |
Transform a given text into a valid JSON format with indentation, proper spacing, and ensure all special characters are properly escaped. Additionally, the JSON output should include the length of each word in the original text.
hello world | codefeedback |
Utilizing the regular expression [a-zA-Z0-9]+, construct a JavaScript script to find all matching patterns from the given string. Additionally, handle cases where the matching patterns must be surrounded by specific characters - '(' and ')'. | codefeedback |
Write a JavaScript function to create a Timer that counts down from a specified duration in minutes and seconds. The function should take two arguments: the duration in minutes and the duration in seconds. The Timer should start counting down as soon as the function is called and should display the remaining time in a ... | codefeedback |
Write a Python script to convert the given list of strings into a comma separated string. The script should also ensure that the resulting string does not contain any leading or trailing whitespaces. Additionally, the script should remove any duplicate strings from the list before converting it to a comma separated str... | codefeedback |
Write a python program to extract the substring from a string after a specific character, but also replace all occurrences of that character with another character in the final substring.
string = "Hello,World!"
character = ","
Expected output:
The substring after the character ',' is "World!" but with all occurrence... | codefeedback |
How to generate all permutations of a given list of items, while excluding any permutations that contain consecutive repeating elements? | codefeedback |
Write a Java program that takes an array of strings as input and prints out each element in reverse order. Use different functions to achieve this.
Original code:
String[] courses = {"Math","Science","English", "History"};
for(int i = 0; i < courses.length; i++){
System.out.println(courses[i]);
}
Rewritten code:
im... | codefeedback |
Write a Python script to merge two given dictionaries into one, but with the following additional requirements:
- If a key is present in both dictionaries, the corresponding values should be multiplied together instead of being overwritten.
- The merged dictionary should be sorted based on the keys in ascending order. | codefeedback |
Create a python program to implement a Binary Search in an array that also keeps track of the number of comparisons made. The program should return the index of the element if found, otherwise return -1. The array arr will contain positive integers in ascending order, and its length will be less than or equal to 100. T... | codefeedback |
Write a JavaScript program to create an array of the first 1000 Fibonacci numbers that are prime. | codefeedback |
Describe an algorithm for sorting an array of n integers in O(n log n) time, while also ensuring that the sorted array contains no duplicate elements. | codefeedback |
Rearrange the given jQuery snippet to use chaining and add an additional step to multiply each element of the array by 3 and then sort the array in ascending order.
var arr = [1,2,3];
arr = arr.map(function(val) {
return val * 3;
}).sort(function(a, b) {
return a - b;
});
console.log(arr); | codefeedback |
Identify the input validation code that would be most appropriate for a form receiving a user's age, taking into consideration the following additional requirements:
1. The user's age must be within a specific range, such as 18 to 65 years old.
2. The validation should handle input in different formats, such as numeri... | codefeedback |
Get the sum of the first 100 prime numbers. | codefeedback |
Describe the process of indexing documents in an Elasticsearch cluster using the REST API, including the steps to handle bulk indexing and configuring mappings for dynamic fields. | codefeedback |
Change the list elements to binary numbers and then sort the list in descending order. Each binary number in the list should have a length of at least 4 digits.
mylist=[3, 8, 9] | codefeedback |
Describe a method for adding two numbers that uses a stack data structure and allows for decimal numbers. | codefeedback |
Design a function in C# which takes an integer parameter and returns the first non-zero digit of the integer. If the integer is negative, return the first non-zero digit of the absolute value of the integer. If there are no non-zero digits in the integer, return -1.
For example, if the input integer is 12345, the func... | codefeedback |
Create a function that takes a list of numbers and removes all elements that occur more than twice. Additionally, the function should return the modified list sorted in descending order.
Example:
Input: [1, 2, 3, 1, 2, 5, 5, 5]
Output: [5, 5, 5, 3, 2, 1] | codefeedback |
Find the index of the first character in a string that is not a space and is not followed by a punctuation mark. The string should contain at least one punctuation mark and at least one alphanumeric character.
string: " Hello world! How are you?" | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.