instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Create a React component to sort an array of objects in ascending order based on a specific property. The component should take in an array of objects as a prop, where each object has a "name" property. The component should display the sorted array based on the "name" property. Additionally, the component should inclu...
codefeedback
Write a function in C++ to convert a list of integers to a tuple, where each element in the tuple must be a positive integer and a prime number. Additionally, the function should sort the integers in ascending order before converting them to a tuple.
codefeedback
Create a function in JavaScript that takes a string and a number as arguments, and returns a new string with the following modifications: 1. The first number of characters (specified by the number argument) should be replaced with the character '@'. 2. The replacement should only be applied to lowercase alphabetic cha...
codefeedback
Create a deep learning neural network in Keras that can accurately classify images from the CIFAR-10 dataset. The network should consist of the following layers: 1. Convolutional layer with 64 filters, a kernel size of 5x5, and a ReLU activation function. 2. Convolutional layer with 64 filters, a kernel size of 5x5, a...
codefeedback
Given a list of integers, find the smallest and the largest of the set. However, the list may contain duplicate values and you should only consider the first occurrence of each value. If the list is empty, return None for both the smallest and the largest values. In addition, the code provided should include a functi...
codefeedback
Perform a radix sort on the given list. List: [9876, 5432, 1098, 7654, 3210, 2468, 1357] In radix sort, we sort the elements based on their digits, starting from the least significant digit to the most significant digit. 1. First, we initialize a list of empty buckets, one for each possible digit (0-9). 2. We itera...
codefeedback
Using the given JSON string, parse the string and convert it into an object or array in JavaScript. Additionally, ensure that the object or array is sorted alphabetically based on the keys and the values are formatted as strings with the first letter capitalized and the rest of the letters in lowercase. Finally, implem...
codefeedback
Write a program to parse and extract dates from a given text that may contain multiple date formats. The conference will be held on Wednesday, June 16th, 2021, at 10:00 AM. However, please note that there are other events scheduled as well. For example, there will be a workshop on Friday, July 2nd, 2021, from 2:00 PM ...
codefeedback
Write a Bash script that prompts the user to input a regular expression and then searches for the line that matches that regular expression from the output of a command. Specifically, use the command "ls -l" to generate the output and grep the line that matches the user-provided regular expression. Ensure that the scri...
codefeedback
Write a MySQL query to insert new records in an 'Employees' table and return the number of records added. The query should ensure that the name of the employee is unique, and if a record with the same name already exists, update the existing record with the new age and job title. The query should return the number of r...
codefeedback
Implement a shell script to retrieve the IP address of a website. However, the script should also check if the website is currently accessible by performing a full TCP handshake and return an error message if it is not. Additionally, the script should display the time taken to retrieve the IP address and handle any pot...
codefeedback
Write a JavaScript function to format a given number of seconds into hours, minutes, and seconds. The function should return a string in the format "HH:MM:SS". The input number can be any positive or negative integer. In addition to the previous requirements, your solution should now also handle input values greater t...
codefeedback
Write a method in Java to return a reversed version of a given string, but only reverse the alphabetical characters in the string while keeping the non-alphabetical characters in their original positions. Additionally, make sure the method is case-insensitive, meaning that the reversal should work for both uppercase an...
codefeedback
Identify and display all the data types within the column 'price' in a table named 'products'. Additionally, calculate and display the average price of all the products in the table. Please note that the 'price' column contains both numeric and string values. Make sure to handle any type errors appropriately and exclud...
codefeedback
Write a JavaScript function that takes an object as input and returns an array of all the key names in the object. The function should handle nested objects as well. However, the provided solution has a bug that results in a ReferenceError when the object contains a key with a value of null. Fix the bug in your impleme...
codefeedback
Create a SQL database containing seven tables. Each table must have at least ten columns and four of the tables should have foreign key constraints referencing primary keys from other tables. Additionally, three of the tables should have columns with unique constraints.
codefeedback
Write a program that parses a JSON string and prints each key-value pair to the console. The program should be able to handle nested JSON objects and arrays as well. Input: '{"name": "John", "age": 30, "address": {"street": "123 Main St", "city": "New York"}, "hobbies": ["sports", {"type": "chess", "level": "advanced"...
codefeedback
Find and display the top 10 employees who earn more than the 90th percentile salary across all departments, excluding any employees who are part-time or have less than two years of experience. Additionally, sort the employees by their job titles in ascending order and display their full names, job titles, departments, ...
codefeedback
Create a C# program to print out the current date and time in the format "dd/MM/yyyy HH:mm:ss" and prompt the user to enter their name. The program should then display a personalized greeting along with the date and time. However, the program should only allow the user to input their name using a maximum of 10 characte...
codefeedback
Create a Python program to accept a string from the user and print out the number of vowels in the string. The program should exclude any occurrences of the letters 'e' and 'u' from the count of vowels. Additionally, the program should ignore any vowels that are followed by a consonant. The program should also handle u...
codefeedback
Create a Python script that accepts a list of positive integers from the user and prints out the sum of the squares of the digits for each number in the list. The script should have the following requirements: - Accept a list of positive integers from the user as input. - Validate that the input is a list of positive...
codefeedback
Create an HTML form to allow a user to enter their contact information with additional requirements. Fields requested: Full Name, Email Address, Phone Number, Birthdate, Gender Additional Requirements: 1. The Full Name field should only accept alphabets and spaces. The input should be case-insensitive and allow for a...
codefeedback
Create a Node.js express server to serve a web page when the root route is requested. Additionally, implement the following functionalities: 1. Allow users to register and log in to the web page. 2. Use a database to store user information, including their username and password. 3. Implement authentication middleware ...
codefeedback
Create a code to validate an email address using Regular Expressions. Additionally, ensure that the email address contains at least one uppercase letter, one lowercase letter, one digit, and one special character. The special character must be one of the following: ! @ # $ % ^ & * ( ) _ - + = { } [ ] : ; " ' < > , . ? ...
codefeedback
Write code that removes spaces and punctuation marks from a given string and returns the modified string. The input string may contain uppercase and lowercase letters, spaces, punctuation marks (such as periods, commas, exclamation marks, etc.), and digits. The modified string should only contain the alphanumeric chara...
codefeedback
Write a function to generate the nth Fibonacci number. The function should have a time complexity of O(n) and use dynamic programming.
codefeedback
Create a nested loop to print every combination of numbers between 0-9, excluding any combination that contains the number 5.
codefeedback
Formulate an equation to calculate the height of a triangle given the angle, side lengths, opposite side length, and the ratio of the side lengths. The equation should take into account the Law of Sines and the Law of Cosines.
codefeedback
Create an array of length 15 containing numbers divisible by 3 up to 45. Each number in the array must be unique and in ascending order. Additionally, the sum of all the numbers in the array should be a prime number.
codefeedback
Write code to find the sum of all numbers between 1 and 1 million.
codefeedback
Write a class to represent a 2D point with x and y coordinates. Include the following functionalities: 1. Calculate the distance between two points. 2. Determine if two points are equal. 3. Calculate the midpoint between two points. 4. Implement a method to rotate a point around the origin by a given angle in degrees. ...
codefeedback
numbers = [i for i in range(10) if i % 2 == 0]
codefeedback
Create a C++ program for randomly shuffling an array of integers without using any built-in shuffling functions or algorithms.
codefeedback
Write a SQL query to calculate the total number of orders in the "orders" table, where the orders have been placed in the last 30 days.
codefeedback
Modify the code to perform the mathematical expression "x to the power of y" while also ensuring that the value of x is between 1 and 10, and the value of y is between 0 and 5. Additionally, the code should handle any potential errors or edge cases that may arise during the calculation.
codefeedback
Develop a classification algorithm in Python to predict whether a bird is a hawk or a falcon based on the following features: wingspan, beak length, talon length, and feather color. In addition to developing the classification algorithm, please also: 1. Preprocess the data by scaling the features to have zero mean and...
codefeedback
Increase the difficulty of the given programming test question: Remove the boilerplate code from the program for printing 10 random numbers. Instead, write a function that generates a sequence of n random numbers, where n is the input to the function. The function should return the sequence of random numbers. The fun...
codefeedback
Create a Java program that prints out the sum of the numbers in the array. int[] numbers = {1, 2, 3 , 4, 5}; Additional Instructions: 1. The program should use a recursive function to calculate the sum of the numbers in the array. 2. The recursive function should have a base case to stop the recursion. 3. The program ...
codefeedback
Write an SQL query to calculate the average order price for each product category in the "orders" table. Additionally, calculate the total number of orders and the total revenue generated for each category.
codefeedback
Write a function in JavaScript to count the number of vowels in a given string. However, you are not allowed to use any built-in string methods or regular expressions. The input string will only contain lowercase alphabets. The function should be case-insensitive, meaning that both lowercase and uppercase vowels should...
codefeedback
Create a C program that prints out the Fibonacci sequence up to the nth term, where n is a positive integer inputted by the user. The program should also calculate and print the sum of all the terms in the Fibonacci sequence.
codefeedback
Create a Java program that prints out the contents of a given two-dimensional array in a spiral pattern. The array will have dimensions M x N, where M represents the number of rows and N represents the number of columns. The program should print the elements of the array in a clockwise spiral pattern, starting from the...
codefeedback
Create a C++ program that sorts a given array in descending order, using the bubble sort algorithm. The input array will contain integers ranging from -1000 to 1000, and may contain duplicate values. The program should handle arrays with up to 100,000 elements efficiently. The program should also include a function to ...
codefeedback
Change the variable `x` to the data type desired and ensure that it contains at least one special character and one uppercase letter. x = 'Hello World!'
codefeedback
Create a PHP code to check if an array contains a given item. The input array can contain up to 1 million integers and the item to check can be any integer value between -10^9 and 10^9. The code should have a time complexity of O(log n) where n is the number of elements in the input array.
codefeedback
Create a Swift code that shows the number of days in the given month. The user should input the month as an integer (1-12). 1. Create a variable named "month" and assign it to a user input, prompting them to enter a month as an integer (1-12). 2. Use a switch statement to determine the number of days in the given mon...
codefeedback
Write a list comprehension to calculate the factorial of each number in the list. arr = [1, 2, 3, 4, 5]
codefeedback
Generate a random integer between 4 and 8 (inclusively), ensuring that the generated number is divisible by 2 and not divisible by 3.
codefeedback
Sum up the positive numbers in the array, excluding the number 3, using Javascript. The array should have a minimum length of 5 and a maximum length of 10.
codefeedback
Create a function that takes in two numbers as arguments and returns the product of the two. However, you are not allowed to use the multiplication operator or any built-in functions or methods that directly calculate the product of two numbers. You should instead implement your own logic to calculate the product using...
codefeedback
Generate a random number between 0 and 1 (inclusively) using only bitwise operations.
codefeedback
How to reverse a list in C++ using only recursion and without using any additional data structures?
codefeedback
Write a program that extracts all the URLs from a given string. The program should handle various types of URLs including those with different protocols (e.g., http, https), subdomains, and query parameters. Additionally, the program should be able to handle URLs that are embedded within other text, such as "Visit thi...
codefeedback
Design a program to find the longest element in the given list, but also ensure that the program can handle negative numbers and floating-point numbers as elements. Additionally, the program should return the longest element and its index in the list.
codefeedback
Write a SQL query to update a value x in a column y in a table z, but only for rows that meet a specific condition. The condition is that the value in column a should be greater than 10 and the value in column b should be less than
codefeedback
Write a function to print all prime numbers between two given numbers, excluding any prime numbers that contain the digit 5.
codefeedback
Implement a Java function that takes in an array of integers and returns the maximum sum of any two adjacent elements in the array. The function should have a time complexity of O(n), where n is the length of the input array.
codefeedback
Write a MySQL query to print the column names and data types of all columns in a table named 'employees'.
codefeedback
Write a code to convert a given spreadsheet in CSV format to JSON format. The code should handle large datasets efficiently, with a maximum file size of 10GB. Additionally, the code should validate the CSV data to ensure that all columns have the correct data type (e.g. integers, floats, dates), and handle any errors o...
codefeedback
Is it possible to set a conditional breakpoint that is not associated with any source code line in a GDB program, where the condition checks for a specific value stored in a global variable?
codefeedback
How to delete a particular row in an SQLite database table based on the result of a complex query involving multiple tables and conditions?
codefeedback
Write a C++ code to find the average of an array of integers. The code should also check if the array contains negative integers and if so, it should not include them in the average calculation.
codefeedback
Using the following code, clean up the bugs and make sure the output functions correctly. Additionally, implement a sorting algorithm to sort the elements in the list in descending order. def example_func(lst): for element in lst: if (type(element) == int): lst.append(element + 5) lst.sort(reverse...
codefeedback
Write a shell script to print the top 5 most frequently used commands, excluding any commands that start with a vowel.
codefeedback
Create a table to store customer information, ensuring that each customer's email address is unique and that the phone number is in the format xxx-xxx-xxxx. Additionally, implement a feature that allows customers to update their information and retrieve the number of customers whose last name starts with a specific let...
codefeedback
Rewrite the given C++ code using only pointer references instead of array subscripts. Additionally, you are not allowed to use any built-in functions or operators to access or manipulate array elements. You must use pointer arithmetic and manual memory allocation. Ensure that the solution is memory efficient and does n...
codefeedback
Write a C++ function to generate a random prime number between 0 and 100.
codefeedback
How to print the elements of a two-dimensional array in C, while also counting the total number of elements and displaying the sum of all elements?
codefeedback
Parse the string and return the number of unique alphabets in the string. The input string can contain both lowercase and uppercase letters. Return the count of unique alphabets in a case-insensitive manner. Example: Input: "Apple" Output: 4 Input: "Mississippi" Output: 4
codefeedback
What is the output of the following code? list1 = ['a', 'b', 'c', 'd', 'e', 'f'] list2 = [1, 2, 3, 4, 5, 6] for x, y in zip(list1, list2): print(x * y)
codefeedback
Write a function to remove all whitespace characters from a given string and return the reversed string. Example: Input: "Hello World " Output: "dlroWolleH" Note: - The input string may contain multiple consecutive whitespace characters. - The function should return the reversed string without any whitespace ch...
codefeedback
Read the JSON string below and convert it into a dictionary. After converting the JSON string into a dictionary, iterate through each key-value pair in the dictionary and perform the following operations: 1. If the key is 'name', check if the value is a string. If it is not a string, raise an exception with an appropri...
codefeedback
Write a function that takes in a list of numbers and prints out the greatest number that is a multiple of 3. If there is no number that is a multiple of 3, the function should print out "No multiple of 3 found". list = [8, 2, 14, 25, 33, 6]
codefeedback
Write a Python function that takes two lists of equal length and creates a dictionary of the elements in each list that have the same index. The function should also handle cases where the input lists are not of equal length and provide appropriate error handling. list_one = [1, 2, 3, 4] list_two = ["a", "b", "c", "d"...
codefeedback
Develop an algorithm to find the value of n where n is the index of the Fibonacci sequence, but with the additional constraint that the algorithm must be implemented using a recursive approach.
codefeedback
Write a function that takes in a matrix of numbers and reverses the order of the rows and columns. The matrix will have at least 2 rows and 2 columns. The function should handle matrices of any size, with the number of rows and columns being greater than or equal to 2.
codefeedback
Design an algorithm that takes a list of strings and returns the longest string without using any built-in string manipulation functions or sorting algorithms. list = ["cat", "dog", "lion", "bird"]
codefeedback
Create a quick-sort algorithm in Python that can handle duplicate elements and sorts the array in descending order, while also keeping track of the number of comparisons made during the sorting process.
codefeedback
Design an algorithm that creates a random password of 12 characters with the following requirements: 1. The password must contain at least one uppercase letter, one lowercase letter, one digit, and one special character. 2. The password must not contain any repeated characters. 3. The algorithm should run in O(n) time ...
codefeedback
Create a multithreaded program that finds all the prime numbers less than or equal to a given number. The program should use a minimum of two threads to divide the workload and ensure efficient execution. Additionally, implement a user interface that allows the user to input the number and view the generated prime numb...
codefeedback
Create a program that can calculate the distance between two points in three-dimensional space. However, you are not allowed to use the standard distance formula (sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)). point1 = (1, 5, 9) point2 = (4, 2, 8)
codefeedback
Create a function to calculate the maximum of two numbers. Your solution should not use any built-in functions or operators for comparison or sorting.
codefeedback
Given a list of integers, create a program that calculates and prints the standard deviation of the elements in the list. The standard deviation is a measure of the amount of variation or dispersion in the dataset. It is calculated by finding the square root of the average of the squared differences from the mean. # I...
codefeedback
Create a program that ciphers a given text using the caesar cipher. The program should also be able to decipher the ciphered text back to its original form. text = "This is a secret message" key = 3 # Example of erroneous code # # The program should add the key value to the ASCII value of each character to cipher the...
codefeedback
Write a Java program to reverse a given string without using the built-in reverse function or any other built-in string manipulation functions.
codefeedback
Write a JavaScript function to validate a given URL and check if it contains a valid domain name. Additionally, the function should also check if the URL is using a secure protocol (https) and if it includes any query parameters.
codefeedback
Write a code to print the current date and time in ISO format, but also include the time zone offset.
codefeedback
Write a C program to find the sum of all the even digits of a given number, where the number must be positive and less than 1000.
codefeedback
Write a code to sort the following array in increasing order. The array may contain duplicate elements. [10, 2, 7, 8, 32, 4, 8, 7, 10, 2] #Expected Output# [2, 2, 4, 7, 7, 8, 8, 10, 10, 32]
codefeedback
Write a Python program to print out an ASCII art of a given word in a specific font style. The program should prompt the user to enter a word and a font style. It should then generate and display the ASCII art representation of the word using the chosen font style. The program should handle various font styles, such a...
codefeedback
Write a code to connect to a remote database using a secure SSL/TLS connection. username: john password: john123 IP: 100.10.0.10 Port: 5432
codefeedback
Create a function in Java that takes a string and prints the reversed version. The function should also remove all duplicate characters from the reversed string before printing it.
codefeedback
Modify the code below to make it calculate the sum of all the numbers from 1 to n, but only include the numbers that are divisible by 3. The final sum should be stored in the variable "total". num = 10 total = 0 for i in range(num): if i % 3 == 0: total += i
codefeedback
Create an HTML form with a textbox, a submit button, and two radio buttons. The textbox should only allow alphanumeric characters and should not be empty when the submit button is clicked. Additionally, the radio buttons should be grouped together and have distinct values assigned to them. When the submit button is cli...
codefeedback
Write a code to get the time difference between two date-time objects, where each date-time object can be in any timezone. date1: 2019-05-11 21:00:00 (GMT) date2: 2019-05-13 10:00:00 (PDT) The code should take into consideration the different timezones and calculate the accurate time difference between the two date-t...
codefeedback
Write a code to access the nth element of a linked list, but you are not allowed to use any built-in methods or functions for accessing the elements of the linked list.
codefeedback
Create a program to generate a histogram using data from a set of numbers. The histogram should display the frequency of each number in the set, but only for numbers that are divisible by 3. If a number is divisible by 3 multiple times, its frequency should be displayed accordingly. values = [3, 4, 2, 5, 8, 1, 2, 6]
codefeedback
Write a code to add two linked lists of different sizes, where each node contains a single digit and the digits are stored in reverse order. The resulting sum should also be stored in a linked list in reverse order. list1 = [9->9->9->9->9] list2 = [1] Example: Input: list1 = [9->9->9->9->9] list2 = [1] Output: [0->0...
codefeedback
Write a JavaScript code snippet to print the numbers from 1 to 100 in a pattern where each number is repeated a number of times equal to its value. For example, the number 1 should be printed once, the number 2 should be printed twice, the number 3 should be printed three times, and so on. The pattern should continue u...
codefeedback
Create a function in Java to convert a list of strings to a 2D array. The strings in the list can be of varying lengths, and the maximum length of a string is 1000 characters. The maximum size of the list is 10^6 strings.
codefeedback