instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Parse a JSON string and transform it into an array. Handle cases where the JSON string is nested or contains arrays as values. Additionally, handle cases where the JSON string contains custom data types and convert them into their appropriate representations in the array. Example: '{"name": "John Doe", "age": 30, "cit...
codefeedback
Use Python to generate a random string of length N (where N is given as input) using lowercase alphabetic characters, uppercase alphabetic characters, and numeric digits. Additionally, the string should contain at least one uppercase alphabetic character, at least one lowercase alphabetic character, and at least one nu...
codefeedback
Construct a C++ class called "Student" with the following data members: 1. A string variable named "name" to store the name of the student. 2. An integer variable named "age" to store the age of the student. 3. An array of floating-point numbers named "grades" to store the grades of the student in different subjects. ...
codefeedback
Create a MySQL statement to count the number of orders for each customer, excluding customers who have placed less than 5 orders in total and have at least one order with a total value higher than $1000.
codefeedback
Design a React component to display a button that increments a counter by a random number between 1 and 10. The component should also display the current value of the counter. Additionally, the component should have a reset button that sets the counter back to 0. However, there are a few additional requirements: 1. I...
codefeedback
Create a Flask endpoint for displaying a paginated list of items from a database, sorted in descending order of price. In case of a tie, sort by name in ascending order. Table name: 'items' Columns: id (integer), name (string), price (float) Requirements: 1. The endpoint should accept two query parameters: 'page' and...
codefeedback
Import the math module in Python and store it in a variable named "import_module". Then, create a function named "calculate_hypotenuse" that takes two parameters, "side1" and "side2", representing the lengths of the two sides of a right triangle. Inside the function, calculate the length of the hypotenuse using the Pyt...
codefeedback
Suggest a way to create a loop of 5 elements in C# that calculates the sum of the first 1000 prime numbers and outputs the average of the sum.
codefeedback
Create a web application that displays a table with five columns: Name, Age, Gender, Address, and Email. Each row should represent a person's information. The table should be sortable by any column when the corresponding column header is clicked. Additionally, the application should allow the user to filter the table b...
codefeedback
Explain the difference between a system call and a library function. Discuss the advantages and disadvantages of using system calls and library functions in a C program. Provide an example of a system call and a library function in the C programming language, and explain how they are used in practice.
codefeedback
Explain the concept of hashing and how it relates to dictionaries in Python. Additionally, write a Python function that takes a list of words as input and returns a dictionary where the keys are the unique words and the values are the number of times each word appears in the list. The function should use a hashing algo...
codefeedback
Create a program that generates an XML file to store customer information, such as name, address, and contact details. The program should allow users to input multiple customer records and save them in the XML file. Additionally, the program should provide functionality to search for specific customers based on their n...
codefeedback
Given an XML string, parse the string and print the tag names and their corresponding values. Additionally, implement error handling to handle cases where the XML string is invalid, if a required tag is missing, or if the tag values do not match a specified data type. Example input: <xml><title>HelloWorld!</title><bod...
codefeedback
Create a Python class for a product that includes data fields for name, description, price, and quantity. Implement a method to calculate the total cost of the product by multiplying the price and quantity together. Additionally, implement a method to validate if the price and quantity are positive numbers. The product...
codefeedback
Explain how constructor chaining works in Java when there are multiple inheritance levels involved, taking into consideration the added constraint that one of the parent classes is an abstract class. Provide an example code snippet to demonstrate the concept, ensuring that the code includes at least one method override...
codefeedback
How would you use a for loop to print the index and item of a list, but with the following additional conditions: 1. Only print the index and item if the item is a string. 2. Print the index in ascending order, starting from 1. 3. Only print the index and item if the index is an odd number. 4. The list should contain ...
codefeedback
Given two strings, determine whether the first string is a substring of the second string. Write a function named "is_substring" that takes in two string parameters, "string1" and "string2". The function should return a boolean value indicating whether "string1" is a substring of "string2" or not. To solve this prob...
codefeedback
Write a code to generate a random password with a given length. The password should contain at least one uppercase letter, one lowercase letter, one digit, and one special character. Additionally, the password should not contain any repeated characters and should follow specific complexity rules: - The length of the pa...
codefeedback
How would you use a while loop to calculate the factorial of a given number, while also ensuring that the calculation is only performed for prime numbers?
codefeedback
Construct a switch statement to return either "Nick" or "Jack" based on the value of the input. The input must be a non-empty string containing only lowercase letters. The output must be a string enclosed in double quotes. The switch statement must have at least five cases. The program should handle both uppercase and ...
codefeedback
Create a program to find the maximum length common subsequence of two given strings. The subsequence should not only be the longest, but it should also have the highest frequency of occurrence in both strings. String1: "abcdgf" String2: "abcdhfe" **Note:** A subsequence is a sequence that can be derived from anothe...
codefeedback
Write a program that performs a case-insensitive substring search with the following additional constraints and requirements: - The substring should only be considered a match if it is surrounded by spaces or punctuation marks. - The search should return the index of the first occurrence of the substring, or -1 if it i...
codefeedback
Create a SQL query that returns the names, job titles, and salaries of all employees in the "Marketing" department, sorted by salary in descending order. Additionally, include the total number of employees in the "Marketing" department, the average salary of all employees in the company, and the maximum salary among al...
codefeedback
Read the two given positive integers and print the larger one. However, you are not allowed to use any comparison operators (such as > or <) in your solution. Additionally, your solution must have a time complexity of O(1) and must not use any built-in functions or libraries to perform mathematical calculations.
codefeedback
Write a code for creating a Fibonacci sequence with the following requirements: - The user should input the value of 'n' where n is the number of terms in the Fibonacci sequence. - The program should validate that the input is a positive integer greater than 1. - The program should handle invalid inputs gracefully and ...
codefeedback
Write a code to split a list of numbers into two sets with equal sum. The sum of the numbers in the list will always be even. The list can contain duplicate numbers. The output should be the two sets of numbers that have equal sums. If it is not possible to split the list into two sets with equal sum, the code should r...
codefeedback
Create an array of 10 integers, where each element is a prime number. Additionally, ensure that the sum of all the elements in the array is a prime number.
codefeedback
Write a SQL query that returns all records from a table where the value in the "email" column contains the "@" symbol, the length of the email is greater than 5 characters, and the domain of the email is a valid domain.
codefeedback
Write a function that takes two strings, "ABC" and "XYZ", as input and returns a list of all possible combinations of characters from both strings. Constraints: - The length of each input string will not exceed 10 characters. - The output list should not contain any duplicate combinations. - The characters in each com...
codefeedback
Write a code to delete a node from a given AVL tree, while also maintaining the property of an AVL tree. Note: An AVL tree is a self-balancing binary search tree where the heights of the left and right subtrees of any node differ by at most 1. Additional Requirements: 1. Your code should have a time complexity of O(l...
codefeedback
Create a Python dictionary that includes the keys "name", "age", "location", "occupation", and "hobbies", and set the values to your name, age, location, occupation, and a list of your hobbies. The dictionary should also include a nested dictionary with the key "education" and its corresponding value should be another ...
codefeedback
Write a Python script to identify all palindromic substrings of length greater than or equal to 4 from a given input string. The script should return a list of all palindromic substrings found. inputString = "racecar" Example: Input: "racecar" Output: ["racecar"] Note: The palindromic substrings can overlap in the i...
codefeedback
Using a regular expression, extract all prices of items from a given HTML string. The HTML string may contain nested div tags and the prices may be mentioned in different formats. Example HTML string: <div> <div> <span>The price of tea is £1.45</span>, the price of burger is £2.50, </div> <div> pric...
codefeedback
Print out the number of items in the following list, but only count the numbers that are divisible by 3. Additionally, ensure that the solution has a time complexity of O(n), where n is the length of the list. my_list = [1, 2, 3, 4, 5, 6, 7]
codefeedback
Write a Java program to implement Matrix multiplication using only bitwise operators and without using any arithmetic operators. The program should also handle matrices of different sizes efficiently. The time complexity of the program should be O(n^3), where n is the size of the matrices.
codefeedback
Write a program to calculate the area and circumference of a circle. The program should prompt the user to enter the radius of the circle, and then display the calculated area and circumference. To calculate the area of a circle, you can use the formula: area = π * radius^2. To calculate the circumference of a circle,...
codefeedback
Write a JavaScript program to check if a given string contains an equal number of P and T characters, at least one U character, and the number of P characters is a multiple of 3.
codefeedback
Construct a Python script to print the last occurrence of a specific character in a string, without using any built-in string manipulation methods or functions (e.g. str.index(), str.rindex(), str.find(), str.rfind(), etc.). string = "Hello world!" character = 'l' You are only allowed to use basic string operations an...
codefeedback
Write a Java program to count the number of unique characters in a sentence without using a loop. Additionally, you should not use any built-in Java methods for counting characters or manipulating strings. The sentence will only consist of lowercase and uppercase letters, spaces, and punctuation marks. The program shou...
codefeedback
Create a function that takes a 2D array of numerical values and returns the number of times the maximum value appears. The function should have a time complexity of O(n^2), where n is the length of the longest row in the 2D array. Additionally, the function should use only constant space complexity, i.e. it should not ...
codefeedback
Create a prompt that takes user input, validates it, and displays a message based on the input. If the input is not valid, provide an error message and prompt the user again until valid input is provided. Additionally, implement a feature that keeps track of the number of attempts made by the user. If the user exceeds...
codefeedback
Use Python to sort a given list of strings in descending order, but with the following additional requirements: 1. Exclude any strings that contain the letter 'e' from the sorting process. 2. Apply a reverse alphabetical order sorting to the remaining strings. 3. If two strings have the same number of characters, prior...
codefeedback
Increase the difficulty by requiring the solution to find the top 10 rows from a matrix with a size of n x m, where n and m are large integers (e.g. n > 1000, m > 1000). Additionally, the solution should only use core Python functionality and not rely on external libraries like NumPy. Furthermore, the matrix may contai...
codefeedback
Create a JavaScript program to convert a given date string into MM/DD/YYYY format. The program should be able to handle different date formats (e.g., "October 5, 2020", "5th October 2020", "10/5/20") and support multiple languages. Additionally, the program should validate the input date and handle any errors or invali...
codefeedback
Build a regression model to predict house prices based on crime rate, school quality, the number of nearby amenities such as parks, restaurants, and shopping centers, as well as other features such as the size of the house, the age of the house, and the average income of the neighborhood. Additionally, provide a piece ...
codefeedback
Generate an HTML select element containing the names of all continents and their corresponding population, ordered by the continent with the highest population first. Additionally, each continent name should be displayed in uppercase letters, and the population should be formatted with commas separating thousands.
codefeedback
Write a program to generate a Fibonacci sequence up to the n-th number using recursion. However, the program should handle large values of n (greater than 10^6) efficiently and without causing a stack overflow. Additionally, the program should implement memoization to optimize the recursive calls and reduce redundant c...
codefeedback
Write a SQL query to select the employee name, start date, and salary of all employees who have joined after 2018 and have a salary greater than the average salary of all employees in the company. Additionally, include the department name of each employee in the result set.
codefeedback
Find the last 1000 digits of the result of raising 2 to the power of 10^18.
codefeedback
Create a Django model that includes a user's name, email address, age, and a list of their favorite books. Additionally, the model should include a field to store the date the user joined the platform. The model should also have a method that calculates the user's current age based on their birth date, which is not di...
codefeedback
Suggest a way to complete the following Python program which takes two strings as input and prints out the longer string. The program should have a time complexity of O(1) and should not use any built-in functions or libraries that directly determine the length of the strings. You may use any other built-in functions o...
codefeedback
Use NumPy to create a 3x3 array of random numbers from -1 to 1, where each element in the array is unique.
codefeedback
Create a shell script that prompts the user to enter a directory name, and then creates the directory in the home directory. Additionally, the script should check if the directory already exists and provide an error message if it does. Furthermore, the script should validate the user's input to ensure that the directo...
codefeedback
Create a function that takes two string arguments, where each string represents a large number with up to 10^6 digits. The function should add the two numbers together and return the result as a string. For example: string1 = "12345678901234567890" string2 = "98765432109876543210" The function should return "111111111...
codefeedback
Design a struct in C that can be used to store personal information, such as name, age, address, phone number, and email. The struct should also include a function that allows the user to calculate the person's BMI based on their height and weight. In addition, the struct should include a function that allows the user...
codefeedback
Write a JavaScript function that capitalizes every word in a sentence, excluding any words that start with the letter 'a'. The function should also reverse the order of the words in the sentence. The function should have a time complexity of O(n), where n is the length of the sentence. Example: Input: 'hello world an...
codefeedback
Implement a deep learning model to analyze the sentiment of a given text. Use a pre-trained word embedding model, such as GloVe or Word2Vec, to convert the text into numerical representations. Build a recurrent neural network (RNN) or a transformer model, such as GPT-2 or BERT, to learn the sentiment expressed in the t...
codefeedback
Find the similarity between two given paragraphs using NLTK library. paragraph1 = "This has been an exciting journey with lots of ups and downs. I have learned so much and grown as a person." paragraph2 = "It's been a thrilling ride full of unexpected twists and turns. I have faced numerous challenges and come out stro...
codefeedback
Write a Python code that takes in a tuple of integers and returns a new tuple that contains only the prime numbers from the original tuple.
codefeedback
Read the given JSON data and display the value of the "Name" field. The program should also validate if the value of the "Version" field is in the format of a semantic version (e.g., 1.0.0). If it is not in the correct format, display an error message. Additionally, the program should check if the value of the "Depende...
codefeedback
Write a function to compute the factorial of a number using recursion. Make sure to handle edge cases such as negative numbers and non-integer inputs. Additionally, modify the function to check if the input number is within the range of 0 to 10 (inclusive) and raise a custom exception of type `FactorialOutOfRangeError`...
codefeedback
Construct a program that can calculate the factorial of a number using a while loop. Additionally, the program should handle negative numbers and return an error message if the input is not a valid number. However, to increase the difficulty, you should also implement the factorial calculation using recursion and com...
codefeedback
Create a program to find the longest substring with unique characters and return the length of the substring. If there are multiple substrings with the same longest length, return the first occurring substring. You can assume that the input string only contains lowercase English alphabets (a-z). #Example# Input: "aaa...
codefeedback
Create a SQL query to find all first names in the table 'Employee' that start with the letter 'A' and have more than 5 characters, and also have at least one vowel and one consonant.
codefeedback
Write a SQL statement to retrieve the first three customers from a table, sorted by their total order amount in descending order. The statement should only consider customers who have placed at least 5 orders.
codefeedback
Create a SQL query to get the top 5% highest salaries in the table 'Employee' for employees who have been with the company for at least 5 years, ordered by salary in descending order.
codefeedback
Create a new Python dictionary with numbers 1-10 as keys and their corresponding squares as values. Ensure that the keys and values in the dictionary are stored in descending order. Additionally, handle any potential errors or exceptions that may occur during the creation of the dictionary.
codefeedback
Implement an optimized version of insertion sort that can efficiently sort a large array of integers in ascending order. The input array can contain duplicate values and may have a length up to 10^6. The implementation should have a time complexity of O(n^2) and a space complexity of O(1). Additionally, the algorithm s...
codefeedback
Construct a function to detect if a binary tree is balanced. A binary tree is balanced if the heights of the two subtrees of any node never differ by more than 1. ## Input: - The root of a binary tree. ## Output: - Return True if the binary tree is balanced, False otherwise. ## Example: ```python tree = TreeNode(3)...
codefeedback
Given a SQL table named `Users` with columns `id`, `name`, and `age`, write a query to select all the records where the `name` column contains the value `John` and the `age` column is greater than 25. Additionally, sort the results in descending order based on the `age` column. To solve this problem, you can follow th...
codefeedback
Write a Python function that takes an array of strings as an argument and returns a boolean. The function should only return True if all the strings in the array contain at least two digits and two uppercase letters. Otherwise, the function should return False.
codefeedback
Create a JavaScript function to find the length of the longest common substring between two given strings. Additionally, ensure that the function returns the actual longest common substring itself.
codefeedback
Create an array of objects in JavaScript that contains twenty objects, each representing a different programming language. Each object should have the following properties: name (string), year (number), creator (string), and popularity (number). The popularity property should represent the number of users of the progra...
codefeedback
Create a Swift program to display the letters of the English alphabet in ascending order, but excluding vowels (a, e, i, o, u). The program should take into account both uppercase and lowercase letters, and should display the letters in the following format: Upper Case Letters: A, B, C, D, ... Lower Case Letters: a...
codefeedback
Write an HTML page with an input form having three text input fields. 1. The first input field should only accept alphabetic characters and should have a maximum length of 10 characters. Additionally, it should have a validation feature that checks if the input contains at least one uppercase letter and one lowercase...
codefeedback
Create a database system to store information about a library, including details about books, authors, and genres. The system should allow for easy addition, modification, and deletion of books. Additionally, it should support querying for books based on different criteria such as author, genre, and publication year. T...
codefeedback
Develop a program that prints out the output of the following expression, but you are not allowed to use any loops, list comprehensions, or recursion. [2, 4, 6, 8]
codefeedback
Code a function to clamp a given number between a minimum value and maximum value. However, if the given number is negative, return the absolute value of the number before clamping it. The input number can be a floating-point number and the minimum and maximum values can be floating-point numbers as well. Additionally,...
codefeedback
Create a function in Python which takes a list of strings as an argument and returns a new list where each string is modified according to the following rules: 1. The first character of each string should be converted to uppercase. 2. Any leading or trailing whitespace in each string should be removed. The function s...
codefeedback
Suggest a solution to store years in ISO 8601 format in Python, but also include the functionality to convert the ISO 8601 format to a different date format such as 'dd-mm-yyyy'. Additionally, implement a validation mechanism to ensure that the input ISO 8601 format is valid and strictly adheres to the standards specif...
codefeedback
Write a code to get the top 1000 trending topics on Twitter with their volume using the Twitter API, but you are only allowed to make a maximum of 10 API calls in total.
codefeedback
Write a Python function that takes in a list of strings and sorts them based on their length in descending order. Your function should not use any built-in sorting functions or libraries.
codefeedback
Suggest an efficient algorithm for validating a password which should contain at least 1 uppercase character, 1 lowercase character, 1 digit, and 1 special character. Additionally, the password must be between 10 and 16 characters in length, cannot contain any spaces, and should not contain any repeating characters con...
codefeedback
Build a MapReduce job with Hadoop to find the 99th percentile of a given data set, while also calculating the median. Additionally, implement a custom combiner to optimize the intermediate data transmission and reduce network traffic. Explain why the custom combiner is necessary and how it improves the MapReduce job pe...
codefeedback
Write a script which takes a list of integers as an argument and shuffles it. The script should not use any built-in functions or libraries for shuffling. The shuffled list should have all even numbers before odd numbers, with the order of the even numbers and odd numbers preserved. The original list should remain unch...
codefeedback
Implement a Fibonacci series generator using Python that only generates the Fibonacci numbers up to a given input limit, and prints the sum of all the generated numbers. Additionally, the implementation should be optimized to have a time complexity of O(n) and a space complexity of O(1), where n is the given input limi...
codefeedback
Generate an HTML page that displays a table of data fetched from a remote API. The table should have the following columns: "Name", "Age", "City". The data should be sorted by name in ascending order. The remote API returns a large amount of data, consisting of thousands of records. The table should only display a max...
codefeedback
Create a program using PHP to display the length of the longest common substring in two given strings. Additionally, ensure that the program handles cases where there are multiple longest common substrings with different lengths, and output all of them. However, the program should not use any built-in PHP functions for...
codefeedback
Introduce a vector of size 10^6 with all elements initialized to random integers between 1 and 1000. Additionally, you must implement a function that can efficiently find the sum of all elements in the vector using only O(log n) time complexity and O(1) space complexity. The function should also return the maximum and ...
codefeedback
Construct a program that prompts the user to enter a range of numbers and then prints out all prime numbers within that range. The program should also display the total number of prime numbers found. Here are the steps to solve the problem: 1. Prompt the user to enter the starting and ending numbers for the range. 2....
codefeedback
Write a Python function called `is_prime` that takes an integer as input and returns a boolean value indicating whether the input is a prime number or not. A prime number is defined as a number greater than 1 that has no positive divisors other than 1 and itself. Additionally, the function should be able to handle lar...
codefeedback
Write a class in Python to represent a division with two integers and the following operations: addition, subtraction, multiplication, division, exponentiation, and modulo. Additionally, implement a method to calculate the factorial of a number. You should also add the following additional requirements: 1. Implement ...
codefeedback
Compute the maximum value in a random array, but only consider the values that are divisible by 3. Additionally, you are not allowed to use any built-in sorting or filtering functions. [4,6,9,2,11,7]
codefeedback
Output the sum of the 3rd and 5th elements in the given array multiplied by the 2nd element, and then subtract the 4th element from the result. [5, 10, 20, 12, 15, 7]
codefeedback
Compare 2 databases and update non-matching information from database A to database B using SQL. Table A: | id | name | age | |----|------|-----| | 1 | John | 20 | | 2 | Joe | 25 | | 3 | Mary | 30 | Table B: | id | name | age | |----|------|-----| | 1 | John | 25 | | 2 | Joe | 25 | | 3 | Alex | 35 ...
codefeedback
Create a program that finds the sum of all numbers divisible by 4 between 150 and 300, where the sum should only include numbers that are also divisible by 5. Additionally, the program should exclude any numbers that are divisible by both 2 and 3.
codefeedback
Construct an SQL statement to select data from four tables, with a minimum of three joins, and include a subquery.
codefeedback
Write a SQL statement to delete all records from a table called 'students' where the grade is below 3, but only if the student's enrollment date is before January 1st, 2022 and the student's nationality is 'United States'.
codefeedback
Write a PHP function called 'getUniqueValues' that takes an array called 'data' as input and returns an array containing only the unique values from the 'data' array. The function should have a time complexity of O(n) and a space complexity of O(n), where n is the number of elements in the 'data' array. Additionally, ...
codefeedback
Explain the step-by-step process of using the `keras.preprocessing.sequence.pad_sequences` function in the Keras library to preprocess and pad variable-length sequences of text data for input to a recurrent neural network model.
codefeedback