instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Construct a SQL query to retrieve all records in a table whose salary is greater than 50,000 and whose job title is "Manager".
codefeedback
Write a SQL query to list the names, salaries, and years of experience of the employees who work in the finance department and have a salary greater than $50,000. Additionally, order the results by years of experience in descending order.
codefeedback
Construct a function to check whether a given number is prime or not in Java. Additionally, provide a piece of erroneous code that incorrectly checks for primality to increase misdirection.
codefeedback
Develop a python program to search for multiple substrings in a string. String = "This is a sample string" Substrings = ["sample", "string"] Requirements: 1. The program should be able to search for all the substrings in the given string. 2. The program should return the index positions of each substring found in the ...
codefeedback
Suggest a valid select statement to display the name, age, and salary of the youngest employee who has a salary greater than $50,000.
codefeedback
Write an algorithm to find the maximum substring with a specific length in the given string. The length of the substring must be a prime number.
codefeedback
Edit the following line of code from C++ to include the use of the precedence operator and also ensure that it uses the bitwise OR operator: (a + b) * (c | d);
codefeedback
Design a HTML form to accept user details (Name, age, address, etc) and validate the user input before submitting the form. The form should include the following validation checks: 1. Name field should not be empty and should only contain alphabets. 2. Age field should be a number between 18 and 99. 3. Address field s...
codefeedback
Offer a solution to the following programming problem Given a list of strings, return the longest string that contains at least one uppercase letter and one lowercase letter.
codefeedback
Write a program in Java to implement a singly linked list with the following operations: 1. Insertion: Implement a method to insert a new node at the beginning of the linked list. 2. Deletion: Implement a method to delete a node at a given position in the linked list. 3. Search: Implement a method to search for a given...
codefeedback
Explain the use of regular expressions and provide a practical example of how they can be utilized in a programming scenario. Additionally, outline the steps involved in creating a regular expression pattern to match specific patterns within a given input string.
codefeedback
Design a recursive solution for the Towers of Hanoi problem using Java, ensuring that each disk can only be moved to a peg with a larger diameter than itself.
codefeedback
Design a web application that allows users to enter a text query and get results in an arranged format. The application should be able to handle a large number of concurrent users and perform the search operation efficiently even with a high volume of data.
codefeedback
Construct a function in C that prints all prime numbers present in an array.
codefeedback
Design an algorithm that can be used to identify if a given binary tree is a valid BST, while also keeping track of the maximum and minimum values allowed for each node.
codefeedback
Generate a program in JavaScript to find the longest common substring of two strings, but now the strings can contain special characters and digits in addition to alphabets. str1 = "ab1cd" str2 = "cdef9g"
codefeedback
Write a Python script that takes in a string and prints out the frequency distribution of the letters in the string. The script should also exclude any special characters or numbers from the frequency distribution. Additionally, the script should handle uppercase and lowercase letters as separate entities in the freque...
codefeedback
Create a function that produces input strings for a calculator. The input strings must be valid mathematical expressions, consisting of numbers (positive and negative integers and floating-point numbers), arithmetic operators (+, -, *, /), parentheses, and at least one mathematical function (e.g. sqrt, sin, cos). The f...
codefeedback
Create a function that takes an integer n as input and returns a dictionary where the keys are the integers up to n, and the values are the cubes of those same integers. Additionally, ensure that the function handles invalid inputs gracefully. If n is not a positive integer, the function should return an empty diction...
codefeedback
Create a function that takes an array as input and returns true if all elements in the array are similarly oriented (i.e. either all positive or all negative). The function should also handle the case when the input array is empty or contains only one element. #Examples is_similarly_oriented([-2, -4, -7, -9]) -> True ...
codefeedback
Design a distributed system to store and retrieve large amounts of data with the following additional requirements: 1. Implement data partitioning: Divide the data into smaller partitions and distribute them across multiple servers. Ensure that each partition is stored on multiple servers to achieve fault tolerance an...
codefeedback
Write a C program to find all the roots of a quadratic equation. Handle all possible cases, including when the equation has no real roots, has repeated roots, or when the equation has complex roots.
codefeedback
Write a program in Objective-C that takes two strings as input and checks if they are anagrams. An anagram is a word or phrase formed by rearranging the letters of another word or phrase. The program should perform the following steps: 1. Prompt the user to enter the first string. 2. Prompt the user to enter the seco...
codefeedback
Create a class for a bank account with the following functions: deposit(), withdraw(), and get_balance(). The balance should be a private attribute that is only accessible through the get_balance() function. The deposit() function should only accept positive integers as input and add the amount to the balance. The with...
codefeedback
Write a SQL query that calculates the total number of orders made in the month of February, excluding orders with a status of 'cancelled' or 'returned', and including orders that were placed on weekends.
codefeedback
You need to provide an efficient way to implement a stack with the following additional requirements: 1. The time complexity for the push operation should be O(1). 2. The space complexity for the stack should be O(1). 3. In addition to the standard push and pop operations, you need to implement a peekMax operation tha...
codefeedback
Output all the elements in an array where the last character of the element is 's', while maintaining a time complexity of O(n). The input array may contain duplicate elements and the output should not contain any duplicates. If an element has multiple occurrences in the input array, it should only appear once in the o...
codefeedback
Calculate the number of Sundays in a given year that falls on the first of a month, excluding the months of January and December. Year: 2021
codefeedback
Write a script to generate 10 random prime numbers between 1 and 100.
codefeedback
Generate a Fibonacci sequence until the 1000th prime number.
codefeedback
Write a Python while loop that iterates through the list `my_list` and prints each item, but only if the item is even. The loop should terminate when it encounters an odd number or when it reaches the end of the list. my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
codefeedback
Design an object-oriented system for a banking application. The system should support the following functionality: 1. Create a new account for a customer with a unique account number. 2. Allow customers to deposit and withdraw money from their accounts. 3. Provide an option for transferring money between two accounts....
codefeedback
What is the syntax for adding a new element to an array of integers, where the element must be a positive integer and the array can only contain a maximum of 10 elements?
codefeedback
Print the longest substring of a string that does not have any repeated characters. If there are multiple substrings of the same length, print the one that appears first in the original string. string = "abcaabccbad" Example Output: Longest substring without repeated characters: "abc"
codefeedback
Generate a function that takes an array and computes the minimum element within the array. However, you are not allowed to use any built-in functions or methods that directly provide the minimum element of an array. The array will always contain at least one element.
codefeedback
Edit the code so that it can handle the fractions. def calculate(x, y): if isinstance(x, int) and isinstance(y, int): return x + y elif isinstance(x, float) and isinstance(y, float): return x + y elif isinstance(x, str) and isinstance(y, str): try: x = float(x) ...
codefeedback
Create an array of strings, such that it contains strings of all possible combinations of n characters from a given string of characters. However, the order of the characters in each string must be lexicographically sorted. Given string: "ABC", n = 3
codefeedback
Print out the average of all elements within a given array, rounded to the nearest integer. The array will contain at least 5 elements and at most 100 elements, and each element will be a positive integer between 1 and 1000, inclusive. The output should be a single integer. arr = [3, 7, 4, 8, 9, 2, 5, 6, 10, 1, 7, 9,...
codefeedback
Given an n x n matrix A, write a function to calculate the trace of A. The trace of a matrix is defined as the sum of the elements on the main diagonal (i.e., the diagonal from the top left to the bottom right). To calculate the trace of A, we need to iterate over the elements on the main diagonal and sum them up. We...
codefeedback
Write a function to count the number of distinct values in an array. The array may contain both integers and strings. arr = [1, 2, 3, "2", 4, 5, 3, "2"] # Erroneous Code # ``` def count_distinct_values(arr): distinct_values = [] for value in arr: if value not in distinct_values: distinct_va...
codefeedback
Write a function to calculate the hypotenuse of a right triangle when passed two sides (lengths) of the triangle. However, the function should also check if the given sides actually form a right triangle. If they don't, the function should return an error message instead of calculating the hypotenuse. For example, if ...
codefeedback
Create a function that not only converts a string of characters to lower case, but also removes any special characters, numbers, and whitespace from the string. Additionally, the function should count the occurrences of each letter in the string and return a dictionary with the letter as the key and its count as the va...
codefeedback
Write a function that takes a string and a list of strings and returns the number of times the string occurs in the given array, while ignoring case sensitivity. The string should only be considered a match if it appears as a whole word in any of the strings in the list. Example: string = "hello" arr = ["hello there",...
codefeedback
Create a 5x5 matrix of random positive integers using a multidimensional array. The integers should range from 1 to 100, and no two integers in the matrix should be the same.
codefeedback
Change all the characters in a given string to uppercase and count the total number of uppercase letters. Additionally, you need to ensure that the string contains at least one lowercase letter and one special character. Print the final string and the count of uppercase letters. str = 'Hello World! This is a Test!'
codefeedback
Write a function that calculates the average of all the numbers in a given array, excluding any negative numbers. arr = [2, 6, -21, 14, -8]
codefeedback
Suppose you have a string with a specific pattern, write a function that checks if the string follows the pattern. The pattern can contain any combination of uppercase letters and special characters such as '.' or '*'. The string can also contain any combination of uppercase letters and special characters. The functi...
codefeedback
Submit an algorithm to find the first non-repeating vowel character in the given string. The string will only contain lowercase letters.
codefeedback
Write a function that given a list of strings, filters out empty strings and strings containing only whitespace characters. The function should also remove any duplicate strings from the list. The filtered and deduplicated list should be returned in alphabetical order. string_list = ["Hello", "", "Bye", "", " ", "See...
codefeedback
Develop a script to create a new folder in the specified directory, where the folder name consists of a combination of random alphanumeric characters with a length of at least 10 characters. The directory path should be provided as an input to the script. Additional Requirements: 1. The folder name should be unique an...
codefeedback
Calculate the remainder when the following number is divided by 4, considering that the solution must be implemented using a recursive function and must not use the modulo operator: 50
codefeedback
Given a list of positive integers, construct a function that returns the highest and the lowest numbers. The function should also check if the highest number is divisible by the lowest number. If it is divisible, the function should return a tuple with the highest number as the first element and the lowest number as th...
codefeedback
Write a function that given a positive number, returns the sum of all positive even numbers from 1 to the given number. number = 10
codefeedback
Create an object of the following data structure. Ensure that the 'type' key is nested within a dictionary called 'category', and the 'name' key is nested within a dictionary called 'identification'. The 'age' key should remain at the top level of the data structure. data = { 'category': { 'type': { ...
codefeedback
Create a function that given a string of words, counts the frequency of each word and returns a dictionary with the word as the key and the frequency as the value. The function should handle different cases of words (e.g. "Hello" and "hello" should be treated as the same word). Additionally, the function should ignore ...
codefeedback
Given a list of integers, append the elements of another list to it. The second list should only contain prime numbers and must be sorted in descending order. The resulting list should not have any duplicate elements and should be sorted in ascending order. listA = [1, 2, 3] listB = [7, 5, 3, 2]
codefeedback
Create a function that prints out an ASCII art of a unicorn with a rainbow-colored mane and tail.
codefeedback
Change the second element of a tuple to the sum of the first and third elements. my_tuple = (1,2,3)
codefeedback
Define a function to calculate the median of a given array of numbers. The array will always have an odd number of elements, and you are not allowed to use any built-in functions or libraries to find the median.
codefeedback
Define a callback in JavaScript to be used with the onclick event. The callback should only execute if the user has clicked the button exactly three times within a 5-second interval.
codefeedback
Write an HTML text input field with the following requirements: 1. The input field must have an ID of "name". 2. The input field must be disabled. 3. The placeholder text inside the input field must be "Enter your name". 4. The input field must have a maximum character limit of 50. 5. The input field must be required a...
codefeedback
Using the list of numbers, create a filter in Python that removes all odd numbers from the list and sorts the remaining even numbers in descending order. Additionally, the filter should only include numbers that are divisible by 3. numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
codefeedback
Write a JavaScript function that converts a string to title case, but only for words that are longer than 3 characters. The function should also ignore common words such as "the", "and", "or", and "but". The converted string should have the first letter of every eligible word capitalized. The input string may contain s...
codefeedback
What is the difference between a mutable and an immutable object in terms of memory management and performance?
codefeedback
Create a class called Person with three variables: name, age, and gender. Implement the following methods in the class: 1. getName(): This method should return the name of the person. 2. setName(): This method should take a string as input and set it as the name of the person. 3. getAge(): This method should return the...
codefeedback
Develop a formula in JavaScript to calculate the volume of a sphere. radius = 10 (Note: The formula for calculating the volume of a sphere is 4/3 * pi * radius^3)
codefeedback
Create a function to calculate the value of "e" to the nth term using the Taylor series expansion. In mathematics, the value of "e" can be calculated using the formula: e^x = 1 + x/1! + x^2/2! + x^3/3! + ... where x is the input value and n is the number of terms to be calculated. For this problem, the input va...
codefeedback
You have a <div> element with a width of 200px and a height of 100px. Write CSS code to center align the <div> element both horizontally and vertically on the page.
codefeedback
Compute the sum of an array using a JavaScript loop, without using any built-in array methods or arithmetic operators (+, -, *, /). The input array can contain both positive and negative integers. array = [7, -2, 5, 9]
codefeedback
Design a user authentication system with a login page, logout page, and a registration page. Implement the following features: 1. User Registration: - Allow new users to register by providing a unique username and a password. - Validate the username to ensure it does not already exist in the system. - Hash th...
codefeedback
Create a database table called "Users" with 4 columns "Name", "Age", "Address" and "PhoneNumber". Implement a function that allows users to perform the following operations on the table: 1. Insert a new user into the table. 2. Retrieve all users from the table. 3. Update the information of a specific user. 4. Delete a ...
codefeedback
Create an SQL query to calculate the total sales per month for each product, where the product must have at least 100 sales in a month to be included in the result.
codefeedback
Create a function in Python that prints out the numbers from the given parameter to 0. Additionally, the function should raise a ValueError if the parameter is negative.
codefeedback
How would you convert a given number in hexadecimal format to binary using bitwise operators and without using any built-in conversion functions? number = 3E.
codefeedback
Implement a binary min-heap data structure in Python.
codefeedback
What are lambda expressions in Python and how can they be used to sort a list of dictionaries based on a specific key value?
codefeedback
Sort a given list of objects (integers or strings) in descending order, using only a single line of code. The sorting algorithm used should be quicksort. The list should be sorted in-place, without using any built-in sorting functions or libraries. The time complexity of the sorting algorithm should be O(n log n) and t...
codefeedback
Write an algorithm for adding two complex numbers.
codefeedback
Generate 10 unique random numbers between 5 and 10, inclusive, without using any built-in random number generation functions or libraries.
codefeedback
Write a C# code to convert a given number to words, but you cannot use any built-in functions or libraries to perform the conversion.
codefeedback
Compute the centroid of given points using mathematical formulas. Find the centroid only for points that have positive y-coordinates. The number of points must be less than or equal to 10. Return the centroid as a tuple rounded to the nearest integer. points = [(2, 3), (4, 7), (6, 9), (-1, 5), (3, 2), (8, 4), (9, 6), (...
codefeedback
Create a function to parse the given HTML and return an array containing the text content of all the <p> tags, excluding any paragraphs that have a class attribute with the value "exclude".
codefeedback
Edit the code to print out the HTML code for a table with five columns and five rows.
codefeedback
Construct a binary search tree from the given array of integers in such a way that the resulting tree is balanced.
codefeedback
Explain what a constructor is in Java and discuss its importance in object-oriented programming. Additionally, provide an example of a parameterized constructor and explain how it differs from a default constructor.
codefeedback
Create a program to filter out keywords from a given text. The input text will be a string of length n and will contain only alphabetical characters and spaces. The input keywords will be a list of m strings, each of length k. The maximum values for n, m, and k are 10^6. The program should return a new string that is...
codefeedback
Create a nested loop that increments a variable from 0 to 5. However, the outer loop must start from 1 instead of 0 and the inner loop must only iterate when the outer loop variable is even.
codefeedback
Build a function that takes an array parameter and returns the sum of the squares of its elements. The input array can contain both positive and negative integers. For each element in the array, check if it is an integer. If it is not an integer, ignore it and move on to the next element. If the element is an integer...
codefeedback
Write a function that checks if a given string contains a valid date in the format "MM/DD/YYYY". #Sample Input/Output# Input: "12/31/2022" Output: True Input: "02/30/2021" Output: False
codefeedback
Create a function in SQL to return the average of all values in a column, but also exclude any rows where the value is less than 10.
codefeedback
Design a MySQL query to count the number of occurrences for each letter of the alphabet in a given string, while ignoring the case of the letters. "Hello World"
codefeedback
Construct a function which will take the name of a month as a parameter and return the number of days in that month. The function should also handle leap years and return an error message if an invalid month name is provided.
codefeedback
Explain what is a median in statistics and write a program that takes a list of numbers as input and outputs the median. Your program should handle both odd and even number of inputs.
codefeedback
Design a Python script to extract the name, date of birth, and address from a given string. However, the string may contain multiple names, dates of birth, and addresses separated by semicolons. Your script should be able to extract all the relevant information from the string and store them in separate variables or da...
codefeedback
Write a Python Class to store a telephone directory's details. The class should be able to handle a large number of entries efficiently, with a maximum time complexity of O(log n) for searching, inserting, and deleting entries, where n is the number of entries in the directory. Additionally, the class should provide a ...
codefeedback
Rewrite the given function without using the ternary expression and without using any built-in mathematical functions or operators.
codefeedback
Write a C program to find the largest number from a set of 6 integer inputs. The program should also display the second largest number from the set of inputs. The inputs should be taken from the user at runtime.
codefeedback
Write a Python function that implements a basic neural network for binary classification. The function should take a set of input features and corresponding labels as input, and return the predicted labels for the given inputs. To implement the neural network, you should use the following steps: 1. Initialize random ...
codefeedback
Write an HTML code snippet to display a blue heart symbol that is animated to continuously pulse.
codefeedback
Write a function in Python that takes two strings as input and returns a sorted version of the first string with all occurrences of the letters in the second string removed. The function should have a time complexity of O(n log n), where n is the length of the first string. The space complexity should be O(n), where n ...
codefeedback