instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
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). In addition, the function should only iterate through the array once and s... | codefeedback |
Implement a function to convert a positive decimal number to binary using only bitwise operators and without using any loops or recursion. | codefeedback |
Create a program that reads two positive integers from the user and prints out their greatest common divisor (GCD) using the Euclidean algorithm.
Additional Details:
1. The program should prompt the user to enter two positive integers.
2. Validate the input to ensure that the numbers entered are positive integers.
3. ... | codefeedback |
Create a program that reads a list of integers and returns the highest prime number that is also a palindrome in the list.
To solve this problem, you should follow these steps:
1. Read the list of integers from the user.
2. Implement a function to check if a number is prime. A number is prime if it is greater than 1 ... | codefeedback |
Generate a random word from a given list of words such that each word has an equal probability of being selected. However, the word should not contain any repeated letters. | codefeedback |
Write a SQL query to count the total number of customers who haven't placed an order yet and have registered within the last month, excluding customers whose email addresses end with ".com". The registration date and email address are stored in the "customers" table, while the order information is stored in the "orders... | codefeedback |
Create a Python program that sorts an array of integers using the insertion sort algorithm. However, the program should also keep track of the number of comparisons made during the sorting process and print it out at the end. Additionally, the program should implement a custom comparator function that sorts the array i... | codefeedback |
Write a JavaScript program that takes an array of strings as an argument and then prints those strings in reverse alphabetical order.
The time complexity of your solution should be O(n log n), where n is the length of the input array.
Do not use any built-in sorting functions or methods. You need to implement your ow... | 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.
The program should implement the series calculation in ... | 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. The program should have a time complexity of O(n log n) and a space complexity of O(n), where n is the length of the string.
#Clarifications#
- The program sh... | codefeedback |
Define a function to find the factorial of the given number. The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. The input number n should be greater than or equal to 2 and less than or equal to 10. The function should handle the case where the inpu... | codefeedback |
Create a method that given an array of integers as input, outputs the quantity of odd numbers that are greater than 10 and divisible by 3. The method should also handle any potential errors that may occur during the execution, such as empty array input or invalid array elements. | codefeedback |
Write a SQL query that returns the average salary and total count of employees for each department, who have been with the company for at least 5 years, and have a salary greater than the average salary of all employees in their department.
Table Name: employees | 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 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 or 5 from the sum. The program should also output the average of the remaining numbers in the array. The program sho... | 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 |
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. Additionally, each string in the output list should be sort... | codefeedback |
Perform the following operation on this array and print the result: remove the last three elements, double each element, and add them to the beginning. Also, ensure that the resulting array is sorted in ascending order and has no duplicates.
arr = [1, 2, 3, 4, 5, 6, 7, 8] | 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.
Additional Requirements:
1. The program should be able to handle large values of n efficiently.
2. The pr... | codefeedback |
Create a method that takes an array of integers as input and outputs a Boolean indicating if the sum of the numbers in the array is divisible by a given number, n. The method should also handle negative numbers in the array.
The method should have a time complexity of O(n), where n is the length of the input array, a... | codefeedback |
Given an integer n, write a Python program to print a pattern consisting of n rows and n columns, where each element in the pattern is a number. The pattern should start with 1 in the top-left corner and increment by 1 for each element moving to the right. When reaching the end of a row, the pattern should continue in ... | 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. The program should also consider outliers in t... | codefeedback |
Write a function in JavaScript that takes a paragraph as input and returns the number of distinct words in the paragraph. The function should ignore punctuation marks, treat uppercase and lowercase letters as the same word, and also handle contractions. The time complexity of the function should still be O(n), where n ... | codefeedback |
Create a function in Python that takes in a list of integers and returns a new list that contains only the prime numbers from the original list. Additionally, ensure that the prime numbers in the new list are sorted in ascending order. The function should have a time complexity of O(n^2), where n is the length of the o... | codefeedback |
Classify the given text as either suitable for children or not, while also identifying the emotions expressed in the text. The emotions must be classified into multiple categories, such as happiness, sadness, anger, fear, and surprise. Additionally, the solution must provide a sentiment score for each emotion, indicati... | 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 |
Implement a function in Python that normalizes a given text string for natural language processing, considering the impact of multilingual data and the requirement for handling linguistic variations and irregularities.
The function should take a string as input and return the normalized version of the text. Normalizat... | codefeedback |
Generate SQL code to create a table of users with the columns (user_id, name, email, age, city), 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 emai... | codefeedback |
Write a computer program to generate a square matrix filled with zeros, with the constraint that the matrix size must be a prime number. Additionally, ensure that the sum of each row and each column in the matrix is a prime number. | codefeedback |
Write a SQL query to list all the distinct products names, their corresponding sales price, the number of units sold for each product, and the total revenue generated for each product. Additionally, sort the result by the total revenue in descending order.
Table: Products
| id | product_name | sale_price | units_sol... | codefeedback |
Explain what overfitting is, in the context of machine learning, and provide an example to illustrate the concept. Additionally, discuss at least three methods to mitigate the issue of overfitting and explain how they work.
#Updated Test#
## Problem Description ##
In machine learning, overfitting refers to the pheno... | 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.
Add the following constraints and requirements:
1. Exclude categories with a total sales amount less than 100.
2. Dis... | codefeedback |
Write a Java code to clone a linked list using recursion. The original linked list contains nodes with both integer values and strings. Additionally, you should implement a method to reverse the cloned linked list using a doubly linked list. | codefeedback |
Write a SQL query to select the rows from the following table based on a certain condition.
Table: Student
| enroll_no | name | marks |
|-----------|------|-------|
| 1 | Jack | 30 |
| 2 | Tom | 40 |
| 3 | Lisa | 50 |
| 4 | Lucy | 60 |
| 5 | John | 70 |
| 6 ... | codefeedback |
How would you modify the code to check whether the list contains a prime number and print "Prime number found" if it does?
list_data = [1, 2, 3, 4]
for item in list_data:
if item > 1:
for i in range(2, item):
if (item % i) == 0:
break
else:
print("Prime number... | codefeedback |
Please write a C++ program to find the elements that appear only once in an array. The program should have the following additional requirements:
1. Instead of using an unordered_map, you should use a custom data structure called `FrequencyCounter` to keep track of the count of each element in the array. The `Frequenc... | codefeedback |
Write a Python program to filter out all the prime numbers in the given list and return them in ascending order.
#Reference Code#
```
def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def filter_primes(numbers):... | 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. Additionally, the function should only iter... | codefeedback |
Generate a Fibonacci sequence of n numbers, where n is provided as input by the user, using Java.
In addition to generating the Fibonacci sequence, the program should also check if each number in the sequence is a prime number. If a number is prime, it should be printed in uppercase. If a number is not prime, it shoul... | 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 and the input number should be greater than or equal to 1. Additionally, the function should handle negative numbers by returning an error message. | codefeedback |
Create a program in Ruby to print the Fibonacci sequence until the 50th element, but exclude any numbers that are divisible by 3. | codefeedback |
Write a program that generates a complete HTML document using the given parameters, with the following additional constraints:
1. The title tag should have a maximum length of 50 characters.
2. The heading tag should have a maximum length of 100 characters.
3. The body tag should have a maximum length of 500 character... | 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. Additionally, remove any duplicate elements from the resulting list.
my_list = ['apple', 'banana', 'orange', 'APPLE', 'Banana', 'grape']
pre_d... | codefeedback |
Create an HTML page with a table containing 4 columns and 8 rows. Each cell in the table should display a prime number between 20 and 100. The prime numbers should be arranged in descending order from left to right, top to bottom. The table should have a black background color and white text color. Additionally, each c... | codefeedback |
Construct a SQL query that gets the average salary of all employees who work in Department A, but only include employees who have been with the company for at least 2 years. Additionally, exclude any employees who have been promoted within the last 6 months from the calculation of average salary. | codefeedback |
Construct a loop to print all the prime numbers between 1 and 1000. Additionally, implement a function to check if a given number is prime, and use this function within the loop to determine and print the prime numbers. | codefeedback |
Write an HTML code to display a table of 3 columns and 5 rows. Each cell in the table should have a different background color, and the color must be randomly generated. Additionally, the first row should be highlighted with a different font color and bold text. Ensure that the table is responsive and adjusts its layou... | 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. The class should have a property called `generatedNumbers` that is initialized as an empty object. This object will store the generated numbers as keys, and the number of t... | 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 |
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 multiple balls bouncing up and down with the following additional requirements:
1. The balls should start at different heights on 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 bou... | codefeedback |
Construct an SQL statement to get the average salary of each department, excluding departments with less than 5 employees. Return the result in descending order of the average salary. If there are multiple departments with the same average salary, order them alphabetically by department name.
Table structure:
employ... | 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. The function should return the number of pairs found.
For example, given the list [1, 4, 2, 9, 5], the... | codefeedback |
Compute the minimum string edit distance between two strings of different lengths. The edit distance is defined as the minimum number of operations required to transform one string into another, where the allowed operations are insertion, deletion, and substitution of a single character.
str1 = "kitten"
str2 = "sittin... | 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. Additionally, the model should be trained using only 50% of the available data, and it should utilize an ensemble of multiple algorithms for classification. | 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). The function should also ignore case sensitivity and consider only alphanumeric characters in the string.
string = "A man, a ... | codefeedback |
Create a function which takes a variable number of arguments, checks if all of them are lists and have an odd length (O(n)), and then adds all the odd-indexed items in the lists (O(n/2)).
The function should return the sum of all the odd-indexed items in the lists.
Example:
Input: [[1,2,3], [4,5,6], [7,8,9,10]]
Output... | 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 string, converts it to lowercase, and prints out the most commonly-used character in the string. If there is more than one character that is used the same number of times, print out all of them in alphabetical order. If the string is empty, print "No characters found.". The input string ... | codefeedback |
Write a Bash script that takes a command and a Docker image as input and runs the command within a Docker container. The script should store the output of the command in a variable. Additionally, the script should handle errors, such as if the Docker image is not available or if the command fails to execute within the ... | codefeedback |
Create a SQL query that gets the list of names, ages, and job titles of all employees who work at the company 'ABC', have a salary greater than $50,000, and have been employed for more than 2 years. Additionally, order the result by the employees' ages in descending order. | codefeedback |
Write a function that takes a number x and multiplies it by itself n amount of times using recursion. The function should return the result of the multiplication. Assume that both x and n are positive integers.
Example:
Input:
x = 4
n = 3
Output:
64
Rewritten Test:
Write a function that takes a number x and multiplie... | 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 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). Additionally, the code should handle edge cases such as negative indices, large indices that may cause overflow, and optimize the solution by using memoization ... | codefeedback |
Write a Python program to print a dictionary where the keys are prime numbers between 1 and 1000 (both included) and the values are the sum of the digits of the corresponding keys. Additionally, the program should also check if the sum of the digits is a prime number, and only include those numbers in the dictionary. | codefeedback |
Write a bash script that can add two numbers, but the script should only use bitwise operations for the addition. The script should also handle negative numbers and output the result in hexadecimal format. | codefeedback |
Create a JavaScript program to capitalize each word in a given string while ignoring words that contain numbers. Also, ensure that the program ignores any special characters or symbols within the words. | 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 |
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.
#Rewritten Test#
In Python, create a function that takes a list of integers and returns the two largest numbe... | 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. Additionally, the input array may contain duplicate elements. Your function should h... | codefeedback |
Write a JavaScript program to get the number of business days (excluding weekends and public holidays) in a given month and year, taking into account the specific public holidays of a particular country. | codefeedback |
Create a Windows batch command to recursively search for all files with a given file extension within a specified directory and its subdirectories. For each file found, create a new folder in the current directory named after the file extension (e.g., if the file extension is ".txt", create a folder named "txt"). Move ... | codefeedback |
Write an algorithm in MIPS assembly language to determine if a given character is a vowel or not. The character can be any uppercase or lowercase letter from the English alphabet.
1. Read the input character into a register.
2. Convert the character to lowercase if it is an uppercase letter. To do this, subtract 32 fr... | codefeedback |
Write an MySQL query to create a view displaying the average monthly income per worker, only for workers who have been employed for at least 6 months. Table contains workerid, month, income columns, and an employmentstartdate column. Also, include a column that shows the cumulative sum of the income for each worker up ... | codefeedback |
Write a JavaScript function that calculates the sum of the squares of two numbers, with a time complexity of O(1). The function should also handle input validation and only accept numbers as input.
However, you are not allowed to use the multiplication operator (*) or the exponentiation operator (**).
Additionally, t... | codefeedback |
Generate a valid Python expression that multiplies a given list of numbers. The length of the list should be at least 10,000 and each number in the list should be a positive integer less than or equal to 100. | 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 |
Compare and analyze the time complexity of three sorting algorithms: selection sort, bubble sort, and insertion sort.
- Provide a detailed explanation of each algorithm, including the steps involved and how the sorting is achieved.
- Analyze and compare the time complexity of each algorithm in terms of the worst-case,... | 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 -100 and 100.
- The rows of the matrix should be sorted in non-decreasing order.
- The columns of the matrix sho... | codefeedback |
Write a pseudocode for the Depth-First Search algorithm, but with the following additional requirements:
1. Instead of using recursion, you need to implement an iterative version of the algorithm using a stack data structure.
2. The time complexity of your algorithm should be O(V + E), where V is the number of vertices... | 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. Additionally, the code should find the square root within a maximum of 10 iterations. | 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, and sort them by the total amount spent in descending order. | 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. The time complexity of your solution should be O(n log n), where n is the number of elements... | codefeedback |
Create a Python function to generate a Fibonacci sequence of a given length. The length of the sequence should be at least 10. Additionally, the function should print the sum of all the numbers in the sequence and the average of the numbers in the sequence. | codefeedback |
Write a program that takes a string of text and a key as input, and performs the Caesar Cipher encryption technique on the text using the given key. The program should then print the encrypted text.
The Caesar Cipher encryption technique involves shifting each letter in the text by a certain number of positions down t... | codefeedback |
Write a HTML structure with a form that includes ``name``, ``email``, and ``password`` fields. Additionally, add client-side validation to check if the password meets the following criteria:
- At least 8 characters long
- Contains at least one uppercase letter, one lowercase letter, and one number.
Provide a piece o... | 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 |
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, including formats with milliseconds and time zones, and return an appropriate error message if the format is invalid. The function shoul... | 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". Ensure that the CSS snippet is applied dynamically based on user input, where the user can specify multiple clas... | codefeedback |
Explain the concept of multiple inheritance in Java and provide an example of how it can be implemented in a practical scenario. Additionally, identify and explain any potential challenges or drawbacks that can arise from using multiple inheritance in Java. | 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 |
Using a for loop, print all the prime numbers between 1 and 100 (inclusive), but only if the number is not divisible by 3. | codefeedback |
Write a function in PHP that takes one parameter and checks if it is a valid email address. The function should also ensure that the domain of the email address is a valid domain name. Additionally, the function should check if the email address is disposable, meaning that it is a temporary email address that can be ea... | codefeedback |
Given a matrix of size n x m, write a program to traverse it spirally and return the elements in a list. The program should have a time complexity of O(n*m) and space complexity of O(1).
Constraints:
- 1 ≤ n, m ≤ 10^3
- The matrix elements can be integers ranging from -10^3 to 10^3
Example:
Input:
matrix = [[1, 2, 3... | codefeedback |
Generate a random 15 character alphanumeric string in Python without using any built-in libraries or functions for generating random numbers. Additionally, the generated string should not contain any consecutive repeating characters. | 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. Each triplet should... | codefeedback |
Customize a WordPress theme to ensure its compatibility with the latest version of the WordPress software. Additionally, implement a feature that allows users to upload and display images in their blog posts. Furthermore, create a functionality that allows users to add tags to their blog posts and display posts with sp... | 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 10 million transactions. Additionally, the system should be able to process the dataset within 1 hour using a maximum of 4GB of memory. Furthermore, the ... | codefeedback |
Create a Python class called "Person" that accepts a name and an age to create a person instance. The person instance should also have a unique identifier generated upon instantiation. Additionally, the person instance should have the following methods:
1. A method called "get_name" that returns the name of the person... | codefeedback |
Develop an algorithm to implement an in-order tree traversal using an iterative approach without using recursion. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.