instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Using the GPT-3 AI language model created by OpenAI, write a program that generates a paragraph containing at least three synonyms for the word "developed" and at least five synonyms for the word "advanced". Ensure that the generated paragraph maintains coherent and grammatically correct sentences. | codefeedback |
Construct a program to find the index of a given element in a sorted array with binary search. However, the array contains duplicate elements, and the program should return the index of the first occurrence of the target element. Additionally, the program should be able to handle arrays with a size of up to 10^9 elemen... | codefeedback |
Create a list of strings in Python with 10 elements, where each string must be unique and have a length of at least 8 characters. Additionally, the strings must contain at least one uppercase letter, one lowercase letter, one digit, and one special character. | codefeedback |
Construct an algorithm to check if two strings have the same characters and same frequency of characters. However, in addition to comparing the characters and their frequencies, you should also consider the case sensitivity of the characters. Furthermore, the algorithm should also consider whitespace characters and pun... | codefeedback |
Create a function that takes in two integers, `start` and `end`, and prints out the square of the numbers between `start` and `end`, inclusive. However, only print the square if the number is divisible by both 3 and 5. Additionally, the function should return a list of all the squares that were printed.
Constraints:
-... | codefeedback |
Create a React component with two TextInputs. The first TextInput should only accept numeric input and should have a maximum length of 5 characters. The second TextInput should only accept alphabetic input and should have a minimum length of 3 characters. Additionally, the component should display an error message if t... | codefeedback |
Write a MATLAB function for calculating the sum of two matrices, but without using the built-in MATLAB function for matrix addition (e.g., `A + B`). Additionally, you are not allowed to use any loops or iterative structures in your solution. You must find a way to solve the problem using only vectorized operations and ... | codefeedback |
Generate a balanced ternary search tree data structure in Python. Additionally, implement a method to perform an in-order traversal of the tree. | codefeedback |
Use RegEx to identify words in a string and count the occurrences of each word. The string should not contain any punctuation marks or special characters, and words should be considered case-sensitive. Consider only words that are at least three characters long. String: "I have 2 apples and 3 bananas. Apples are delici... | codefeedback |
Create a class in Java called Employee with the following fields (name, ID, department, position, and experience). Implement a method called "calculateSalary" that takes in the number of hours worked, the hourly rate, and a bonus percentage and returns the salary of the employee, including the bonus. The bonus percenta... | codefeedback |
Write a Bash script to accept two command line arguments (username and password) and echo them out. Additionally, the script should check if the password meets the following criteria:
- The password must be at least 12 characters long.
- The password must contain at least one uppercase letter, one lowercase letter, one... | codefeedback |
Increase the difficulty of the given programming test question by adding additional steps and logic:
1. Create an empty dictionary named `dict1`.
2. Iterate over each tuple in `list1`.
3. Extract the first element of the tuple as the key and the second element as the value.
4. Check if the key already exists in `dict1... | codefeedback |
Compute the length of a string without using the built-in length function, while also not using any loops or recursion.
String: Hello World | codefeedback |
Write a class with a method named 'helloWorld' that takes in a string parameter and returns the string with all vowels replaced by the corresponding vowel's next letter in the alphabet. The method should also convert all uppercase letters in the input string to lowercase before performing the vowel replacement. The inp... | codefeedback |
Describe a multi-class classification problem in machine learning and explain the steps involved in solving it. Additionally, discuss the challenges faced and potential techniques to improve the model's performance. | codefeedback |
Design an Android application to store a user's sensor data and display real-time graphs of the sensor readings. Additionally, implement a feature that allows the user to set custom thresholds for each sensor, and notify the user when a sensor reading exceeds or falls below the specified threshold. | codefeedback |
Modify the following HTML code to add a new div element inside the existing div and give it a unique id. Additionally, add a paragraph element inside the new div with the text "This is a new div inside the existing div". The new div should have a class attribute with the value "nested-div", and the paragraph should hav... | codefeedback |
Create a query in MySQL that returns the names, ages, and genders of all people in the table over 18, sorted in descending order of their ages. Include only those individuals whose ages are between 18 and 35, and whose names are not more than 10 characters long. Additionally, filter the results to only include individu... | codefeedback |
Create an SQL query that returns all customers in New York state who have made at least 5 purchases in the last 3 months, with the most recent purchase being within the last week. | codefeedback |
You need to clean a given string by removing all the punctuation marks and ensuring that all letters are in uppercase.
let str = 'Hello, World!'; | codefeedback |
write a function in R that rounds a positive number to the nearest whole number and handles negative numbers as well | codefeedback |
How can we sort an array of numbers in ascending order in Python using bubble sort algorithm? Additionally, provide the time complexity of the bubble sort algorithm and explain its working principle in detail. | codefeedback |
Transform the following string in Python into a dictionary whose keys are the names of the colors and the values are the hex codes for the colors. The input string may contain multiple color entries separated by commas. Each color entry consists of a color name followed by a space and a hex code, separated by a colon. ... | codefeedback |
Define a class in C++ to represent a point in 4-dimensional space. The class should include a method to calculate the distance between two points in 4-dimensional space. | codefeedback |
Generate an HTML page with a table that displays data from a database. The table should have sortable columns and allow users to filter the data based on multiple criteria simultaneously. Additionally, implement functionality to dynamically update the table without refreshing the entire page. However, there is a bug in... | codefeedback |
Write a function in Java that can be used to search an array and return the index of the element. The function should also handle cases where the element is not present in the array and return -1 in such cases. Additionally, the function should be able to handle arrays with duplicate elements and return the index of th... | codefeedback |
Write a SQL query to list the unique office locations which are older than 5 years, have a minimum of 50 employees, and belong to a company with a revenue of at least $1 million. | codefeedback |
Create a Python script that sets the value of a variable from the command-line, but the value must be encrypted using a custom encryption algorithm before being assigned to the variable. Additionally, the script should include error handling to ensure that the encrypted value is properly decrypted and assigned to the v... | codefeedback |
Design an algorithm that determines the greatest common multiple of two numbers in a list of n numbers.
Time complexity requirement: O(n^3)
Space complexity requirement: O(n) | codefeedback |
Design an algorithm that calculates the sum of all positive even numbers greater than 5 and less than or equal to 1000 in a given array, while also ensuring that the sum is not divisible by 3. The array may contain duplicates, negative numbers, and numbers greater than 1000.
[2, 4, 7, 10, 12, 16, -6, 1002, 8, 12, 14, 1... | codefeedback |
Write a program that visualizes the given data using a stacked bar chart. The data consists of the name of the month and the corresponding values for three different categories. The program should display the stacked bar chart with each bar representing the total value for that month, divided into three sections repres... | codefeedback |
Create an object-oriented C# program that prints "Hello, World!" using a custom-built logging framework that logs the message to a file with a timestamp and log level. The logging framework should also have the ability to write the log messages to a remote server over a secure connection. | codefeedback |
Please increase the difficulty of the given programming test question a bit.
You can increase the difficulty using, but not limited to, the following methods:
Add new constraints and requirements to the original problem, adding approximately 10 additional words.
#Given Test#
Modify the given code to handle errors in ... | codefeedback |
Create a class that can be used to filter a given list of numbers using a given condition.
nums = [3,6,7,2,1,12,14]
condition = lambda x: x>5 and x%2==0
The condition should now check if the number is greater than 5 and divisible by 2. | codefeedback |
Write a function that takes in two strings and returns True if they are anagrams of each other, and False otherwise. An anagram is a word or phrase formed by rearranging the letters of another word or phrase. Your function should also handle any possible exceptions that may occur during the comparison process, such as ... | codefeedback |
Write a function that takes two strings and compare to see if they have the same set of characters. The function should also account for case sensitivity, ignore any spaces in the strings, and handle special characters. The function should return True if the strings have the same set of characters, otherwise return Fal... | codefeedback |
Given a list of tuples, write a function that returns a new list containing the first element of each tuple if it is an odd number, otherwise, return the second element of each tuple. The input list will always contain tuples with two integers. The function should have a time complexity of O(n), where n is the number o... | codefeedback |
Write a JavaScript function that takes two numbers and a mathematical operator as parameters and returns the result of the specified operation. The mathematical operator can only be one of the following: '+', '-', '*', '/' or '%'. If the operator is '+', the function should return the sum of the two numbers. If the ope... | codefeedback |
Construct an algorithm that checks if the given sequence is a strictly increasing arithmetic sequence with a common difference of 1. The sequence may contain negative numbers and can have a length of up to 10^9. The algorithm should have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Write a function to compute the maximum depth of a binary tree from a given list of numbers. However, the list may contain invalid inputs such as strings, negative integers, or numbers larger than 1000. You need to handle these cases and return an appropriate error message.
For example:
nums = [3,9,20,None,None,15,7,... | codefeedback |
Write a function that creates a new array of a given size by copying the elements of a given array. The new array should only contain unique elements from the original array. The function should also remove any duplicate elements in the original array before creating the new array. The time complexity of the function s... | codefeedback |
Find all prime numbers up to a given number, but also keep track of the number of times each prime number occurs in a separate list. The solution should have a time complexity of O(n log log n) and a space complexity of O(n). | codefeedback |
Create a function that takes a string representation of a JSON object and converts it into a Python dictionary. The JSON object may contain nested objects, arrays, and primitive data types such as strings, numbers, booleans, and null. The function should handle cases where the JSON object is not well-formed by raising ... | codefeedback |
Develop a program to identify the top k highest numbers in a given array, without using any built-in functions or sorting algorithms, and with a time complexity of O(n log k), where n is the size of the array and k is a user-defined constant.
Array: [2, 5, 15, 4, 7, 10]
k = 3 | codefeedback |
Find the nth Fibonacci number in a given range, where the range is defined as the Fibonacci sequence between two given numbers. The nth Fibonacci number is defined as the sum of the previous two Fibonacci numbers.
For example, given the range [10, 100], the Fibonacci sequence between 10 and 100 is [13, 21, 34, 55, 89]... | codefeedback |
Create one line of code to sum the contents in a given array, without using any built-in sum function or list comprehension. Additionally, the solution must have a time complexity of O(n), where n is the length of the array. The input array will only contain positive integers. Instead of using addition (+) as the opera... | codefeedback |
Construct a one-liner that takes a nested dictionary and reverses the keys and values of the dictionary, where the nested dictionary can have multiple levels of nesting. Additionally, the solution should have a time complexity of O(n), where n is the total number of elements in the nested dictionary.
my_dict = {'Tony... | codefeedback |
Alter the following program such that it returns the complement of the given list, but without using any built-in functions or methods, and ensure that the program has a time complexity of O(n) and a space complexity of O(1), where n is the length of the list. | codefeedback |
Create a method to delete items from a specified array by their index.
The method should:
1. Prompt the user to enter the index of the item they want to delete.
2. Validate the input to ensure it is a valid integer within the range of the array's indices.
3. Delete the item at the specified index and shift all subsequ... | codefeedback |
Construct a SQL query to list the titles and prices of books from the "Books" table, but exclude any books with a price greater than $50 and published after the year 2010. | codefeedback |
Implement a function that will take a parameter input and return the number of unique characters in the parameter.
Additionally, modify the function to count both uppercase and lowercase characters as unique characters.
Furthermore, implement the function in such a way that it is case-insensitive. In other words, t... | codefeedback |
Write a function to sort a dictionary of dictionaries in descending order based on a given key. However, the key can be nested within multiple levels of dictionaries and lists.
For example:
d = {'dict1': {'name':'tom','age':20},
'dict2': {'name':'jerry','age':25},
'dict3': {'name':'bill','age':24}}
key = 'ag... | codefeedback |
Implement a class method in C++ that takes a string parameter, checks to see if it is all uppercase, and outputs a Boolean value. Additionally, if the input string contains any non-alphabetic characters, the method should throw an exception with the message "Non-alphabetic characters are not allowed". If the input stri... | codefeedback |
Implement a quicksort algorithm in Python to sort a list of 10,000 integers randomly generated between 1 and 1,000,000. You must use a recursive approach and cannot use any built-in sorting functions or libraries. Additionally, the sorting algorithm must be implemented as a separate function rather than using the built... | codefeedback |
Construct a loop in PHP to add all elements from an array [2, 3, 8, 9]. The loop should be implemented using a nested loop structure. Additionally, you should check if each element is divisible by 2 before adding it to the sum. | codefeedback |
Write a JavaScript function that checks if a given parameter is a leap year. Additionally, the function should return the number of leap years between the given parameter and the current year. The function should have a time complexity of O(1) and should not use any built-in date or time functions. | codefeedback |
Produce a Java program that converts miles, yards, and feet to kilometers and vice versa. The program should prompt the user to enter the conversion type (1 for miles to kilometers, 2 for kilometers to miles, 3 for yards to kilometers, 4 for kilometers to yards, 5 for feet to kilometers, 6 for kilometers to feet) and t... | codefeedback |
Compute the square root of the sum of the first 150 prime numbers and output the decimal part only using C++.
#Explanation#
To solve the rewritten test, you will need to perform the following steps:
1. Generate a list of the first 150 prime numbers.
2. Sum all the prime numbers in the list.
3. Calculate the square roo... | codefeedback |
Generate a random 4x4 array using Java. The array should contain only unique prime numbers ranging from 1 to 16. | codefeedback |
Write a function to search in a 2D array of integers, and return the coordinates (row and column) of the target if it is present. The target must be found using a binary search algorithm.
The 2D array is structured as follows:
array = [
[1, 3, 5, 7, 9],
[2, 4, 6, 8, 10],
[11, 13, 15, 17, 19],
[12, 14, 16, 18, ... | codefeedback |
Create a program that takes a positive integer n as input and prints the pattern given below. The program should validate the input to ensure that n is between 1 and 10 (inclusive) and that it is a prime number. If the input is invalid, the program should display an error message and ask for a valid input. The pattern ... | codefeedback |
Create a MongoDB document to store a user's profile with the following information: name, email, profile_image, age, and hobbies.
name = "John Doe"
email = "jdoe@example.com"
profile_image = "https://example.com/images/jdoe.png"
age = 25
hobbies = ["reading", "playing guitar"]
Additionally, add a nested document to st... | codefeedback |
Implement the Gnome sort algorithm in Python.
Note: You are not allowed to use any built-in sorting functions or libraries for this implementation. Additionally, you must implement the algorithm using a recursive approach. | codefeedback |
Write a function to return the count of all prime numbers from 1 to n (inclusive) where n is a positive integer greater than or equal to 2. However, the function should not use any built-in prime number libraries or functions. | codefeedback |
Create a SQL query to find the employees with the highest salary in each job role, but exclude any employees who have been employed for less than 5 years. Additionally, exclude any employees who have a job title that contains the word "manager" and have a salary less than the average salary of all employees in the same... | codefeedback |
Code an algorithm in Java to check if a given array contains duplicate elements and return the number of duplicates found. If there are duplicates, print them out as well.
arr = [3, 6, 5, 4, 6, 9]
Expected output:
Duplicates: [6]
Number of duplicates: 1 | codefeedback |
You need to code a function in JavaScript that takes in a string and checks if the length of the string is greater than or equal to 10 characters and contains at least two uppercase letters, two lowercase letters, two special characters, and two digits. | codefeedback |
Create a query in SQL to list all the employees with their salary, who work in the IT department and have more than 10 years of experience. Additionally, display the average salary for employees in the IT department, the maximum salary among those with more than 10 years of experience, and the minimum salary among thos... | codefeedback |
Develop an SQL query to find the name, email address, and department of the employees who do not have any job role, have been employed for more than 2 years, and have a salary above a specified threshold.
#Difficulty Increase Explanation#
The difficulty of the question is increased by adding the requirement to include... | codefeedback |
Write an SQL query to select the employees who have worked full-time for more than 5 years, have a salary greater than $100,000, and belong to a department that has at least 10 employees. Display their employee ID, name, department name, and salary. | codefeedback |
Compute the sum of all numbers from 0 to n that are divisible by either 2, 3, or 5, and are also prime numbers, using Java.
n = 100 | codefeedback |
Create a Swift program to remove duplicates from a given array, but without using any additional data structures. The program should have a time complexity of O(n^2), where n is the size of the array. Additionally, the program should not use any built-in Swift array functions or methods, and should only use basic contr... | codefeedback |
Modify the following python program to return the sum of even numbers that are divisible by 5 and contain the digit 2 from the input list.
def sum_list(input):
sum = 0
for num in input:
if num % 2 == 0 and num % 5 == 0 and '2' in str(num):
sum += num
return sum | codefeedback |
Develop an algorithm in C++ to reverse a linked list, but with the following additional requirements:
1. The algorithm should have a time complexity of O(n), where n is the number of nodes in the linked list.
2. The algorithm should use only a constant amount of additional space, i.e., the space complexity should be ... | codefeedback |
Remove all prime numbers from an array in JavaScript, while keeping the original order of the remaining elements intact. The resulting array should contain only non-prime numbers.
let arr = [1, 2, 3, 4, 5]; | codefeedback |
What is a function pointer and how can it be used in C programming? Provide an example of a function pointer declaration and usage in a program. Additionally, explain the concept of callback functions and demonstrate their usage using a function pointer. | codefeedback |
Write a SQL query to find the most recent 5 login dates for each user who has logged in at least 10 times in the last month. Additionally, exclude any users whose username starts with the letter 'A'. Finally, sort the results in descending order based on the login date.
table_name: users
column_names: user_id, usern... | codefeedback |
Write a query to find records created in the last 30 days in a MySQL database, excluding weekends (Saturday and Sunday). The table name is "users" and the column name is "created_at".
The query should also return the count of records created in each of the last 7 weekdays. | codefeedback |
Write a shell script that takes an input string, calculates its length, counts the number of vowels in the string, counts the number of consonants in the string, and prints the length, vowel count, and consonant count.
Additionally, the script should convert all uppercase letters in the string to lowercase before perf... | codefeedback |
Explain how polymorphism can be achieved in a specific programming language of your choice. Provide code examples to illustrate the concept. Additionally, discuss the benefits and limitations of using polymorphism in the context of a real-world problem that you have encountered in your programming experience. | codefeedback |
Increase the difficulty by modifying the code to use a more complex algorithm to find prime numbers efficiently.
Debug the following code in Java to list all the prime numbers until 1000.
class Main {
public static void main(String[] args) {
for(int i = 2; i < 1000; i++) {
if (isPrime(i)) {
... | codefeedback |
Generate the fibonacci sequence for the first 10 numbers using PHP. The solution should be implemented using recursion and without using any loop constructs. Additionally, the function should have a time complexity of O(n) and space complexity of O(1). | codefeedback |
Structure an HTML form taking inputs of name, age, email address, and phone number. Additionally, implement form validation to ensure that all fields are filled out correctly before submitting the form. Include error messages that are displayed if any of the fields are left empty or contain invalid data. Use appropriat... | codefeedback |
Reverse the words in a given sentence using JAVA.
String sentence = "Hello World";
Write a Java program that takes a sentence as input and reverses the order of the words in the sentence. Your program should preserve the spacing and punctuation in the original sentence.
For example, if the input sentence is "Hello Wo... | codefeedback |
Implement a binary search algorithm to find the position of a target element in a sorted array. The target element may appear multiple times in the array. If the target element is not found, return -1.
Requirements:
1. Your binary search algorithm should be implemented recursively.
2. The input array must be sorted in... | codefeedback |
Write a C# script that takes an input string from the user and prints it three times. The script should also count the number of characters in the input string and display the count at the end. Additionally, the script should handle any errors that may occur during the user input process, such as invalid characters or ... | codefeedback |
Define a class for a student with the following additional constraints:
- The student's name should be at least 5 characters long and can contain only alphabets. The first character of the name should be in uppercase and the rest should be in lowercase.
- The student's age should be between 15 and 25, inclusive.
- The ... | codefeedback |
Create an HTML page that includes a dynamically generated chart using data fetched from an API. The chart should display real-time updates every 5 seconds. Additionally, implement a feature that allows the user to filter the chart data based on specific criteria.
Erroneous code reference:
In the dynamically generated ... | codefeedback |
Write a function that takes in two lists of numbers as input. The first list represents the coefficients of a polynomial equation, while the second list represents the values to be substituted into the equation. The function should return a new list that contains the results of evaluating the polynomial equation for ea... | codefeedback |
Create a new Java program that prints out all the prime numbers between 2 and 1000, but without using any built-in methods or libraries for prime number generation or checking. Your algorithm must be optimized to run in O(sqrt(n)) time complexity, where n is the input number being checked. Additionally, your program sh... | codefeedback |
Given two strings, string1 and string2, remove all letters from string1 which are present in string2 and vice versa, while also keeping track of the frequency of each letter that is removed. Finally, return the letters that were removed along with their frequencies in a sorted order.
Constraints:
- The strings may con... | codefeedback |
Construct a function that takes in a time in hours (ranging from 0 to 23) as a parameter and returns a corresponding greeting based on the time. The function should have a time complexity of O(1) and should not use any if-else statements or switch statements. | codefeedback |
Write a JavaScript Object that contains employee data such as name, age, contact number, and salary. Additionally, include a function that calculates the employee's yearly bonus based on their performance rating and job position. The performance rating should be a value between 1 and 10, with 10 being the highest. The ... | codefeedback |
Given a positive integer 'base' and a positive integer 'exponent', write a function to calculate the result of 'base' raised to the power of 'exponent'. The function should handle large values of 'exponent' efficiently. The function should also handle negative values of 'exponent' and return the result as a decimal wit... | codefeedback |
Create a database table for student information with the following attributes: Name, Age, Year, GPA, and Major. Additionally, ensure that the Year attribute is an integer and has a minimum value of 1 and a maximum value of 4, indicating the student's academic year.
To increase the difficulty, modify the question to i... | codefeedback |
Generate a query to find the average age of female students who are enrolled in a course with given course ID, have a GPA above 3.5, and belong to a specific department. The department should have at least 50 students and offer at least 3 courses. Additionally, the query should exclude students who have already taken t... | codefeedback |
Compare two arrays and output the result in Boolean. However, instead of comparing the arrays directly, you need to compare the arrays while ignoring any duplicate elements and taking into account the order of the remaining elements. Additionally, the comparison should only consider the elements that are multiples of a... | codefeedback |
Construct an algorithm for reversing a string without using any built-in string reversal functions or methods. The algorithm should have a time complexity of O(n), where n is the length of the string, and a space complexity of O(1).
You are not allowed to use any additional data structures or arrays.
Additionally, th... | codefeedback |
Evaluate a mathematical expression given as a string. The expression can contain parentheses and the following operators: addition (+), subtraction (-), multiplication (*), division (/), and exponentiation (^). The expression can also contain floating-point numbers.
The expression can include multiple levels of parent... | codefeedback |
Write an R function to print the contents of a dataframe in reverse order. The function should also display the total number of rows and columns in the dataframe, and print an error message if the dataframe is empty. Additionally, the function should check if any column in the dataframe contains only unique values and ... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.