instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Design a function that takes a string of HTML tags as input and removes the tags from the string while preserving the content within the tags. #Additional Steps# 1. Validate the input to ensure it is a valid HTML string with proper opening and closing tags. 2. Handle cases where tags are nested within each other. 3. H...
codefeedback
Write an HTML table with four columns consisting of ID, name, email address and phone number. The table should be sortable by each column in ascending and descending order. Implement pagination for the table, with a maximum of 10 rows per page. Additionally, include a search functionality that allows users to search fo...
codefeedback
Write a JavaScript code that randomly generates a 2D array of size m X n, wherein each element has a random value between 0 and 5. The sum of all the elements in the array should be greater than or equal to 50.
codefeedback
Write a shell script to print the unique values from an array, but without using any built-in array functions or external commands. Example input: [1, 2, 2, 3, 4, 4, 5] Expected output: 1 3 5 Note: The array can contain any positive integer, and the elements may not be sorted.
codefeedback
Analyze the given text and label each token, ensuring that the program can handle multiple sentences and punctuation marks.
codefeedback
Create a program in Ruby to print out the first n prime numbers, where n is a positive integer provided as input by the user.
codefeedback
Create a program in C to calculate the average of nodes in the given linked list. The program should handle linked lists of any size and should also consider the possibility of an empty linked list.
codefeedback
Write a regular expression to detect phone numbers with country code in a string. The phone number should start with a plus sign (+) followed by a two-digit country code (between 1 and 99), followed by a hyphen (-), and then followed by a 10-digit phone number. Example: Input: "+918327886067" Output: True Input: "+12...
codefeedback
Write a function that converts a given three-digit number to its binary equivalent, without using any built-in conversion functions or libraries.
codefeedback
Calculate the sum of squares of all positive even numbers till 10, considering only numbers that are divisible by both 3 and 5.
codefeedback
Increase the difficulty by adding a constraint to the function: 1. The function should be implemented using recursion instead of a loop.
codefeedback
Create an HTML form that submits data to a server and performs the following additional requirements: 1. The form should contain at least 5 different input fields (e.g., text, checkbox, radio buttons, select dropdown, etc.) to capture various types of data. 2. Implement form validation using JavaScript to ensure that ...
codefeedback
Print the array elements in reverse order using a recursive function in JavaScript. The solution should have a time complexity of O(n) and should not use any built-in array methods or additional data structures. The function should also handle arrays with up to 100,000 elements.
codefeedback
Generate a working React component to parse GEDCOM data and display the parsed data in a hierarchical structure. Additional requirements: 1. The component should handle nested GEDCOM data. 2. The parsed data should be displayed in a tree-like structure, with each level of the hierarchy represented by a nested list. 3....
codefeedback
Write a JavaScript program to find the longest common prefix string amongst two given strings, while also ensuring that the common prefix is at least 3 characters long? "hello" and "heaven"
codefeedback
Generate a working C program to accept a sentence as an input and count the occurrences of each letter in the sentence. Additionally, implement a feature to ignore case sensitivity and count both uppercase and lowercase occurrences of each letter as separate counts.
codefeedback
Write a python function that takes two strings as an argument and returns True if they are anagrams of each other, else False. The function should also handle cases where the strings contain special characters and whitespace. The function should be case-insensitive and should ignore any leading or trailing whitespace. ...
codefeedback
Write a code to construct the following diamond pattern using a given number of rows. Note: The number of rows will always be an odd number. Example: Input: 7 Output: * *** ***** ******* ***** *** *
codefeedback
Write a shell script to perform a binary search of an array [2, 3, 6, 8, 10] and return the index of the first occurrence of the target element.
codefeedback
Create a function to sort an array of numbers from least to greatest. You are not allowed to use any built-in sorting functions or libraries. arr = [3, 4, 12, 1, 5, 85]
codefeedback
Create a function that reverses a string without using any built-in functions or data structures (such as arrays or lists). Your solution should have a time complexity of O(n), where n is the length of the string. Your function should take a string as input and return the reversed string. Example: Input: "Hello worl...
codefeedback
Create a web page to display two input fields to enter two numbers. Add a third input field for the user to select an operation to perform on the numbers (such as addition, subtraction, multiplication, or division). Implement the logic to perform the selected operation on the two numbers and display the result on the w...
codefeedback
Write a function that takes a list of strings and joins them together with a pipe (|), but only for strings that start with a vowel. The resulting string should also be reversed. words = ["Apple", "App", "Application", "Applications", "Apples", "Ace", "Acer", "Iguana", "Eagle", "Ostrich"]
codefeedback
Generate a script to print out the sum of all even numbers in a given list, but also handle the case when the list contains non-numeric elements. Example input: [2, 4, 5, 6, '7', 8] Expected output: 20
codefeedback
Create an algorithm that uses a hash table to detect if an element is a duplicate. The algorithm should also return the frequency of each duplicate element in the array. Additionally, the algorithm should handle cases where the array contains negative numbers and floating-point numbers. The input array can have a maxim...
codefeedback
Given a list of integers, return a new list with even numbers doubled and odd numbers replaced with their square root (rounded to the nearest integer). lst = [1, 2, 3, 4, 5, 6]
codefeedback
Create a program that implements an autocomplete or predictive search feature. The program should support multiple languages and handle diacritics, such as accents and umlauts. Additionally, the program should take into account the frequency of word usage and prioritize suggestions based on popularity. The autocomplete...
codefeedback
Design an SQL query to select the top 10 most popular movies from a given movie table. The popularity of a movie is determined by the number of times it has been rented. In addition to selecting the top 10 most popular movies, also display the title, release year, and average rating of each movie. To calculate the po...
codefeedback
Write a JavaScript program to generate and print a multiplication table up to a specified number. The program should prompt the user to enter the number of rows and columns for the multiplication table. The program should then calculate and display the multiplication table using nested loops. Additionally, the program ...
codefeedback
Create a function to merge two sorted lists and remove duplicates. The function should have a time complexity of O(n+m), where n and m are the lengths of the two input lists. The merged list should also be sorted in ascending order. list1 = [1, 3, 5, 7] list2 = [2, 3, 8, 10]
codefeedback
Create a React component which shows a list of items with a delete button for each item. Additionally, implement a feature where the user can undo the deletion of an item by clicking on an "Undo" button.
codefeedback
Use a neural network with backpropagation to predict the price of a car based on its make, model, and year of manufacture. The make can be one of the following: 'Mazda', 'Volkswagen', or 'Chevrolet'. The model can be one of the following: '3', 'PASSAT', or 'Malibu'. The year of manufacture can be any integer between 19...
codefeedback
Write an instruction for a GPT model to generate a response when it is given an English sentence as input and the response must include a unique id that is a combination of the current date and time, in the format of "YYYY-MM-DD_HH:MM:SS".
codefeedback
Create a function to convert an XML string to a JSON object. The function should handle nested XML elements and attributes. The XML string may contain multiple root elements. The function should return the JSON object in a compact form, without any unnecessary white spaces or line breaks. The time complexity of the fun...
codefeedback
Write a function in Python that takes a sentence and a number as inputs, and returns the number of words in that sentence that are longer than the given number. Additionally, exclude any words that contain special characters such as punctuation marks or numbers. Sentence = "Hello, this is a sentence. It has some words ...
codefeedback
Create a program in Python that will take in a list of strings and print out each unique string in the list. Additionally, the program should ignore case sensitivity when determining uniqueness. The program should also handle cases where the input list contains both strings and integers. Lastly, the program should only...
codefeedback
Write a function that takes a string representing a human readable date in the format "Monday, Month Day, Year" and converts it to the ISO 8601 format "YYYY-MM-DD". For example, if the input is "Monday, April 7th, 2020", the output should be "2020-04-07". You need to handle the following cases: - The input can be in ...
codefeedback
Read the given list and filter out the odd numbers. The filtered numbers should be stored in a new list. Requirements: - The time complexity of the solution should be O(n), where n is the length of the input list. - The space complexity of the solution should be O(1) (i.e., constant space), excluding the space require...
codefeedback
Write a Python program that connects to a MongoDB database hosted on a remote server using a specific port number and authentication credentials.
codefeedback
Create an HTML page to display the output of a JavaScript greeting message. message: Welcome! Requirements: - The greeting message should be displayed in a heading element with a font size of 24px. - The background color of the HTML page should be set to light blue. - The greeting message should be displayed in the cen...
codefeedback
Write a JavaScript program to validate whether a given phone number is valid. The phone number should follow the following format: - It should consist of 10 digits. - It can have an optional country code at the beginning, which should be preceded by a plus sign (+). - It can have an optional area code, which should b...
codefeedback
Write a function in Python that takes two parameters, a list of integers and a target integer. The function should return the number of times the target integer appears in the list. The list will always have at least 10 elements and will not exceed 100 elements. The target integer will always be within the range of -10...
codefeedback
Write a Java class to implement a priority queue data structure that has a constant time complexity of O(1) for both insertion and deletion operations.
codefeedback
What is the maximum possible value that can be stored in a single byte of an unsigned integer in Java? #Erroneous Code Reference# What is the maximum possible value that can be stored in a single byte of a signed integer in Java?
codefeedback
Write a Python script that takes a string as input and outputs a string with the same characters in reverse order, while ignoring any whitespace characters and punctuation marks. The script should also check if the resulting string is a palindrome (reads the same forwards and backwards), and if it is, it should append ...
codefeedback
Write a C++ program to create a linked list of length N, where N is input by the user.
codefeedback
Explain the concept of a dining philosophers problem and propose a solution to prevent deadlock in this scenario.
codefeedback
Implement a recursive algorithm to count the number of elements that are divisible by k and have a remainder of 1 when divided by m in an array. The array will contain positive integers only. Example: [5, 8, 11, 14, 17, 20], k = 3, m = 2
codefeedback
Write a SQL statement to join table1 and table2 on the "name" column, but also include only the rows where the "age" column in table1 is greater than 25.
codefeedback
Given an array of strings "words", write a code to remove all the words which are greater than 5 characters in length. If a word has more than 5 characters, replace it with the reverse of the word. Finally, print the updated array. #Updated Test# Given an array of strings "words", write a code to remove all the words ...
codefeedback
Modify the following code so that it takes a list of numbers and calculates their weighted median. In a weighted median calculation, each number in the list is assigned a weight. The weighted median is the value that splits the list into two halves, where the sum of the weights of the numbers less than the median is e...
codefeedback
Design a JavaScript program to find the factorial of an integer, but ensure that the program includes error handling for non-integer inputs and displays a helpful error message. Additionally, the program should be optimized to handle large inputs efficiently. Find the factorial of 5.
codefeedback
Compile a Java program using the command line, ensuring that it uses an external library and multiple packages.
codefeedback
Rewrite the following function to check if a given number is a power of two. You are not allowed to use any built-in JavaScript functions or mathematical operations that directly solve this problem. ```javascript function isPowerOfTwo(num) { // your code here } ``` Please explain the time and space complexity of yo...
codefeedback
Strip the spaces in the given string, but do not use any built-in string manipulation functions or libraries.
codefeedback
Insert code to reverse a list in place without using any built-in reverse or swap functions. arr = [1,2,3,4]
codefeedback
Generate a random code string with each character from A-Z, a-z, and 0-9. The code string should have a length between 8 and 12 characters.
codefeedback
Given a collection of strings, sort the strings by their length in descending order. Return the sorted list of strings. Example: Input: ["a", "abc", "defg"] Output: ["defg", "abc", "a"] Note: - The input list will not be empty. - The strings in the input list will not be empty. - If two or more strings have the same ...
codefeedback
Given a 2D array, return the sums of all columns. However, the time complexity of your solution must be O(n), where n is the total number of elements in the array.
codefeedback
Find all duplicates in an array of positive integers where each integer is between 1 and 100, inclusive. The array may contain up to 10^6 elements. Return the duplicates in ascending order. arr = [1, 2, 4, 2, 1, 5]
codefeedback
Calculate the sum of every second element in an array. However, the elements must be skipped in a specific pattern. Start by skipping 1 element, then 2 elements, then 3 elements, and so on. Repeat this pattern until the end of the array is reached. arr = [1, 5, 4, 8, 10, 12, 6, 2, 7, 3, 9, 11] For example, the sum wo...
codefeedback
Create a program to encode a message with the Caesar cipher encryption algorithm, but now the message may contain both uppercase and lowercase letters. The shift value should also be randomly generated within the range of 1 to 26.
codefeedback
Create a program to generate a random password of length n (input by the user) consisting of both alphabets (both uppercase and lowercase) and numbers. The password should also contain at least one special character (!@#$%^&*()-_=+~`[]{}|;:,<.>/?) and should not have any repeated characters.
codefeedback
Create a web page with a form that takes a user's name and birthdate. Calculate the user's age based on the birthdate and display a personalized greeting based on the age. Additionally, implement a validation check to ensure that the user's birthdate is entered in the format "YYYY-MM-DD" and that the entered date is no...
codefeedback
Create a web service to convert a given list of temperatures from Celsius to Fahrenheit, while also checking for any invalid temperature inputs and handling them appropriately. The input list may contain both valid and invalid temperature values. Invalid temperature values can be defined as temperatures below -273.15°...
codefeedback
Create a class named 'Circle' which calculates the area and circumference given a radius. The class should also have a method named 'is_inside' which checks if a given point (x, y) is inside the circle. To calculate the area, you can use the formula: area = π * radius^2. To calculate the circumference, you can use th...
codefeedback
Sort an array using bubble sort technique in descending order. arr = [8, 6, 7, 5, 4, 3, 1]
codefeedback
Write a function that takes two strings as input, one being a base string and the other being a sub-string, and returns True if the sub-string appears in the base string and False otherwise. The function should also handle cases where the sub-string is present in the base string but with different letter case. For exa...
codefeedback
Write a code to implement a round-robin scheduling algorithm. Round-robin scheduling is a pre-emptive algorithm where each process is assigned a fixed time slice or quantum to execute before being interrupted and moved to the back of the queue. The purpose of this algorithm is to provide fair allocation of CPU time to...
codefeedback
Implement a function to solve the following equation: x3+y3=z3
codefeedback
Given a string, write code to remove all the consecutive characters and output the new string. The new string should also have all the non-consecutive characters in the original string, but in reverse order. The code should be implemented using recursion. string='AAABBBCCC'
codefeedback
Create a program that takes in two lists and prints out a new list with the elements from the first list followed by the elements from the second list, without using any built-in functions or methods such as append() or extend(). Additionally, the program should sort the new list in descending order. list_1 = [7, 4, 9...
codefeedback
Write a function to convert an array of strings to an array of floats, but with the following additional requirement: - The function should ignore any strings that cannot be directly converted to floats, and return only the converted floats. string_arr=['1.1', '2.3', '3.4', 'abc', '5.6']
codefeedback
Compute the number of ways for a host to select k items from a list of n options, where k <= n.
codefeedback
Create a histogram chart of the given data. dataset = [2, 3, 5, 6, 7, 4, 9, 1, 2, 5, 3, 4, 6, 7, 8, 9, 1, 3, 5, 7, 8, 9, 0, 1, 2, 4, 6, 8, 0, 3, 5, 7, 9]
codefeedback
Write a program that can parse a given string and extract the full name from it. The full name should consist of a first name and a last name, separated by a space. Example: Input: "Hi! My name is John Smith" Output: "John Smith" Note: - The input string will always start with the greeting "Hi! My name is" followed b...
codefeedback
Design an algorithm to eliminate duplicate elements in a given array while maintaining the order of the remaining elements. Array: [1, 5, 1, -2, 5] Additional requirement: The algorithm should have a time complexity of O(n) and use only a constant amount of additional space.
codefeedback
Search a list of strings to find a specific string and return its index. However, the search term may contain wildcards, represented by asterisks (*), which can match any number of characters (including zero). Implement a function that takes in the list of strings and the search term, and returns the index of the first...
codefeedback
Write a function to generate an array of all possible permutations of N numbers, where N is a positive integer. The numbers in the array can range from 1 to N. #Reasoning# To solve this problem, we can use backtracking. We start with an empty array and iteratively add numbers to it, making sure to avoid duplicates. ...
codefeedback
Given a number N, find the square root of N using the Newton-Raphson method.
codefeedback
Write a function that takes an array of integers and multiplies them together. The function should handle negative numbers and should return the product as a floating-point number. arr = [-3, 5, 4]
codefeedback
You are given a string. Count the total number of lowercase letters in the string. Additionally, the string may contain special characters and numbers. Ignore all special characters and numbers while counting the lowercase letters.
codefeedback
What is this coding question asking you to do? Write a Python function to check whether a number is a perfect prime or not. A perfect prime is a prime number that is also equal to the sum of its proper divisors (excluding itself).
codefeedback
You are given a list of positive and negative integers. Find the maximum sum of any subsequence in the list. The length of the list will not exceed 10^6. Additional Constraints: - Your algorithm should have a time complexity of O(n), where n is the length of the list. - The maximum space complexity allowed is O(1). - ...
codefeedback
Find all the possible permutations in a string without using any built-in functions, where the input string can contain duplicate characters. string = "ABA"
codefeedback
Create a function that removes duplicates from an array and returns an array of the unique values. The function should only use O(1) additional space and have a time complexity of O(n), where n is the length of the input array. The input array can contain integers, floating-point numbers, and strings. The output array ...
codefeedback
Implement a function to calculate the greatest common divisor of two numbers. Inputs: Two positive integers, A and B, where 1 <= A, B <= 10^9 The function should return the greatest common divisor (GCD) of A and B. Note: - The GCD of two numbers is the largest positive integer that divides both numbers without leavin...
codefeedback
In HTML, write a code to create a registration form that includes fields for the user's first name, last name, email address, and password. Additionally, add a confirmation field for the user to re-enter their password to ensure accuracy.
codefeedback
Write a JavaScript function to find all unique words in a string, ignoring any common stop words such as "the", "and", "or", and "is".
codefeedback
Write a function to perform bubble sort on an array of integers in ascending order. The function should not use any built-in sorting functions or libraries. The input array can contain duplicate elements and may have a length of up to 10^6. Your implementation should have a time complexity of O(n^2), where n is the l...
codefeedback
Create a C# class that represents a car. The class should have the following properties: - Make: a string representing the make of the car. - Model: a string representing the model of the car. - Year: an integer representing the year the car was made. - Mileage: a double representing the mileage of the car. Implement...
codefeedback
Using the list of strings, create a new list without any vowels. Additionally, remove any duplicates from the final list and sort it in descending order based on the length of the strings. strings = ['apple', 'ball', 'cat', 'dog', 'elephant', 'frog', 'goat', 'hippopotamus', 'iguana', 'jaguar', 'kangaroo'] #Expected O...
codefeedback
Implement a variation of the bubble sort algorithm to sort a given array of 16 elements in ascending order. Additionally, keep track of the number of swaps performed during the sorting process.
codefeedback
Create a function named "parse_urls" which takes a single string parameter and returns a dictionary of queries from the URL. The URL can contain multiple query parameters separated by "&". Each query parameter is represented by a key-value pair, with the key and value separated by an equals sign ("="). The value can be...
codefeedback
Construct a 3 level hierarchical tree data structure in PHP. The tree must be balanced and each level must have a maximum of 5 nodes.
codefeedback
Write a program that takes user input for a name and displays the results from a MySQL query in HTML table format. The MySQL query should retrieve all records from the "employees" table where the name contains the inputted name. The program should also include the following additional features: 1. Validate the user in...
codefeedback
Write a CSS rule to hide all elements with class "hidden" that are nested within a div element with class "container".
codefeedback
Create a JavaScript function to take an array of numbers and return the sum of all its elements, but without using any built-in array methods such as reduce, map, or forEach. The time complexity of your solution should be O(n), where n is the length of the input array. The space complexity should be O(1), meaning you s...
codefeedback
Define a Java annotation that can be used to annotate a method and specify the maximum number of times the method can be called in a given time interval.
codefeedback
Write a Java program to generate a schedule for students with a given set of available IDs and a specified maximum number of courses per student. IDs to be scheduled [1, 2, 3] Maximum number of courses per student: 3
codefeedback