instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Take two strings and a separator as inputs and join the two strings using the separator, ensuring that both strings have at least 3 characters, and output the resulting string. Additionally, the separator should not be a part of either string and the resulting string should be sorted in descending order. | codefeedback |
Convert the given list of dictionaries to a tuple of tuples, where each inner tuple contains the name and age of a person. Each person's name must be capitalized and the age must be a positive integer. If a person's name or age is missing or invalid, skip that dictionary. lst = [{"name":"John", "age":21}, {"name":"Bill... | codefeedback |
Create a loop that will print out all prime numbers between 0 and 100. | codefeedback |
Implement a webhook endpoint in Java using Spring MVC to process a payment request. The endpoint should validate the request payload using JSON schema validation. If the payload is valid, the endpoint should process the payment by making a request to a third-party payment gateway API. The payment gateway API requires a... | codefeedback |
Convert the following chess board into a 2D array in JavaScript, where each element represents a piece on the board. Each piece is represented by a string of two characters, where the first character represents the color of the piece ('B' for black or 'W' for white) and the second character represents the type of the p... | codefeedback |
Create a program that takes a string and returns an object with the count of all the characters in the string, excluding any whitespace characters. The program should also handle cases in a case-insensitive manner. | codefeedback |
Find the lowest positive integer that can not be represented as the sum of three distinct prime numbers. | codefeedback |
Develop a program that finds the maximum number of overlapping events within a given time period, taking into consideration that each event has a minimum duration of 2 units of time. Implement a solution that can efficiently handle large input sizes of events, with a time complexity of O(n log n). The program should re... | codefeedback |
Write a class definition for a Box class that includes methods to calculate the volume and surface area of the box, as well as a method to check if the box is a perfect cube. The Box class should also have a static variable to keep track of the total number of boxes created and a method to retrieve the total count. The... | codefeedback |
Create a validation rule to check if an email address is valid for an input field in JavaScript. Additionally, ensure that the email address is not a disposable email address (i.e., an email address from a temporary or disposable email service).
To accomplish this, you can follow these steps:
1. Check if the input fie... | codefeedback |
Create a new list filled with the same values as the existing list but with the values multiplied by 5. Additionally, the solution should be implemented using a recursive function. The input list may contain up to 10^6 elements and the solution should have a time complexity of O(n), where n is the length of the input l... | codefeedback |
Write a VBA macro to convert a sequence of text to uppercase, but only for characters that are at odd positions in the sequence. The text is: "Hello World". | codefeedback |
Design a method for reversing a string in Java without using any built-in string reversal functions or using additional data structures. The method should have a time complexity of O(n), where n is the length of the string. | codefeedback |
Create a formula that calculates the total cost of an item given the item price, tax rate, and any applicable discounts or surcharges. | codefeedback |
Formulate a SQL query that fetches the records with the latest date and the highest value in another column called "value". Additionally, order the results in descending order based on the "value" column. | codefeedback |
Construct an if-else statement to determine if a given number is divisible by 4 and greater than 100. | codefeedback |
Convert a given XML document to a JSON document while maintaining the original hierarchical structure of the XML elements and adding a new constraint that the JSON output should only include specific XML elements that meet certain criteria. | codefeedback |
Rewrite the given test question in such a way that the answer requires a more in-depth understanding of the class keyword in C++. | codefeedback |
Write a Python function to check if a given string is a palindrome and contains all the vowels (a, e, i, o, u) in it in alphabetical order. | codefeedback |
Write a Python script to detect if two numbers have the same frequency of digits. You are not allowed to convert the numbers to strings or use any built-in functions for counting the frequency of digits.
#Erroneous Code Reference#
```python
def same_frequency(num1, num2):
return sorted(str(num1)) == sorted(str(num... | codefeedback |
Write a JavaScript function that returns the count of all possible combinations of elements from an array of numbers that sum up to a given target. The function should also return the combinations themselves.
array = [2, 3, 7, 8, 10]
target = 11 | codefeedback |
What is polymorphism and how is it used in object-oriented programming? Provide a practical example of polymorphism in a real-world scenario and explain how it improves code reusability and maintainability. Additionally, discuss the concept of dynamic polymorphism and explain how it differs from static polymorphism. | codefeedback |
Create a function in JavaScript to search an element in a given sorted array. The function should also return the number of occurrences of the element in the array. Additionally, the function should handle cases where the input array is not sorted and should sort the array before performing the search. The array will a... | codefeedback |
Sort the list using Quick Sort in descending order
[9, 8, 7, 6, 5, 4, 3, 2, 1]
#Reasoning Steps#
1. Select a pivot element from the list (in this case, we can choose the last element as the pivot).
2. Partition the list into two sublists: one with elements greater than the pivot and one with elements smaller than the ... | codefeedback |
Write an SQL statement to add two new columns, 'size' and 'color', to the existing products table. The 'size' column should only allow values of 'small', 'medium', or 'large'. The 'color' column should only allow values of 'red', 'blue', 'green', or 'yellow'. | codefeedback |
Suggest a type of join to use to find all customers who have placed an order for more than 3 different products.
Table: Customers
Columns: customer_id, name
Table: Orders
Columns: order_id, customer_id
Table: OrderItems
Columns: order_item_id, order_id, product_id | codefeedback |
Write a python function to calculate the factorial of a given number. | codefeedback |
Implement a min-heap data structure from scratch in any programming language of your choice. The min-heap should support the following operations:
1. Insertion of an element into the heap.
2. Removal of the minimum element from the heap.
3. Peek operation to retrieve the minimum element without removing it.
4. Update o... | codefeedback |
Given an array of integers, print all the prime numbers in descending order. | codefeedback |
Modify the following block of code to set a maximum length of the list. Additionally, ensure that the length of the list cannot exceed the maximum length.
max_length = 5
list = [1, 2, 3, 4, 5, 6]
# Erroneous code to increase misdirection
if len(list) > max_length:
list = list[:max_length]
print(list) | codefeedback |
Write a program to find the maximum and minimum elements in a given array, and swap their positions. | codefeedback |
Create a method to transform a string from lowercase to title case while preserving the original capitalization of certain words.
Title case rules:
1. The first letter of every word should be capitalized.
2. All articles (a, an, the), conjunctions (and, but, or), and prepositions (in, on, at, etc.) should be lowercas... | codefeedback |
Create an object to store the variables that are necessary for the following code snippet. The object should be implemented as a custom data structure with specific methods for performing mathematical operations on the variables stored in it. The data structure should support addition, subtraction, multiplication, and ... | codefeedback |
Generate a unique ID string of length 12 using a Python function. The ID should only contain alphanumeric characters (letters and numbers), and the first character must be a letter. | codefeedback |
Design a data structure to store the details of a student (Name, Age, Course) and their academic performance (Grade, GPA) with the following constraints:
1. The name of the student should be a string of at least 2 characters and not exceed 50 characters.
2. The age of the student should be a positive integer between 18... | codefeedback |
Reverse an array of size n in Python, where n is a positive integer not exceeding 10^6. The array elements are integers between 1 and 10^9 (inclusive). Implement an efficient algorithm with a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Convert a given positive integer less than or equal to 3999 to its corresponding Roman numeral representation. | codefeedback |
Write a program in Java that removes all duplicate characters from a string and returns the remaining characters in the order they appear in the original string. Your program should only consider alphabetic characters (A-Z and a-z) and ignore any non-alphabetic characters. | codefeedback |
Find the two missing numbers in an array in C++.
You are given an array of n-2 integers, where all the integers are in the range from 1 to n inclusive. It is guaranteed that the array contains two missing numbers. Your task is to find and return these two missing numbers in ascending order.
Implement the following fu... | codefeedback |
Design and implement a C++ program to calculate the Yield to Maturity (YTM) of a bond. The program should take into account the following considerations:
1. The bond has a fixed coupon rate, face value, and maturity date.
2. The YTM is the discount rate that equates the present value of the bond's cash flows (coupons ... | codefeedback |
Write Python code to extract the title and description from a URL. The code should retrieve the title and description meta tags from the HTML of the webpage at the given URL.
Example:
url = "https://en.wikipedia.org/wiki/Artificial_intelligence"
Output:
Title: Artificial intelligence - Wikipedia
Description: Artifici... | codefeedback |
Given a list of integers, write a Python code snippet to print the elements of the list in reverse order without using any built-in functions or additional data structures. The code should have a time complexity of O(n), where n is the length of the list.
my_list = [1, 2, 3, 4, 5] | codefeedback |
Run the given code and determine the result. The variables `a`, `b`, and `c` are already defined with initial values. Your task is to use bitwise operations to add `a` and `b` together and store the result in `c`. | codefeedback |
Create a Java method that computes the factorial of an integer, but with the following additional requirements:
1. The method should use a recursive approach to calculate the factorial.
2. The method should handle negative input values by throwing an IllegalArgumentException with a meaningful error message.
3. The met... | codefeedback |
Using Python, reverse a given string "Hello World!" without using any built-in string manipulation functions or libraries. | codefeedback |
Write a program that takes a string input representing an HTML document and outputs the name of all font styles available within the document.
The program should consider the following font style tags: <b>, <i>, <u>, <s>, <strong>, <em>, <ins>, <del>.
The program should correctly handle nested font style tags, meani... | codefeedback |
Create a React component for a button that takes three props: an onClick event handler, an id, and a label.
- The button should display the label passed in as a prop.
- The button should have a unique id passed in as a prop.
- When the button is clicked, it should trigger the onClick event handler passed in as a prop.
... | codefeedback |
Train a machine learning model without using any frameworks with the following input and output data.
Input Data: A, B, C, D
Output Data: 0, 1, 0, 1
Provide a piece of erroneous code as a reference to increase misdirection:
```python
def train_model(input_data, output_data):
model = MyModel()
model.fit(input_... | codefeedback |
Create a class in Java that will take two integers as input and perform the following operations:
1. Print the sum of the two integers.
2. Print the difference between the two integers.
3. Print the product of the two integers.
4. Print the quotient of the two integers (integer division).
5. Print the remainder of the... | codefeedback |
Write a code that takes a list of integers as input and returns a list of every permutation of that list, where each permutation must have the largest integer as the first element. | codefeedback |
Design a MySQL Table to store company employees with the following requirements:
- Each employee should have a unique employee ID.
- Each employee should have a first name, last name, and email address.
- The email address should be unique for each employee.
- Each employee should have a job title.
- Each employee shou... | codefeedback |
Develop a web page that displays the current temperature, humidity, and wind speed in various cities, with an option to view the weather forecast for the next 5 days. | codefeedback |
Write a code that takes a string and a character as an argument and counts the number of occurrences of that character in the string. The string can contain both uppercase and lowercase letters. The code should be case-sensitive. The string can also include special characters and numbers. The code should only count the... | codefeedback |
Create a code that edits a list by adding a prime number to each element. The code should find the next prime number greater than the current element and add it to the element. The prime number generator function should have a time complexity of O(n log log n) and the code should have a space complexity of O(1).
Examp... | codefeedback |
Create a functional HTML form that includes the following attributes: name, email, country, and password.
In addition, add the following requirements:
1. The name field should only accept alphabetic characters and should not be left blank.
2. The email field should only accept valid email addresses in the format [use... | codefeedback |
Write a query to find all employees whose age is between 25 and 30, whose department is Marketing, and whose salary is above the average salary of all employees in the company. | codefeedback |
Create a while loop in Java to calculate the Fibonacci numbers up to the number 10000. | codefeedback |
Using HTML and JavaScript, create a button that displays a message when clicked. Additionally, make the button change color randomly every time it is clicked. | codefeedback |
Write a SQL query to find the count of all the books published in the last year and listed in a library catalog, excluding books that have been borrowed more than 5 times. | codefeedback |
Create a program to determine the type of triangle given 3 side lengths. The program should also check if the triangle is valid.
For a triangle to be valid, the sum of any two sides must be greater than the third side. If the triangle is not valid, the program should display an error message.
The program should deter... | codefeedback |
Write a code to get the current exchange rate between two currency using the OpenExchangeRates API and convert a given amount from one currency to another.
fromCurrency = "USD"
toCurrency = "GBP"
amount = 100
Provide a piece of erroneous code as a reference to increase misdirection:
#Erroneous Code#
# Assumption: T... | codefeedback |
Create a method to join an array of strings together, but only include strings that start with a vowel.
arr = ['one', 'two', 'three', 'apple', 'banana', 'cat', 'elephant', 'dog', 'iguana'] | codefeedback |
Create a JavaScript function called "calculateFactorial" that takes a positive integer as input and returns its factorial. The function should handle input validation to ensure that the number is within the range of 1 to 10 (inclusive). If the input is not within this range, the function should throw an error with a de... | codefeedback |
Create a method to sort a given array of integers in descending order without using any of the built-in sorting functions in JavaScript. The method should also remove any duplicate integers from the sorted array.
array = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5] | codefeedback |
Calculate the factorial of n using a recursive function. The function should also check if n is a positive integer and raise an exception if it is not. | codefeedback |
Explain the concept of 'unsupervised learning' in machine learning and provide an example of a real-world problem that can be solved using unsupervised learning techniques. | codefeedback |
Write the definition of a function to calculate the perimeter of a triangle, which takes as input the lengths of all three sides of the triangle as parameters. The function should also include a validation check to ensure that the lengths provided form a valid triangle according to the triangle inequality theorem. If t... | codefeedback |
Given a large text document, develop an algorithm to automatically generate a concise summary of the main ideas and key points within the text. The summary should be a shorter version of the original document, capturing the most important information.
Note: The algorithm should take into account the relevance and sign... | codefeedback |
Create a dictionary in which keys are characters and values are the occurrences of that character in a given string. However, exclude any characters that are vowels from the dictionary. Additionally, the occurrences should be case-sensitive, meaning that uppercase and lowercase versions of the same character should be ... | codefeedback |
How could Big data analysis be used to provide better services and products by considering the privacy concerns and implementing real-time analysis? | codefeedback |
Implement a sorting algorithm that can sort a variety of data types, including integers, floating-point numbers, strings, and arrays of objects. The sorting algorithm should be able to handle duplicate values and should be stable. Additionally, the algorithm should have a time complexity of O(n log n) and should be abl... | codefeedback |
Edit a program to calculate and display the area of a rectangle with the following specifications:
1. The program should prompt the user to enter the length and width of the rectangle.
2. The program should validate that the user inputs are positive integers greater than 0. If the user enters invalid inputs, the progra... | codefeedback |
Develop a C program to print a pattern like a pyramid with a given number of rows, where each row contains an increasing number of asterisks, starting from 1 and ending with the maximum number of asterisks in the middle row. The program should also take an input from the user to determine whether the pyramid should be ... | codefeedback |
Create a code in Python to get the historical stock prices of a company from Yahoo Finance for a given time period.
The code should accept the following inputs:
- Ticker symbol of the company (e.g., "AAPL" for Apple)
- Start date and end date of the time period for which the historical prices should be retrieved
The c... | codefeedback |
Write a Python code to initialize a 10 x 10 matrix with random values, but ensure that the sum of the values in each row is equal to a specific target value. | codefeedback |
Describe the recursive approach for solving a problem, and provide an example of a problem that can be solved using recursion. | codefeedback |
Write a function to calculate all the possible paths for a N x M matrix, where N and M are positive integers.
The function should return the total number of unique paths from the top-left corner to the bottom-right corner of the matrix. You can only move down or right in each step.
The time complexity of your solutio... | codefeedback |
Design a database schema for an online banking system with support for multiple currencies. Additionally, the system should have a feature to generate monthly bank statements for each account holder. | codefeedback |
Construct an SQL statement to select the column names from a table that have a specific data type of "varchar".
table_name="customers" | codefeedback |
Write a command line program in C++ which takes a string as input and prints all its characters in reverse order. The program should also handle cases where the input string contains special characters and whitespace. The output should exclude any duplicate characters in the reversed string.
input_string = "Hello world... | codefeedback |
Create a JavaScript function to convert a string to pig-latin, while handling both upper and lower case letters. | codefeedback |
Using React, create a component to display an alert message. The alert message should have a close button that allows the user to dismiss the alert. Additionally, the component should have the ability to display different types of alerts (e.g. success, warning, error) with different styling. The alerts should also have... | codefeedback |
Create a style sheet in CSS to display an element as a block with a width of 200px and a padding of 10px, but also include a requirement that the element must have a background color of #F00 (red) and a border radius of 10px. | codefeedback |
Using HTML and CSS, create a responsive web page layout that includes a sidebar, main content area, and footer. The sidebar should be fixed and take up 20% of the screen width, while the main content area should take up 60% of the screen width and be scrollable if the content exceeds the available space. The footer sho... | codefeedback |
Implement a quicksort algorithm in JavaScript that takes an array of numbers as input and returns a sorted array. The algorithm should have a time complexity of O(n log n) and must be implemented without using any built-in sorting functions or libraries. Additionally, the algorithm should be able to handle arrays with ... | codefeedback |
What is the complete syntax of an if-else block in Java, including the required keywords and brackets, and at least one condition statement? | codefeedback |
Create a matrix of size 1000 x 1000 in Python. | codefeedback |
Print the longest palindrome from the given string, but the function should not use any built-in string manipulation functions (e.g. reverse(), slice()).
s = "abbaba" | codefeedback |
Increase the difficulty by requiring the function to eliminate passing by reference and also have a time complexity of O(n^2).
#Rewritten Test#
Change the function to eliminate passing by reference and have a time complexity of O(n^2).
def f(arr):
new_arr = []
for i in range(len(arr)):
if i != 0:
... | codefeedback |
Write a Spark program to count the number of distinct words for a given text and calculate the average length of those words.
Text: This is a test text.
Time Complexity Requirement: O(n), where n is the number of words in the given text.
Space Complexity Requirement: O(m), where m is the number of distinct words in t... | codefeedback |
Write a SQL query that joins three tables on multiple conditions, selects distinct records, and includes aggregate functions.
TableA:
id | name | type | category_id
TableB:
id | age | gender | category_id
TableC:
id | category_id | location
The query should join TableA, TableB, and TableC on the condition that the c... | codefeedback |
Write an algorithm for computing the sum of all prime digits between 1 to N. | codefeedback |
Write a PHP script to generate a random password with at least 10 characters. The password should contain a combination of uppercase and lowercase letters, numbers, and special characters. | codefeedback |
Count the number of quadruples that sum up to zero in a given array. A quadruple is defined as a set of four numbers in the array. The array can contain both positive and negative numbers.
For example, if the array is [-2, -1, 0, 1, 2], there are two quadruples that sum up to zero: (-2, -1, 1, 2) and (-2, 0, 0, 2).
T... | codefeedback |
Construct a python list comprehension that generates a list of numbers from 2 to 8, excluding any numbers that are divisible by 3. | codefeedback |
How could you add a classname of "main" and an id of "container" to the div element in this HTML code?
<div>Hello World!</div> | codefeedback |
Write a query to find the names of all employees who have a salary higher than the average salary of all employees and have been working for more than 5 years.
Table Name: Employees
Columns: Name, Salary, Years_of_Experience | codefeedback |
Write a function to remove all occurrences of the value x from a list l and return the modified list. If the value x is not present in the list, the function should return the original list unchanged.
x = 2
l = [1, 2, 3, 2, 4, 5]
Example:
Input: x = 2, l = [1, 2, 3, 2, 4, 5]
Output: [1, 3, 4, 5]
Input: x = 6, l = [1... | codefeedback |
Create a SQLite database table called "Students" with the following columns: "Name" (string), "Age" (integer), "GPA" (float). Additionally, add a primary key column called "ID" (integer) that auto-increments for each new record. Ensure that the "Name" column only allows a maximum of 50 characters, the "Age" column only... | codefeedback |
Suggest an algorithm to search for a matching string in a large text, but with the following additional requirements:
- The algorithm should be case-sensitive, meaning it should differentiate between uppercase and lowercase letters.
- The algorithm should return the index position of the first occurrence of the matchin... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.