instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Create a loop in Python that prints the prime numbers between 1000 and 2000 and also calculates the sum of these prime numbers.
codefeedback
Create a while loop in JavaScript that reverses an array and prints each element to the console. The array to be reversed is ["apple", "banana", "orange", "grape"]. However, you are not allowed to use any built-in array manipulation methods such as reverse() or sort(). Additionally, you are not allowed to use any addi...
codefeedback
Modify the following SQL query so that it returns the customers who have made a purchase in the last 30 days and have not yet made a purchase in the city "New York". Additionally, exclude customers who have made a purchase in the city "Los Angeles" in the last 15 days. SELECT * FROM Customer WHERE City <> 'New York' A...
codefeedback
Construct a HTML form for user registration that includes the following specific requirements: 1. The form should have fields for the user's first name, last name, email address, password, and a confirm password field. 2. The first name and last name fields should be mandatory and should only allow alphabetic characte...
codefeedback
Write a JavaScript function that takes an input string and replaces all occurrences of the letter 'e' with an asterisk, but only if it is followed by the letter 'o'. Otherwise, leave the letter 'e' unchanged. Constraints: - The input string can have a maximum length of 10^6 characters. - The function should have a tim...
codefeedback
Write a Python program that takes an integer as input and prints the same message that many times, but only if the input number is a prime number and greater than 100.
codefeedback
Design a JavaScript class for a bank account with two private variables, account_balance and transactions. The class should have four public functions: deposit(amount), withdraw(amount), getBalance(), and getTransactionHistory(). The deposit(amount) function should add the given amount to the account_balance variable ...
codefeedback
Design a function in Java that takes in a string and returns true if the string contains at least three occurrences of the letter "a" and false otherwise. The function should be case-sensitive and should consider both lowercase and uppercase versions of the letter "a". Additionally, the function should ignore any occur...
codefeedback
Write a function in Python to move the second-to-last element of a given list to the beginning of the list. However, you are not allowed to use any built-in list manipulation methods or slicing operations. You can only use basic operations such as assignment, loops, and conditionals. Additionally, your solution should...
codefeedback
Create a web page that displays a list of 1000 items. Each item should have a clickable link that opens in a new tab and has a custom tooltip text when hovered over. The list should be dynamically generated using JavaScript and should have a search bar at the top that allows users to filter the items by name. The searc...
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 or equal to 40, whose username contains the letter "a", and whose email address ends with ".com".
codefeedback
Generate code to create a PDF report from a given dataset of customer orders, with additional requirements and constraints. 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 fil...
codefeedback
Create a function in Python to generate a list of consecutive prime numbers starting from 2 up to a given number. The given number should be greater than 2 and less than or equal to 10^6. The function should have a time complexity of O(n^2) or less and should use a memory-efficient approach to store the prime numbers. ...
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. A...
codefeedback
Create a function to calculate the sum of the first n prime numbers less than 1000, where n is a positive integer not exceeding 100, and the function should have a time complexity of O(n^2) or better. Use JavaScript.
codefeedback
Reverse the order of the values in the input list without using any built-in Python functions or methods, and ensure that all negative numbers in the list are placed at the end of the reversed list. Your solution should have a time complexity of O(n) and a space complexity of O(1). The input list will always contain at...
codefeedback
Write an HTML snippet that contains two input fields. The first input field only allows alphanumeric characters, does not exceed a length of 10 characters, and displays an error message if the entered value is not alphanumeric. Additionally, the first input field should also be case-insensitive and should display an er...
codefeedback
Write a Python function that takes a dictionary as input and adds a new key-value pair to it. The key should be a string and the value should be a list containing 5 randomly generated integers between 1 and 100 (inclusive). Additionally, ensure that the dictionary has a maximum of 20 key-value pairs and that each key i...
codefeedback
Using the function you wrote in question 4, write a Python program to convert a binary list to an integer. The binary list can contain up to 100 elements, and each element can only be 0 or 1. Additionally, the program should handle edge cases where the binary list is empty or contains invalid elements. In order to im...
codefeedback
Construct the code which will generate addition equations with randomized numbers ranging from -100 to 100, but exclude any equation that results in a sum greater than 200 or less than -200. Additionally, implement a feature to generate subtraction equations with randomized numbers ranging from -100 to 100, but exclude...
codefeedback
Write a PHP function that takes a string as input and returns the string with all the alphabetic characters in uppercase. Additionally, remove all duplicate characters from the resulting string and sort the characters in descending order based on their ASCII values. Provide an erroneous code snippet as a reference to ...
codefeedback
Create a Python program that takes two lists as arguments and returns a list that contains the elements present in both lists. The program should also remove any duplicates from the resulting list and sort the list in descending order. The program should perform the following steps: 1. Create an empty list called "com...
codefeedback
Construct a PHP function to log the user out of the system and securely destroy all session data. Additionally, implement a two-factor authentication process where the user must enter a verification code sent to their mobile phone and a fingerprint scan using a biometric scanner before successfully logging out.
codefeedback
Design a function in C++ that takes two input parameters and swaps their values. Additionally, ensure that the function can handle different data types, such as integers, floating-point numbers, and characters, and swap their values correctly. However, you should also handle the case where one or both of the input para...
codefeedback
What data structure should we use to solve this problem? We want to store a list of names and their associated addresses, and then look up names quickly. Additionally, we need to ensure that the names are sorted in alphabetical order for efficient searching. However, you are not allowed to use any built-in data structu...
codefeedback
Please implement a function `removeExtraWhitespace` that takes in a string sentence and returns the modified sentence with all extra whitespace removed. The sentence may contain leading and trailing whitespace, as well as multiple consecutive whitespaces between words. The function should have a time complexity of O(n)...
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. Make sure to include only tables that have at least one column of type "integer" and e...
codefeedback
Construct an array in Python of size n (where n is a positive integer) and fill it with random integers from 0 to 100. Additionally, the array must have unique elements and be sorted in ascending order. The algorithm should have a time complexity of O(nlogn) and a space complexity of O(n). Furthermore, the algorithm s...
codefeedback
Create a JavaScript object with three properties: a number property, a string property, and an array property. The array property should contain a list of objects, each with a number and string property. Add a method to the object that takes in two parameters (a number and a string) and returns the concatenation of the...
codefeedback
Write a SQL query to display a table with the number of records in each month of a year, but exclude the months with no records from the result. Additionally, display the average number of records per day for each month. The table must be sorted in descending order based on the average number of records per day.
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, the full name should only include alphabetic characters, the first name should have at least two vowels, and the first letter of ...
codefeedback
Generate a Ruby program to find the sum of the even-valued terms in the Fibonacci sequence up to a given input number n. # Additional Instructions # 1. Input Validation: The program should validate if the input number n is a positive integer greater than 1. If it is not, the program should display an error message and...
codefeedback
Create a JavaScript object property with a string value that is encrypted using a custom encryption algorithm. The encryption algorithm should incorporate a random salt value and a key derived from a password. The encrypted string should be stored in the property as a hexadecimal string. The password used for encryptio...
codefeedback
Modify the following SQL query so that it returns all the customers whose first names begin with the letter "A" and whose last names begin with the letter "B". However, exclude any customers whose last names contain the letter "C" and whose ages are less than 30. SELECT * FROM Customer
codefeedback
Implement a function to delete all elements from a given set in constant time complexity, using only a single loop and without using any built-in functions or data structures. Additionally, ensure that the function also deletes any nested elements within the set recursively.
codefeedback
Create a Python script to combine two lists into a dictionary. However, instead of combining the lists based on a common attribute, combine them based on multiple common attributes between the elements of both lists. For example, given the following two lists: list1 = [{"id": 1, "name": "John", "age": 25, "gender": ...
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
Write a SQL query to output the most common first names among all male customers in the customer table, while also considering the total number of orders each customer has made. Additionally, include the percentage of orders made by each customer in relation to the total number of orders made by all male customers. Als...
codefeedback
Please modify the code to calculate the sum of all prime numbers from 0 to 1,000,000.
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
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
Write a code that prints all the possible outcomes of rolling three dice and calculates the product of each outcome.
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, price, and quantity of a product...
codefeedback
Write a JavaScript function that takes in an array of positive integers and a number between 1 and 100 (inclusive) as arguments. The function should return the array sorted in ascending order with the number inserted in the right position. The array should not contain any duplicate elements. Additionally, the function ...
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 Java program to read a text document and count the number of unique words in the given document. However, the program should ignore any words that are enclosed within quotation marks or any special characters, and consider only distinct words. To solve this problem, the program should: 1. Prompt the user to en...
codefeedback
Write a program that removes the extra spaces from a given string and makes the spaces between letters and words consistent. The input string can be of any length and can contain special characters. The final output should be in uppercase. The program should follow the following steps: 1. Take the input string from th...
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. However, the function should now have a time complexity of O(n^2),...
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. Additionally, the code should calculate the product of all prime numbers in ...
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
Construct an HTML page including a heading, button, paragraph, and a form that collects user input. Upon clicking the button, the user's input should be displayed in a separate paragraph on the page. Additionally, implement a validation mechanism to ensure that the user input is a valid email address before displaying ...
codefeedback
Rewrite this code snippet from a functional programming perspective, with the requirement that the implementation must not use any built-in functions or methods for checking if a number is even. The input is a list of positive integers. Implement a function called `has_even_sum` that returns True if the sum of all the...
codefeedback
Given a 2-dimensional array, where each element is a list of integers, write a function to calculate and print the sum of all elements in the array. The array can have any dimensions, where n is the number of rows and m is the number of columns. Each row may have a different number of columns. Write a function: ```pyt...
codefeedback
Create a class in C++ to store the rolling average, rolling median, and rolling mode of a stream of numbers. The class should also provide a method to calculate the standard deviation and variance of the numbers in the stream. Additionally, the class should implement a method to remove outliers from the stream before c...
codefeedback
Write a JavaScript program that takes a specific timezone as input and displays the current date and time in the format "DD/MM/YYYY HH:MM:SS". The program should also consider daylight saving time adjustments, if applicable. To solve this problem, you can follow these steps: 1. Create a function that takes the timezon...
codefeedback
Write a function to reverse the contents of a stack without using any additional data structures. Additionally, the function should have a time complexity of O(n), where n is the size of the stack. The original stack should not be modified or destroyed during the reversal process.
codefeedback
Write a SQL statement to query the names, ages, and departments of all employees from the Employees table whose salary is less than 3000, whose age is greater than or equal to 25, and whose department has more than 10 employees. Additionally, sort the results in descending order of salary.
codefeedback
How would you construct a nested loop to print out the contents of a 2D array, but only print the odd numbers in reverse order, and only if they are divisible by 3? Additionally, implement the loop using a recursive function instead of a for loop. arr=[[3,5,9,15],[21,27,32,36],[45,51,54,60]] Please note that the abov...
codefeedback
Design a SQL query to find all records from the table "Users" where the user's name is "John" and the user's age is greater than 25, and the user's email domain ends with ".com". Additionally, the query should only include records where the user's address is in a specific city, "New York".
codefeedback
Create a loop in Python to find the sum of all prime numbers from 1 to 1000, excluding 2 and 3.
codefeedback
Please implement a JavaScript function that takes in two strings as arguments and returns true if the first string is present in the second string, and false otherwise. The function should be case-sensitive. Example: ```javascript function isSubstring(substring, string) { if (substring.length > string.length) { ...
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. Additionally, the function should handle the case where...
codefeedback
Create a Bash script that takes in a single argument and prints it in reverse order, without using any built-in string reversal functions or commands. The script should also check if the argument is a valid file path and, if so, display the contents of the file in reverse order instead of just printing the argument its...
codefeedback
Please write a function called `multiply_two_numbers` that takes in two integer inputs `a` and `b` and returns their product. However, the function should include additional logic to handle the following edge cases: 1. If `a` and `b` are both equal to 0, the function should return 0. 2. If `a` is equal to 0 and `b` is...
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). Additionally, modify the algorithm to handle arrays containing duplicate integers, without sacrifi...
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 and each word is printed in reverse order as well. Additionally, the time complexity of the code should be O(n), where n is ...
codefeedback
Write a SQL query to find the customer id, name, and salary of the customers whose salary is in the range 2000-6000, have made at least 5 purchases in the last month, belong to a specific product category such as electronics or fashion, and have a total purchase amount exceeding $500. #Reasoning Steps# 1. Retrieve the...
codefeedback
Write a query in MongoDB to find all documents which have a count greater than 100 and less than 200, the name field starts with the letter "A", and the created_at field is within the last 7 days. Additionally, sort the results in descending order based on the count field.
codefeedback
Create an array of five different colors in JavaScript. Each color must be randomly selected from a predefined list of at least 15 colors. Additionally, the colors in the array must be sorted in alphabetical order and should not include any duplicate colors.
codefeedback
You are working for an e-commerce platform and your task is to create a report that shows the top 10 products that have been sold the most in the last month, excluding any cancelled orders. To achieve this, you need to use the mySQL COUNT function to retrieve the number of unique customers who have made at least 10 pur...
codefeedback
Design a data structure that can efficiently store unique user IDs and their corresponding usernames. Additionally, the data structure should provide fast lookup and deletion of user IDs. The data structure should now also support searching for users by their usernames. What type of data structure is this? Provide a ...
codefeedback
Write a program to calculate the Fibonacci sequence up to a given number. Please note that you need to implement the Fibonacci sequence using recursion and memoization in your program. Additionally, you need to modify the program to calculate the sum of all the even numbers in the Fibonacci sequence up to the given n...
codefeedback
Alter the following python code such that it prints "Hello, world!" exactly 10 times, without using any loop constructs or the multiplication operator. Additionally, you are not allowed to use any string concatenation or repetition methods.
codefeedback
Visualize the given dataset using a horizontal 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 b...
codefeedback
Using the HTML provided, add an ID attribute to the div tag to specify the unique identifier "box1". Additionally, use JavaScript to change the background color of the div tag to red when it is clicked. However, this should only happen if the div tag is clicked twice within a span of 1 second. If the div tag is clicked...
codefeedback
Create a boolean expression in JavaScript, which returns false if a variable named "result" is an empty string or a string consisting of only whitespace characters. Additionally, the solution should also return false if the string contains any special characters. The solution should have a time complexity of O(1) and s...
codefeedback
Develop a function in Java to print the Fibonacci series up to a given number 'n', where 'n' is a positive integer greater than 2. The function should also check if each number in the series is a prime number and print "Prime" next to the number if it is. Additionally, the function should calculate the sum of all prime...
codefeedback
Write a C++ code to generate a random number in the range 0 - 1000, but the number generated must be divisible by both 7 and 11, and it should also have exactly 5 distinct prime factors.
codefeedback
Edit the given code snippet to generate a table in HTML with five columns and ten rows. Each cell in the table should contain a randomly generated number between -1000 and 1000. Additionally, the table should have alternating row colors, with one row being light gray and the next row being white. The table should also ...
codefeedback
Create a for loop for counting from 100 to 1000, but skip the numbers that are divisible by both 3 and 5. Additionally, ensure that the loop does not execute if the number is a prime number and a perfect square.
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 5 and 15 (inclusive). If the user enters an invalid input, the program should display an error message and ask for inp...
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
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. Additionally, you are required to handle cases where the ta...
codefeedback
Develop a function in Java that prints out the squares of all prime even numbers between 1 and 100, and also counts the number of times the square root of the number is a prime number. #Reasoning Steps# 1. Create a function named "printPrimeEvenSquaresAndCountPrimeSquareRoots" that takes no parameters and returns noth...
codefeedback
Compare and contrast object-oriented programming and functional programming paradigms, highlighting their fundamental principles, advantages, and use cases in software development. Include specific examples to illustrate how each paradigm can be effectively utilized. Moreover, provide a code snippet that showcases a pr...
codefeedback
Find the nth prime number, where n is a positive integer greater than 100 and less than or equal to 10^6. Additionally, the program should handle inputs up to 10^12 efficiently. Note: Please provide your solution with a time complexity of O(n^2) or better.
codefeedback
Write a filter function in JavaScript to return elements from an array of strings which start with the letter "a" and end with the letter "t". The function should also ignore case sensitivity, so it should match words starting with "A" or "a" and ending with "T" or "t". Additionally, the function should sort the filter...
codefeedback
Generate a JavaScript program that asks the user to input a list of numbers separated by commas. The program should then check each number in the list and display a message indicating whether it is greater than 10 and divisible by both 3 and 5, greater than 10 and divisible by only 3, greater than 10 and divisible by o...
codefeedback
Write a MySQL query to select all customers who have a birthday on the 1st day of May and have made at least 10 purchases in the last 2 months.
codefeedback
Create a function in JavaScript that takes in an array of strings and returns a new array with all the elements in reverse order. However, you are not allowed to use any built-in array methods such as `reverse()` or `sort()`. The function should have a time complexity of O(n), where n is the length of the input array.
codefeedback
Create a SQL query to get the top 10 salaries from a given table, but exclude any employees who have been with the company for less than 1 year. Additionally, the query should only consider employees who have a job title of "Manager" or "Director" and have a salary above $100,000. Additionally, the query should calcula...
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 least...
codefeedback
Create a function in Python to take a list of integers as input and return the count of pairs whose sum is divisible by 3. The function should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the input list. Additionally, the function should be able to handle a list with duplicate...
codefeedback
Write a Python program to convert a string to a list of characters, while ignoring any whitespace characters. The string is "This is a test". Implement the solution without using any built-in string or list methods, such as str.split(), list(), or str.join(). Constraints: - The program must have a time complexity of O...
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. Additionally, if the 2-d array is empty, the method should return an empty array. Additional Constraint: Your solution should have a time complexity of O(nlo...
codefeedback
Construct a MySQL query to select all customers from the database whose last name starts with 'S' and whose first name contains the letter 'a'. Additionally, order the results in descending order based on the length of the last name. You should also exclude customers whose age is less than 30 and whose email address ...
codefeedback
Write a HTML code to display a hyperlink with the text "GitHub" and point it to the github.com website. Additionally, add a tooltip that displays the full URL when the user hovers over the hyperlink. Implement this using only CSS, without using any JavaScript. Further, the hyperlink should change its background color ...
codefeedback
Write a program to estimate the value of pi to twenty decimal places using the Monte Carlo method, but with the additional requirement that the program must be implemented using a functional programming language. The program should also be able to handle a larger number of random points within a reasonable amount of ti...
codefeedback
Construct the loop in the code to find the maximum element in a non-empty array. The array contains positive integers ranging from 1 to 1000. The length of the array can range from 10 to 1000 elements. In addition to finding the maximum element, modify the code to also find the minimum element in the array. After fin...
codefeedback
Write a query in Redis to get all the keys starting with 'user:' and ending with a numeric value. Additionally, exclude any keys that contain the string 'admin' anywhere in the key name. Finally, sort the keys in descending order based on their length.
codefeedback