instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Create a query that returns the top 5 cities with the highest population, but only include cities that are located in countries with a GDP per capita greater than $50,000 and a literacy rate higher than 90%. | codefeedback |
Compare the two strings and output the number of characters that are different between the two strings. Additionally, the program should provide the positions of the differing characters within the strings. The program should also consider uppercase and lowercase characters as different. String A: "Hello there" String ... | codefeedback |
Create an exponential moving average function in R that accepts a vector of numbers as input and returns a vector of the same length containing the exponential moving average values. The function should also include an optional parameter for specifying the smoothing factor (alpha) used in the calculation. If the parame... | codefeedback |
Write a Python program to check if a string contains at least three consecutive special characters, where special characters are defined as any character that is not a letter or a number.
#Additional Instructions#
1. The program should be case-sensitive, meaning that uppercase and lowercase letters should be considere... | codefeedback |
You are given an array of strings. Write a Python script to sort the array in alphabetical order. However, you are not allowed to use any built-in sorting functions or methods, and you must implement a bubble sort algorithm. | codefeedback |
You are given an array of numbers. Create a function to check if the array contains duplicate values. Your function should also return the indices of all duplicate values found. The input array will have a length of at most 1000. The array will only contain positive integers. The function should have a time complexity ... | codefeedback |
Create a program to remove all duplicate elements from a list and return a new list with the unique elements. Your program should also maintain the order of the original list while removing the duplicates. Additionally, your program should have a time complexity of O(n) and space complexity of O(n), where n is the numb... | codefeedback |
Create an algorithm to implement a binary search that can handle a list of integers in ascending order and efficiently find the position of a given target number. The algorithm should have a time complexity of O(log n) and should not use any built-in search functions or libraries. Additionally, modify the algorithm to ... | codefeedback |
Create an Angular app with a login page and registration page. The registration page should include a form with fields for username, password, and email. Implement validation to ensure that the password is at least 10 characters long and contains at least one uppercase letter, one lowercase letter, one special characte... | codefeedback |
Train a recursive neural network to classify whether a sentence is positive or negative sentiment, taking into account the intensity of the sentiment. Additionally, consider the presence of sarcasm in the sentence and incorporate it into the classification process. | codefeedback |
Make a POST request to a specific endpoint on the same server and download the response content. Additionally, implement error handling to catch and display any potential network errors that may occur during the request. The request must include a custom header named "Authorization" with a valid token for authenticatio... | codefeedback |
Program a function in Go that takes a string and returns the sum of the ASCII codes of all the characters in the string. However, if the input string contains any non-alphabetic characters, their ASCII codes should be multiplied by the length of the string before adding to the sum. | codefeedback |
Generate the reCAPTCHA API key and ensure that it is valid for use in a production environment. Additionally, write a function that handles the verification process for reCAPTCHA responses. The function should take in the user's response and the secret key, and return a boolean value indicating whether the response is ... | codefeedback |
Convert the given array of objects to a dictionary, but only include objects that have an even id and whose names contain the letter 'a'. The dictionary should have the id as the key and the name as the value.
const arr = [
{id: 1, name: "John"},
{id: 2, name: "Jane"},
{id: 3, name: "Jake"},
{id: 4, name: "Joe... | codefeedback |
Filter the following array of numbers so that only the prime numbers remain.
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
#Erroneous Code Reference#
Provide a piece of erroneous code that attempts to filter out prime numbers but does not work correctly. | codefeedback |
Categorize the sentiment of each sentence in a given text as positive, neutral, or negative. Additionally, determine the overall sentiment of the entire text by analyzing the sentiment of individual sentences. Ensure that the sentiment analysis algorithm is capable of handling texts in multiple languages and can accura... | codefeedback |
Write a SQL query to find all teachers who have taught at least 5 different subjects, have more than 10 years of experience, and are currently employed by a school with a student population of at least 500. | codefeedback |
Create a function which accepts a string and prints out each word with the count of its characters. However, you must use a recursive approach to solve this problem. Additionally, if the string contains any special characters or numbers, you should ignore them and only consider the words. Lastly, you should handle case... | codefeedback |
## Problem Statement ##
Write a function in JavaScript that removes adjacent duplicates from a given array. The array may contain both numbers and strings.
## Example ##
```javascript
removeAdjacentDuplicates([2, 3, 3, 3, 6, 9, 9]); // [2, 3, 6, 9]
removeAdjacentDuplicates(['a', 'b', 'b', 'c', 'c', 'c']); // ['a', ... | codefeedback |
Initialize a hash table with 7 buckets in C programming language. Ensure that the hash function used to map keys to buckets is collision-free and takes constant time complexity. Additionally, implement a resizing mechanism that automatically doubles the number of buckets when the load factor exceeds 0.7, and halves the... | codefeedback |
Using Java, create a program to find the highest value in this array, but with the following additional constraints:
1. You cannot use any built-in sorting or searching functions such as Arrays.sort() or Arrays.binarySearch().
2. You cannot use any additional data structures such as ArrayList or LinkedList to help wit... | codefeedback |
Create a program that extracts the first and last names from a string and ensures that the first name starts with an uppercase letter and the last name starts with a lowercase letter. The program should also handle cases where the input string contains middle names or multiple spaces between names. Additionally, the pr... | codefeedback |
Given a JSON object, output an object with keys sorted in descending order based on the length of the key. If two keys have the same length, sort them alphabetically. If two keys have the same length and alphabetical order, sort them based on the number of vowels in the key. If two keys have the same length, alphabetic... | codefeedback |
Write a Python program to read two numbers between 1 and 100, inclusive, and print their multiplication. The program should also check if the two numbers are prime numbers. If they are not prime, the program should print a message stating that at least one of the numbers is not prime. If the multiplication of the two n... | codefeedback |
Design a SQL database to store the information of teachers, including their personal details, educational qualifications, teaching experience, and courses they are currently teaching. Implement appropriate data types, constraints, and indexes to ensure efficient querying and data integrity. Additionally, include a feat... | codefeedback |
Define an F# array and initialize it with prime numbers from 0 to 100.
You are not allowed to use any built-in functions or libraries to check for prime numbers. You must implement your own function to determine whether a number is prime or not. | codefeedback |
Create a function to validate a given email address according to the following criteria:
1. The email address must start with a string of alphanumeric characters.
2. The string must be followed by the "@" symbol.
3. After the "@" symbol, there must be a domain name consisting of a string of alphanumeric characters, fo... | codefeedback |
Create a loop to delete all elements in a linked list, but also ensure that the loop is efficient and does not have a time complexity higher than O(n), where n is the number of elements in the linked list. Additionally, you must implement the linked list using a doubly linked list structure instead of a singly linked l... | codefeedback |
Create a barplot using Matplotlib to display the given data. The x-axis should represent the numbers from 1 to 10, and the y-axis should represent the frequency of each number in the given data. Additionally, the barplot should have a legend indicating the colors used for each bar, and the bars should be sorted in desc... | codefeedback |
Create a JavaScript code snippet to check if a given number is a prime number. Your solution should have a time complexity of O(sqrt(n)) and should not use any built-in JavaScript functions or libraries for prime number calculation. | codefeedback |
Change the provided dataset into a 4-dimensional tensor and normalize the pixel values between -1 and 1, in order to feed it into a Convolutional Neural Network model. The dataset contains 100,000 color images of size 512x512. Additionally, implement data augmentation by randomly applying horizontal and vertical flips,... | codefeedback |
Create a webhook in Python to listen to webhook requests and validate the incoming requests using HMAC-SHA256 authentication. Additionally, implement rate limiting functionality to allow only 10 requests per minute from each unique IP address. | codefeedback |
Please implement the Quick Sort algorithm in Python.
## Requirements:
- The time complexity of the solution should be O(n log n), where n is the length of the input list.
- The space complexity of the solution should be O(log n), i.e., the solution should use recursion to sort the list.
## Constraints:
- You should n... | codefeedback |
Compute the Shannon entropy of a given probability distribution, where the probability distribution is represented by a dictionary with variable-length keys.
Distribution: {'a': 0.15, 'b': 0.35, 'c': 0.5}
Additionally, handle the case where the probability distribution is not valid, i.e., the probabilities do not sum ... | codefeedback |
Rewrite the following in Swift language, ensuring that the program outputs the names in reverse order. Additionally, the program should only print names that contain more than 4 characters. The time complexity of the program should not exceed O(n), where n is the number of names in the input list. | codefeedback |
Write a program to count the number of occurrences of each vowel (a, e, i, o, u) in the given string, while also considering uppercase letters as vowels. The string may contain special characters and punctuation marks. Additionally, the program should also keep track of the number of consonants and display the total co... | codefeedback |
Create a program in C++ that takes an input integer and checks whether it is odd or even. The program should also handle the case where the input is not a valid integer. Additionally, the program should only use bitwise operations to determine if the number is odd or even.
Erroneous code reference:
```
int checkEvenOr... | codefeedback |
Generate a Python code to convert a list of strings to a list of integers. The code should handle situations where the input list contains both integers and non-integer strings. Any non-integer strings should be skipped and not included in the final list of integers. The converted list should be sorted in ascending ord... | codefeedback |
You are provided with a list of integers and a given number. Generate Python code that detects if the given number is in the list or not. Additionally, you need to ensure that the code has a time complexity of O(log n), where n is the length of the list. The list will always be sorted in ascending order. Return True if... | codefeedback |
Write a for loop that prints the integers from 100 to 1 in reverse order, but only if the integer is divisible by both 3 and 5. | codefeedback |
Build a React component called "ToggleText" that toggles the display of some text and changes the text color when toggled.
You need to implement a component called "ToggleText" that renders a button and a paragraph. When the button is clicked, the paragraph should toggle between being hidden and visible. Additionally,... | codefeedback |
Create a Python code that takes in two strings and finds all common characters from the strings. The code should handle cases where there are multiple occurrences of a character in a string and should return a dictionary where the keys are the common characters and the values are the number of occurrences of that chara... | codefeedback |
Construct the following JSON object:
```json
{
"name": "John Doe",
"age": 25,
"email": "johndoe@example.com",
"address": {
"street": "123 Main Street",
"city": "New York",
"state": "NY",
"zipcode": "10001"
},
"hobbies": ["reading", "playing guitar", "hiking"],
"education": {
"school":... | codefeedback |
You need to create a Python function to remove duplicate elements from a given list while maintaining the original order of elements. The function should return the updated list.
# Constraints and Requirements
1. The function should have a time complexity of O(n^2), where n is the length of the input list.
2. You are ... | codefeedback |
You need to create a Python function to detect if a given number is prime or not. However, you are not allowed to use any built-in functions or libraries to check for prime numbers. You must implement the prime-checking logic from scratch using only basic programming constructs.
In addition to the above requirements, ... | codefeedback |
Create a Python code to find all uncommon characters between two strings, ensuring that the code can handle strings of up to 1000 characters in length. The code should also be optimized to find the uncommon characters in O(n) time complexity, where n is the length of the longer string.
Provide a piece of erroneous cod... | codefeedback |
You need to create a Python class to represent a 3-dimensional point. The class should also have a method that calculates the distance between two points in 3D space. Additionally, the class should have a method that calculates the angle between two vectors formed by connecting the origin to each point. | codefeedback |
Write a function that takes in a positive integer N as input and returns a list of all prime numbers from 1 to N. The function should have a time complexity of O(N√N).
#Additional Information#
You can assume that N will always be a positive integer greater than or equal to 1.
A prime number is a positive integer grea... | codefeedback |
Update the given code to add a statement to check if the input number is a prime or not. Additionally, modify the code to include a function that takes a range of numbers as input and returns a list of all prime numbers within that range.
```python
num = 5
is_prime = True
if num > 1:
for i in range(2, num):
... | codefeedback |
You need to write a Python function that finds all unique substrings of a given string in order, and returns them as a list. The function should have the following signature:
def find_unique_substrings(string: str) -> List[str]:
The function should return a list of all unique substrings of the input string, in the or... | codefeedback |
Create a Python function to sort a list of strings based on a given alphabetical order. The alphabetical order is defined by a dictionary where each letter is associated with a unique integer value. The strings in the list can contain any printable ASCII characters. The sorting should be performed in a way that the str... | codefeedback |
Given a string, find the longest palindrome within it that starts and ends with the same letter. The length of the string will not exceed 10^6 characters.
string = "abracadabraanamadamalayalamradar" | codefeedback |
Create a function to print out a numbered list of items from an array, but exclude any items that contain the letter 'a' as the second letter.
array = ['apple', 'banana', 'orange', 'grape', 'watermelon'] | codefeedback |
Construct a function to output the product of two numbers. Additionally, handle the case where one or both of the input numbers are negative. However, you should not use the multiplication operator (*) or any built-in multiplication functions.
#Difficulty Increase#
Implement the function using bitwise operations and/o... | codefeedback |
Construct a function that prints the first n terms in a Fibonacci sequence, but also checks if each term is a prime number. If a term is prime, print "prime" next to it. Additionally, calculate the sum of all the prime terms in the Fibonacci sequence and return it.
The function should take an integer n as input and re... | codefeedback |
Can you build a linear regression model with a minimum R-squared value of 0.9 to predict the housing prices in the given dataset? The dataset contains 20 columns with 5,000 records, and you are required to include at least 5 additional variables in your model, selected from a list of 20 potential predictor variables pr... | codefeedback |
Get a user input and check if the input is a palindrome. The input should not exceed 100 characters and should only contain alphabetic characters. Additionally, the program should ignore any leading or trailing spaces in the input. | codefeedback |
Create a function that takes a specific input and produces a specific output using only addition and subtraction operators. The function must also satisfy the following constraints: the input must be a positive integer between 1 and 1000, and the output must be a negative integer between -1000 and -1. | codefeedback |
Create a responsive HTML form to allow the user to register an account with an email address and a password. The form should include client-side validation to ensure that the email address is in the correct format and that the password meets certain complexity requirements.
The password strength meter should dynamical... | codefeedback |
Create a function that generates a series of Fibonacci numbers up to a certain number of items. The function should also calculate the sum of all the prime Fibonacci numbers in the series. | codefeedback |
Please create a function that selects all the div tags within a document and returns their attributes (id, class, and style) in a dictionary format. Additionally, the function should also extract the text content of each div tag.
Example input:
```
<html>
<body>
<div id="div1" class="box" style="color: red;">He... | codefeedback |
Write an algorithm to insert a new element in a given sorted array, but you are not allowed to use any built-in sorting functions or libraries. Additionally, you need to optimize the algorithm to have a time complexity of O(log n) instead of O(n). | codefeedback |
Write an algorithm to find the smallest missing positive number greater than or equal to K from a given list of integers. The algorithm should also have a time complexity of O(n) and should not use extra space. Return -1 if there is no missing positive number greater than or equal to K in the list.
Example:
Input: [3,... | codefeedback |
Convert this C code to Java. Implement a class called "MathUtils" that contains a method called "addTwoNumbers" with the following signature: "public static int addTwoNumbers(int a, int b)". The method should return the sum of the two input integers. You are not allowed to use the "+" operator or any built-in mathemati... | codefeedback |
Create a while loop in Java to find and break at the first prime number greater than 1000. Additionally, modify the code to throw a custom exception named "PrimeNotFoundException" if no prime number is found within the first 10000 numbers. | codefeedback |
Use class inheritance to create an object in Java and demonstrate the use of abstract methods. Additionally, implement method overriding and show the usage of interfaces. | codefeedback |
Analyze this text using spaCy and extract all the named entities. Then, calculate the sentiment score for each named entity and sort them in descending order of sentiment scores.
Text: Modern technologies like artificial intelligence and blockchain are revolutionizing the way we live and work. | codefeedback |
What is the maximum amount of memory that a 32-bit system can address, considering that it can address a maximum of 4GB of memory? Provide your answer in bytes. | codefeedback |
Generate an HTML page with a heading and a paragraph. The heading must have a font size of 24px and the paragraph must have a font size of 16px. Additionally, the heading must be centered both horizontally and vertically on the page. The paragraph must have a line height of 1.5 and a letter-spacing of 1px. The HTML pag... | codefeedback |
Create a function to capitalize all the words of a sentence. The function should have a time complexity of O(n) and should not use any built-in string manipulation functions or regular expressions. Additionally, the function should use constant space complexity, meaning it should not create any additional data structur... | codefeedback |
How would you access the value of the key 'name' in the following dictionary if the dictionary is stored inside a list and the list is nested within another dictionary? Additionally, you must ensure that the value of the key 'name' is only accessible if the length of the list is greater than 2 and the value of the key ... | codefeedback |
Construct a function to convert feet to meters, but the function should only accept floating-point numbers as input and should return the result with a precision of up to 5 decimal places. Additionally, handle the case where the input is a negative number and return the result as a positive value. | codefeedback |
Find the sum of the elements of an array, but only include elements that are divisible by both 2 and 3, and are also prime numbers.
arr = [1,2,3,4,6,9,12,13,15,16,18,19,20] | codefeedback |
Create a SQL query to find all users who have a premium account, have made at least 10 purchases in the last month, and have an average purchase value of more than $100. | codefeedback |
Create a React component that allows the user to input their name. When the user clicks a button, display a greeting message that includes the user's name and the current date and time. The greeting message should be styled with CSS to have a background color and a border. Additionally, add a countdown timer that start... | codefeedback |
Implement quick sort on an array of strings. The strings will contain only lowercase letters and will have a maximum length of 100 characters. The input array will have a maximum length of 1,000,000. The implementation should be able to handle this worst-case scenario efficiently, with a time complexity of O(n log n) a... | codefeedback |
Compute the maximum subarray sum for the given array. Find the subarray that has the largest sum, and also has a length greater than or equal to 3. Additionally, the subarray should be non-empty and contiguous. Array: [-2,1,-3,4,-1,2,1,-5,4] | codefeedback |
Create a responsive HTML website with a fixed navigation bar, logo, and footer. The navigation bar should include a dropdown menu with at least five options. The logo should be an image that is displayed in the center of the page and should resize proportionally based on the screen size. The footer should include socia... | codefeedback |
Provide a code for creating a function which receives an array of integers, sorts them in descending order, and prints the sorted array.
Additional Requirements:
1. The code should not use any built-in sorting functions or libraries.
2. The code should have a time complexity of O(n log n) or better. | codefeedback |
Write a code for concatenating two arrays, while ensuring that the resulting array does not contain any duplicate elements. The code should also remove any negative numbers from the resulting array.
Array1: [1,2,3]
Array2: [3,4,5,-1,-2]
Expected Output: [1,2,3,4,5] | codefeedback |
Write a Python script to take two lists and output the common elements of the given lists. The script should handle cases where the input lists may contain duplicates. Additionally, the script should only output unique common elements, even if they occur multiple times in the input lists. Finally, the script should be ... | codefeedback |
Implement a function called `string_compressor` that takes in a string as input and returns a compressed version of the string using the following rules:
1. The compressed string should consist of repeated characters followed by the count of consecutive occurrences.
2. If the compressed string is not shorter than the ... | codefeedback |
Please preprocess this data using Python. The input data will be a list of dictionaries, where each dictionary represents a person's information. Each person will have the following attributes: "name" (string), "age" (integer), "gender" (string), "city" (string), and "hobbies" (list of strings).
The output should be ... | codefeedback |
Rotate the given array by k steps in the clockwise direction. Return the modified array.
Array: [1,2,3,4,5,6,7,8,9]
k: 3 | codefeedback |
Using a while loop, print the first 100 prime numbers that are also palindrome numbers. | codefeedback |
Write a SQL query to select the grocery items under $50 with a quantity of at least 5 units in stock, sorted by price in descending order, and grouped by the first letter of the item's name from the table.
Table "Grocery":
ID | Name | Price | Quantity
1 | Apple | 15 | 10
2 | Banana| 20 | 3
3 | ... | codefeedback |
Rewrite the following code as a MySQL query, but also include the total number of athletes in each team who have achieved a score higher than the team average.
SELECT team, count(*) AS num_athletes,
(SELECT count(*) FROM athletes) AS total_athletes,
(SELECT AVG(score) FROM athletes AS a2 WHERE a2.team =... | codefeedback |
Create a code which prints a multiplication table of a given size.
The size should be an odd number between 5 and 15, inclusive.
The code should generate the multiplication table using nested loops, without using any built-in multiplication functions or operators.
The time complexity of the code should be O(n^2), where... | codefeedback |
Generate a list of integers up to the given number n, but only include prime numbers in the list. Additionally, the generated list should be in descending order. The function should return the sum of all prime numbers in the list.
50 | codefeedback |
Select the student's name and matric number whose grade is "A" and is ranked within the top 10% of all students in the database. The table "Students" has the following columns: Name, Matric No, Grade.
Table "Students":
Name | Matric No | Grade
James | 151763 | A
David | 143563 | B
John | 1... | codefeedback |
Design a loop in Python to find the maximum value from a given array. The array can contain duplicate elements and can have a maximum length of 10^6. The time complexity of the solution should be O(n), where n is the length of the array.
Additionally, the array may also contain negative values. You need to handle this... | codefeedback |
Sort the books in alphabetical order using JavaScript. The array of books contains strings with random characters and numbers in addition to the book titles. However, the sorting should be case-sensitive and numbers should come before letters in the sorted result. If two books have the same starting letter, sort them b... | codefeedback |
Suggest an algorithm for finding the maximum sum for all subarrays in an array of integers. The array may contain both positive and negative numbers. The algorithm should have a time complexity of O(n^2).
Provide a piece of erroneous code as a reference to increase misdirection.
arr = [2, 3, -5, 4]
#Erroneous Code#
... | codefeedback |
Rewrite the following JavaScript code such that it prints the numbers 1 to 10, but this time, every odd number should be squared before printing. Additionally, ensure that the code uses a recursive function to calculate the squares of odd numbers. | codefeedback |
Generate an HTML table to display the countries, their population, and the percentage of the world population they make up. The table should be sorted in descending order of population. Additionally, the table should only display countries with a population greater than 1 billion.
The table should also include an addi... | codefeedback |
Create a Python class to encode a string of characters using a Vigenère cipher. Your implementation should include a method to handle both encryption and decryption. Additionally, the Vigenère cipher should have a variable keyword that can be set by the user. The keyword should be a string of characters, and any value ... | codefeedback |
Write a Java program to display a pattern of numbers in a pyramid shape, where each number is the sum of the two numbers directly above it. The program should take an integer input from the user, representing the number of rows in the pyramid. The program should then generate the pyramid pattern accordingly. The time c... | codefeedback |
Write a code which takes two strings and prints the length of its longest common subsequence. The longest common subsequence should satisfy the following additional constraint: it should be a palindrome.
String1: "ABCDGH"
String2: "AEDFHR"
#Reasoning Steps#
1. Initialize a 2D array dp of size (n+1) x (m+1), where n i... | codefeedback |
Write an SQL query to find the maximum number of orders for each state, display the corresponding customer_id, and calculate the average order amount for each state.
Orders (id, customer_id, state, order_num, order_amount)
Note: The maximum number of orders for each state should only include unique customer_ids. | codefeedback |
Fill in the blanks in the following SQL query to select the names of customers who have placed more than one order, and have made at least one order in the current year. Additionally, exclude customers who have placed any orders with a total order amount less than $100.
SELECT customer_name
FROM Orders
WHERE order_c... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.