instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Generate a sentence that consists of at least 10 unique words, where each word must have a length greater than 5 characters and start with a vowel. The sentence should also be in alphabetical order.
codefeedback
You need to fix the following code to make it work correctly. The code should return the mean of the numbers in the input list, rounded to the nearest integer. You should also ensure that the code handles cases where the input list is empty or contains non-numeric values. Additionally, the code should be optimized to h...
codefeedback
Create a function in C++ that inserts a new student name and score in the given 2D vector. The function should also handle cases where the new student name is already present in the vector and should update the corresponding score instead of adding a new entry. students = [ ["Sam", 70], ["Tom", 85], ["Jess...
codefeedback
Implement a stack using a doubly linked list, where each node contains an integer value. The stack should have a maximum capacity of 1000 nodes and should throw an exception if a push operation is attempted when the stack is full. Additionally, the stack should have a method that returns the minimum value currently sto...
codefeedback
List the different access modifiers in Java and provide an example of each. Additionally, you must explain the difference between the "default" access modifier, the "protected" access modifier, and the "private" access modifier, and provide a use case scenario for each. Finally, explain the concept of inheritance and h...
codefeedback
Create an algorithm in Java to sort an array in descending order using a specific sorting algorithm called "QuickSort". However, there is a bug in the provided code that needs to be fixed before the array can be correctly sorted. Find and correct the bug in the code. array = [10, 15, 7, 2, 13, 18]
codefeedback
Create a function in JavaScript to convert a given string to a positive integer. However, the string may contain non-digit characters in between the digits and at the beginning or end of the string. For example, if the string is "3a2b3", the function should return 323. If the string is "1a0b0c5", the function should r...
codefeedback
Write an algorithm in python to find the second largest number of an unsorted list. The algorithm should handle edge cases such as an empty list or a list with duplicate numbers. Additionally, it should optimize the algorithm to have a time complexity of O(n), handle lists with a very large number of elements efficient...
codefeedback
Create a program in Python to find the longest common contiguous subarray between two integer arrays. The program should have a time complexity of O(n) and space complexity of O(1). int arr1[8] = {1,2,4,4,4,4,7,9} int arr2[6] = {1,4,4,5,5,9} Note: The given arrays are sorted in ascending order. Rewritten Test: Crea...
codefeedback
Construct an algorithm in python to find the length of the longest common substring between two strings. The input strings are str1 and str2. The algorithm should return the length of the longest common substring. # Example str1 = "abbcdefg" str2 = "zabxdefujh" output: 4 # Additional Requirements 1. The algorithm sho...
codefeedback
You need to generate a list of all the prime numbers between two given numbers. Additionally, you should implement the Sieve of Eratosthenes algorithm to optimize the solution and improve its efficiency.
codefeedback
Write a function to compute the product of all elements in a matrix, but return -1 if any element in the matrix is zero or negative. [[1, 2, 3], [4, -5, 6], [7, 8, 0],] #Additional Reasoning Steps# 1. Check if any element in the matrix is negative. If yes, return -1. 2. Check if any element in the matrix is zero. I...
codefeedback
Categorize a given list of integers into odd and even numbers, and display the results in ascending order. Additionally, the program should only use a single loop for efficiency. The program should have a time complexity of O(nlogn) and should not use any built-in sorting functions. [9,8,7,6,5,4,3,2,1]
codefeedback
Write a SQL query to delete the record of a person whose id is 1234, but only if their age is greater than 18, they have a salary above $50,000, and their employment status is "full-time".
codefeedback
Create a function in JavaScript to create a subset of a given array, but the subset must contain all possible combinations of k elements from the original array, where k is an even number. Additionally, each combination must contain at least one element that is a prime number. The output should be an array of arrays, w...
codefeedback
Generate a PHP array containing 1000 random prime numbers in the range 0 to 10,000.
codefeedback
Create a dictionary with three key-value pairs in Python. The keys must be unique and consist of alphanumeric characters only. The values must be strings and have a minimum length of 5 characters. Additionally, the dictionary must be sorted in ascending order based on the keys.
codefeedback
You need to compute the sum of all odd elements in a given matrix, where the matrix can now have negative numbers as well. The matrix will always have at least one row and one column. Additionally, you are now required to solve the problem in a single pass through the matrix without using any extra space.
codefeedback
You need to implement a class for a numerical calculator that supports addition, subtraction, multiplication, and division operations. Additionally, the calculator should be able to handle complex numbers and perform calculations with precision up to 10 decimal places.
codefeedback
Write an SQL query to select the most recent entry from a table, but only for users who have registered within the last month. Table Name - user_table Field Names - name, date Reference Erroneous Code: ``` SELECT name, MAX(date) FROM user_table WHERE date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY name ORDE...
codefeedback
Write an HTML page to create a survey form with a minimum of 15 questions and a maximum of 30 questions. Each question should have a minimum of 3 options and a maximum of 6 options. Additionally, the survey form should have a timer that counts down from a randomly generated time interval between 5 and 15 minutes and au...
codefeedback
Write a Python function to calculate the Fibonacci sequence up to a given limit, N. The function should take an integer N as input and return a list of Fibonacci numbers up to N. The function should handle N being less than or equal to 0, and should return an empty list in such cases. Additionally, the function should...
codefeedback
Create a Swift code to find the maximum number from an array of integers. Your solution should also return the index of the maximum number in the array. Additionally, you must implement the solution using a recursive approach. Make sure to handle empty arrays and arrays with negative numbers.
codefeedback
Create a CSS class for displaying large text in an HTML page. The font size must be 5 times larger than the default font size, and the text color must be a shade of purple. Additionally, the class should include a hover effect that changes the background color to a shade of green when the mouse is over the text.
codefeedback
Use Python to call an API to get the current temperature in New York City and convert it from Fahrenheit to Celsius. Additionally, display the temperature in both Celsius and Kelvin. Handle any errors that may occur during the API call and display an appropriate error message.
codefeedback
Write a function in JavaScript to check if a given list of strings is a palindrome. The function should return true if the list is a palindrome, and false otherwise. A palindrome list is defined as a list where the concatenation of its elements in reverse order is the same as the original list. Example: let list = ['r...
codefeedback
Create a virtual environment with Python version 3.9 and ensure that it has the necessary packages installed for web scraping, data visualization, and machine learning. Additionally, the virtual environment should include TensorFlow and scikit-learn libraries for implementing a neural network model and performing data ...
codefeedback
Given a table named "students" with the following columns: - id (integer) - name (string) - age (integer) - score (float) Write a MySQL query to calculate the median of the "score" column for all students who meet the following criteria: 1. Only consider students who are older than 18 years old. 2. Exclude any studen...
codefeedback
Design an algorithm to check if a number is a palindrome, where the number can be of any size. The algorithm should have a time complexity of O(log n), where n is the number of digits in the input number. Additionally, the algorithm should use only constant space complexity and should not convert the number to a string...
codefeedback
Create a shell script to find the size of all folders in a directory, but exclude any folders that have the word "temp" in their name. Additionally, exclude any folders that have more than 10 files in them.
codefeedback
Design a data structure to hold a user's name, age, and city. Additionally, include a field for the user's email address and phone number. Ensure that the email address follows a specific format: it must contain the user's first name, followed by a dot, followed by their last name, followed by a domain from a predefine...
codefeedback
What is the sum of all the prime numbers in list l? l = [1,2,3,4,5,6,7,8,9,10]
codefeedback
Create a React component to display a list of 10 user names. Each user name should be displayed inside a clickable button. When a button is clicked, an alert should be displayed with the corresponding user's name. The user names should be fetched from an API endpoint: https://example.com/users. The endpoint returns an ...
codefeedback
Write a function in Python to shuffle an array, ensuring that no two adjacent elements in the shuffled array have a difference greater than 1. Additionally, the shuffled array should have the smallest possible difference between its minimum and maximum values. The time complexity of the solution should not exceed O(n l...
codefeedback
Create a function that takes a string and returns the first letter of each word in the string, but exclude any vowels in the first letters. The returned letters should be in uppercase. The string will only contain alphabetic characters and spaces. Additionally, the function should handle cases where the string contains...
codefeedback
Create a C++ object class that stores information about different employees. Each employee should have the following attributes: - name (string) - age (integer) - address (string) - salary (double) Implement the following methods in the class: 1. A constructor that initializes the object with default values for all at...
codefeedback
Create a function that retrieves the first value from a dictionary that starts with a given letter and is greater than a specified number. The dictionary must have at least 5 key-value pairs. The function should also return the key associated with the retrieved value. Additionally, the function should handle cases wher...
codefeedback
Find the maximum element in a Binary Search Tree without using recursion or any built-in functions or libraries. The time complexity of your solution should be O(h), where h is the height of the tree. The space complexity should be O(1).
codefeedback
Create a function that takes in a string and returns a dictionary with each unique word as a key and the number of times it appears in the string as the value. The function should ignore punctuation and be case insensitive. The function should have a time complexity of O(n), where n is the length of the string. Exampl...
codefeedback
Build a mobile app with React Native to display the current temperature and weather conditions (e.g., sunny, cloudy, rainy) of a given city. Additionally, the app should include a feature to display a 5-day forecast for the selected city. However, the app should retrieve the weather data from a custom-built API server ...
codefeedback
Develop a Java method to calculate the square root of a given positive number n without using any built-in math functions or libraries. The method should handle both integer and floating-point inputs. Your solution should have a time complexity of O(logn) and should return the square root rounded to the nearest integer...
codefeedback
Is a valid ISBN-10 number with hyphens or spaces? isbn = "0-478-15668-6" # Instructions An ISBN-10 (International Standard Book Number) is a unique identifier for a book. The ISBN consists of 10 digits and is divided into four parts of varying lengths, separated by hyphens or spaces. The last digit is a check digit th...
codefeedback
Create an SQL query that finds the average number of orders for each customer over the last year, excluding any customers who have not placed any orders in the last year. The query should also display the total count of orders for each customer, as well as the customer's name and contact information. Additionally, the ...
codefeedback
Sort this list of strings in reverse alphabetical order, while ignoring any case differences. Additionally, ensure that the sorting is stable, meaning that if two strings have the same value after ignoring case, their original order in the list should be maintained. strings = ['Hello', 'world', 'this', 'is', 'A', 'lis...
codefeedback
Generate a random set of 10 unique numbers between 0 and 1000, with the condition that the sum of the numbers must be a prime number. Additionally, ensure that all the numbers in the set are divisible by 3.
codefeedback
Please write a program that calculates the sum of all prime numbers from 1 to a given number (inclusive).
codefeedback
Create a SQL query to return the names of all customers whose balance is greater than 1000 and have made a purchase in the last 30 days, sorted in descending order by their balance.
codefeedback
Implement a quick-sort algorithm in Python to sort a given array in ascending order. Your implementation should handle arrays with duplicate elements efficiently and should have a time complexity of O(nlogn). Additionally, you are not allowed to use any built-in sorting functions or libraries in your implementation. Fu...
codefeedback
Create a function that takes a string and displays it in the output, but with each character repeated three times. Additionally, the function should reverse the order of the characters in the output. Input: "Hello World" Output: "dddllllooo dlrrroooW"
codefeedback
Write a SQL query to retrieve the names, addresses, and email addresses of customers from the "customer" table who live in the same city as the customer with ID 3, have made at least 2 purchases in the past month, and have a total purchase amount greater than $100.
codefeedback
Create an object-oriented design in Python to represent a customer, with the following requirements: 1. The customer should have a unique identifier, which is a combination of their name and a randomly generated alphanumeric string. 2. The customer should have a name, address, contact information, and an email address...
codefeedback
Write a Python function to calculate the least common multiple (LCM) of a list of numbers. The function should take a list of integers as input and return the least common multiple of all the numbers in the list. The function should have a time complexity of O(n log n), where n is the length of the input list. To cal...
codefeedback
Create a stack data structure using Python with the additional requirements: 1. The stack must have a maximum capacity of 100 elements. 2. The push operation should have a time complexity of O(1). 3. The pop operation should have a time complexity of O(1). 4. The peek operation should have a time complexity of O(1). 5...
codefeedback
Implement a binary search algorithm to find the first occurrence of a target integer in a sorted list of integers using Python. Write a function called binary_search_first that takes in two parameters: a sorted list of integers called nums, and a target integer called target. The function should return the index of th...
codefeedback
Write a Python function that takes in a sentence as input and returns the sentiment analysis score of the sentence. The sentiment analysis score should be a decimal number ranging from -1.0 to 1.0, where -1.0 indicates extremely negative sentiment and 1.0 indicates extremely positive sentiment. The function should ana...
codefeedback
Modify the C++ program below to print the average value of an array, but without using the arithmetic operators '+', '-', '*', or '/'. ``` #include <iostream> int main() { int array[4] = {2, 3, 5, 7}; int sum = 0; int n = sizeof(array)/sizeof(array[0]); for(int i = 0; i < n; i++) { sum += arr...
codefeedback
Write an SQL statement to display all the records from the 'Cars' table and sort them in descending order based on the 'Year' column. Additionally, only display records where the 'Make' column is not null and the 'Model' column starts with the letter 'A'.
codefeedback
Modify the given code to implement an Insertion Sort algorithm that sorts the elements of the input array arr in non-decreasing order. The array arr may contain duplicate elements. The modified code should have a time complexity of O(n^2) and should not use any built-in sorting functions or libraries. Additionally, the...
codefeedback
Rewrite the given code to use a dictionary comprehension and ensure that the resulting dictionary only contains names with odd lengths. Additionally, the code should ignore any names that start with a vowel. The names should also be sorted in descending order based on their lengths.
codefeedback
Create a Ruby program to count the occurrences of each character in a given string and display them in descending order. However, you are not allowed to use any built-in Ruby methods or libraries for counting or sorting the characters.
codefeedback
Write a Python program to implement a text-based game where the player must navigate through a randomly generated maze and solve puzzles to advance to the next level. The game should have a time limit for each level, and the player's score should be based on how quickly they complete each level. The program should also...
codefeedback
Write a Java program to find the second maximum and second minimum values in an array of integers, excluding any duplicates. #Additional Notes# - The array can contain both positive and negative numbers. - The array may have a variable number of elements, ranging from 1 to 1000. - The program should return both the se...
codefeedback
Write a query to display the top five employees from the table "employees" with the highest salaries, along with their department names and job titles, in descending order of their salaries.
codefeedback
Create a MongoDB query to find all documents where "sale_price" is greater than 10, "quantity" is less than 100, and "category" is equal to "electronics".
codefeedback
Replace 'x' with the correct input from an API request. Url: https://exampleAPI.com/user?id=2 Response: { "name": "John Doe", "age": "50" } Write a program to retrieve the user's name and age from the API response and store them in variables. Conditions: - You are not allowed to hardcode the values "John Doe"...
codefeedback
Write a function that takes in a list of integers and returns a dictionary representing a frequency table of the integers. The keys of the dictionary should be the unique integers from the list, and the values should be the number of times each integer appears in the list. Your solution should handle the following edg...
codefeedback
Create a MySQL query to display all the distinct items from the table "Orders" and their corresponding quantities. Additionally, calculate and display the total quantity of each item across all orders. Consider the following additional requirements: 1. Exclude any items that have a quantity of 0. 2. Sort the results i...
codefeedback
Write a function to search for an element within a doubly linked list. #Additional Information# 1. A doubly linked list is a linked data structure that consists of a set of sequentially connected nodes. Each node contains two pointers, one pointing to the previous node and one pointing to the next node. The first node...
codefeedback
Create a new array after doubling the value of all numbers in the given array. The input array can contain both positive and negative integers. The size of the input array can be up to 10^6 elements. The resulting array should be sorted in non-decreasing order. Additionally, the resulting array should not contain any d...
codefeedback
Evaluate the sum of two numbers and the product of two numbers using a JavaScript expression. Additionally, calculate the sum and product of the sum and product of the two numbers. Print all the results. The numbers should be within the range of 1 to 100.
codefeedback
Create a database table with the following fields: id, name, age, email, phone_number, address Write a program that prompts the user to enter data for each field and inserts it into the database table. Validate the user input to ensure that the email is in the correct format, the phone number is in the correct format,...
codefeedback
Merge the two given arrays and remove duplicates. The merged array should be sorted in ascending order. In addition to the previous requirements, you should now implement the merge sort algorithm to merge the two arrays in O(n log n) time complexity. You should also implement an efficient algorithm to remove duplicat...
codefeedback
Write a C# program to calculate the area of a triangle. Your program should handle triangles with both positive and negative lengths for their sides. Additionally, the program should check if the given side lengths form a valid triangle, i.e., the sum of any two sides should be greater than the third side. To further ...
codefeedback
Write a JavaScript function that takes in a number and a specific number of decimal places as parameters. The function should format the number to the specified decimal places and round it accordingly. The function should also handle negative numbers and numbers with a large number of decimal places. #Example# format...
codefeedback
Create an assembler program to count the number of vowels in a given string, while ignoring any vowels that are followed by a consonant. Additionally, you should implement the following requirements: 1. The program should handle both uppercase and lowercase letters as vowels. 2. The program should handle special charac...
codefeedback
Create a Chrome extension that highlights hyperlinks in green, but only if they are nested within a specific div with a class of "highlight-container" and have a data attribute of "highlight-link". The extension should also display a tooltip with the number of times each highlighted link has been clicked, and prevent t...
codefeedback
You are given an array of strings. Generate a unique key for each item in the array and store it in a new array. The key should be a combination of the first two letters of the item in uppercase, followed by a random number between 100 and 999. Additionally, the key should be unique among all the keys generated. For e...
codefeedback
Create a JavaScript function to extract the text from a given HTML element, but you cannot use any built-in HTML parsing libraries, regular expressions, or DOM manipulation methods such as `querySelector`, `getElementById`, or `innerHTML`.
codefeedback
Write a query to select all artworks whose titles starting with a 'C' and have a year of creation after 2000. Additionally, the artworks must have been created by an artist whose name contains the letter 'A' and have a price higher than $1000.
codefeedback
Write a Ruby program to convert the temperature from Fahrenheit to Celsius. The program should also display a message indicating if the converted temperature is below freezing (32°F) or above boiling (212°F). However, the program should also be able to handle temperature values in the range of -273.15°C (absolute zero...
codefeedback
Write a JavaScript program to convert month numbers to month names. However, you are not allowed to use any built-in JavaScript functions or libraries that directly provide month names. Additionally, you cannot use arrays or other data structures to store the month names. You have to implement the conversion logic usin...
codefeedback
Write a JavaScript function that extracts the numbers from a given string, while ignoring any non-alphanumeric characters. The function should meet the following requirements: 1. The function should return an array containing all the extracted numbers. 2. The function should be case-sensitive, meaning it should differ...
codefeedback
Write a function in R that takes in a vector as input and returns a new vector containing only the unique elements from the input vector. You should not use any built-in functions or libraries that directly solve this problem (e.g., the `unique()` function). Instead, you should implement your own logic to identify and ...
codefeedback
Write a SQL query to return the first name, last name, salary, and department of employees from a database with the given conditions: - Table Name: Employees - Salary > 50000 - Department must have at least 3 employees with salaries greater than 50000. - Only include departments where the average salary of all employee...
codefeedback
Generate an array of numbers from 0-100 in Python, but with the constraint that all the numbers in the array must be unique, in increasing order, and must satisfy the following conditions: 1. The sum of all the numbers in the array must be a prime number. 2. The number of odd numbers in the array must be a perfect squ...
codefeedback
Use PHP to convert a given decimal number to binary, without using any built-in functions or libraries, and without using any loops.
codefeedback
Create a JavaScript function to accept a range of numbers (from 1 to 10000) and display all the prime numbers within that range. The function should also calculate the sum of all the prime numbers and display it along with the list of prime numbers.
codefeedback
Rewrite a program in C language to determine whether a given string is a palindrome or not. The program should consider the case of characters (uppercase or lowercase) as well as any non-alphanumeric characters present in the string. The program should only consider alphanumeric characters for the palindrome check. Add...
codefeedback
Create a JavaScript function called "createUser" that takes in three parameters: name, age, and location. The function should validate the input and return an object with properties name, age, and location. The name parameter must be a string containing at least 3 characters. If the name is invalid, the function shou...
codefeedback
Make a Perl program to detect whether a given string is a valid phone number. Requirements: 1. A valid phone number must be in the format of xxx-xxx-xxxx, where x represents a digit. 2. The area code (first three digits) must not start with a zero or one. 3. The second group of three digits must not start with a zero ...
codefeedback
Write a program that takes a string as input and outputs the sum of the Unicode values of all characters in the string, excluding any characters that are not letters (a-z and A-Z). The program should also handle special characters, such as spaces and punctuation marks, by subtracting their Unicode values from the final...
codefeedback
Write a SQL query to find the oldest customer who has made at least three purchases in the past month, where each purchase has a different product category.
codefeedback
Create a function which takes two lists and outputs all the common elements. The function should ignore duplicates in both lists and should return the common elements in ascending order. Additionally, the function should also return the count of common elements. The input lists can contain both positive and negative in...
codefeedback
Write a SQL query to find all the customers who have made at least 5 orders with a total amount greater than 10000, and have placed their orders in the last 3 months. Additionally, the query should only consider orders with a status of "Completed" or "Shipped".
codefeedback
Given the following HTML structure, write a CSS selector that selects the h2 tags with class "green" and contains the text "Title". Only select elements that are direct children of the div element. Additionally, make sure the selected h2 tags are not preceded by a p tag.
codefeedback
Convert the given list of strings to a dictionary whose keys are numbers and whose values are strings. The numbers should be in ascending order starting from 1, and the strings should be in uppercase letters. The resulting dictionary should only include strings that have at least 5 characters, contain at least two vowe...
codefeedback
Calculate the sum of all odd numbers from 1 to 1,000,000, but only considering the numbers that are divisible by 3 and not divisible by 5.
codefeedback
Create a JavaScript program to validate the username entered by the user, which must meet the following criteria: 1. The username must be between 8 and 16 characters long. 2. The username must start with a letter (a-z or A-Z). 3. The username can only contain letters, numbers, underscores, or hyphens. 4. The username m...
codefeedback
Create an object of class 'Car' that has the following properties: - A color property that can only be set to one of the primary colors (red, blue, or yellow) - A make property that can only be set to one of the following makes: Ford, Toyota, Honda, or BMW - A model property that can only be set to one of the following...
codefeedback
Calculate the maximum product of four numbers in a list, where at least two of the numbers must be negative and one of them must be odd. [4, -2, 3, -1, 5, -3, 7]
codefeedback