instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Implement a function in C++ that takes two strings as parameters and returns the length of the longest common substring between the two. Additionally, you should implement an algorithm with a time complexity of O(n^2) or better. str1 = "aaaaaaaaaaaaaaa" str2 = "aaaaaaaaaaaaaaabbbbbb" In this modified test, the input ...
codefeedback
Write a Java method to remove repeated elements from an array of integers, while maintaining the original order of the elements. Additional requirements: 1. The time complexity of the method should be O(n), where n is the length of the array. 2. The space complexity of the method should be O(n) as well, where n is the...
codefeedback
Create a dictionary and parse the following JSON object into it. The parsed dictionary should only include the "name", "age", and "hobbies" fields. Additionally, the "name" field should be converted to uppercase letters in the parsed dictionary. The program should also validate that the "age" field is a positive intege...
codefeedback
Generate a customized welcome message that welcomes a given customer by name. The welcome message should include the customer's full name, their preferred title (Mr., Mrs., Miss, Dr., etc.), and their age. The customer's age should be calculated based on their date of birth, which is provided in the format "YYYY-MM-DD"...
codefeedback
Write a code snippet that adds two matrices of equal sizes and stores the result in a new matrix. The size of the matrices will be given as inputs to the code snippet. The input matrices should have a maximum size of 1000x1000 and contain only integer values. The code snippet should handle cases where the input matrice...
codefeedback
Implement a linked list using C language with the following additional requirements: 1. Each node in the linked list should contain two fields: a data field to store an integer value, and a pointer field to point to the next node in the list. 2. The linked list should support the following operations: - Insertion o...
codefeedback
Generate a code to parse an HTML string and extract the body text only. The HTML string will contain nested elements such as <div>, <span>, <ul>, <li>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <strong>, <em>, <a>, <img>, <table>, <tr>, <td>, etc. The code should handle nested elements up to a depth of 5 levels and extract t...
codefeedback
Write a Python script that detects if a given text contains any URL and returns the number of URLs found. Additionally, extract and print the domain name of each URL found.
codefeedback
Generate a program to sort the list in descending order without using any built-in sorting functions. unsorted_list = [3, 5, 1, 0, 9]
codefeedback
Generate a code to transform each string in the list into the upper case and sort the list in descending order based on the length of the strings.
codefeedback
Print out the first 20 elements in the sequence interpreted by the rule F(n) = F(n-1) + F(n-2), where F(0) = 0 and F(1) = 1.
codefeedback
Create a function that generates a random string of length n using only uppercase letters and numbers.
codefeedback
Construct a sorting algorithm to sort an array in increasing order. Write a function called `bubble_sort` that takes in an array of integers and returns the sorted array. The `bubble_sort` function should implement the bubble sort algorithm, which works as follows: - Start at the beginning of the array and compare ea...
codefeedback
Create an object oriented program to print the Fibonacci sequence, but with the following additional requirements: 1. The program should only use iterative (non-recursive) methods to calculate the Fibonacci sequence. 2. The program should print the Fibonacci sequence up to the nth term, where n is a user-defined input....
codefeedback
Generate a syntax-correct program to calculate the sum of the elements in a given 2D array, but ensure that the program also checks for and handles any potential runtime errors, such as a null array or an array with mismatched dimensions.
codefeedback
Generate a syntax correct program which reverses a given linked list without using any built-in functions or data structures.
codefeedback
Construct a HTML page that displays a form with two text fields, a dropdown menu, and a submit button. The first text field should only accept alphanumeric characters and have a maximum length of 10 characters. The second text field should only accept numeric characters and have a minimum length of 5 characters. The dr...
codefeedback
Create a JavaScript function to return the longest string from an array. The function should have a time complexity of O(n), where n is the length of the array. The space complexity should be O(1). Example: ``` Input: ["Hi", "Hello", "Good Morning"] Output: "Good Morning" ```
codefeedback
Create a C++ program to create a triangle with the maximum possible area given three side lengths a, b, and c, where a, b, and c are integers between 1 and 100 (inclusive). The program should output the side lengths of the triangle and its corresponding area.
codefeedback
What operator should be used to compare two strings in a programming language using a case-insensitive comparison and also returning true if the strings are anagrams of each other?
codefeedback
Calculate the area of a parallelogram with base lengths 5m and 8m and height of -4m.
codefeedback
Write a code snippet to convert the text to lowercase, but only for vowels.
codefeedback
Write a Java method to return the kth largest element from an array of integers, where k is provided as an input parameter. The array may contain duplicate elements. [4, 8, 3, 10, 6], k = 2
codefeedback
Write a JavaScript function to convert a CamelCase string to a snake_case string. The function should handle special characters and numbers, and the resulting snake_case string should start with a lowercase letter and only contain lowercase letters and underscores. The function should have a time complexity of O(n), wh...
codefeedback
Write a REGEX pattern to only match valid JavaScript variable names, with the additional requirement that the variable name must start with a lowercase letter and can only contain lowercase letters, uppercase letters, underscores, and digits.
codefeedback
Generate a correct SQL query to return all customers' names, their total orders, and the average order amount for each customer. Also, sort the result in descending order based on the total orders.
codefeedback
Classify this problem as either a multi-class classification or a regression problem. Predict the future value of a stock based on past data, considering the market trends, news sentiment analysis, and technical indicators. Ensure the solution handles missing data gracefully and include a feature selection step to impr...
codefeedback
Add a class attribute to the given Python class, where the attribute is a dictionary that stores the student's name and age as key-value pairs.
codefeedback
Create a loop to print "I love Python" ten times, but make sure that the loop variable increments by 2 each time.
codefeedback
Create a function that takes input as a string and returns the number of occurrences of each unique word in the string. The function should ignore punctuation and consider words in a case-insensitive manner.
codefeedback
Create a while loop to iterate over the elements in the given list my_list, but only iterate until the sum of the elements encountered so far exceeds a certain threshold value. The threshold value should be the product of the previous two elements encountered in the iteration. If the sum exceeds the threshold, the loop...
codefeedback
Write code to encrypt a string using the Caesar cipher. The Caesar cipher is a substitution cipher where each letter in the plaintext is shifted a certain number of places down or up the alphabet. For example, with a shift of 1, 'A' would be replaced by 'B', 'B' would become 'C', and so on. The alphabet wraps around, ...
codefeedback
Create a data structure in Java to store books and their associated information like ISBN, authors, publication date, and number of pages. Implement the following operations: 1. Add a new book to the collection. 2. Remove a book from the collection. 3. Search for a book by its ISBN and return its details. 4. Update th...
codefeedback
Parse a JSON string and print all the key-value pairs in alphabetical order. Also, count the number of key-value pairs that have a value greater than 2 and print the count at the end. { "orange": 4, "apple": 1, "banana": 2, "mango": 3, "grape": 5 }
codefeedback
Given a dictionary, write a program to create a new dictionary where the values are the keys and the keys are the values. Additionally, add a condition where the new dictionary should only include keys that have an odd length. Example: Input: {"apple": 1, "banana": 2, "carrot": 3, "tomato": 4} Output: {1: "apple", 3:...
codefeedback
Construct a shell script to find the sum of all odd numbers between 1 and 100, inclusive.
codefeedback
Create an HTML page with a blurred background image and centered text "Hello World". The background image should be fetched asynchronously from an external API, and the blur effect should be applied dynamically using CSS. Additionally, the text "Hello World" should be animated to fade in and out continuously.
codefeedback
Given a matrix of size n x m, write a program to rotate it by 90 degrees clockwise. The matrix will contain positive integers ranging from 1 to 1000. #Newly Added Requirement# In addition to rotating the matrix by 90 degrees clockwise, your program should also swap the values in the upper and lower halves of the matri...
codefeedback
Create a script that extracts the page titles from the given HTML page. However, the HTML code may contain nested elements and the page titles may be enclosed in different HTML tags such as `<h1>`, `<h2>`, `<title>`, `<div>`, or `<p>`. The script should be able to handle all these cases and extract the correct page tit...
codefeedback
Design a function to take a URL and return the content of the URL, but only if the URL is encrypted using TLS version 1.2 or higher. If the URL is not encrypted using TLS version 1.2 or higher, the function should raise an exception.
codefeedback
Implement a function that takes in 2 strings and returns a new string consisting of alternating characters from the strings passed in. If one of the strings is shorter than the other, append the remaining characters of the longer string to the end of the resulting string. However, if both strings are of the same length...
codefeedback
Create a function to check the validity of an email address. The email address must have a minimum length of 5 characters and a maximum length of 50 characters. It should also contain an "@" symbol and a domain name with at least 2 characters. Additionally, the function should check if the email address is in a valid f...
codefeedback
Create a class in Java for a Person object with the following fields: name (string), age (integer), and address (string). The Person class should have the following methods: 1. A constructor that initializes the name, age, and address fields. 2. Getter methods for all three fields. 3. A setter method for the address...
codefeedback
Write a function that takes in a dictionary as input and a key name as a parameter. The function should return the value associated with the given key in the dictionary. If the key is not found in the dictionary, the function should return None. You should also handle cases where the input dictionary is empty or wh...
codefeedback
Write a web scraping program to extract all the hyperlinks from a given webpage, and sort them in alphabetical order.
codefeedback
Calculate the factorial of a positive integer using recursion, with a time complexity of O(n) and a space complexity of O(n).
codefeedback
Create a JavaScript program to calculate the Fibonacci number for a given integer n, but this time, the program should not use recursion.
codefeedback
Find the maximum sum of a subarray of size 'k' in a given array. The subarray must be contiguous and cannot contain any duplicate elements. If multiple subarrays have the same maximum sum, return the subarray with the smallest starting index. Example: arr = [1, 4, 2, 10, 23, 3, 1, 0, 20] k = 4 Expected output: [4, 2,...
codefeedback
Write a function to create a new nested list with twice the length of the original, while also reversing the order of the elements in each sublist. Additionally, the function should remove any duplicates within each sublist. original_list = [1, 2, [3, 4], [4, 5, 6], 5]
codefeedback
You need to check a given list of strings to determine if it contains all valid English words. Output true if so, output false otherwise. #Updated Test# You need to check a given list of strings to determine if it contains all valid English words. Output true if so, output false otherwise. The list may contain duplic...
codefeedback
How do you create a new array of the same size as an existing array but with every element as the sum of its index and the previous element in Java?
codefeedback
Implement an algorithm to solve the Tower of Hanoi problem iteratively instead of recursively.
codefeedback
Write a recursive code to walk through a binary search tree (BST) and print out all the elements in reverse order. The time complexity should be O(n) and the space complexity should be O(h), where n is the number of nodes in the BST and h is the height of the BST.
codefeedback
Find all the prime numbers in between two given numbers.
codefeedback
Write a JavaScript function that generates a series of numbers from `10` to `41`, with each number being a prime number.
codefeedback
Using an SQL query, sum up the total cost of all items in the product table and group the result by category.
codefeedback
Using a database query, count the number of employees in a company database and display the count in descending order based on the number of projects they are assigned to.
codefeedback
Replace the commented out code with a single line of code that calculates the product of all elements in the array, but without using any loops or recursion.
codefeedback
Write a JavaScript function that takes in two numbers as arguments and returns their sum. The function should not use the "+" operator or any other arithmetic operators. Instead, you should use only bitwise operators and logical operators to perform the addition. Example: ```javascript function bitwiseAddition(a, b)...
codefeedback
Using a loop and a conditional statement in Python, check if the number is a prime number. A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. 1. Declare the variable "number" and assign a value to it (e.g., 13). 2. Check if the number is less than or equal to 1. ...
codefeedback
Determine the maximum sum of a subarray within the given array, but with the constraint that the subarray must contain at least two elements.
codefeedback
Edit the following Java program to add a method printMyName. The method should print your name followed by the number of characters in your name. Note: You are not allowed to use any built-in Java methods to calculate the length of your name (e.g., length() or size()). public class HelloWorld { public static void...
codefeedback
Build a JavaScript program to compute the largest prime number less than a given number N, using the Sieve of Eratosthenes algorithm.
codefeedback
Write a SQL query to calculate the number of days between two date fields, ensuring that the result excludes weekends and holidays.
codefeedback
Create an algorithm to find the longest continuous increasing subarray in an array of positive integers, with the additional requirement that the subarray must contain at least three elements.
codefeedback
Design a data visualization to show the average salary per gender, taking into account different industries and job levels.
codefeedback
Create a class in Java that creates a calculator with advanced mathematical functions, including addition, subtraction, multiplication, division, square root, logarithm, exponentiation, and factorial of two numbers. The calculator should be able to handle large numbers (up to 10^9) and floating-point numbers with high...
codefeedback
Implement an algorithm to select k elements from an array such that the sum of those elements is maximized, but with the following constraints: - The selected elements must be non-consecutive in the original array. - The selected elements must be non-repeating. - The time complexity of the algorithm should be O(n), whe...
codefeedback
Write a Java program to produce the Fibonacci sequence up to a given number, but with a twist. Instead of starting with 0 and 1, start with two user-defined starting numbers. The program should take two integers as input from the user, representing the first two numbers in the sequence, and then produce the Fibonacci s...
codefeedback
Construct an API using Flask that returns an array of distinct positive integers in ascending order, where each integer is a prime number, in response to a request. The API should also include a query parameter to specify the range of the prime numbers to be returned, and the default range should be from 2 to 100.
codefeedback
Categorize the words from the list ["Apple", "Carrot", "Banana", "Tomato", "Lemon"] into their respective groups based on the number of vowels in each word. Return a dictionary where the keys are the number of vowels and the values are lists of words with that number of vowels. The input list can contain duplicates and...
codefeedback
Write a query to find users who have more than 5 posts and their account has been active for at least 6 months in a table.
codefeedback
Write a JavaScript function to find the first three prime numbers that are also common in three arrays. The prime numbers should be greater than 100. Array A: [2, 3, 5, 6, 7, 9] Array B: [5, 7, 10, 11, 15] Array C: [7, 9, 10, 11, 12]
codefeedback
Write a SQL query to find the average number of 'likes' for each post in a table, where the posts are only from the past month and have at least 100 likes. Additionally, display the average number of comments for each post alongside the average number of likes.
codefeedback
Suggest three methods for removing duplicate elements from an array in JavaScript, while maintaining the original order of the elements. The time complexity should be O(n), where n is the number of elements in the array. Additionally, please do not use any built-in JavaScript methods or libraries.
codefeedback
Design a Python class structure for playing cards with three classes: Deck, Card, and Player. The Deck class should have methods to initialize a deck of cards, shuffle the deck, and deal cards to players. It should also keep track of the number of remaining cards in the deck. The Card class should have attributes fo...
codefeedback
Create a function in JavaScript that takes a start year and an end year as parameters and returns an array of all the leap years within that range. The function should also handle invalid inputs, such as non-numeric years or an end year that is smaller than the start year.
codefeedback
Explain the uses of AJAX in web development and provide a code example showcasing its implementation. Additionally, discuss the potential drawbacks or limitations of using AJAX in certain scenarios.
codefeedback
Write a program to replace the first letter of each word in a given string with an underscore (_). Sample Input: "Hello World!" Sample Output: "_ello _orld!"
codefeedback
Calculate the frequency of occurrence of each letter in a sentence, taking into account punctuation marks and case sensitivity. sentence = "The quick brown fox jumps over the lazy dog."
codefeedback
Use TensorFlow to build a convolutional neural network (CNN) to classify the MNIST digits.
codefeedback
Rewrite the given JavaScript snippet into Standard Form, but without using the `onMouseOver` event. Instead, use the `addEventListener` method to attach a `mouseover` event to the element and change the cursor style to `'pointer'` within the event handler function.
codefeedback
Using Perl, write a program that reads a text file and extracts all email addresses from it. The program should then count the occurrences of each domain and display the top 3 domains with the highest number of occurrences.
codefeedback
Make an array with 10 prime numbers between 0 and 100.
codefeedback
Calculate the GCD of numbers 8 and 12 using the Euclidean algorithm.
codefeedback
Use HTML, CSS, and JavaScript to format a responsive page with three columns, two of which contain two paragraphs each and the last containing a dynamically generated list of 10 items fetched from an API. The page should also include a search functionality that filters the list based on user input, and a button that tr...
codefeedback
Add a method called "printTitle" to the “Book” class defined above. This method should take no parameters and should return the title of the book as a string. The title should be displayed in uppercase letters with each word separated by a single space. Additionally, the method should remove any leading or trailing spa...
codefeedback
Design and implement a convolutional neural network (CNN) for image classification. The CNN should have at least three convolutional layers with different kernel sizes and pooling layers. Additionally, the CNN should include at least two fully connected layers and utilize a dropout layer for regularization. Train the C...
codefeedback
Create a 4x4 matrix filled with random numbers between -100 and 100, with the following additional requirements: 1. The sum of each row must be divisible by 3. 2. The sum of each column must be a prime number. 3. The sum of all numbers in the matrix must be negative.
codefeedback
Reverse the order of the elements in the list using recursion. [1, 2, 3, 4, 5]
codefeedback
Construct a query using MongoDB to find all the documents with a "city" field that equals "New York" and a "population" field greater than 1 million.
codefeedback
Construct a query using MongoDB to find documents where the "user_id" field contains any number greater than 5 and the "age" field contains any number greater than or equal to 18.
codefeedback
Implement a dynamic programming solution to find the maximum sum of a subarray in a given array of integers.
codefeedback
Write a SQL query to sort the records by the given field in descending order, but only for records that have a price greater than 100.
codefeedback
Create a function to calculate the volume of a specific 3D shape called a "frustrum". The frustrum is a cone with the top cut off by a plane parallel to the base. The function should take the following parameters: - base_radius: the radius of the base of the frustrum (float) - top_radius: the radius of the top of the ...
codefeedback
Write an Apache Spark program to count the occurrence of each word in the given dataset. Additionally, for each word, compute the percentage of its occurrence out of the total number of words in the dataset. Finally, output the word, its count, and its percentage of occurrence, sorted in descending order of count.
codefeedback
Create a SQL query to retrieve the first name, last name, and email address of each customer whose total number of orders is greater than 10. Sort the results in descending order of the total number of orders.
codefeedback
Write a Bash script to print a message when the system time is between 8pm and 8am, only on weekdays and excluding public holidays.
codefeedback
Write a script to display the Fibonacci sequence up to the 100th number in the console.
codefeedback
Analyze the given statement for any syntax errors and logical errors. Statement: The user entered his name James and password1234, and the program should verify if the password meets the following criteria: 1. The password must be at least 8 characters long. 2. The password must contain at least one uppercase letter, o...
codefeedback