instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Explain the concept of pipelining in computer architecture and provide a code example in Python to demonstrate its implementation. | codefeedback |
Create a React component that displays a search bar with autocomplete functionality specifically for searching movie titles.
Requirements:
1. The search bar should have an input field and a button.
2. The autocomplete functionality should suggest possible movie titles as the user types in the input field.
3. The sugge... | codefeedback |
Write a function that takes in a list of integers and an element, and returns the index of the first occurrence of the element in the list. The function should handle cases where the element is not present in the list and return -1 in such cases. The input list should have a length of at least 3. The function should on... | codefeedback |
Create a responsive HTML form with three text fields (First Name, Last Name, and Email) that includes client-side form validation to ensure that all fields are filled out correctly. Additionally, implement a server-side validation that checks if the email entered is unique and not already registered in the system. The ... | codefeedback |
Implement a binary classification model using Support Vector Machines (SVM) to predict the likelihood of a customer subscribing to a bank's term deposit based on historical customer data. In addition to precision, recall, and F1-score metrics, calculate the model's accuracy and specificity metrics as well. Plot a ROC c... | codefeedback |
Write a function in Java to find the length of the longest common subsequence of two strings. The strings can only contain uppercase letters. The function should also return the actual longest common subsequence itself. | codefeedback |
Write a SQL query to select all occurrences of a color and sort them in descending order. If there are multiple occurrences of a color, sort them by the name of the person in ascending order.
Records:
Name | Color
Robert | Red
John | Blue
Mike | Red
Samantha | Blue
Jessica | Green
Emily | Bl... | codefeedback |
Debug the following code to print a list of all prime numbers between 1 and 1,000,000,000,000,000,000,000 using the Miller-Rabin primality test algorithm. | codefeedback |
Create a JavaScript function that takes a sentence as a parameter and replaces all occurrences of a given word with another word. The function should also keep track of the number of replacements made and return it as part of the output.
Input: sentence (string), word to replace (string), replacement word (string)
Outp... | codefeedback |
Develop a python code to sort an array of numbers in descending order using only recursion. | codefeedback |
Explain what a Monadic function is and provide an example implementation in a programming language of your choice. Additionally, discuss the advantages and disadvantages of using Monadic functions in software development.
In your implementation, make sure to include error handling by using the Maybe monad. The Maybe ... | codefeedback |
Compare multiple inheritance and composition in Python and provide a code example showcasing the difference between them. Additionally, discuss the advantages and disadvantages of using each approach in different scenarios. | codefeedback |
Write a code to print out all dates between two given dates in Python, with the following additional requirements:
- The code should be able to handle any valid date format, including both 12-hour and 24-hour formats.
- The start_date and end_date can be in any order, and should be inputted as strings.
- The code shoul... | codefeedback |
Generate a Java program that prints the longest palindrome word in a sentence, considering that the sentence may contain multiple palindrome words with the same length. If there are multiple longest palindrome words, the program should print all of them. | codefeedback |
Create a for loop in Java to find the sum of the first 20 prime numbers, but exclude any prime numbers that are divisible by 5. | codefeedback |
Using the provided template, create a function which calculates the area of a right triangle. The function should only use basic arithmetic operations (addition, subtraction, multiplication, and division) and should not use any built-in math functions or libraries. Additionally, the function should handle cases where s... | codefeedback |
Develop a Java program to calculate the average of n numbers, where n is a positive integer entered by the user. Additionally, implement error handling to handle the case where the user enters a non-positive integer for n. | codefeedback |
Compare the two given strings and output the longer one. The length of the strings can be up to 1 million characters. Additionally, you must implement a time complexity of O(n) for your solution, where n is the length of the longer string. | codefeedback |
Formulate a regex expression in Python to check if a given string is a valid email address. The email address must adhere to the following criteria:
- It must start with a combination of alphanumeric characters, dots, underscores, or hyphens.
- It must contain the "@" symbol.
- It must have a domain name that starts wi... | codefeedback |
Create a recursive algorithm to find the sum of the Fibonacci sequence up to the nth term, excluding any term that is divisible by 5.
n = 10 | codefeedback |
Create a function to find the sum of all the multiples of 7 or 13 below 5000, but exclude any multiples that are divisible by both 7 and 13. Return the result. | codefeedback |
Write a code that takes in a string and returns the total count of each letter of the alphabet it contains, considering both uppercase and lowercase letters. Additionally, you should ignore any non-alphabet characters in the string. The code should also handle strings that contain non-English alphabet characters.
Exa... | codefeedback |
Write an SQL query to count the number of unique customers in an orders table. Include only customers whose total order amount is greater than $1000. | codefeedback |
Create a code to generate a unique 7-character string of random numbers and letters, ensuring that no two generated strings are the same. Additionally, implement a function to check if a given string is already present in a list of generated strings, and if so, generate a new unique string. | codefeedback |
Write a Java program to print the Fibonacci sequence up to the limit of n, where n is a positive integer provided by the user. The program should include error handling to ensure that the user enters a valid positive integer. Additionally, the program should use recursion to generate the Fibonacci sequence. Furthermore... | codefeedback |
Write code to sort a given array of strings in descending order based on the length of each string. The sorting algorithm should have a time complexity of O(nlogn) and should not use any built-in sorting functions or libraries. Additionally, the solution should be implemented in a language that does not support any str... | codefeedback |
Create a SQL query to select the top five customers based on purchase amount, excluding customers who have made purchases in the last 30 days. Additionally, exclude any customers who have made purchases more than once in the last 30 days. | codefeedback |
Write SQL code to select records from a table whose ID is greater than 200, whose name starts with the letter 'S', and whose age is less than 30. | codefeedback |
Create a JavaScript function to convert a given string to a Base-64 encoded value. The function should only use built-in string manipulation methods and should not utilize any third-party libraries or modules. The input string will always consist of alphanumeric characters and may include special characters. The functi... | codefeedback |
Given a string, concatenate the first and last character of the string together. Additionally, if the length of the string is odd, remove the middle character before concatenating. The input string will contain only alphabetic characters and its length will be between 3 and 100 characters, inclusive. The solution shoul... | codefeedback |
Create a program that counts the number of unique words in a sentence, excluding any common stopwords. The program should also handle cases where the sentence contains punctuation marks, special characters, and emojis. The program should be efficient and have a time complexity of O(n), where n is the length of the sent... | codefeedback |
Write a function that calculates the factorial of a given number. The factorial of a number n is the product of all positive odd integers less than or equal to n. For example, the factorial of 5 (denoted as 5!) is calculated as 5 * 3 * 1, which equals 15. | codefeedback |
Write a function in Python to print out the elements of a given array in reverse order without using any built-in functions or libraries such as reverse(). The function should only use basic logical steps and loops to solve the problem efficiently. Additionally, the function should not create any new variables or use a... | codefeedback |
Write a SQL query to select the names of all the female students from the table "students" whose age is between 20 and 25, whose major is "Computer Science", and whose GPA is above 3.7. | codefeedback |
Create a function that refreshes a web page until an element with the given ID becomes visible. Additionally, the function should handle scenarios where the element does not exist or is not visible even after refreshing multiple times.
To accomplish this, the function should have the following logic steps:
1. Accept ... | codefeedback |
Write a C# code to print an array in reverse order, but you are not allowed to use any built-in array reversal methods or create a new array to store the reversed elements. Additionally, you must ensure that the time complexity of your solution is O(n) and the space complexity is O(1). The solution must be done in-plac... | codefeedback |
Write a JavaScript code snippet to sum all the elements of an array. However, the code should ignore any negative numbers in the array and only sum the positive numbers. Additionally, the code should also ignore any decimal numbers and only sum integers. The resulting sum should then be multiplied by 2 before returning... | codefeedback |
Write a program in Python to print the first 100 prime numbers. | codefeedback |
Create a Python script to scrape all links from a web page, while ensuring that the links are unique and not duplicate.
The script should implement a breadth-first search algorithm to crawl through multiple levels of pages, starting from the given web page. The depth of crawling should be user-defined.
Additionally, ... | codefeedback |
Write a Java method to insert a given string at the beginning of every word in a given sentence. The given sentence can contain special characters, numbers, and multiple consecutive spaces between words. The inserted string should be enclosed in square brackets.
Additionally, you need to implement the following requi... | codefeedback |
Using a loop, output all the prime numbers up to the given number n. Additionally, the program should skip any number that is divisible by 5. The program should also calculate and output the sum of all the prime numbers. Finally, the program should keep track of the total count of prime numbers and output it at the end... | codefeedback |
Write an algorithm in Python to search for the first non-repeating prime number in a given array. The array may contain both positive and negative integers. The array may also contain duplicate elements. If there are no non-repeating prime numbers, return None.
Example:
array = [4, 6, -4, 1, 8, 6, 44, -21, 11, 7, 3, 7... | codefeedback |
Name the most common relational database management systems and their respective query languages. Additionally, provide an example of a common mistake or error that developers might encounter when working with these systems and their query languages. | codefeedback |
Write a function that takes a list of numbers as input and returns the second largest number in the list. However, you are not allowed to use any built-in sorting functions or any functions that directly find the maximum or minimum value in the list. You must implement your own logic to find the second largest number. | codefeedback |
Write a JavaScript program to create a random string of 20 characters, where each character must be a unique lowercase letter or number. The string must not contain any duplicate characters. | codefeedback |
Write a SQL query to find the number of employees in the Department table with a salary greater than 50,000, have been employed for more than 5 years, and whose department has more than 10 employees. Exclude employees with the job title "Manager" from the count.
Provide a piece of erroneous code as a reference to incr... | codefeedback |
Use the .filter() function to find all even numbers from an array of numbers: [3, 5, 10, 7, 8, 11]. You are not allowed to use the modulus operator (%) to check for evenness. Instead, you should use bitwise operations to determine if a number is even. | codefeedback |
Write a shell script to output a given string to the console, but with the following conditions:
1. The string should be printed in reverse order.
2. Every character in the string should be printed on a new line.
3. Before printing each character, display the index position of that character in the original string.
4. ... | codefeedback |
Create an HTML input form to collect user information, including the following constraints: the form must have at least 8 input fields, two of which must be dropdown menus; the form must include a validation mechanism to ensure that all fields are filled out correctly before submission. Additionally, implement server-s... | codefeedback |
Create a code in C++ to search for a user input word in an array of strings, while ignoring case sensitivity. The user input word is "apple". Additionally, the code should display the number of occurrences of the word in the array and the indices at which the word is found. | codefeedback |
Generate a code in R to remove spaces, punctuation, and duplicate characters from a given string, while also converting all characters to lowercase. The given string should contain at least one alphanumeric character. The given string is "Hello, World.".
The code should have a time complexity of O(n) and a space compl... | codefeedback |
Design an advanced color palette for a website with ten colors, where each color must be a shade of a primary color (red, blue, or yellow) and must be chosen using the HSL (Hue, Saturation, Lightness) color model. Additionally, each color in the palette should have a unique saturation and lightness value, ensuring a di... | codefeedback |
Write a recursive function in Python that calculates the factorial of a given positive integer. However, the function should also return the number of digits in the factorial as an additional output. | codefeedback |
Create an Angular component that displays information about a user and allows the user to update their information.
const user = {
id: 1,
name: 'Bob',
age: 23,
email: 'bob@example.com'
};
The component should have the following features:
1. Display the user's name, age, and email in separate HTML elements... | codefeedback |
Modify the following function to ensure that the number is always greater than zero. If the number generated is less than or equal to zero, the function should raise a ValueError with the message "Number must be greater than zero".
The function should also implement a retry mechanism that allows for a maximum of 3 att... | codefeedback |
Write a code in SQL to create a database table that stores the names, scores, and subject grades of students in a class. The subject grades should be calculated based on the scores using the following criteria:
- A score above 90 should be given an 'A+' grade.
- A score between 80 and 90 should be given an 'A' grade.
-... | codefeedback |
Write a code in Ruby to convert an array of integers into a string, with the following conditions:
1. The array may contain negative integers.
2. The string should contain the integers separated by a comma and a space.
3. The string should start and end with a square bracket, e.g., "[1, 2, 3, 4, 5]".
4. The code should... | codefeedback |
Create a JavaScript function that checks if a given string is a palindrome, considering the following rules:
1. The given string must contain only alphanumeric characters (letters and numbers).
2. The function should ignore any leading or trailing whitespace characters in the string.
3. The function should be case-inse... | codefeedback |
Create an HTML form with two inputs, one to enter a first name and another to enter a last name. Additionally, the form should include a submit button that is disabled until both inputs have been filled in. The first name input should only allow alphanumeric characters and be limited to a maximum of 20 characters. The ... | codefeedback |
Let n1 and n2 be two positive integers. Write a program that calculates and prints the result of n1 % n2, without using the modulus operator.
n1 = 8
n2 = 5
Provide a piece of erroneous code as a reference to increase misdirection. | codefeedback |
Explain the concept of variable scoping in JavaScript and provide an example code snippet that demonstrates how variable scoping works in different scopes. Additionally, explain the differences between the var, let, and const keywords in terms of variable scoping and provide examples to illustrate these differences. | codefeedback |
Write a code to generate a random password consisting of 12 characters with at least two lowercase letters, two uppercase letters, two numbers, and two special characters. The password should also not contain any repeating characters. Additionally, ensure that the special characters used in the password are limited to ... | codefeedback |
Create a program that prints out a pyramid of stars with a user-defined height, where the height must be a positive integer between 1 and | codefeedback |
Create a class called "BankAccount" in Java with instance variables for the account number, name, balance, and transaction history.
The BankAccount class should have the following methods:
- A constructor that takes parameters for the account number, name, and balance, and initializes the instance variables.
- Getter ... | codefeedback |
Explain in detail what APIs are, their purpose, and provide an example of how they are commonly used in a programming context. Additionally, explain the concept of API endpoints and how they are utilized in the communication between different systems. | codefeedback |
Describe how dynamic programming works in programming. Provide an efficient implementation in a language of your choice that uses memoization to solve a problem of finding the maximum sum of a subarray in an array of integers. The implementation should handle arrays of size up to 10^9 and should have a time complexity ... | codefeedback |
Create a MongoDB collection named "users" with 3 fields called "name", "age", and "email". The "name" field should store a string of length between 8 and 12 characters, the "age" field should store an integer between 18 and 65 (inclusive), and the "email" field should store a valid email address. Additionally, implemen... | codefeedback |
Specify an appropriate condition that limits the set of documents produced based on the given context.
In a newsreader application, train a classifier to pull out only the articles about current world news, but exclude articles about politics, sports, and entertainment. Additionally, ensure that the classifier accurate... | codefeedback |
Create a function in JavaScript that takes an array as input and returns a new array containing only the unique values from the original array. The input array can contain both numbers and strings. The function should have a time complexity of O(n) and a space complexity of O(n). Make sure to handle edge cases, such as... | codefeedback |
Write a query to select the first 3 characters of every row from a column called 'name' from a PostgreSQL table, but exclude any rows where the first character is a vowel. Additionally, the query should also exclude any rows where the second character is a digit. | codefeedback |
Calculate the average of the numbers in the given list, but only consider the numbers that are divisible by 3, greater than 10, and have a digit sum greater than | codefeedback |
Implement a function that takes a string as a parameter and returns a modified string with the words reversed. Additionally, the function should remove any leading or trailing whitespace from the input string before processing. The function should also handle multiple spaces between words by converting them into a sing... | codefeedback |
Compute the standard deviation of the given array, but exclude any negative numbers and zero from the calculation. The array may contain duplicate values. The resulting standard deviation should be rounded to two decimal places.
data = [10, -15, 20, -25, 30, 0, 10, 30] | codefeedback |
Create a program that will filter out all numbers divisible by 3 and 4 from the given list of integers. The program should also sort the remaining numbers in descending order.
Example input: [2, 3, 4, 6, 8, 9, 10, 12]
Expected output: [12, 9, 6]
Erroneous code reference: Introduce a syntax error in the code, such as... | codefeedback |
Design a distributed URL shortening system where a given URL is converted to an 8 digit alphanumeric string. The system should be able to handle a maximum of 1 million URLs at any given time, spread across multiple servers, with the ability to scale horizontally. It should also provide real-time analytics, tracking the... | codefeedback |
Given two input strings s and t, find the length of the longest common substring that starts and ends with the same character.
Example:
s = "abcde"
t = "acfgh"
In this example, the longest common substring that starts and ends with the same character is "a". Therefore, the expected output is 1.
To solve this proble... | codefeedback |
Identify the data structure usage in the following code and explain how it can be optimized for better performance.
Erroneous code reference:
# Identify the data structure usage in the following code and explain how it can be optimized for better performance.
filenames = ['/home/user/project_data/sample_1.json', '/hom... | codefeedback |
Given a BST, write a function to find the number of values greater than the root node. Additionally, find the number of values greater than each node in the BST.
Let's say we have the following BST:
50
/ \
30 70
/ \ \
20 40 80
/ \ / \
10 25 75 90
Output: [7, 4, 6, ... | codefeedback |
Write a code to generate a list of common elements from two given lists. The code should ignore duplicates and should return the common elements in descending order. The two given lists can contain integers, floats, or strings. The code should be able to handle lists of any length, with a maximum length of 10,000 eleme... | codefeedback |
Create a function that takes a list of words and returns a list of capitalized words. Each capitalized word should have the first letter in uppercase and all other letters in lowercase. The function should also remove any duplicates from the list. The input list can contain up to 1000 words and each word can have a max... | codefeedback |
Usage of Global Variable, Recursion, and Time Complexity Optimization
## Problem Statement ##
You are given a list of positive integers, `nums`, and an integer, `target`.
Write a function, `find_combinations(nums: List[int], target: int) -> int`, that will return the number of distinct combinations of the given pos... | codefeedback |
Compute the Minkowski distance between two lists, where each list can contain up to 10^6 elements. Additionally, the elements in each list can range from -10^9 to 10^9.
#Erroneous code reference#
list_1 = [1, 2, 3, ..., 10^6]
list_2 = [-1, -2, -3, ..., -10^6]
#Provide a piece of erroneous code#
def compute_minkowski... | codefeedback |
Describe what an else-if clause does in an if statement and provide an example of how it can be used in a real-world scenario. | codefeedback |
Find the weighted mean of the following set of numbers: 10, 20, 30, 40, where the weights are as follows: 0.25, 0.35, 0.15, 0.25. Additionally, implement the calculation of the weighted mean using a custom function named "custom_weighted_mean" and provide a brief explanation of how the custom function works. | codefeedback |
Find the maximum value in a given array of integers, but without using any built-in array functions or sorting algorithms. Additionally, you are not allowed to use any loops or recursion. You must solve the problem using only recursion or functional programming techniques.
[4, 6, 9, 11, 15] | codefeedback |
Given a string, write a program that retrieves the last character of the string, converts it to uppercase, and displays it. | codefeedback |
Obtain the parameter names from a given JavaScript function, where the function must have at least 3 parameters and the parameter names must be in alphabetical order. The function should also check for duplicate parameter names and return an error if any duplicates are found. Additionally, the function should ignore an... | codefeedback |
Transform the following XML code into JSON format while also handling nested elements. Additionally, the JSON output should include the number of devices and the average price of all devices. | codefeedback |
Create a function to convert a positive integer to its binary representation using a recursive approach. The function should have a time complexity of O(log n), where n is the given integer.
Example:
Input: 15
Output: "1111"
# Revised Test #
Create a function to convert a positive integer to its binary representation... | codefeedback |
Create a Python function that takes a list of strings and removes any words that include numbers and start with a capital letter. If the removed word starts with a lowercase letter, capitalize the first letter of the next word. If there are multiple consecutive words starting with a lowercase letter, capitalize the fir... | codefeedback |
Create a JavaScript class to represent a rectangle with properties for width and height. The class should also have the following methods:
1. A method to calculate the area of the rectangle.
2. A method to calculate the perimeter of the rectangle.
3. A method to check if it is a square.
4. A method to check if it is a ... | codefeedback |
Design and implement an algorithm to add two integers with the additional requirement that the solution must not use the '+' operator. The integers can be positive or negative. The solution should also have a time complexity of O(1). num1 = 4, num2 = 5. | codefeedback |
Build an algorithm to find all prime numbers within a given range and print them in ascending order. | codefeedback |
Design an algorithm to find the longest increasing subsequence in an array of positive integers. The subsequence should be strictly increasing, meaning each element in the subsequence should be greater than the previous element. Additionally, the subsequence should not contain any even numbers.
input = [9, 8, 4, 12, 2... | codefeedback |
Create a function that compares two binary strings and returns the number of differences between them. The length of the two input strings can be up to 10^7 characters. Additionally, you must implement the function without using any string comparison or built-in functions for comparing characters. | codefeedback |
Find the prime factorization of the given number, ensuring that the algorithm runs in O(sqrt(n)) time complexity and uses a space complexity of O(1). | codefeedback |
Create an array of 1000 random integers from -1000 to 1000, and sort the array in descending order. Then, find the mode value of the array. | codefeedback |
Write a program that converts a decimal number to binary. The program should take user input for the decimal number and output the corresponding binary representation.
In addition to the above, please implement the following:
- Handle negative decimal numbers and output their two's complement binary representation.
-... | codefeedback |
Design a program for implementing a binary search algorithm.
Given a sorted array of integers and a target value, write a function to search for the target value within the array using a binary search algorithm. If the target value is found, return its index in the array. If the target value is not found, return -1.
... | codefeedback |
What is tail recursion and how does it help in avoiding stack overflow errors? Provide a piece of code that uses tail recursion and explain how it avoids stack overflow errors. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.