instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Create a MySQL query to get the item names, their respective prices, and the total quantity sold for each item from the table "Orders" where the quantity sold is greater than 100. Additionally, calculate the total revenue generated for each item by multiplying the price with the quantity sold. Order the results in desc... | codefeedback |
Write a function to find the first prime number after the given number. If the given number is negative, raise an exception with a custom error message "Number must be positive". The function should also check if the given number is a multiple of 5 and return the next prime number after it.
num = -5 | codefeedback |
Write a PHP function that takes two integers as input and returns the result of the expression (a * b) - (a / b) + (a % b), where '%' represents the modulus operator. The function should handle edge cases such as division by zero and non-integer inputs. | codefeedback |
Manipulate a given list in Python where every element in the list has to be doubled. The resulting list should be sorted in ascending order. Additionally, the original list should not be modified, and the manipulation should be done using list comprehension.
The input list can contain duplicate elements. Your solution... | codefeedback |
Design a CSS layout for a div with a height of 50px, a width of 100px, a rounded-corner of 10px, a gradient background that transitions from red to blue, and a requirement that the layout must be responsive and adjust its dimensions based on the screen size. | codefeedback |
Write a Python program that generates a 10x10 grid of random colors and displays it using the turtle graphics library. Each cell in the grid should be filled with a random color, and the grid should be displayed on the screen.
In addition, the program should also calculate and display the total number of cells that ha... | codefeedback |
Write a query in MongoDB to find all documents with the value of field "city" as "Berlin" and the field "population" greater than 1 million, excluding documents where the field "country" is "Germany". | codefeedback |
Create an HTML page that displays two columns consisting of the numbers 1 to 100. Additionally, the numbers in the left column should be in ascending order, while the numbers in the right column should be in descending order. The columns should be styled with alternating background colors, and each number should be cli... | codefeedback |
Write a function to calculate the sum of the first n terms of the mathematical series:
x = 2^n / (n!)
Where n is a positive integer greater than 1.
Increase the difficulty by adding the following requirements:
1. Validate the input: The function should check if n is a positive integer greater than 1. If n is not va... | codefeedback |
Write a MySQL query statement that finds the total number of records in a table, but the table contains 1 billion records and you are only allowed to use a single SELECT statement in your solution. | codefeedback |
Write a SQL query to find the number of students living in zipcode 90001 who are also enrolled in at least three courses and have a GPA higher than 3.5. | codefeedback |
Write a Python program to parse a complex XML document containing nested elements and attributes. Extract specific data points based on multiple conditions, such as the presence of certain elements and the values of specific attributes. Additionally, implement error handling to gracefully handle any parsing or data ext... | codefeedback |
Create a TensorFlow model that recognizes handwritten digits from the MNIST dataset, but with the following additional requirements:
1. The model should be able to classify digits that are written using only straight lines and without any curves.
2. The model should have a maximum of 100,000 parameters.
3. The model s... | codefeedback |
Create a program in Java that simulates a fruit shop. Implement a class called "FruitShop" which contains a HashMap to store the name of fruits and their corresponding prices. The program should have the following functionalities:
1. Add a fruit and its price to the shop. The name of the fruit should be unique and sho... | codefeedback |
Write a query that returns the first 10 cities in the US table sorted by population in descending order, excluding any cities with a population below 1 million and a median household income above $100,000. | codefeedback |
Create a FizzBuzz program that uses a function called `fizzbuzz` which takes in two parameters, `start` and `end`, representing the range of numbers to be considered. The function should return a list of strings where each element in the list corresponds to a number in the range.
For each number in the range, if the n... | codefeedback |
Transform the given Ruby code into its JavaScript equivalent. The JavaScript code should utilize arrow functions instead of traditional function declarations. Additionally, the output of each book should be displayed on a new line. The JavaScript code should only utilize built-in array methods, such as forEach, and sho... | codefeedback |
Create a HTML page that displays a table dynamically generated using JavaScript. The table should contain 100 rows and 10 columns. Each cell should display a random number between 1 and 1000. The table should also have a button labeled "Sort" that, when clicked, sorts the table in ascending order based on the values in... | codefeedback |
Create a Python script that converts temperatures from Fahrenheit to Celsius and vice versa. The program should handle input validation to ensure that the user enters a valid temperature value. Additionally, the program should allow the user to convert a list of temperatures at once and display the converted values in ... | codefeedback |
Design a responsive HTML page with a header, navigation bar, and 3 sections. The header should include a logo and a search bar. The navigation bar should include links to at least 4 different pages. The sections should each have a background image and contain different types of content such as text, images, and videos.... | codefeedback |
What is the time complexity of an iterative mergesort algorithm if the input array contains duplicate elements and the algorithm needs to handle arrays of size N where N can be as large as 10^6? | codefeedback |
Create a program in Python to generate a random string using the given characters. The length of the string should be equal to the number of vowels in the characters string.
characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
Requirements:
1. The program should have a time complexity of O(n), where n ... | codefeedback |
Create a bash program that takes a directory path as input and lists the contents of the directory in reverse alphabetical order, excluding any subdirectories. The program should only display files that have a size greater than 1MB and were last modified within the past 24 hours. Additionally, the program should calcul... | codefeedback |
Write code in Python to retrieve the top 100 Rated Movies in IMDB. Additionally, display the movie genre, director, runtime, and list of actors for each movie. | codefeedback |
Create a HTML page containing an input field, a submit button and a table for displaying the results. Additionally, implement the functionality that allows users to add new rows to the table when the submit button is clicked.
Modify the functionality so that when a new row is added, it is inserted at the correct posit... | codefeedback |
Write a Python program that creates a dictionary with names as keys and phone numbers as values. The names should be in uppercase and the phone numbers should be in the format "+1-XXX-XXX-XXXX" where XXX-XXX-XXXX is a random 10-digit number. The dictionary should be sorted in descending order based on the length of the... | codefeedback |
Write a code to infer the data type of a lambda expression, while also considering nested lambda expressions, type inference based on the lambda body, and type erasure. | codefeedback |
Using the data provided, write a SQL query that returns the product with the highest price. | codefeedback |
Construct an array in JavaScript containing ten elements, where each element must be a prime number and must be greater than or equal to 100. | codefeedback |
Create a HTML code that contains a table with the following specifications:
- The table should have 5 columns and 10 rows.
- Each cell in the table should have a unique identifier in the format "cell-x-y", where "x" represents the row number and "y" represents the column number.
- The text in each cell should be a rand... | codefeedback |
Store the text "Hello World!" in a variable in Ruby, and reverse the order of the characters in the string without using any built-in string manipulation methods. | codefeedback |
Write a JavaScript code snippet to create a password-protected pop-up window that opens with a width of 800px and a height of 600px. The pop-up window should have a maximum of 5 tabs and should only be allowed to close after the user has entered the correct password. The password should be stored securely and should be... | codefeedback |
Construct an object in Python containing three elements, where one of the elements is a nested object. Each element should be a unique data type, and the nested object should contain at least two nested elements. Additionally, the object must be immutable and cannot be modified once created. | codefeedback |
Create a CSS class to center an element with a width of 100px, while also vertically aligning it in the middle of its parent container. Additionally, the element should have a border radius of 5px and a background color of #333333.
However, the CSS class should only work for Internet Explorer 11 and above. For other ... | codefeedback |
Write a SQL query to select customer names whose city is Tokyo and age is greater than 25, ordered by the number of times they have made a purchase in descending order. Additionally, only include customers who have made at least 5 purchases in total.
TABLE customers
Columns:
customer_id
name
city
age
TABLE purchases... | codefeedback |
Given a list of strings, write a function that filters out all strings that have a length less than two characters and are not in uppercase. The function should then return the filtered list in descending order of string length, and in the case of strings with the same length, sort them in lexicographical order.
Examp... | codefeedback |
Given a list of integers, find the longest common substring of the list, considering the numbers in the list as characters. The substring should consist of consecutive integers in the list, and the characters in the substring should be in strictly increasing order. If there are multiple substrings that meet this criter... | codefeedback |
Generate a pseudorandom sequence of hexadecimal numbers with length 100, where each number must be divisible by 3. Additionally, the sequence should not contain any repeated numbers. | codefeedback |
Construct an API call in Python that returns information about a given book, but you are not allowed to use any external libraries or frameworks for making the API call. Additionally, you must implement error handling for any potential issues that may arise during the API call, such as connection errors or invalid inpu... | codefeedback |
Create a JSON data structure to represent a car with the following fields: make, model, color, year, engine type, transmission type, number of doors, and price. Additionally, add a nested object called "owner" with fields for name, age, and address.
However, ensure that the "price" field can only accept numerical valu... | codefeedback |
Create an array of size 10, initialize the array elements with random prime numbers between 1 to 100. Additionally, ensure that the sum of all prime numbers in the array is greater than 200. | codefeedback |
Compute the hamming distance between two strings and print the result, but this time, the strings can have varying lengths. If the strings have different lengths, the hamming distance should only be computed up to the length of the shorter string. If the strings have the same length, the hamming distance should be comp... | codefeedback |
Using CSS, create a responsive page layout with two columns of equal width. The page layout should adapt to different screen sizes and should have a minimum width of 600px. Additionally, the columns should have a 10px margin between them and the page should have a maximum width of 1200px. The layout should also have a ... | codefeedback |
Create an HTML form to ask the user for their email, password, and an additional security question. The security question should be "What is the name of your favorite childhood pet?" and should have a dropdown menu with at least 5 options to choose from. Additionally, the form should have client-side validation to ensu... | codefeedback |
Calculate the scalar product of two vectors and print the result. The vectors can have a maximum length of 10^6. The vectors must contain only positive integers. The program should handle the case where one or both vectors are empty. Vector1: [1,2,3,4,5,6,7,8,9,10]. Vector2: [11,12,13,14,15,16,17,18,19,20]. | codefeedback |
Count the number of words in the given sentence that start and end with a vowel, considering both lowercase and uppercase vowels, and print the result. The sentence will contain at least 15 words and each word will have a maximum length of 20 characters. Additionally, you should exclude any words that contain a vowel f... | codefeedback |
Create an Android application with a Button and a TextView. When the button is clicked, the TextView should be populated with the text "Hello, World!". Additionally, the button should change its background color to a random color after being clicked, and the TextView should display the number of times the button has be... | codefeedback |
Construct an SQL query to list the name, age, and email address of all female students who are taking the course ‘Data Science’ and have scored above 90 in both the midterm and final exams, and have not missed any class. | codefeedback |
Create a class in Java representing a car with the following attributes and functionalities:
1. Make: A string representing the make of the car.
2. Model: A string representing the model of the car.
3. Year: An integer representing the manufacturing year of the car.
4. Color: A string representing the color of the car... | codefeedback |
Create a script to fetch the information from the following API endpoint. However, this API has implemented a rate limit, allowing only 5 requests per minute for each user. Your script should be able to handle this rate limit and ensure that no more than 5 requests are made within a minute for each user. If the rate li... | codefeedback |
Write a code to update a given column using the data from another table, but the update should only happen if certain conditions are met.
Table1: Student
Table2: Course
Column to be updated: Student.CourseId
Conditions:
- The update should only happen if the CourseId from Table2 is greater than 5.
- The update should... | codefeedback |
Write a function called `get_prime_numbers()` that takes in an integer `n` as a parameter and returns a list of the first `n` prime numbers.
You should use the Sieve of Eratosthenes algorithm to efficiently find prime numbers. The Sieve of Eratosthenes algorithm works as follows:
1. Create a boolean array `is_prime[0... | codefeedback |
Design an algorithm to detect the pattern of spikes in an EEG while ensuring that the algorithm can handle EEG data with varying levels of noise and artifacts. Consider the following additional requirements:
1. Implement a noise reduction technique, such as wavelet denoising or bandpass filtering, to reduce the impact... | codefeedback |
Create and initialize a two-dimensional array of size 8x8 with randomly generated integers between 1 and 100 (inclusive). The sum of all elements in the array should be greater than 400. | codefeedback |
Write a Java method to convert a given decimal number to its equivalent English words. However, you must implement the conversion logic yourself without using any pre-built libraries or classes for number to word conversions. You can only use basic arithmetic and string manipulation operations to achieve the desired re... | codefeedback |
Generate a function to calculate the grade of a student based on their marks. The grading system is as follows:
- Marks above or equal to 95% are given an 'A+' grade.
- Marks between 90% and 94% (inclusive) are given an 'A' grade.
- Marks between 85% and 89% (inclusive) are given a 'B+' grade.
- Marks between 80% and ... | codefeedback |
Create a thread-safe singleton class with lazy initialization and ensure that the singleton instance is immutable. | codefeedback |
Generate a function to check for the largest common divisor between two numbers that runs in O(log(min(a,b))) time complexity and uses constant space. Additionally, the function should not use the modulus operator (%) or any built-in math functions such as sqrt() or pow(). | codefeedback |
Write a function named "calculate_average" that takes a list of positive numbers as input and returns their average, rounded to two decimal places. The function should also handle empty lists by returning 0. Additionally, the function should check if the list contains any non-numeric values and raise a ValueError if it... | codefeedback |
Generate a random password with 20 characters including uppercase letters, lowercase letters, digits, and symbols. The password should not contain any repeating characters and should have at least two characters from each category (uppercase letters, lowercase letters, digits, symbols) with no consecutive characters be... | codefeedback |
Design a class that can create objects with a unique ID, ensuring that the IDs are sequential and cannot be repeated, while also maintaining thread-safety in a multi-threaded environment. Additionally, the class should have a method to retrieve the total number of objects created so far. | codefeedback |
Suggest a comprehensive strategy to minimize memory usage in a given application while ensuring optimal performance and minimal impact on code readability. Additionally, provide a code snippet demonstrating a complex memory-related error and explain in detail how to fix it.
#Rewritten Test (2)#
Design an efficient mem... | codefeedback |
Use JS to create an object called `user` which contains two properties: `name` with a string value of "John Doe", and `age` with a numeric value between 18 and 60. Additionally, the `user` object should have a third property called `address` with an object value that contains the following properties: `street` with a s... | codefeedback |
Write an SQL query to select the top 10% of the most expensive products from a table called 'products'. Additionally, display the total sum of the prices of these products and the average price of all the products in the result. | codefeedback |
Edit this code to make the function take an integer n as an argument and print the fibonacci series till the nth term, using a recursive approach.
However, you should also make the following changes to increase the difficulty:
1. Add error handling for invalid input. The function should raise a ValueError if n is not... | codefeedback |
Write a code in Python to convert a string of text to its equivalent uppercase characters, without using any built-in string methods or libraries. Additionally, you should also remove any whitespace characters from the given string.
str_lower_case = "hello world" | codefeedback |
Generate a web page which shows the top 10 trending movies of the year, where each movie must have at least 500,000 votes and be rated above 8.5 on a scale of 10. Additionally, the movies should be sorted based on their popularity score, which is calculated by a weighted average of their ratings and number of votes. Th... | codefeedback |
Define a function that takes in two numbers, and calculates the power of the first number raised to the power of the second number. The function should have a time complexity of O(log(n)) where n is the value of the exponent. Additionally, the function should not use any built-in exponentiation or logarithmic functions... | codefeedback |
Write a code that takes in a list of names and creates a dictionary with the names as keys and their lengths as values. The code should ignore any names that contain numbers or special characters. The dictionary should be sorted in descending order based on the lengths of the names. Additionally, the code should remove... | codefeedback |
Create a code that takes in a sentence and outputs counts of each word and its frequency (how often it occurred), excluding common words such as "the", "is", and "to". Additionally, the code should remove any numbers present in the sentence. The code should ignore punctuation and handle case sensitivity. Finally, the c... | codefeedback |
Write HTML to create a form with the following requirements:
- The form should have three input elements: a text input, a password input, and a file input.
- The text input should have placeholder text "Enter your username" and be required to fill before submitting the form.
- The password input should have placeholder... | codefeedback |
Create a code to input a 2D matrix of integers (with each integer between -1000 and 1000) and output the sum of each row, excluding any rows where the sum is less than 10 or greater than 1000. Additionally, calculate the average of each column and output the column with the highest average. | codefeedback |
Create a class in Python to represent an employee and define the attributes. Additionally, implement a method that calculates the employee's annual bonus based on their performance rating. The performance rating is a decimal value between 0 and 1, with 0 being the lowest and 1 being the highest. The bonus is calculated... | codefeedback |
Develop a web page layout using HTML, CSS, and JavaScript to create a three column layout with a header, footer, and content. The header should have a fixed position at the top of the page, the footer should have a sticky position at the bottom of the page, and the content should have a scrolling feature if the content... | codefeedback |
Generate a paragraph from a given text input, using a GPT-3 model. Ensure that each sentence in the generated paragraph ends with a punctuation mark. Additionally, remove any repeated sentences from the generated paragraph. Here is an example input: "This is a sentence. This is another sentence. Here is a third sentenc... | codefeedback |
Create a code which takes in a list of strings, and returns a string with all the characters of the strings sequentially. The input list can contain duplicate strings. The output string should only contain unique characters, and should be sorted in lexicographic order.
Example:
Input: ["Hello", "World", "World"]
Outpu... | codefeedback |
Compose a query to find the titles of the movies released in 2021, which produce revenue more than $2,000,000, have a rating higher than 8.0, and are classified as action movies. Sort the results in descending order of revenue, and limit the results to the top 10 movies only.
movies_table = 'movies'
# Additional Info... | codefeedback |
Write a function that takes a NumPy array as input and converts it to a list. However, the function should also sort the elements in descending order before converting it to a list. The function should have a time complexity of O(n log n), where n is the number of elements in the array.
import numpy as np
def conve... | codefeedback |
Given a string of alphanumeric characters, write the appropriate regex pattern that checks if the string contains exactly two consecutive digits and at least one uppercase letter. | codefeedback |
Given a document, remove all numbers from the content. The document can contain multiple lines and can have up to 10^6 characters. The algorithm should have a time complexity of O(n), where n is the number of characters in the document, and should use only O(1) space. The document can contain any printable ASCII charac... | codefeedback |
What is the result of using the "==" operator to compare two variables of different data types in Python? | codefeedback |
Write a JavaScript program to calculate the sum of each individual index value from two given arrays of equal length, where each value in the array must be greater than or equal to zero. Additionally, the program should return the sum as a string with a preceding '$' symbol. Furthermore, the program should only use a s... | codefeedback |
Establish a secure database connection using the inputs given and ensure that the password is encrypted using SHA-256 hashing algorithm. Only allow connections from the specified hostname "localhost" and reject any connection attempts from other IP addresses. The database username should be at least 8 characters long a... | codefeedback |
Sort the given two lists in ascending order and merge them into a single sorted list. Additionally, ensure that the time complexity of the solution is O(nlogn), where n is the total number of elements in both lists. | codefeedback |
Create a SQL query for finding the number of orders made each day in a given month, but exclude orders with a status of 'cancelled'. The orders_table has the following columns: order_id, customer_id, order_date, status. Additionally, the query should also calculate the total order value for each day. Use the orders_tab... | codefeedback |
Given a string, classify the sentiment of the text as either positive or negative. The sentiment classification should take into account both the overall sentiment of the text as well as the sentiment associated with each individual word in the text. The sentiment of each word should be determined based on a pre-traine... | codefeedback |
Write a SQL statement to retrieve the name, age, and department of all employees who are older than 33, have been with the company for more than 5 years, and have a salary above the company average. | codefeedback |
Write a MySQL query to select the name of the customer, the total sales made by each customer, and the number of unique products purchased by each customer in a given month. Additionally, display the percentage of total sales that each customer contributed to in the given month.
tables:
customers_table = 'customers';
... | codefeedback |
Implement a function that takes in a string as input and returns the length of the longest substring without repeating characters. The function should have a time complexity of O(n).
For example, given the input "abcabcbb", the function should return 3, as the longest substring without repeating characters is "abc". | codefeedback |
Create a C++ code to generate 10 random numbers between 1-100 and store them in an array. Sort the array in ascending order using a sorting algorithm of your choice (not built-in sort function). Then, find the sum, average, and standard deviation of the numbers. Ensure that the sum is calculated using a separate functi... | codefeedback |
Create a function that takes in two integers, `rows` and `cols`, and returns a `rows x cols` matrix using nested lists.
The matrix should be initialized with random integer values between 1 and 10 (inclusive).
Additionally, the function should check if the sum of all the integers in the matrix is a prime number.
Con... | codefeedback |
Implement a function to check if two binary trees are structurally identical or not. Two binary trees are considered structurally identical if they have the same structure and the same node values at each corresponding position.
To solve this problem, follow these steps:
1. Define a function named `isStructurallyIdent... | codefeedback |
How to convert a pandas DataFrame to a python list while excluding null values and ensuring the list is sorted in descending order based on a specific column? Write a function called `convert_df_to_list` that takes three arguments: `df` (a pandas DataFrame), `column` (a string representing the name of the column to sor... | codefeedback |
Write a CSS selector to select all the list items with class "list-item" and with a data attribute of "active", except for those that are descendants of an element with the class "exclude". | codefeedback |
Edit the following HTML code to redirect the user to example.com on click. The code must be written using only pure JavaScript and no external libraries or frameworks. The button element should have a class attribute with the value "redirect-button". Additionally, the redirect should only occur if the user's browser su... | codefeedback |
Sort the following list of numbers in ascending order: 53, 8, 12, 4, 21, but without using any built-in sorting functions or libraries. Additionally, you are not allowed to use any additional data structures or arrays. The sorting algorithm must be implemented in-place, modifying the original list directly. | codefeedback |
How many types of methods are available in Python? Provide a detailed explanation of each type, including their syntax and use cases. Additionally, provide code examples for each type of method. | codefeedback |
Design a JavaScript function that takes three inputs (a, b, and c) representing the lengths of three sides of a triangle and determines whether the triangle is equilateral, isosceles, or scalene. The function should also handle cases where the inputs are negative or zero.
Additionally, the function should include erro... | codefeedback |
Design a Java program for computing the weighted average of a given list of numbers, with each number having a specific weight assigned to it. The list of numbers can contain duplicates and can be unsorted.
List of numbers: [1, 2, 4, 5, 2, 1, 3, 5, 4]
List of weights: [0.5, 0.25, 0.15, 0.1, 0.05, 0.02, 0.01, 0.01, 0.00... | codefeedback |
Create a PHP function that calculates the difference between two dates in months, weeks, days, hours, minutes, and seconds. The function should handle leap years, validate the input dates to ensure they are in the format 'YYYY-MM-DD' and fall within a specified range of 1800-01-01 to 2200-12-31, account for different t... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.