instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Update a MongoDB document in the "users" database and "customers" collection. Replace the field "name" with the new value "John Doe" only if the document meets the following conditions:
1. The field "age" is greater than 18.
2. The field "country" is not empty.
If any of these conditions are not met, the update should... | codefeedback |
Develop a SQL query to count the number of people who are born before 1992 and have at least 10 years of work experience, considering the following additional criteria:
- The query should not use any subqueries.
- The query should not use any aggregate functions like COUNT or SUM.
- The query should not use any built-i... | codefeedback |
Develop a PHP code snippet to retrieve all records from a database table "POSTS" where the value of the "status" column is set to "published" and the "category" column is set to "technology". Additionally, sort the results by the "created_at" column in descending order. | codefeedback |
Combine two sorted arrays into one sorted array, without using any built-in sorting functions. The two input arrays are arr1 and arr2. Your task is to create a new array that contains all the elements from arr1 and arr2, in sorted order. The new array should have a time complexity of O(n), where n is the total number o... | codefeedback |
Separate the numbers from the non-numeric characters in the given string variable. Return the sum of all the separated numbers.
String: 1a2b34c
Note: You should not use any built-in functions or libraries that directly solve the problem. Additionally, you are not allowed to use any regular expressions or built-in me... | codefeedback |
Write a Java class named "Shape" which has an abstract method named "surfaceArea". Additionally, the "Shape" class should have a constructor that takes in a parameter representing the dimensions of the shape. The dimensions can be of any type, such as integers or floating-point numbers. The "Shape" class should also ha... | codefeedback |
Write an HTML code snippet to create an interactive dropdown menu with a maximum of 10 options that cannot be hard-coded in the HTML file. Additionally, implement functionality to dynamically add and remove options from the dropdown menu using JavaScript. | codefeedback |
Create an HTML page with a table containing the following data in ten rows. The table should have the ability to dynamically add or remove rows. Each row should have a unique identifier and contain the following columns: Id, First Name, Last Name, Age, Email. The table should also include sorting functionality for each... | codefeedback |
Write a SQL query that returns the 10 most recently created entries from a table with a timestamp column. Additionally, include the total count of entries created in the last 24 hours, as well as the average, minimum, and maximum values of a numeric column in the result set.
To further increase the difficulty, you can... | codefeedback |
Develop a machine learning model in Python to classify emails as either important, urgent, or not important. The model should be able to accurately predict the urgency level of each email based on its content, sender's reputation, attachments, and time sensitivity. The model should also take into account the language u... | codefeedback |
Develop a code snippet in Java to create a thread that runs a simple print statement every 5 seconds. Additionally, the thread should print the current time along with the statement. However, the thread should only print the statement if the current time is between 9:00 AM and 5:00 PM on weekdays (Monday to Friday). If... | codefeedback |
Write a code that takes a given list and sorts them using heapsort. The list will contain positive integers only and will have at least 100 elements. The code should handle cases where the list has duplicate elements and sort them in descending order. The code should also handle cases where the list is already sorted i... | codefeedback |
Write an SQL query that returns the fourth highest salary from a table with a salary column, but only consider salaries that are greater than or equal to $50,000. | codefeedback |
Create a function to print out a multiplication table of two given multidimensional arrays. The function should also check if the arrays have the same number of rows and columns, and throw an error if they don't. Additionally, the function should only accept arrays with positive integers as elements, and throw an error... | codefeedback |
Write a CSS class that will apply a border around an HTML element with the following specifications:
- The border should have a thickness of 2 pixels.
- The border color should be red.
- The border should have a dotted line style.
- The border should have a radius of 5 pixels.
- The border should be applied only to the... | codefeedback |
Create a Python function that takes an object as an input and returns its names and values. The function should also handle nested objects and lists within the input object. Additionally, the function should only return the names and values of the top-level attributes of the object, excluding any attributes within nest... | codefeedback |
Create a ReactJS component to display a modal window with a form. The form should have the following fields:
- Name (required, maximum length of 50 characters)
- Email (required, valid email address)
- Password (required, minimum length of 8 characters, at least one uppercase letter, one lowercase letter, and one speci... | codefeedback |
Write a C program that creates a structure called "Employee" with the following members:
- Name (string)
- Age (integer)
- Salary (floating point number)
- Employee ID (integer)
Create an array of 5 Employee structures. Initialize each structure with different values for each member. Print the details (name, age, sala... | codefeedback |
Write a CSS code to create a responsive navigation menu with drop down sub menus that collapses into a hamburger menu on smaller screens, and must be implemented using flexbox and media queries. Additionally, ensure that the hamburger menu has an animated transition effect when expanding and collapsing the sub menus. | codefeedback |
Parse the following HTML string and get a list of all the <p> tags that have a class attribute equal to "highlight". If a <p> tag does not have a class attribute or if its value is not "highlight", it should not be included in the list.
<html>
<p class="highlight">This is a highlighted paragraph</p>
<div>
<spa... | codefeedback |
Write a SQL query to get the name, age, address, and average salary of the people whose age is greater than 25, whose average salary is greater than $50,000, and whose address is not in a specific city ('New York' for example). | codefeedback |
Write a code to extract the odd numbers from a given array in JavaScript. The extracted numbers should be sorted in ascending order and then squared. Additionally, you are not allowed to use any built-in array methods or sorting algorithms. The input array will have at most 1000 elements. [1, 2, 3, 4, 5, 6, 7, 8, 9]
#... | codefeedback |
Generate HTML output for displaying the following table, where the names and ages are retrieved from a database and sorted in descending order based on age. However, the age values should be formatted as Roman numerals in the output table:
| Name | Age |
| ---------- | --- |
| Michael | XL |
| Emily ... | codefeedback |
Generate a Fibonacci number sequence with n numbers where each number is the sum of the previous four numbers.
10 | codefeedback |
Edit the following HTML code to add an ID attribute with the value "demo-id" to the <h1> element, change the text inside the <h1> element to "Welcome to our website", and ensure that the <h1> element is the first child element of the <body> element. | codefeedback |
Create a C++ program that finds the first 20 prime numbers greater than 100 and prints them in reverse order, using a recursive function to check for primality. | codefeedback |
Construct a C++ program that checks whether a number is prime or not.
Allow the user to input the number.
Validate the user input to ensure it is a positive integer greater than 1.
Implement a function that uses the Miller-Rabin primality test to determine if the number is prime.
The program should also include a f... | codefeedback |
Use PHP to replace all occurrences of the word 'apple' with the word 'orange' in a given string, but also capitalize the first letter of each replaced word. Additionally, count the number of replacements made and display it at the end of the string. Ignore any occurrences of 'apple' that are inside a pair of parenthese... | codefeedback |
Implement a sorting algorithm to sort the given array in ascending order. The array may contain duplicate elements.
array = [12, 5, 9, 2, 15, 10, 4, 12, 2, 9]
Additional requirements:
1. Do not use any built-in sorting functions or algorithms.
2. Optimize your algorithm for time complexity. Aim for an efficient algori... | codefeedback |
Use Python to filter out all the prime numbers from a given list of integers. Additionally, handle any errors that may occur during the filtering process and provide appropriate error messages. | codefeedback |
Generate all possible strings of length n using A, B and C. Each string must have at least two occurrences of each character and the characters must appear in consecutive positions. | codefeedback |
Check if the following statement is a valid Python syntax and also determine the output produced when executing the statement:
Statement:
for x in range(0, len(listname)):
if x % 2 == 0:
print(listname[x] + 1)
else:
print(listname[x] - 1)
Input: A list of integers, listname.
Output: The outpu... | codefeedback |
You need to delete all occurrences of a given pattern of characters from a string, but the pattern can be any combination of lowercase letters, uppercase letters, and digits.
Write a function that takes in two strings, `string` and `pattern`, and returns a new string with all occurrences of `pattern` removed.
The fun... | codefeedback |
Implement a function to remove all occurrences of string t from string s, but the removal should be case-insensitive and the matching should be based on regular expressions.
s = 'The quick brown fox jumps over the lazy dog.'
t = 'the' | codefeedback |
Increase the difficulty by adding the following requirements:
1. The program should handle nested comments properly. For example, if there is a comment inside another comment, the program should ignore both comments and not count any string literals inside them.
2. The program should also handle escape characters pro... | codefeedback |
Design a CSS class for displaying a gradient background with alternating colors. The class should support not only horizontal gradients, but also diagonal and radial gradients. Additionally, the class should allow for customization of the gradient angle and size. | codefeedback |
Generate a random string of length n (where n is provided as an input) with characters from a-zA-Z0-9, ensuring that the string contains at least m uppercase letters, m lowercase letters, m digits, and m special characters (such as !@#$%^&*()) where m is provided as an input. | codefeedback |
Create an algorithm that sorts an array of words in alphabetical order, without using any built-in sorting functions. The algorithm should be able to handle words containing both uppercase and lowercase letters. Additionally, the algorithm should remove any duplicate words from the sorted array. The algorithm should al... | codefeedback |
Create a JavaScript function for finding the two largest prime numbers among a given array of numbers, where the array is guaranteed to contain at least two prime numbers and all other numbers are non-prime. | codefeedback |
Given two lists of strings, write a program to combine them into a dictionary whose keys are the strings in one list and values are the strings in the other list. The lengths of the two lists will always be the same. Each key in the dictionary should be unique and should not contain any whitespace characters. The value... | codefeedback |
Retrieve the third item from a doubly linked list, delete it from the list, and then insert it at the end of the list. | codefeedback |
Given a string s and a list of words words, write a program to find all occurrences of words in the string s, while ignoring any occurrences that are part of a larger word. Additionally, the program should return the frequency of each word in the string s.
The string s will only contain lowercase letters, and each wo... | codefeedback |
Retrieve the word with the second highest frequency from a given text while also considering word case sensitivity and excluding words that start with a vowel. Text: This is a sample text with a lot of words. | codefeedback |
Please check if the given string can be used as a valid password according to the following requirements:
String: myPassword123@
1. Check if the password contains at least one lowercase letter, one uppercase letter, one digit, and one special character (!@#$%^&*()-_=+[]{}|;':",./<>?`~).
2. Check if the password has a... | codefeedback |
Write a different style of a given JavaScript code snippet that calculates the sum of two numbers without using the addition operator (+) or any other arithmetic operators. Additionally, your solution should have a time complexity of O(1). | codefeedback |
Write a PHP code snippet to display "Hello, World!" in console. However, the code must use recursion to print each character of the string individually, with a delay of 1 second between each character. Additionally, the code must not use any built-in functions or libraries for string manipulation or time delays. | codefeedback |
Create a function that calculates the total amount of money after a specified number of years given an initial amount of money, a certain rate of interest, and a yearly deposit. The function should also account for compound interest.
The function should have the following signature:
```python
def calculate_total_amoun... | codefeedback |
Design a data structure to store the following information for a contact:
- Name (string)
- Phone number (string)
- Address (string)
- Email (string)
In addition to storing the contact information, the data structure should support the following operations:
1. Add a new contact to the data structure.
2. Retrieve the c... | codefeedback |
Write a SQL query to find the values that have occurred more than three times consecutively in a specific column of a table. Additionally, you should only consider consecutive occurrences if they occur within a specific date range specified by a start date and end date. | codefeedback |
Write an HTML page with two headings "Home" and "About". Implement a toggle functionality where clicking on the "Home" heading should hide the "About" heading and vice versa. Additionally, when the "Home" heading is clicked, the background color of the page should change to a random color. | codefeedback |
Write a function in JavaScript that takes in two parameters: a username and a password. The function should check if the username and password match. If they do not match, the function should throw a custom error with the message "Username and password do not match." The error should be displayed in the console. Additi... | codefeedback |
Create a SQL query to update all rows of the table "product" if their stock is below 10. However, you are not allowed to use the UPDATE statement or the WHERE clause. | codefeedback |
Write a short piece of code in Java to display the following message, but make sure to include a syntax error in your code. Additionally, your code must utilize at least one loop statement and handle a specific exception that may occur during runtime. | codefeedback |
How would you write a function in C++ to check if a given number is a prime number, but with a requirement that the time complexity of your solution should be less than or equal to O(sqrt(n))? | codefeedback |
Write code in Java to find the maximum value of the array, while also ensuring that the maximum value is greater than or equal to 100. Additionally, you must handle cases where the array contains negative numbers and return a meaningful error message if the array is empty. The array can contain up to 10^6 elements.
No... | codefeedback |
Increase the difficulty of the given programming test question by requiring the use of additional data structures or algorithms, or by adding more complex problem-solving steps.
## Revised Test ##
You are given a list of words. Your task is to find the word(s) with the longest length that contains an even number of c... | codefeedback |
How would you use a for loop in Python to print the sum of all prime numbers between 50 and 100? | codefeedback |
Write a JavaScript code to reverse the words in the following string and also capitalize the first letter of each word. The code should also handle cases where the string contains multiple spaces between words or leading/trailing spaces. The code should have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
In Python, construct a function to fit a curve to a given set of data points, using a polynomial of degree N. The degree N must be specified as an additional input parameter to the function. The function should return the coefficients of the polynomial that best fits the data points. Additionally, the function should i... | codefeedback |
Write a piece of code in Java to check if the following string contains at least two numeric characters, one uppercase letter, one lowercase letter, and one special character, with a minimum length of 10 characters.
"Hello123%World!" | codefeedback |
Create a React component in JavaScript which displays the given string as a status update. The component should also include a timestamp that shows the date and time when the status was posted. The timestamp should be formatted as "DD/MM/YYYY HH:mm". Additionally, the component should only show the status update if it ... | codefeedback |
Write a SQL query to get all employees' name, salary, and years of experience who are from the department "IT" and have a salary above the average salary of all employees in the company. Additionally, the query should exclude any employees who have been with the company for less than 3 years and have a salary below the... | codefeedback |
Create a class in Python that implements the __len__ method to return the length of a given string. However, you should also add an additional method called count_vowels that returns the number of vowels in the given string. The vowels that should be considered are 'a', 'e', 'i', 'o', and 'u' in both uppercase and lowe... | codefeedback |
In JavaScript, construct a function to count the occurrence of an element in an array, but the array can contain nested arrays as well. The function should recursively search for the element in the array and its nested arrays. Additionally, the function should return the count of occurrences as well as the indices at w... | codefeedback |
Convert the following SQL query into a Java code using JDBC.
SELECT Employees.Name, Departments.DepartmentName, COUNT(DISTINCT Employees.ID) AS EmployeeCount FROM Employees JOIN Departments ON Employees.DepartmentID = Departments.ID WHERE Employees.Salary > 50000 AND Departments.Location = 'New York' GROUP BY Employees... | codefeedback |
Create a function in Python that performs a web scrape of a specific website and returns the most frequent words from the resulting text, excluding stop words, punctuation marks, and words with a length of less than 5 characters. | codefeedback |
Generate a dynamic HTML table displaying 1000 unique random numbers from 1 to 1000, sorted in descending order. Additionally, the table should only display prime numbers. | codefeedback |
Suggest an API endpoint in Ruby on Rails for creating a new blog post with the following additional requirements:
- The blog post should have a minimum word count of 1000 words.
- The blog post should include at least three image attachments.
- The API should automatically generate a unique slug for the blog post based... | codefeedback |
Construct a SQL query to get all the rows of a table ordered by the sum of all values in each row, in descending order. Additionally, only include rows where the sum of the values is greater than a specified threshold value. | codefeedback |
Create a Swift class that implements a queue data structure with the following methods and additional requirements:
- `enqueue`: Adds an element to the back of the queue. The element must be of a custom data type called "QueueElement".
- `dequeue`: Removes and returns the element at the front of the queue. If the queue... | codefeedback |
Develop a program to convert an infix expression to prefix notation. The infix expression may contain the following operators: +, -, *, /, ^ (exponentiation), and % (modulus). The operands can be positive or negative integers.
For example, given the infix expression: 5 + 3 * 2 - 7, the program should output the prefix... | codefeedback |
Develop an HTML page with a div and table, and use CSS to make alternating rows of the table red and blue. Additionally, add a hover effect to each row that changes the background color to green. The table must be dynamically generated using JavaScript and should be populated with data from an API endpoint. The API end... | codefeedback |
Develop an HTML page with three sections, each containing different colors. Additionally, implement a feature that allows users to change the colors of each section by clicking on a button. However, you are not allowed to use any JavaScript or CSS in your solution. | codefeedback |
Construct a set of HTML tags to design a responsive two-column layout. The layout should automatically adjust its width based on the screen size. Additionally, the columns should have equal heights, even if the content in one column is longer than the other.
In addition to the above requirements, ensure that the layou... | codefeedback |
Develop a new class in Python to represent a Rectangle object with the following methods: getArea(), getPerimeter(), and getDiagonal(). Additionally, the Rectangle object should have a validate() method that checks if the provided length and width values are valid (greater than 0). The Rectangle object should also impl... | codefeedback |
Implement a function in C++ that dynamically allocates an array of integers with a size specified by the user. The function should then calculate the sum of all the elements in the array and return it. Finally, discuss the advantages and disadvantages of using dynamic memory allocation for this task compared to using a... | codefeedback |
You need to write a query in SQL to calculate the total salary of the employees in the database, but only for those who have been with the company for at least 2 years, have a performance rating of 8 or higher, and are not in any managerial or executive roles. | codefeedback |
Develop a class in Java to implement a calculator with functions add(), subtract(), multiply(), and divide().
Please include error handling for the following scenarios:
1. Division by zero: If the divisor is zero, throw a custom exception "DivisionByZeroException" with the error message "Cannot divide by zero!".
2. In... | codefeedback |
Develop an HTML form which includes three input fields, two labels, two checkboxes, a submit button, and a dropdown menu with at least five options. Additionally, implement the following features:
1. Validation: Ensure that all input fields are filled out before submitting the form. Display an error message if any fie... | codefeedback |
Explain the concept of object-oriented programming (OOP) and discuss the advantages it offers over procedural programming. Additionally, provide examples of how OOP can be utilized in practical scenarios to demonstrate its effectiveness. Furthermore, discuss the key principles of OOP, such as encapsulation, inheritance... | codefeedback |
Write a Python function that takes in a string and outputs a dictionary where the keys are the characters in the string and the values are the frequency of the characters in the string. Additionally, the function should ignore any special characters, whitespace, and should be case-sensitive. The input string will not e... | codefeedback |
Write a C++ program that demonstrates the differences between the stack and the heap memory by implementing a custom memory management system. The system should allow dynamic allocation and deallocation of memory on both the stack and the heap, and should include the following functionalities:
1. A function to allocat... | codefeedback |
Extend the program from Question 4 to allow the user to specify the upper limit and the lower limit as well. Additionally, modify the program to only calculate and display the prime numbers within the specified range. However, you should now ensure that the program executes in O(n) time complexity, where n is the diffe... | codefeedback |
Develop a function in C++ to find the roots of a cubic equation ax^3 + bx^2 + cx + d = 0, where the coefficients a, b, c, and d are limited to be complex numbers. | codefeedback |
Write a Python function to decode a given string (with special characters) to its original form. The function should have a time complexity of O(n), where n is the length of the string. Additionally, the function should not use any built-in string manipulation methods (such as replace or split) or regular expressions. ... | codefeedback |
Write a code that migrates data from one database to another, while also transforming and manipulating the data in the process. The code should be optimized to handle large datasets efficiently and effectively, with a time complexity requirement of O(n log n). Additionally, the code should ensure data integrity by impl... | codefeedback |
Create an SQL table to store information about books, authors, and publishers. Additionally, ensure that the table has proper constraints to enforce referential integrity, such as foreign key relationships between the books and authors, as well as books and publishers. Implement a trigger that automatically updates the... | codefeedback |
List all possible combinations of three distinct elements from a given array, where the sum of the elements in each combination is equal to a given target value. The array may contain duplicate elements. Additionally, there may be negative numbers in the array. | codefeedback |
Implement the quicksort algorithm using C++ and ensure that the time complexity is O(nlog^2n) and the space complexity is O(log^2n). | codefeedback |
Construct a SQL query to find the employee records with salary between 2000 and 3000 dollars, have been with the company for more than 2 years, and have received a promotion within the last 6 months. | codefeedback |
Create a function in JavaScript to convert a number to its equivalent string format. The function should handle both positive and negative numbers, as well as decimal numbers. The output should also include any trailing zeros in the decimal part. Additionally, the function should not use any built-in JavaScript functio... | codefeedback |
Write a query in MySQL which will get all the records from a table, but exclude any records where the value in a specific column is equal to a certain value. Additionally, the query should sort the results in descending order based on another column and only return the first 10 records. | codefeedback |
Write a Java program to find the sum of two arrays of length 10, where each array element is a 10-digit positive integer. The program should also handle cases where the sum of the corresponding elements in the two arrays exceed the maximum value of a 10-digit integer. Additionally, the program should throw an exception... | codefeedback |
Given the following list of dictionaries, use list comprehension to create a new list with the string "student_" added to the beginning of each student's name, but only for students who have a grade higher than 80. Additionally, sort the new list in descending order based on the student's grade.
students = [{'name': 'J... | codefeedback |
Create a JavaScript object which will contain data about a person, but instead of simply including basic information such as name and age, the object should also include more specific details such as the person's blood type, genetic traits, and a detailed medical history. Additionally, the object should have a method t... | codefeedback |
Create a while loop in C++ that iterates over integers from 1 to 10, and for each iteration, computes the factorial of the current number using a recursive function. Additionally, within the loop, print out the result of each factorial calculation along with the current number being processed.
Ensure that the recursiv... | codefeedback |
Create a column-oriented MySQL table with the columns "id", "name", "age", "address", and "phone number".
Additionally, implement the following features:
1. Ensure that the "id" column is the primary key of the table and that it auto-increments.
2. Make the "name" column a non-null column.
3. Add a constraint to ensur... | codefeedback |
Write a JavaScript function that takes in an array of numbers (length <= 1000) and returns a new array containing only the numbers that are greater than 10 and less than 100. The function should also sort the resulting array in descending order and remove any duplicates. Additionally, the function should not use any bu... | codefeedback |
Construct a recursive function in PHP that calculates the nth number in the Fibonacci sequence, where n is a positive integer. The function should have a time complexity of O(2^n) and space complexity of O(n). | codefeedback |
Write a SQL query to retrieve the title, genre, and the date published of books created by the author "Smith", sorted in descending order based on the number of copies sold, where the number of copies sold is greater than 100. Additionally, only retrieve books that have a rating higher than 4.5 and were published in th... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.