instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Write a SQL query to get the names of all customers who have placed orders from a given store in the last week and have purchased more than $100 worth of items. Given store name: "ABC Store"
codefeedback
Write an algorithm to identify whether a given number is prime or not, but without using any looping or recursion.
codefeedback
Write a function to reverse a given sentence in Python. The function should not use any built-in string reverse functions or methods. Given sentence: "The quick brown fox jumps over the lazy dog." Erroneous code: ```python def reverse_sentence(sentence): return sentence[::-1] ``` This code incorrectly uses str...
codefeedback
Create a MySQL table called "orders" with the following columns: "Order_ID" (integer), "Customer_Name" (string), "Product_Name" (string), "Quantity" (integer). Implement a Python function called "calculate_total_cost" that takes an order ID as input and returns the total cost of the order. The total cost should be ca...
codefeedback
Write a function in Go language that splits a string into three parts based on a specified separator and ensures that each part contains at least 3 characters. If any part does not meet this requirement, it should be discarded. Additionally, the function should handle cases where the separator occurs consecutively by m...
codefeedback
Write a query in MySQL that returns all unique values of a given column, while also ordering the results in descending order. Additionally, the query should only include values that have a count greater than or equal to 5. Table name: student Column: gender
codefeedback
Find the maximum number of left and right parentheses that can be balanced for a given expression. Expression: ((())
codefeedback
Implement a class in C++ that creates a stack with the following additional methods: 1. `getMinimum()`: Returns the minimum element in the stack in O(1) time complexity. 2. `getMaximum()`: Returns the maximum element in the stack in O(1) time complexity. 3. `getAverage()`: Returns the average of all elements in the st...
codefeedback
Write code to iterate through a nested dictionary and return the sum of all values. However, this time, the dictionary may contain lists as values in addition to integers. #Erroneous Code# dictionary = { 'level1': { 'level2a': { 'level3a': [1, 2, 3], 'level3b': [4, 5] }, 'level2b': { 'level3a': [6, 7],...
codefeedback
Design a class in Python to model a hospital. The hospital should be able to handle multiple patients and doctors. Each patient should have a unique identification number and should be able to schedule appointments with doctors. Each doctor should have a unique identification number and should be able to accept appoint...
codefeedback
Create a function that takes a list of numbers and identifies the sublists of numbers that add up to a given sum. The function should return the starting and ending indices of each sublist. #Example# Input: numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] target_sum = 10 Output: [[0, 3], [4, 6], [8, 9]] In this example, the s...
codefeedback
Write code to find the maximum sum for a non-contiguous subarray of a given array.
codefeedback
Create a function to parse a string that has lines of key/value pairs and return a dictionary of the values paired with the keys. The keys should be case-sensitive. The string may contain duplicate keys, and in such cases, the value associated with the last occurrence of the key should be stored in the dictionary. The ...
codefeedback
Write a SQL query that finds the total number of courses offered in a specific semester, where each course must have at least 10 enrolled students and be taught by a professor with a minimum of 5 years of teaching experience.
codefeedback
Write a JavaScript function that returns the name of the user only if the user's age is above 18 and the name is not empty. The function should also capitalize the first letter of the name and remove any leading or trailing whitespace. The function should handle cases where the name is not provided or is not a string b...
codefeedback
Create a function to format a given list of numbers with commas as thousands separators and round each number to the nearest hundredth decimal place.
codefeedback
Create a MySQL query to group clubs by the number of players, but only include clubs that have at least 10 players.
codefeedback
Create a Java program to find the sum of the following array, but without using any loop or recursion: [1,2,3,4,5].
codefeedback
Create a program in Java that finds the average of a given array, but with the following additional requirements: 1. The program must use a recursive approach to calculate the average. 2. The program must have a time complexity of O(n). 3. The program must use only a constant amount of additional space (i.e., no additi...
codefeedback
Create an algorithm that returns an array of the unique items in a given list, but now you are not allowed to use any built-in functions or data structures to solve the problem. You must implement your own logic to find and remove duplicate items.
codefeedback
Write a regex (in Python) to match the following pattern: "an apple a day keeps the doctor away". Additionally, the regex should also match variations of the sentence with minor differences, such as: - Different capitalization of letters (e.g., "An apple a day keeps the doctor away") - Extra spaces between words (e.g.,...
codefeedback
Generate a code to sort a list of floats in descending order, using only bubble sort algorithm.
codefeedback
Create an efficient algorithm to determine if two strings are rotations of each other. The algorithm should have a time complexity of O(n), where n is the length of the strings. Additionally, the algorithm should handle strings containing only lowercase alphabets and should return True if the strings are rotations of e...
codefeedback
Given a piece of text, write a Python function that finds the number of unique words in the text. The function should disregard any punctuation marks and consider words in a case-insensitive manner. For example, given the text "This is a sample text to find the number of unique words.", the function should return 9. ...
codefeedback
Create a C# function called "InsertCharacter" that takes a string input and inserts a character at a given index. However, the inserted character must be the ASCII value of the character at the given index plus the ASCII value of the last character in the string. The function should handle cases where the given index i...
codefeedback
Given the following array and a number k, determine if two elements from the array, excluding any duplicates, add up to k. The array may contain negative numbers. arr = [10, 15, 3, 7, 7, -5, -2], k = 17
codefeedback
Programmatically generate a random password of length 10 that contains at least two lowercase letters, two uppercase letters, two numbers, and two special characters. Additionally, the password should not contain any repeating characters.
codefeedback
Sort the following list of numbers in increasing order without using any built-in sorting method. You are not allowed to use any additional data structures or modify the original list. The solution should have a time complexity of O(n^2) and a space complexity of O(1). arr = [2, 5, 3, 8, 7]
codefeedback
Write a code to get the kth smallest number from a list of integers, where k is a positive integer less than or equal to the length of the list.
codefeedback
How would you calculate the shortest distance between two points in a three-dimensional space, considering that there are obstacles present in the environment that the line connecting the points must avoid?
codefeedback
Write a function that takes in two lists of equal length and forms a new list by taking the elements at the same index from both lists. The function should then remove any duplicate elements from the new list and return the sorted result.
codefeedback
Edit the given code snippet to reverse the elements of a list in Python, but you are not allowed to use the built-in reverse() function.
codefeedback
Output the remaining items in the following array after removing duplicates and sorting the array in descending order: let arr = [1, 2, 1, 4, 5, 2, 6]
codefeedback
Use dictionaries in Python to merge the data from two given dictionaries, while excluding any keys that start with a vowel. Additionally, the merged dictionary should be sorted in descending order based on the values of the keys. dictA = { 'keyA': 1, 'keyB': 2 } dictB = { 'keyC': 3, 'keyD': 4 }
codefeedback
Create a function in Java to find the number of values greater than a given number in a given array. The array can contain negative values. The function should also check if the given array is sorted in ascending order, and if not, it should return an error message. Finally, the function should handle the case when the...
codefeedback
Count the number of vowels present in the input text. Ignore vowels that occur consecutively and consider them as one. For example, "ee" should be considered as one vowel, not two. Good morning!
codefeedback
Please write a program that identifies the parts of speech for each word in a given input text.
codefeedback
Use TensorFlow to build a machine learning model for predicting continuous values given a data set of temperature, humidity, wind speed, and air quality index vs electricity consumption. The data set contains 100,000 records and is divided into 80% training data and 20% testing data. Additionally, the data set contains...
codefeedback
Implement an in-place quicksort algorithm in Python that can handle duplicate elements. The time complexity of your implementation should be O(n log n) in the average case, and the space complexity should be O(log n).
codefeedback
Design a class in Java called 'Student' which contains student's information such as name, age, etc. Implement a method called 'calculateGPA' that calculates the Grade Point Average (GPA) of the student based on their grades in different subjects. The GPA should be calculated using a weighted system, where each subject...
codefeedback
Compose an algorithm to determine whether a given string contains all unique characters, without using any additional data structures.
codefeedback
Create an algorithm to determine whether the given array contains an odd number of prime elements. The array can contain both positive and negative integers. For example, given the array [-3, 2, 5, -7, 10, -11], the algorithm should return true because there are 3 prime elements in the array: 2, 5, and -11. You should ...
codefeedback
Generate a list of integers between a given start and end value, inclusive. The start and end values can be negative, and the range can be large (up to 10^9). The resulting list should be sorted in descending order. The time complexity of the solution should be O(n log n), where n is the number of integers in the range...
codefeedback
Describe the timeline of a given project, considering that the social media app must have features such as user authentication, post sharing, real-time notifications, and a recommendation system.
codefeedback
Create a Go program to convert a given temperature from Kelvin to Celsius, taking into account the potential loss of precision due to floating-point arithmetic. Requirements: - The program should accept the temperature value in Kelvin as a floating-point number. - The program should return the temperature in Celsius a...
codefeedback
Create an Angular2 component that displays a "Hello, world!" message and also includes a button. When the button is clicked, the message should change to "Goodbye, world!". Additionally, the component should have an input field where the user can enter their name, and when the button is clicked, the message should chan...
codefeedback
Output the square of the following number: the sum of the first 1000 prime numbers.
codefeedback
Rewrite a PHP program to produce the same result. However, you must implement the solution without using any loops or built-in array functions (such as count() or array_sum()).
codefeedback
Use Ruby on Rails to generate a migration to add a column "name" to the table "users" with the following specifications: 1. The "name" column should be of type string. 2. The "name" column should have a maximum length of 50 characters. 3. The "name" column should be indexed for faster searching. 4. The "name" column sh...
codefeedback
Create a React component to render a table with four columns: "ID", "Name", "Occupation", and "Salary". The table should display data for five employees. The employee data should be stored in an array of objects, where each object represents an employee and has the properties "id", "name", "occupation", and "salary". T...
codefeedback
Using Tensorflow, set up a convolutional neural network model to predict the classification of a handwritten digit. Implement data augmentation techniques such as random rotations and translations to improve the model's accuracy. Additionally, include a validation set to evaluate the model's performance during training...
codefeedback
Create a SQL statement that generates the total profit made by each salesperson over the year. Additionally, include only the salespersons who have made a profit greater than $10,000.
codefeedback
Explain why it is important to have comprehensive exception handling in a multithreaded environment, where each thread must be able to handle specific exceptions and gracefully terminate while still allowing other threads to continue executing concurrently.
codefeedback
Write a C++ method to calculate the Fibonacci series, but with a constraint that the time complexity should be O(1).
codefeedback
Create a program to identify a given string as a valid ISBN 10 code. The program should also check if the string is a valid ISBN 13 code and return a boolean value for both. The program should handle leading and trailing spaces in the input string and consider them as valid characters.
codefeedback
Create a web page with styles and implement a custom dropdown menu using only HTML and CSS.
codefeedback
Verify if a given password string matches the regular expression and has at least one uppercase letter, one lowercase letter, one digit, and one special character. Additionally, the password should not contain any consecutive repeating characters.
codefeedback
Create a complex query using three variables, where each variable represents a different color: sky, blue, and grass. The query should retrieve all records where the sky is blue and the grass is green.
codefeedback
Create a react component to render a table with the following structure: ``` | ID | Name | Age | Salary | |----|-------|-----|--------| | 1 | John | 28 | $3000 | | 2 | Sarah | 32 | $4000 | | 3 | Alex | 25 | $2500 | ``` The component should receive an array of objects as a prop, where each object represent...
codefeedback
Optimize the following MySQL query to select the latest record in each group and also include the total count of records in each group: SELECT t1.*, COUNT(*) as total_count FROM myTable t1 INNER JOIN ( SELECT type, MAX(date) as max_date FROM myTable GROUP BY type ) t2 ON t1.type = t2.type AND t1.date = t2....
codefeedback
Train a machine learning model for a multiclass classification problem where the target variable has three classes: 'A', 'B', and 'C'. The input features X are a list of 1000 samples, where each sample is a 100-dimensional vector. The target variable y is a list of corresponding labels for each sample. The labels are e...
codefeedback
Generate C code to swap two integers without using a third variable and without using any arithmetic operations (e.g., addition, subtraction, multiplication, division).
codefeedback
Generate SQL code to query a database table containing student names, ages, and grades. The table has millions of records. SELECT the top 100 students who are between 18 and 25 years of age, ordered by their grade in descending order.
codefeedback
How to define a multidimensional array in PHP with a specific number of dimensions?
codefeedback
Write a Micropython program to turn on an LED connected to pin number 5, wait for 2 seconds, and then turn it off. The program should also keep count of the number of times the LED has been turned on and print the count on the console after each on/off cycle.
codefeedback
How can we obfuscate a JavaScript code to make it harder for hackers to reverse engineer it while ensuring that the performance of the code is not compromised?
codefeedback
Apply K-means clustering to a 3-dimensional dataset given a certain number of clusters. The number of clusters must be between 4 and 6, inclusive. Additionally, you must implement your own version of the K-means algorithm without using any external libraries or packages.
codefeedback
Identify the type of variable (integer, float, string) for the given value. Value: 1968.5
codefeedback
Create a new dictionary in Python with the given keys and values, where the keys are integers ranging from 1 to 1000000 and the values are randomly generated integers ranging from -1000000 to 1000000. The dictionary should have a length of 1000000.
codefeedback
Write a JavaScript program to find the sum of all prime numbers the user has entered in to the input box.
codefeedback
Develop a function to fetch the maximum element from a given nested dictionary. d = { 'Name': 'John', 'Age': 28, 'Score': { 'Math': 98, 'English': 85, 'Science': 93 } } The function should return the maximum value among all the values in the nested dictionary. In this case, the...
codefeedback
Write an SQL query to find the ten most popular books among the library readers, considering that each reader can borrow multiple copies of the same book and that the popularity is determined by the total number of copies borrowed. Table: library Columns: book_name, reader_name, copy_id Table: readers Columns: reader_...
codefeedback
Given a string "I am a programmer", convert each character in the string to its corresponding upper case letter. Return the modified string. #Additional Reasoning Steps# 1. Initialize an empty string to store the modified string. 2. Iterate through each character in the given string. 3. Check if the character is a low...
codefeedback
Implement a method in C# that reverses the digits of an integer, but the method should not use any built-in functions or convert the integer to a string.
codefeedback
Explain how you would use the given array to create a valid JSON output while ensuring that the values for "firstname", "lastname", and "birthdate" are all non-empty strings and that the "birthdate" is in the format "dd-mm-yyyy". Additionally, the JSON output should include an additional key-value pair "age" which repr...
codefeedback
Suggest a design pattern to solve the following problem in a multithreaded environment: A system needs to access different types of data from multiple data sources, with each data source being accessed by multiple threads simultaneously. Additionally, the system should handle potential concurrency issues such as race c...
codefeedback
Suggest a data structure to efficiently store a set of phone numbers, where each phone number has an associated name and address. The data structure should allow for fast retrieval of phone numbers based on their associated names, and also support efficient searching for phone numbers within a specific address range. A...
codefeedback
Design a public Java API to generate a cookie with the following requirements: 1. The cookie must include a unique identifier for tracking purposes. 2. The cookie must have an expiration date, which should be set to 1 week from the current date by default. 3. The cookie must have a secure flag, indicating that it can ...
codefeedback
Generate a for loop to iterate over all div elements on a website and print their content. Additionally, for each div element, check if it has any child elements. If it does, iterate over all the child elements and print their content as well. Finally, for each child element, check if it has any nested child elements a...
codefeedback
What is the correct code to access the fourth element of a singly linked list in Java?
codefeedback
Design an SQL query to get all the employees from a database who are over 40 years old and have at least 5 years of work experience. Table Name: employee Attributes: id, firstname, lastname, age, start_date Explanation: 1. Retrieve all employees from the database who are over 40 years old. 2. Calculate the number of y...
codefeedback
Design a method in JavaScript to validate a password according to the following criteria: 1. The password must contain at least 8 characters. 2. The password must contain at least one uppercase letter. 3. The password must contain at least one lowercase letter. 4. The password must contain at least one numeric digit. 5...
codefeedback
Find the maximum number from an array of numbers using JavaScript. The array can contain positive and negative numbers. Implement a solution with a time complexity of O(n), where n is the length of the array.
codefeedback
Write a shell script that displays the folder structure of the current working directory, but excludes hidden folders.
codefeedback
Create a function in Java that takes a 2D array of integers as input and prints out all diagonals, starting from the top left corner and moving towards the bottom right corner. The function should also check if the input array is a square matrix (i.e., the number of rows is equal to the number of columns) and throw an ...
codefeedback
Write a C++ method to convert a string into lowercase and remove any duplicate characters from the resulting lowercase string.
codefeedback
Write an SQL query to display the average age of employees in each department, where the average age should not include employees who have a salary higher than $100,000.
codefeedback
Create a HTML form with three input fields for taking a user's name, email, and address. The form should include client-side validation to ensure that the name input is at least 5 characters long, the email input follows a valid email format (e.g. example@example.com), and the address input is a valid postal address (e...
codefeedback
Write a Cypher query to select all nodes with the label 'address' and retrieve their corresponding relationships with nodes labeled 'person'.
codefeedback
Calculate the number of weekdays taken to finish a task given its start and end dates. The task must be completed within a maximum of 30 weekdays. Start Date: 01 June 20
codefeedback
Write a JavaScript code snippet to create and display a dynamic table of products and their prices, while also allowing users to add new products to the table. The table should have the following additional requirements: 1. The table should display the total number of products. 2. The table should display the average ...
codefeedback
Given a value, x, write a line of code that converts it from a float to an integer and rounds it up to the nearest whole number. x = 25.32
codefeedback
Write a loop that prints the cube of each element in a given array. The elements in the array will be positive integers greater than 1. arr = [2, 3, 4, 5]
codefeedback
Design a Swift class for a 3-dimensional point that includes the following functionalities: 1. Implement a method to calculate the distance between two points. 2. Implement a method to calculate the dot product between two points. 3. Implement a method to calculate the cross product between two points. 4. Implement a ...
codefeedback
Check if a given webpage contains all the words from a given list? Webpage URL: https://en.wikipedia.org/wiki/Cat Word list: ["Felis", "domesticus", "carnivorous"] Requirements: 1. The solution should have a time complexity of O(n), where n is the total number of words in the webpage. 2. The solution should have a spa...
codefeedback
Implement a function that takes in a list of integers and returns the maximum product of any three integers in the list. The function should have a time complexity of O(n) and a space complexity of O(1).
codefeedback
Edit the following JavaScript code to make it able to log only prime numbers. const myArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; for (let i = 0; i < myArray.length; i++) { let isPrime = true; for (let j = 2; j < myArray[i]; j++) { if (myArray[i] % j === 0) { isPrime = false; break; } } if (is...
codefeedback
Create an HTML page with a basic structure and text, but ensure that the text is written in a non-Latin script, such as Chinese, Arabic, or Devanagari.
codefeedback
Write a JavaScript function to find the maximum value from an array of numbers, but without using the built-in Math.max() method or the spread operator (...). You should iterate through the array and compare each element with the current maximum value found so far, updating the maximum value if necessary. Finally, retu...
codefeedback
Construct a CSS style sheet to set the background color of all <h1> tags with the class name "header" as blue and a gradient effect from top to bottom.
codefeedback