instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Write a SQL query to find all customers who have made at least 5 purchases in the past month and live in the city of Boston.
codefeedback
Given an array of numbers, write a Python function to remove even numbers from the array. The function should also remove any duplicate numbers in the array. If the array is empty, the function should return an empty array. If the array only contains even numbers, the function should return an empty array as well. Exa...
codefeedback
Build a graphical user interface using Java that includes a custom-designed navigation menu with animated transitions between menu items.
codefeedback
Generate a regular expression which matches the following strings: “Run”, “Rune”, “Runner”, but does not match the strings “Running”, “Ran”, “Runder”.
codefeedback
Create a dictionary that contains the countries and their total populations according to the given list of country-population pairs. The list will now include additional pairs for more countries, making the problem more complex. [('India', 1237696000),('Nigeria', 142429000),('China', 1139517000),('United States', 33100...
codefeedback
Write a SQL statement to create a table called "Employees" with five columns for ID number, first name, last name, salary, and department. Additionally, enforce the following constraints on the table: 1. The ID number should be a unique, non-null integer. 2. The first name and last name should be non-null strings, wit...
codefeedback
Create an SQL query to select the names, departments, and salaries of employees who have salaries greater than $50000 and are also in a specific department (e.g. 'IT' department). #Explanation# The original problem was straightforward, requiring only a single logical step of selecting names and salaries of employees w...
codefeedback
Write an algorithm that sorts the following list of integers in descending order: [15, 5, 8, 0, 42]
codefeedback
Write a function that checks whether an array contains an element. The array can contain integers or floating-point numbers. The function should return True if the element is found in the array and False otherwise. Constraints: - The array can have a maximum length of 10^6. - The element can be any number between -10^...
codefeedback
Create a web application that allows users to sign up and log in using their email address and password. The application should have the following features: 1. Registration: - The user should be able to enter their email address and password to create an account. - Validate that the email address is in a valid ...
codefeedback
Create an HTML form with 3 input boxes to get user name, email, and phone number. Additionally, implement client-side validation to ensure that the user name contains only alphabetical characters, the email is in a valid format, and the phone number follows a specific format (e.g. XXX-XXX-XXXX).
codefeedback
Ask the user to input a positive integer and find the sum of all prime numbers up to that number.
codefeedback
Create a dynamic HTML structure with a table to display a list of cities and their population. Implement functionality to allow users to sort the table by city name or population in ascending or descending order. Additionally, add a search bar to enable users to filter the table based on city names.
codefeedback
Create a calculator that takes two float numbers as input and outputs the sum of the two numbers. Additionally, implement functionality for subtraction, multiplication, and division. Handle division by zero errors and any other potential errors that may arise during the calculations.
codefeedback
Write a script to filter out strings with more than five characters and contain at least one uppercase letter from a list of strings. The filtered strings should then be converted to lowercase and printed in reverse order. arr = ["code","programming","language","Python","Loops","Conditions"]
codefeedback
Create a web page that allows users to input their favorite color, name, and age. Validate the user input to ensure that the color is a valid hexadecimal color code, the name is not empty, and the age is a positive integer. Display an error message if any of the validations fail. Once the user has entered valid input, ...
codefeedback
Create a function to add two numbers without using the + operator. The function should handle negative numbers and floating-point numbers as well. Additionally, the function should not use any arithmetic operators or bitwise operators like addition, subtraction, multiplication, division, or bit manipulation.
codefeedback
Suggest a method in Python to remove any whitespaces from a given string, while maintaining the original order of the characters. Additionally, optimize the solution to have a time complexity of O(n) and a space complexity of O(1), where n is the length of the string.
codefeedback
Develop an algorithm for a breadth-first search that also tracks the shortest path from the starting node to each node in the graph.
codefeedback
How can we remove duplicates from an array in JavaScript without using any built-in array methods or additional data structures?
codefeedback
Suggest a method in Java to compare two strings, considering both case sensitivity and whitespace characters. Additionally, provide a piece of erroneous code that attempts to compare two strings using the wrong method.
codefeedback
Print out the elements of the list in reverse order without using the reverse() method and without using any additional lists or data structures. The solution should have a time complexity of O(n), where n is the length of the list. list_of_words = ["Hello", "World", "How", "Are", "You"]
codefeedback
Create a function that returns the number of prime numbers between the numbers provided in the input. The function should also handle negative input numbers and return an error message if the start_num is greater than the end_num. The function should only consider prime numbers greater than 1 and less than or equal to ...
codefeedback
Edit the code below so that the condition outcome is true and you are not allowed to use any comparison operators (e.g., >, <, ==). if 3 - 2 * 2 == 2 - 1: outcome = True
codefeedback
Create a function that returns the longest word in a sentence, excluding any punctuation marks. sentence = "This is a sentence with lots of words, including some hyphenated-words and words with apostrophes."
codefeedback
Write a script to sort an array of numbers from largest to smallest using quick sort. The time complexity should be O(n log n) and the space complexity should be O(log n).
codefeedback
Print the sum of the first 100 natural numbers.
codefeedback
Find the maximum product of three numbers in an array, where at least one of the numbers must be negative. Return 0 if no such triplet exists. [1, -5, -6, 10, 20, 15]
codefeedback
Create a function that recursively flattens an array of arbitrarily nested arrays. The function should handle cases where the input array contains a mixture of integers and strings. Additionally, the function should ignore any empty arrays or arrays that only contain empty arrays. array = [[1, [2, [3, [[4, 5], []]]]], ...
codefeedback
Construct a function to check whether a string is a valid IPv6 address or not.
codefeedback
Write a formatter to wrap the text at a given number of characters, while maintaining the original formatting and line breaks. The formatter should also handle special characters and punctuation marks properly.
codefeedback
Write a function to select the second largest unique value in an array. The array may contain duplicates. Example: Input: [1, 3, 6, 8, 7, 0] Output: 7 Note: In the given example, the second largest unique value in the array is 7.
codefeedback
Compress the following string using a modified Huffman algorithm. # New Test # Compress the following string using a modified Huffman algorithm and implement a decompression function as well. "abacabadabacaba" Note: The modified Huffman algorithm assigns variable length codes to characters in such a way that no code...
codefeedback
Write a function to retrieve and reverse the order of all words in a sentence, excluding any words that contain the letter 'a' or 'e' in them. sentence = "This is a sentence."
codefeedback
How can you find all the subsets of a set in Python, where each subset must contain at least one element from a specific subset of elements?
codefeedback
Convert a binary string to a decimal integer, but without using any built-in conversion functions or libraries. You can only use basic arithmetic operations (such as addition, subtraction, multiplication, and division) and loops. The binary string can have up to 1 million digits.
codefeedback
Compress a given string to shorter characters by replacing substrings of length 3. The compressed string must also include the count of each substring occurrence. string = "aaabbcc" Example Output: compressed_string = "a3b2cc"
codefeedback
Create a function that converts a string of words into a dictionary with the words as keys and the number of occurrences of each word as values. The function should ignore punctuation and be case-insensitive. string = "Hello World bye World. Hello World!"
codefeedback
You must refactor a code to reduce the complexity and improve its readability. The original code checks whether a given number is even or odd by recursively calling two functions `is_even` and `is_odd`. Your task is to refactor the code by creating a single function `is_even_or_odd` that takes an integer `num` as inpu...
codefeedback
Perform insertion sort on a given array of objects. Each object has the following properties: 'name' (a string), 'age' (an integer), and 'score' (a floating-point number). arr = [ {'name': 'John', 'age': 25, 'score': 78.5}, {'name': 'Alice', 'age': 30, 'score': 82.1}, {'name': 'Bob', 'age': 22, 'score': 76...
codefeedback
Create a function that deletes all non-alphanumeric characters from an input string, and returns a new string with the remaining alphanumeric characters in reverse order. #Example# Input: "Hello, World!" Output: "dlroWolleH" #Note# - The input string can contain upper and lowercase letters, numbers, and special cha...
codefeedback
You must reverse a given array of numbers in-place without using any built-in methods or additional data structures. arr = [1, 2, 3, 4, 5]
codefeedback
Use JavaScript to find the area of a circle with a radius of 7. Additionally, you are required to implement error handling for negative radius inputs and display a custom error message.
codefeedback
Given a string in Python, how do you extract all the unique words while preserving their order of occurrence?
codefeedback
Write a line of code in C# to find the index of the first occurrence of a given element in a given array, without using any built-in functions or libraries. The array may contain duplicate elements and can have a maximum length of 1000. The element is a positive integer less than or equal to 1000.
codefeedback
Write a recursive function in Python that implements depth-first search on a binary tree. The function should take in a binary tree as input and return a list of all the nodes visited during the search in the order they were visited.
codefeedback
There is an array of integer numbers. You need to replace all the odd numbers with the sum of their adjacent even numbers. If there are no adjacent even numbers, replace the odd number with 0. arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
codefeedback
Given a list of string objects, write an SQL query to concatenate all the strings into a single string and count the number of vowels in the resulting string.
codefeedback
Write an AngularJS controller to set the "page" variable to be the same as the page parameter passed in the URL, but only if the page parameter is a positive integer greater than 10 and less than 100.
codefeedback
Write a sliding window algorithm in JavaScript to collect all the subarrays with size k from an array of size n. In the resulting subarray, each element should be squared. Return the sum of all the subarrays. let input = [1, 2, 3, 4, 5, 6, 7, 8]; let K = 3; Example: Input: input = [1, 2, 3, 4, 5, 6, 7, 8], K = 3 Outp...
codefeedback
Write a Java program to find the largest prime number among three numbers entered by the user.
codefeedback
Given an array of numbers, write a prototype JavaScript function to find the average value of all numbers in the array. If the array is empty, the function should return 0. If the array contains any non-numeric values, the function should skip those values and calculate the average based on the remaining numbers. For...
codefeedback
Write a JavaScript function to modify a given list and convert all elements to lowercase. The function should not use any built-in JavaScript methods or libraries for string manipulation. The time complexity of the function should be O(n), where n is the length of the input list. Input: - A list of strings Output: - ...
codefeedback
Sort the given array of numbers from least to greatest. The sorted array should also have the even numbers before the odd numbers. Additionally, you are not allowed to use any built-in sorting functions or libraries. [11, 5, 9, 3, 6]
codefeedback
Using the Python requests library, implement a call to the given URL and print the response. Additionally, ensure that the request is made using a POST method and include a request header with the key "Authorization" and value "Bearer <token>". The token should be obtained from the user as an input. Finally, the respon...
codefeedback
Parse the given HTML string into a readable JSON object. HTML string: ```html <html> <body> <h1>Hello World!</h1> </body> </html> ``` Required JSON object: ```json { "html": { "body": { "h1": "Hello World!" } } } ``` Please write a function that takes an HTML string as input and returns a JSON obje...
codefeedback
Create a list comprehension expression to generate a list of the squares of all even numbers from 1 to 10, but exclude any numbers that are divisible by 3.
codefeedback
Explain the concept of serverside rendering in web development and discuss its advantages and disadvantages. Additionally, provide a code example showcasing how serverside rendering can be implemented in a JavaScript framework of your choice (e.g., React, Angular, Vue.js).
codefeedback
Create a program that searches a given string for a word and prints out its position. However, you are not allowed to use any built-in string search or matching functions. Instead, you need to implement your own algorithm to find the word. String: "I am a programmer" Word: "programmer" Time complexity requirement: O(...
codefeedback
Rewrite the following Bash program to print only prime numbers between 0 and 100. #!/bin/sh for i in $(seq 0 100) do prime=true for j in $(seq 2 $(($i - 1))) do if [ $(($i % $j)) -eq 0 ] then prime=false break fi done if $prime then echo $i fi done
codefeedback
Create a function that sorts a given list of strings alphabetically, but with the following additional conditions: 1. Ignore case sensitivity when sorting the strings. For example, "apple" should come before "Banana". 2. If two strings have the same letters but different cases, the one with lowercase letters should co...
codefeedback
Create an assembly language program to find the sum of two floating-point numbers and round the result to the nearest whole number.
codefeedback
Create a C++ function to search for a given item in the given array. The array contains n elements, where n is a power of 2. The array is sorted in ascending order and may contain duplicates. The function should return the index of the first occurrence of the given item in the array, or -1 if the item is not found. Ex...
codefeedback
Write a routine to reverse the elements in a linked list.
codefeedback
Calculate the probability of an event that occurs exactly 3 times out of a sequence of 10 independent and identically distributed Bernoulli trials, where the probability of success for each trial is 0.3.
codefeedback
Implement a search algorithm to find an element in an array with the following additional constraints: 1. The array is sorted in ascending order. 2. The array may contain duplicate elements. 3. The search algorithm should return the index of the first occurrence of the element in the array. 4. If the element is not fou...
codefeedback
Output the top 10 most common strings in a given list of strings. ["apple", "orange", "apple", "banana", "apple", "cherry", "banana", "kiwi", "strawberry", "orange", "kiwi", "apple", "orange", "banana", "cherry", "strawberry", "kiwi", "orange", "banana", "cherry", "kiwi", "strawberry", "kiwi", "orange", "banana", "cher...
codefeedback
Convert the given numerical value from base 10 to base 2 using bitwise operators only. Number: 50
codefeedback
Design a physics experiment to measure the acceleration due to gravity, considering the effects of air resistance and the need for accurate time measurements.
codefeedback
Reverse the order of elements in an array without using any built-in functions or creating a new array. my_arr = [1, 2, 3]
codefeedback
Write a function to determine if two rectangles intersect. The rectangles are represented by their bottom-left coordinate, width, and height. rect1 = (x1, y1, w1, h1) rect2 = (x2, y2, w2, h2) The function should return True if the rectangles intersect and False otherwise. The coordinates of the rectangles can be nega...
codefeedback
Create a function to generate random English sentences that must contain at least one word with 10 or more characters.
codefeedback
Calculate the area of a triangle given the lengths of its three sides. However, the sides are represented as floating-point numbers and can have decimal values. Additionally, you are not allowed to use the Heron's formula for calculating the area.
codefeedback
Using a nested for loop, print out a countdown from 100 to 1, but only display odd numbers.
codefeedback
Write an algorithm to print out the prime numbers between 0 and 100 in an increasing order. #Explanation# 1. Initialize a variable `num` to 0. 2. Create a loop that runs until `num` reaches 100. 3. Inside the loop, create a boolean variable `isPrime` and set it to true. 4. Create a nested loop that starts from 2 and r...
codefeedback
Interpret the following regular expression: ((\d{2})\s[A-Z]{3})|((\d{2})\s[a-z]{3})
codefeedback
Query an API and display its results, including the following additional steps: 1. Take user input for the IP address to query. 2. Validate the user input to ensure it is a valid IP address format (e.g. xxx.xxx.xxx.xxx). 3. Handle any errors or exceptions that may occur during the API request. 4. Parse the JSON respon...
codefeedback
Find the latitude and longitude of an input address, using only primitive data types and without using any external libraries or APIs. address = "1600 Amphitheatre Parkway, Mountain View, CA"
codefeedback
Calculate the square root of a positive number without using any built-in function. The output should be rounded to the nearest integer. Additional constraint: The algorithm should have a time complexity of O(log n). num = 25
codefeedback
Given a list of words, sort them in descending order using a bubble sort algorithm. The length of each word in the list will not exceed 50 characters.
codefeedback
Compose a function that takes in two strings and produces an array of characters that are only in the first string and are also prime numbers. stringA = "abcdefg" stringB = "hijklmn"
codefeedback
Generate a random string of length n containing only lowercase letters. The string must have at least one vowel and one consonant.
codefeedback
Calculate the inverse of this matrix, where the matrix is guaranteed to be a square matrix of size n x n, where n is a positive integer. [[1, 0, 0], [2, 1, 0], [4, 4, 4]]
codefeedback
Create a class for a Counter object that will keep track of a total count, and increase and decrease the count when functions are called. Additionally, implement a feature that allows the Counter object to keep track of the count for multiple instances of the class. Each instance should have its own independent count.
codefeedback
Create a function that takes two numerical parameters and checks if they are equal. However, you are not allowed to use any comparison operators (e.g., ==, !=, <, >) or built-in functions (e.g., equals(), compareTo()) to compare the values.
codefeedback
Develop a program to count the number of items of a given list, where each item is a positive integer between 1 and 100. The program should also calculate the sum of all the items in the list. The list can contain up to 1000 items. Print both the count and the sum of the items as the output.
codefeedback
Write a function to extract the substring between two given indices of a string. If the start index is greater than the end index, return an empty string. If either index is out of range (less than 0 or greater than the length of the string), return None. Example: string = "Hello World", start_index = 2, end_index = 5...
codefeedback
Generate a program to filter a list of numbers, passing only the numbers that are greater than a given number, and store them in a new list. The program should also remove any duplicates from the resulting list. Example: Input: [12, 24, 36, 45], 36 Output: [45] Time complexity: O(n) Space complexity: O(n) Note: The ...
codefeedback
Using the Java programming language, print out the direct children of a given element in an HTML document. However, you are not allowed to use any built-in HTML parsing libraries or regular expressions.
codefeedback
Write a SQL query to get the products with the lowest price in each category, excluding products that are out of stock.
codefeedback
Write a function in Python to print out the top k most common words in a given text, where k is a positive integer input to the function. The function should ignore punctuation and consider words in a case-insensitive manner. If multiple words have the same frequency, they should be sorted alphabetically. You can ass...
codefeedback
Using the PHP programming language, write a function to check if a string contains all vowels (a, e, i, o, u) in any order and any number of occurrences. The function should ignore case sensitivity and return true if the string meets the requirement, otherwise return false.
codefeedback
Write an algorithm to find the common elements in two arrays. The algorithm should have a time complexity of O(n), where n is the size of the larger array. Additionally, you are not allowed to use any additional data structures or built-in functions for solving the problem.
codefeedback
Create an HTML page with two input fields, one for the first name and one for the last name. The first name field should only accept alphabetic characters and should be limited to a maximum length of 20 characters. The last name field should only accept alphabetic characters and should be limited to a maximum length of...
codefeedback
Write a function in Java to calculate the number of days in a given month and year. Your function should handle leap years correctly and account for the differences in number of days in different months (e.g. February has 28 or 29 days depending on the year). Provide a piece of erroneous code as a reference to increas...
codefeedback
Implement a recursive function to compute the factorial of a given number. The function should have a time complexity of O(n), where n is the given number. The function should not use any loops or iteration, and should only use recursion to calculate the factorial. Additionally, the function should handle edge cases su...
codefeedback
Reverse the following array using slicing. Your solution should have a time complexity of O(n) and should not use any built-in functions or libraries that directly reverse the array.
codefeedback
Explain the underlying principles and operations of a hash table, including collision resolution strategies and load factor calculations.
codefeedback
The following code is broken, please rewrite it so that it prints out all the prime numbers within a given range. You need to implement a function called `print_primes` that takes in two parameters: `start` and `end`, representing the range of numbers to check. The function should print out all the prime numbers withi...
codefeedback
Create a program in python that takes a number as input and checks if it is a prime number. Additionally, the program should only accept positive integers as input and should provide an error message and ask for input again if a non-integer value is entered or if the input is negative.
codefeedback