instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Compose a function in C to display the result of raising a number to a positive power, considering the number may be a floating-point number and the power may be a negative integer. Additionally, the function should handle cases where the number is zero and the power is zero, returning an appropriate error message.
codefeedback
Create a function that takes in a list of strings and sorts it by the reverse order of its length. The function should also remove any duplicate strings from the list before sorting. The resulting sorted list should then be converted to all uppercase letters. Finally, the function should return the sorted and converted...
codefeedback
Construct a loop in Python that iterates through each row of a dataframe and performs the following operations for each row: 1. Print the index of the current row. 2. Print the values of all columns in the current row. 3. Calculate the sum of all numerical values in the current row. 4. Check if any missing values exist...
codefeedback
Write a Python function to edit a given list by replacing all occurrences of an existing element with a new value. If the element does not exist in the list, the function should raise a custom exception called "ElementNotFoundError". The function should have a time complexity of O(n), where n is the length of the list....
codefeedback
Create a web application that displays a dynamic animation of multiple shapes moving across the screen in a random pattern. The shapes should gradually change their size, color, and rotation based on the mouse's position on the page. Additionally, implement a feature that allows the user to click on the shapes and drag...
codefeedback
Write a Python code to print the multiplication table for any number inputted by the user, up to a limit of their choice. Additionally, the program should handle erroneous inputs by displaying an error message and asking the user to re-enter a valid input.
codefeedback
Given two strings, haystack and needle, find the starting index of all occurrences of the needle within the haystack, taking into consideration both case sensitivity and partial matches. Return the indices as a list in ascending order. Note: Partial matches refer to instances where the needle is a substring of a word ...
codefeedback
Develop an algorithm in Java to compute the Fibonacci sequence modulo a given prime number p, but with the following additional requirements: 1. The algorithm should be able to handle extremely large input values for n (e.g., n > 10^18). 2. The algorithm should have a time complexity of O(1). 3. The algorithm should us...
codefeedback
Create a function to identify whether a given number is a power of two. Additional Instructions: 1. Your function should have a time complexity of O(1) and a space complexity of O(1). 2. You cannot use any built-in math or bitwise operators (e.g., log, pow, &, <<, etc.). 3. You cannot use any loops or recursion. 4. Yo...
codefeedback
Write a code to categorize the given list of numbers according to their divisibility by a certain number, and return the count of numbers that are divisible by the given number. However, you must use a recursive function to solve this problem. numbers = [9, 12, 15, 18, 21] divisible_number = 3
codefeedback
Create a code to rotate an array to the right by k steps, where k is a positive integer. You are given an array arr and an integer k. Your task is to rotate the array to the right by k steps. This means that each element in the array should be shifted to the right by k positions, with the last k elements being moved t...
codefeedback
Write a code that allows a user to search an array of objects by any parameter, but the search must be case-sensitive and should consider only the first letter of each parameter. For example, searching for 'J' should return an object with the name starting with 'J', but searching for 'j' should not return any result. A...
codefeedback
Edit the code below so that the variable 'name' cannot be modified after the first print statement. Additionally, add a requirement that the program must ask the user to input their name, and the name must be at least 5 characters long. The program should continue to ask for the name until a valid name is entered. nam...
codefeedback
Write a code to find the shortest possible palindrome where the resulting palindrome must contain at least one uppercase letter and one special character. The code should work for any given string and should not use any built-in string manipulation functions or libraries. The input string will have a maximum length of ...
codefeedback
Given a number n, count the total number of digit-only divisors of n that are also prime numbers. A digit-only divisor is defined as a divisor of n that only consists of the digits present in n. Constraints: - 1 <= n <= 10^9 Example: n = 123456 Explanation: In the given test, we are counting the total number of dig...
codefeedback
Edit the following code so that it prints an appropriate error message when attempting to divide by zero. Additionally, ensure that both num1 and num2 are positive integers and print an error message if they are not. If either num1 or num2 is not a positive integer, prompt the user to input a valid positive integer unt...
codefeedback
Using the data provided, create a SQL command to get the total number of orders from customers in the USA and the total number of orders from customers in Canada. Additionally, calculate the average number of orders per customer for each country. However, you are not allowed to use the COUNT function or the AVG functi...
codefeedback
Generate a C code snippet to print a given string with a width of 20 characters, ensuring that each word in the string is displayed in a separate line, and the last line is not left with any empty spaces. Additionally, the code should truncate any words that exceed the 20 character width limit and replace them with ".....
codefeedback
Create a class in JavaScript called "Person" that includes a constructor, a method for changing the greeting, and a method for saying the greeting. The class should also have a static variable that keeps track of the total number of Person objects created. Additionally, create a subclass called "Student" that extends ...
codefeedback
Develop an algorithm in JavaScript to calculate the frequency of each lowercase vowel in a given string, ignoring any uppercase letters, non-alphabetic characters, and spaces. Additionally, exclude the vowels 'a' and 'e' from the calculation.
codefeedback
Implement a function in Python to convert a given sentence into title case, ensuring that all articles, prepositions, and coordinating conjunctions are lowercase unless they are the first or last word of the sentence. The function should also handle contractions and hyphenated words correctly. Additionally, the functio...
codefeedback
Develop a service handler in C# to filter the records of a list to find the ones that satisfy a certain condition. The condition is that the length of the string should be a prime number and the string should contain at least two vowels in reverse order. List of strings - ['apple', 'car', 'cat', 'dog', 'elephant', 'ba...
codefeedback
Compare the performance of quicksort, mergesort and heapsort on an unsorted array of size 1000, considering that the input array can contain duplicate elements. Additionally, implement a time complexity analysis for each sorting algorithm, explaining their best, average, and worst-case scenarios.
codefeedback
Create a SQL query to get the names, ages, and addresses of all the users with an age greater than 25, who have at least 1000 followers and are sorted in descending order based on the number of followers. Additionally, exclude any users whose addresses contain the word "Street" and include the total count of followers ...
codefeedback
Write an R script to find the number of days in the current month, but you are not allowed to use any built-in date or time functions. Additionally, you must implement your own algorithm for determining leap years and account for the correct number of days in February for both leap and non-leap years.
codefeedback
Create a MySQL query to find all users whose first name starts with 'J', last name starts with 'D', and the sum of the ASCII values of their first name and last name is a prime number. Additionally, the query should return the number of characters in the user's first name and last name combined.
codefeedback
Write a Java program to print out all possible combinations of the numbers from 0 to 9 in ascending order, without using any loop statements. Additional Constraints: - The program should use recursion to generate the combinations. - The program should output the combinations in lexicographical order. - The program sho...
codefeedback
Create a Python program to check if all items in a list are unique, without using any built-in functions or data structures. Additionally, handle the case where the list contains nested lists and/or dictionaries. list_items = [1,2,3,2,3, [4,5,6], {'a': 1, 'b': 2}]
codefeedback
Design a Python program to identify odd numbers in a given range and store them in a list. The range should be specified by the user. Additionally, the program should check if the user input for the range is valid. If the user enters a non-numeric value or a negative value, the program should display an error message ...
codefeedback
Convert the given JSON data into an Excel spreadsheet. Each product should be placed in a separate row, with the following columns: ID, Name, Price, Category, and Quantity. The ID column should be formatted as a number, while the Name, Price, Category, and Quantity columns should be formatted as text. Additionally, ad...
codefeedback
Compose a PHP code to store the data entered by the user into a database, but make sure to validate the user's input for the name and age fields before storing them. Additionally, implement a password field that requires the user to enter a password containing at least one uppercase letter, one lowercase letter, one nu...
codefeedback
What is memory management in C and how does it differ from memory management in other programming languages? Explain the concept of dynamic memory allocation in C and provide an example of how it is implemented.
codefeedback
Implement a secure login feature to a given website, using encryption algorithms such as AES or RSA for storing and verifying user passwords. The website should also include a password strength checker that evaluates the complexity of a user's chosen password based on factors such as length, character variety, and the ...
codefeedback
Given a string containing alphanumeric characters, special characters, and spaces, write a Python function that extracts all unique numbers from the string while ignoring any duplicate numbers. The function should return a list of the unique numbers in ascending order. You may assume that a number is defined as a sequ...
codefeedback
Generate code in C++ for performing Bubble Sort on an array of integers. Implement the sorting algorithm using a recursive approach and ensure that the code handles arrays of up to 10,000 elements efficiently. Additionally, your code should have a time complexity of O(n^2) and should not use any extra space other than ...
codefeedback
Write a function that takes in an array of integers and returns a string with each number in reverse order, separated by a comma. The function should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the input array. #Example# Input: [1, 2, 3, 4, 5] Output: "5,4,3,2,1" #Function ...
codefeedback
Design a SQL query to select students older than 25 years from a database, who have a GPA higher than 3.5 and are enrolled in at least 3 different courses.
codefeedback
Write a C program to print the elements of a given matrix in spiral order. The matrix will always be square and have an odd number of rows and columns. The elements in the matrix will be integers. Additionally, the program should handle matrices with negative numbers and the size of the matrix should not exceed 100x100...
codefeedback
Write a C program that takes in a string as input and checks if it is a palindrome. The program should ignore any non-alphanumeric characters and should not be case-sensitive. The program should print "YES" if the input is a palindrome and "NO" if it is not. Additionally, the program should handle strings containing up...
codefeedback
Convert the given input into a string and output it. The input may contain negative numbers. The output should contain the numbers in ascending order, separated by commas. The length of the input should be at least 5.
codefeedback
Print the following string with all asterisks in lower case and output it. However, you are not allowed to use any built-in string manipulation functions, regular expressions, or loops.
codefeedback
Write a HTML code to create a form to register a new user. Additionally, add client-side validation using JavaScript to ensure that the password meets the following criteria: - Contains at least 8 characters - Contains at least one uppercase letter, one lowercase letter, one digit, and one special character - Cannot co...
codefeedback
Create an algorithm that takes in two sorted arrays, arr1 and arr2, of size n and m respectively, and merges them into a new sorted array. The merged array should have a size of n + m. Example: arr1 = [1,2,3,4,5] arr2 = [6,7,8,9,10] Merged array: [1,2,3,4,5,6,7,8,9,10] Constraints: - The input arrays will always be ...
codefeedback
Given a matrix of integers, output a vector that contains the sum of each row in the matrix. Additionally, calculate the sum of all the elements in the matrix and append it as the last element in the output vector.
codefeedback
Write a Bash shell script to run a program called 'myProgram' 10 times with different parameters each time. Additionally, ensure that each parameter is passed as a command line argument to the program. Furthermore, implement error handling to catch any potential failures during the execution of 'myProgram' and provide ...
codefeedback
Construct a CSS code that adds a background color of red to the ’div' element only if the element has a class of "highlight" and is nested inside a parent element with a class of "container".
codefeedback
Create a SQL query that selects all customers who bought a product within the last year and have made at least two purchases in total. Include customers who made the purchase exactly one year ago today.
codefeedback
Create a SQL query to sort data from highest to lowest in the column ‘age’, but exclude any records where the age is negative. Additionally, include only records where the age is greater than or equal to 18 and the name starts with the letter 'A'.
codefeedback
Write a Python program to convert a given temperature in Fahrenheit to Celsius. The temperature input should be taken from the user. Additionally, the program should handle invalid input by displaying an error message and prompting the user to enter a valid temperature. #Sample Input/Output# Enter temperature in Fahre...
codefeedback
Develop a program that takes in two arrays of integers and returns the index of the first occurrence of the smallest common element in both arrays. If there is no common element, return -1. Example: Input: Array 1: [1, 5, 2, 9, 10] Array 2: [4, 6, 3, 1, 7, 8] Output: 3 In this example, the smallest common element be...
codefeedback
Create an HTML form that consists of three checkboxes, each representing a different category. The categories are "Technology", "Sports", and "Food". The form should include a submit button that is only enabled when at least two checkboxes are checked. Each checkbox should have a label associated with it that displays...
codefeedback
Create a JavaScript function to check if a given positive integer n is a perfect square using only bitwise operations.
codefeedback
Write a SQL query to find the records with a price greater than 100 and quantity less than 10, sorted in descending order by price, from a table called "product_catalog". The query should also exclude any records where the product name contains the word "out of stock".
codefeedback
Write a HTML fragment to display a textbox with the following requirements: 1. The textbox should have a placeholder "Enter your name". 2. The textbox should only accept alphabetic characters. 3. The textbox should have a maximum character limit of 10. 4. The textbox should display a live character count as the user t...
codefeedback
Write an SQL query to find the records with a name starting with "A" and ending with "s", the age is greater than 30, and the records must also have a salary greater than 50000.
codefeedback
Take a positive integer input greater than 1 and output the Fibonacci sequence up to that number, with each Fibonacci number being raised to the power of 3 and multiplied by 2. n = 15
codefeedback
Write a JavaScript code to create a responsive web page with a navigation bar that should have a dropdown menu with multiple options. Each option in the dropdown menu should have a corresponding content section on the page. The navigation bar should also have a search bar that allows users to search for specific conten...
codefeedback
Write a C++ program to generate the Fibonacci sequence up to the given number n. However, you must use a recursive function to generate the sequence instead of using a loop. Additionally, the program should handle the case when the given number n is negative and print an appropriate error message. Finally, the program ...
codefeedback
Write a Python script to find the area of a triangle with sides given as strings instead of integers. The code should convert the string inputs to integers before calculating the area. The program should also check if the given sides can form a valid triangle, and if not, display an error message. Additionally, the pro...
codefeedback
Develop a C++ program to list all the prime numbers divisible by 7 from 1 to 50, while also excluding any numbers that are multiples of 3. Additionally, the program should print the sum of all the prime numbers found.
codefeedback
Please create a program that prompts the user to enter two strings. The program will compare the two strings and, if the two strings are the same, print out "Equal strings". If the two strings are different, the program should print out “Unequal strings” and identify the number of characters that are different between ...
codefeedback
Create a function 'combineTwoLists' with two parameters which combines two given lists into a new list. The new list should only contain unique elements and be sorted in ascending order. The combined list should also have a maximum length of 10 elements. Additionally, the function should have a time complexity of O(nlo...
codefeedback
Construct the SQL query to select the rows from the "Employees" table whose salary is greater than the average salary, but only for employees whose department has more than 10 employees. Additionally, include a subquery to calculate the average salary for each department and display it in the result set.
codefeedback
Write a Bash script which detects if a given argument is a number, a string, or a combination of both (e.g. "123abc"). The script should also handle special cases such as negative numbers, floating-point numbers, and scientific notation. Additionally, the script should also check if the given argument is a valid email ...
codefeedback
## Problem Statement ## Create a Python function `findPattern` with two parameters which takes two strings and returns 1 if the second string is a subsequence of the first string, otherwise 0. ### Example ### ```python findPattern("abcde", "ace") -> 1 findPattern("hello", "world") -> 0 ``` ### Constraints ### * Th...
codefeedback
Create a new HTML page and add a <div> element inside the <body>. Additionally, use JavaScript to dynamically change the background color of the <div> element to a random color every time the page is loaded. However, you are not allowed to use any built-in JavaScript functions or libraries to generate random colors. In...
codefeedback
Given an array named 'numbers' containing at least 2 unique integers, write a function to find and print the element with the second greatest value. Your function should not use any built-in sorting functions or methods. Additionally, the time complexity of your solution should be O(n), where n is the length of the arr...
codefeedback
Write a function that takes an array of numbers and prints out all the pairs of numbers whose sum is equal to a given number. The function should also handle duplicate pairs, where the order of the numbers in the pair does not matter. The output should be sorted in ascending order of the first number in each pair. The ...
codefeedback
#Rewritten Test# Modify the following code to turn all the words in a sentence to upper case and remove any duplicate words. Additionally, the code should sort the words in descending order based on their length. string = "Hello World hello world" #Expected Output: "WORLD HELLO" #Erroneous Code Reference# Below is ...
codefeedback
Write a JavaScript function that generates a random number between 0 and 10, inclusive. The function should not use any built-in random number generator functions or libraries. Additionally, the function should only use a maximum of 5 lines of code and must not use any loops or recursion.
codefeedback
Implement a function to implement Bubble Sort with a time complexity of O(n^2) and space complexity of O(1). The function should sort an array of integers in ascending order. The input array will contain at most 1000 elements.
codefeedback
Rewrite the code snippet using a recursive function instead of a while loop. def increment(x): x += 1 if x == 10: return increment(x) return x x = increment(0)
codefeedback
Given two lists of integers, create a new list that contains the difference between the two lists, but with the following conditions: 1. The difference should only be calculated for elements that are common to both lists. 2. The difference should be calculated by subtracting the element in list2 from the element in lis...
codefeedback
Given two strings, create a new string that is their concatenation, but with the condition that the resulting string should not contain any duplicate characters. Step 1: Read the first string from the user and store it in a variable called string1. Step 2: Read the second string from the user and store it in a variabl...
codefeedback
Convert the given expression from infix notation to postfix notation. The expression will contain operators: +, -, *, /, % (modulo operation) The expression will contain both positive and negative integers. The expression may contain parentheses to indicate the order of operations. The expression may also contain expon...
codefeedback
Write a function that takes in a list of integers and splits it into two sublists. The two sublists must have an equal sum and an equal number of elements. If it is not possible to split the list in such a way, the function should return None. To solve this problem, you can use a recursive approach. Here's a possible ...
codefeedback
Given a text, classify each word in the text into its respective category based on the following rules: 1. If a word starts with a vowel (a, e, i, o, u), it belongs to the "Vowel" category. 2. If a word starts with a consonant and ends with a vowel, it belongs to the "Consonant-Vowel" category. 3. If a word starts with...
codefeedback
Find the shortest path between two nodes using Dijkstra's algorithm while also ensuring that the path includes at least one specific intermediate node. The graph has N nodes and M edges, and the intermediate node must be visited exactly K times. Additionally, the graph may contain negative-weight edges.
codefeedback
Implement a 4-to-1 multiplexer using VHDL and ensure that the output is latched on the rising edge of the clock signal. Additionally, the multiplexer should have a programmable delay of 2 nanoseconds for each input signal, which can be adjusted through a configuration file. Erroneous code: Implement the 4-to-1 multipl...
codefeedback
You need to classify a given paragraph into one of 10 categories, considering the sentiment, topic, and language complexity of the paragraph. This paragraph is about sports and has a positive sentiment. Additionally, the paragraph should be written in a highly technical and jargon-filled language, making it more challe...
codefeedback
Write a function that generates a unique integer ID given a string input. The generated ID should have a time complexity of O(n) and a space complexity of O(n), where n is the length of the input string.
codefeedback
Build a system that takes in two positive integers less than 100 and outputs the summation of the two numbers, without using the addition operator or any mathematical operators. The system should also ensure that the input integers are prime numbers.
codefeedback
Generate a random string with length 100 consisting of lowercase letters. Additionally, ensure that the generated string does not contain any repeated characters and that it starts and ends with a vowel.
codefeedback
Create a class that implements a set data structure with the following additional requirements: - The set should only allow elements of integer data type. - The set should have a maximum capacity of 100 elements. - The set should provide a method to calculate the sum of all elements in the set. - The set should provide...
codefeedback
You need to find all the words in a given sentence sorted by their length in descending order. Additionally, you need to return the count of unique words in the sentence. The sentence may contain punctuation marks and special characters, and words are case-insensitive. The output should not include any duplicates. Each...
codefeedback
What is the difference between a Node.js callback and a promise, and explain the advantages and disadvantages of each in terms of error handling, code readability, and performance efficiency? Additionally, provide an example of a common error in code implementation when using callbacks or promises and explain how to fi...
codefeedback
Write an HTML form that collects first name, last name, and email address. The email address must be validated to ensure it is in the correct format (e.g. name@example.com). Additionally, the form should include a checkbox for the user to agree to the terms and conditions before submitting the form. Increase the diff...
codefeedback
You need to rearrange the characters in a given string such that no two same characters are adjacent to each other. The goal is to minimize the number of character swaps required to achieve this rearrangement. Implement a function that returns the minimum number of swaps needed, or -1 if it is impossible to rearrange t...
codefeedback
Write a Lambda expression for finding the maximum absolute value from a list of integers, excluding zero. [3, -5, 21, -11, 9, 0]
codefeedback
Construct an SQL query to find the employees whose salary is greater than $5,000, their age is less than 30, and they have been with the company for more than 2 years, from the Employees table.
codefeedback
Take two text strings as input and output the difference between two strings. The output should be the number of characters that are different between the two strings, excluding spaces. The input strings can be of any length and may contain special characters. The program should be case-sensitive and consider character...
codefeedback
Design a program that takes a string of decimal numbers separated by commas as input and prints out the corresponding Unicode characters for each number. Input: "65, 66, 67, 97, 98, 99" Expected Output: "A B C a b c" Note: - The input string may contain leading or trailing spaces. - The numbers in the input string w...
codefeedback
Please implement a function that takes a binary tree as input and returns a list containing the data stored at each level. The function should have a time complexity of O(n), where n is the number of nodes in the tree. Additionally, the space complexity should be O(h), where h is the height of the tree. Example: Inpu...
codefeedback
Write a C++ function that takes a queue of integers as input and deletes all the elements except for the last element. The function should also reverse the order of the remaining elements in the queue.
codefeedback
Convert this octal number to a binary number, ensuring that your solution is implemented using recursion. Octal number: 777 To solve this problem, follow these steps: 1. Define a recursive function that takes in an octal number as input. 2. Inside the function, check if the octal number is equal to 0. If it is, retu...
codefeedback
Create a function in Python that takes in a positive integer N as input and returns a list of N randomly generated numbers between 0 and 100, without repetition. The function should have a time complexity of O(N) and should not use any external libraries or functions for random number generation. Furthermore, ensure t...
codefeedback
Find the values of a, b, and c in this equation, while also ensuring that a, b, and c are positive integers. Additionally, the sum of a, b, and c should be the minimum possible value. 7a + 5b + 4c = 70
codefeedback
Generate a list comprehension to find the highest number in the given list. Additionally, the program should ignore any negative numbers in the list, consider only the positive numbers for finding the highest number, and ensure that the highest number is greater than 50. The list can contain at most 1000 elements. List...
codefeedback
Use a CSS code snippet to make a div element into a circle with a given radius. However, the radius should be dynamically set based on the width of the viewport, and the circle should have a border that changes color every second.
codefeedback
Produce a JavaScript code snippet for opening a new browser window with the following requirements: 1. The new window should have a specific width and height, which are not allowed to be larger than the user's screen resolution. 2. The new window should have a specific position on the screen, which is randomly generat...
codefeedback