instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write a code in Java to print the Fibonacci series till a given number, where the input is a user-specified number. However, you should not use recursion to solve this problem. | codefeedback |
Create a new string that is the reverse of the original string, but exclude any vowels. The original string can contain both uppercase and lowercase letters. | codefeedback |
Create a new list that is the combination of two other given lists, ensuring that the length of the resulting list is equal to the sum of the lengths of the original lists. The new list should also maintain the order of the elements from the original lists. Additionally, the elements in the new list should be in the fo... | codefeedback |
Write a function that takes two integer arguments and returns their sum. The function should also handle cases where the input arguments are not integers, and return an error message in such cases. Additionally, the function should be able to handle negative integers as input.
x = -3
y = 5 | codefeedback |
Create a React component for displaying a list of books. The component should have a search functionality where the user can enter a keyword and the list of books will be filtered based on the keyword. The search functionality should be case-insensitive. Additionally, the component should have a sort functionality wher... | codefeedback |
Create a function 'convertStringToInt' that takes a string and converts it into an integer. The string may contain leading or trailing white spaces, and may also include commas. The function should handle these cases and return the corresponding integer value. | codefeedback |
Create a dynamic HTML page that displays the top 5 countries in the world by population, where the population is constantly changing in real-time. The page should also include a search functionality to allow users to search for specific countries and their corresponding populations. Additionally, the page should have a... | codefeedback |
Construct a SQL query to retrieve the records from a table that satisfy a certain condition, but only if the condition involves joining multiple tables together. | codefeedback |
What is the data structure of a hash table and how does it handle collisions between hash values? | codefeedback |
Create a program that reads an integer and prints out the next prime Fibonacci number. | codefeedback |
Write a function that takes a list of strings and returns the longest common prefix of the list of strings. The function should have a time complexity of O(n*m), where n is the number of strings in the list and m is the length of the longest string. Additionally, the function should not use any built-in string matching... | codefeedback |
You are given an array of integers and the task is to create a function that returns the maximum pairwise product of those numbers. However, the function should have a time complexity of O(n), where n is the length of the array. | codefeedback |
Create a program that reads two numbers and prints out their greatest common divisor using the Euclidean algorithm.
#Additional Details#
1. The program should prompt the user to enter two numbers.
2. Validate the input to ensure that the numbers entered are positive integers.
3. Implement the Euclidean algorithm to fi... | codefeedback |
Create a program that reads a list of integers and returns the highest prime number that is also a palindrome in the list. | codefeedback |
Create a JavaScript function to get the highest value from a given array. Additionally, ensure that the function does not use any built-in array sorting or comparison methods (e.g. `sort()`, `Math.max()`, etc.) and has a time complexity of O(n). | codefeedback |
Create a program that reads an integer N and calculates the sum of the series 1/1 + 1/2 + 1/3 + . . . . . + 1/N, where N can be a very large number (up to 10^9). The program should handle this large input efficiently without causing any overflow or memory issues.
Additionally, the program should implement the series c... | codefeedback |
Create a Java program that takes an array of integers as an argument and then prints out the elements of the array in reversed order. The program should handle arrays of any length and should not use any built-in functions or libraries to reverse the array. The program should also check if the input array is null or em... | codefeedback |
Create a JavaScript program that takes a string as an argument, removes any duplicate characters, and then prints out the remaining characters in reverse order. | codefeedback |
Create a C++ program that sums up all the numbers in a given array. The array can contain both positive and negative integers. Additionally, the program should exclude any numbers that are divisible by 3 from the sum. The program should also output the average of the remaining numbers in the array. | codefeedback |
Create a program to calculate the Fibonacci sequence up to the nth element, but with the additional requirement that each number in the sequence must be checked for primality before being included in the sequence. | codefeedback |
Create a list comprehension that outputs a list of strings with the same character. The list should only include strings that have a length greater than or equal to 5. The input string should be stripped of any leading or trailing whitespace before processing. | codefeedback |
Create a program to search a nested list and print all the elements containing the number 3. The nested list may contain integers or other nested lists. The program should handle lists of any depth.
nested_list = [[1, 2, 3], [4, 5, 6], [7, 8, [3, 4, 5]], [9, [10, 11, [3, [12, 13, [3]]]]]]
The program should have a ti... | codefeedback |
Perform the following operation on this array and print the result: remove the last three elements and add them to the beginning. Also, ensure that the resulting array is sorted in ascending order.
arr = [1, 2, 3, 4, 5, 6, 7, 8] | codefeedback |
Write a program that performs principal component analysis on a dataset containing a mixture of numerical and categorical variables. The program should be able to handle missing values in the dataset and should implement a customized algorithm for dimensionality reduction. Additionally, the program should provide a gra... | codefeedback |
Write a JavaScript function that takes an array of numbers and a function as arguments and returns an array with the same numbers as the input, but sorted in ascending order. The input array can contain duplicate numbers and negative numbers as well. The sorting algorithm used should be more efficient than a simple bub... | codefeedback |
Explain what overfitting is, in the context of machine learning, and provide an example to illustrate the concept. Additionally, discuss at least two methods to mitigate the issue of overfitting and explain how they work. | codefeedback |
Classify the given text as either suitable for children or not, while also identifying the emotions expressed in the text.
#Reasoning#
In addition to determining whether the text is suitable for children or not, this rewritten test also requires identifying the emotions expressed in the text. This adds an additional l... | codefeedback |
Explain why normalization is needed for natural language processing, considering the impact of multilingual data and the requirement for handling linguistic variations and irregularities. | codefeedback |
Write a code in Python to find the longest increasing subsequence of a given sequence.
sequence = [1, 6, 2, 4, 3, 7]
#Erroneous Code Reference#
# Assume that the code provided is a solution to the problem, but it contains a mistake that leads to incorrect results.
# For example:
# def find_subsequence(sequence):
# ... | codefeedback |
Generate SQL code to create a table of users with the columns (user_id, name, email, age), where the user_id is a primary key and auto-increments for each new user added to the table. Additionally, ensure that the name column only accepts alphanumeric characters and has a maximum length of 50 characters. The email colu... | codefeedback |
Classify the given text into either positive or negative sentiment based on multiple criteria, including the presence of profanity or hate speech.
This movie was one of the worst movies I've ever seen, filled with vulgar language and offensive content. | codefeedback |
Write a Java code to clone a linked list using iteration. The original linked list contains nodes with both integer values and strings. Additionally, you should implement a method to reverse the cloned linked list. | codefeedback |
Write a SQL query to list all the product categories with their sales numbers in the given data set. Additionally, calculate the total sales amount for each category and display it in descending order.
Table: Products
| id | product_name | category | sale_price |
|----|---------------|----------|------------|
| 1 |... | codefeedback |
Generate a Fibonacci sequence of n numbers, where n is provided as input by the user, using Java. | codefeedback |
How would you modify the following code to store the output of the function in a dictionary, where the keys are the first character of each item in the list and the values are the remaining characters of each item? | codefeedback |
Edit the function so that an element can be deleted from the list, but the function should return True if the element was successfully deleted and False if the element was not found in the list. If the element is found multiple times in the list, delete all occurrences of it.
def delete_element(lst, element):
foun... | codefeedback |
Compare the input list with a pre-defined list and return a new list containing only the elements that are present in both lists, but the comparison should be case-insensitive.
my_list = ['apple', 'banana', 'orange']
pre_defined_list = ['APPLE', 'BANANA', 'grape'] | codefeedback |
Write a code to find the factorial of a given number using a recursive function. However, the recursive function must use tail recursion optimization. | codefeedback |
Create a program in Ruby to print the Fibonacci sequence until the 50th element. | codefeedback |
Write a Java program that takes in a string and reverses the order of its characters, while also removing any duplicate characters. The program should ignore any punctuation or special characters and should only consider alphanumeric characters. The program should also keep track of the frequency of each character and ... | codefeedback |
Construct a loop to print all the prime numbers between 1 and 1000. | codefeedback |
Convert the following JSON data into XML format and include the following additional requirements:
1. Ensure that the resulting XML contains attributes to represent the key-value pairs in the JSON data.
2. Handle nested objects and arrays within the JSON data and represent them appropriately in the XML format.
3. Impl... | codefeedback |
Generate a JSON string from a given Python dictionary. The dictionary should contain the following key-value pairs:
- "title": "GPT Model Evaluation"
- "category": "Natural Language Processing"
- "score": 8
Ensure that the JSON string is properly formatted with correct indentation and spacing.
Furthermore, add the fo... | codefeedback |
Create a CSS animation to animate a ball bouncing up and down with the following additional requirements:
1. The ball should start at the top of the screen and bounce off the bottom of the screen.
2. The animation should have a smooth acceleration and deceleration effect, giving a more realistic bouncing motion.
3. Ad... | codefeedback |
Write a JavaScript class that generates a random integer between 1 and 100, and keeps track of the number of times each integer has been generated.
#Additional Reasoning Steps#
1. The class should have a property called `generatedNumbers` that is initialized as an empty object. This object will store the generated num... | codefeedback |
Create a MySQL query to get the maximum salary from the employees table section. However, exclude any employees whose salary is above 100,000.
Table structure:
employees
id | name | department | salary |
Erroneous code reference:
```
SELECT MAX(salary) FROM employees WHERE salary > 100,000;
``` | codefeedback |
Write a Python function to find all pairs in a given list of positive integers whose sum equals a given target number and the difference between the two numbers in the pair is less than or equal to a given threshold.
Given List: [1, 4, 2, 9, 5]
Target number: 7
Threshold: 3 | codefeedback |
Compute the minimum string edit distance between two strings of different lengths.
str1 = "kitten"
str2 = "sitting on a chair" | codefeedback |
Parse this list of JSON objects to get the first name of the employee with the highest age. | codefeedback |
Write a function that inserts a new row in the table Inventory with the following details: itemname as "keyboard", quantity as 10, and price as 10.25. The function should also validate the input before inserting the row.
Table structure:
Inventory
id | itemname | quantity | price |
The function should perform the f... | codefeedback |
Build a machine learning model to classify the type of iris flower, but now the model should have an accuracy of at least 95% on a test dataset. | codefeedback |
Write a CSS rule to set the background color to a linear gradient that starts with pink and ends with purple, and the text color to a random color from a predefined list of 10 colors. | codefeedback |
Given two strings, write a Python function that finds the common letters between them. The function should also return the number of times each common letter appears in both strings. Both strings should be case-insensitive and can contain spaces and special characters. Return the result as a dictionary where the keys a... | codefeedback |
Create a function which takes a variable number of arguments, checks if all of them are lists and have an odd length, and then adds all the odd-indexed items in the lists.
my_lists = [[1,2,3], [4,5,6], [7,8,9,10]] | codefeedback |
Write a function that takes a string, checks if it is a palindrome, and returns a corresponding boolean value. The function should have a time complexity of O(n) and a space complexity of O(1).
string = "A man, a plan, a canal: Panama!" | codefeedback |
Create a function that takes a list of integers as an argument and returns a dictionary containing the frequency of each number. The input list can contain both positive and negative numbers, and there may be duplicate numbers in the list. The returned dictionary should only include numbers that have a non-zero frequen... | codefeedback |
Write a Bash script to run a command and store its output in a variable, but the command must be executed within a Docker container. | codefeedback |
Create a SQL query that gets the list of names of all employees who work at the company 'ABC' and have a salary greater than $50,000. | codefeedback |
Write a Java code to generate a Fibonacci number at a given index. The code should utilize recursion to solve the problem and have a time complexity of O(2^n). | codefeedback |
Write a Python program to print a dictionary where the keys are prime numbers between 1 and 100 (both included) and the values are the sum of the digits of the corresponding keys. | codefeedback |
Answer the following question about the data structure Stack.
Implement a stack using a singly linked list and provide the necessary operations:
- push(x): Insert element x into the stack.
- pop(): Remove the element at the top of the stack and return its value.
- top(): Return the value of the element at the top of ... | codefeedback |
Write a bash script that can add two numbers, but the script should only use bitwise operations for the addition. | codefeedback |
In Python, create a function that takes a list of integers and returns the two largest numbers in the list. The function should have a time complexity of O(n) and should not use any built-in sorting functions. | codefeedback |
Write a JavaScript program to get the number of business days (excluding weekends and public holidays) in a given month of the current year. | codefeedback |
Write a function that takes an array of integers as input and returns the array sorted in ascending order using the Bubble Sort technique. Your implementation should be efficient and not use any built-in sorting functions or libraries.
Example:
Input: [5, 2, 8, 1, 9]
Output: [1, 2, 5, 8, 9] | codefeedback |
Create a web application that allows users to input two numbers and performs various mathematical operations on them. The application should have the following requirements:
1. The application should be built using HTML, CSS, and JavaScript.
2. The application should have a user interface that allows users to input tw... | codefeedback |
Write a LaTex command that displays a matrix of size NxM, where N and M are positive integers. The matrix should have the following properties:
- Each element in the matrix should be a random integer between 1 and 100.
- The rows of the matrix should be sorted in non-decreasing order.
- The columns of the matrix should... | codefeedback |
Generate a valid Python expression that multiplies a given list of numbers. The length of the list should be at least 10,000. | codefeedback |
Come up with Java code to find the square root of a given number, using only bitwise operations and without using any built-in functions or libraries. The number will always be positive and will have at most 6 decimal places. | codefeedback |
Write a pseudocode for the Depth-First Search algorithm, but with a twist. Instead of using recursion, you need to implement an iterative version of the algorithm using a stack data structure. | codefeedback |
Complete the following Java code to sort a list of integers. The sorted list should only contain unique elements. Additionally, you should implement the sorting algorithm without using any built-in sorting methods or libraries.
List<Integer> list = Arrays.asList(5, 2, 8, 1);
// Code to sort | codefeedback |
Write a SQL query to get all the users who have registered in the last 7 days and have made at least one purchase. | codefeedback |
Create a Python function to generate a Fibonacci sequence of a given length. The length of the sequence should be at least 5. Additionally, the function should also print the sum of all the numbers in the sequence. | codefeedback |
Design a JavaScript function that can convert any string into a camel case version. The function should also be able to handle special characters and numbers in the input string and convert them accordingly. Additionally, the function should exclude certain words from being capitalized in the camel case output, such as... | codefeedback |
Write an algorithm to solve the Stock Span problem.
The stock span problem is a financial problem where we have a series of n daily price quotes for a stock and we need to calculate the span of stock’s price for all n days. The span S[i] of the stock’s price on a given day i is defined as the maximum number of consecu... | codefeedback |
Design a JavaScript function to convert a given time in 24-hour notation to 12-hour notation. Additionally, the function should handle time inputs with both valid and invalid formats and return an appropriate error message if the format is invalid. | codefeedback |
Create a CSS snippet to set a font size of 18px for all elements in the webpage, but only if they have a class of "content". Additionally, the font color should be red for all elements with an id of "title". | codefeedback |
Given a list of positive integers, write a program to find all unique triplets in the list whose sum is equal to the given target number. The list may contain duplicate integers, but each triplet should be unique. The program should return a list of lists, where each inner list represents a triplet.
Example:
Input:
n... | codefeedback |
Write a function to detect the smallest window in a string containing all characters of another string.
string1 = "abcde", string2 = "ade"
**Example:**
Input:
string1 = "abcde"
string2 = "ade"
Output:
"ade" | codefeedback |
Generate a random 10 character alphanumeric string in Python without using any built-in libraries or functions for generating random numbers. | codefeedback |
Create a responsive HTML page that includes a table with 3 columns and 3 rows. The table should have a fixed header and a sticky footer. Each cell in the table should have a hover effect and display a tooltip with the cell's content. Additionally, implement a feature where clicking on a cell changes its background colo... | codefeedback |
Write a function to check if two Python objects have the same values. The objects can be of any type, including nested structures like lists, dictionaries, and sets. Your function should return True if the objects are equal, and False otherwise.
Example 1:
Input:
obj1 = {'a':1,'b':2}
obj2 = {'b':2, 'a':1}
Output:
True... | codefeedback |
Implement a genetic algorithm in Python to find an approximate solution to the traveling salesman problem. The algorithm should take a set of cities as input and return the shortest possible route that visits each city exactly once and returns to the starting city. The algorithm should use a population of candidate sol... | codefeedback |
Develop a machine learning system to detect fraud, where the system must achieve a minimum accuracy of 95% and a precision of at least 90% when tested on a dataset of 1 million transactions. Additionally, the system should be able to process the dataset within 1 hour using a maximum of 8GB of memory. | codefeedback |
Develop an algorithm to implement a tree traversal using an iterative approach without using recursion. | codefeedback |
Write a SQL query to calculate the total number of items purchased within the last 24 hours, excluding any items that have been returned or canceled. | codefeedback |
Compile a C program to print the given text “Hello World” to the terminal, while also ensuring that the program takes a command line argument specifying the number of times the text should be printed and that the program must terminate if the argument is not provided or if it is a negative number. | codefeedback |
Generate a web page with a navigation bar on it that includes dropdown menus for multiple levels of navigation, with the ability to dynamically load content for each dropdown menu. | codefeedback |
Create a function to remove the second largest element in a given array. The function should return the modified array. If the array does not have a second largest element, the function should return the original array unchanged.
arr = [5, 4, 2, 1, 3]
#Difficulty Increased Test# | codefeedback |
Write a function to find the median of an array of n numbers, where n is an odd number. | codefeedback |
Implement a basic calculator in Java that can handle addition, subtraction, multiplication, and division operations. The calculator should also support parentheses for grouping expressions. The input expression can include both positive and negative numbers, and the calculator should be able to handle floating-point nu... | codefeedback |
Given a String and a list of words, write a Python program to determine if the String is a sequence of any of the words in the list. The sequence must be in the same order as the words in the list.
For example, if the String is "thequickbrownfox" and the words_list is ["the", "quick", "brown", "fox"], the program sho... | codefeedback |
Create a Python class for a thread-safe queue that has the following additional requirements:
- The queue should have a maximum capacity of 100 elements.
- If the queue is full and a new element is added, the oldest element in the queue should be automatically removed to make space for the new element.
- The queue shou... | codefeedback |
Create an array of five positive numbers, where each number is greater than or equal to 10, and output the result in descending order. | codefeedback |
Create a SQL query to find the names of all students who have scored at least 80 points in Maths and Science, and have not scored less than 70 points in any other subject. | codefeedback |
Given a 2D array, print out all the elements in a spiral order.
[
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20],
]
The expected output should be: 1, 2, 3, 4, 5, 10, 15, 20, 19, 18, 17, 16, 11, 6, 7, 8, 9, 14, 13, 12
Note: The spiral order starts from the top-le... | codefeedback |
Count the total number of words in a given text, excluding any punctuation marks or special characters. The quick brown fox jumped over the lazy dog. Ensure that the program can handle large text inputs with multiple paragraphs and accurately count the words. | codefeedback |
Create a Java program that takes an array of n elements (where n > 6) and prints out the sum of the three largest distinct values. The program should also handle cases where there are duplicate elements in the array.
Example input:
[3, 8, 4, 16, 1, 7, 7, 4, 8, 8]
Expected output:
Sum of the three largest distinct val... | codefeedback |
Generate a random string of length n with k vowels, m consonants, and p digits, where n, k, m, and p are provided as input. | codefeedback |
Write a JavaScript program to check if a given string is a palindrome, but ignore any non-alphabetic characters and consider case sensitivity.
A man, a plan, a canal, Panama! | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.