instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Develop a program to encrypt a text using a combination of substitution cipher and transposition cipher.
codefeedback
Construct a regex pattern to match a valid IP address and validate each component of the IP address separately.
codefeedback
Write a program that reads a file named "input.txt" and extracts the following information from it: the name of a person and their age. The file will contain multiple lines of data, with each line in the following format: Name: [name] Age: [age] Your program should extract the name and age from each line and print the...
codefeedback
Create a deep neural network to accurately classify various types of dogs from a dataset of images, while also optimizing for high efficiency and minimizing computational resources. The model should incorporate advanced techniques such as transfer learning, data augmentation, and regularization to achieve superior perf...
codefeedback
Suggest a code to add the values of all odd prime numbers in an array. arr = [1, 2, 3, 4, 5, 6]
codefeedback
Develop a web page which takes user inputs and validates them. Implement the following validation rules: 1. The username field should not be empty and should contain only alphabets. 2. The email field should be a valid email address. 3. The password field should have a minimum length of 8 characters and should contain...
codefeedback
Replace all negative values in the given dataframe with a string. Stored in the form of a Pandas dataframe. 0 1 2 3 a -1 b -2 4 -3 5 6
codefeedback
Write a function that takes a Pandas DataFrame as input and returns a new DataFrame containing only the rows where the mean of a specific column is greater than a given threshold. The function should also accept an optional parameter to specify the column to compute the mean for. Example input: ``` data = { 'A': [...
codefeedback
Construct a boolean check to detect if a given string contains the word "hello" in any case (upper or lower case) and also count the number of times the word "hello" appears in the string.
codefeedback
Create a bash script that prints out the days in a month, but instead of using the built-in `cal` command, you should calculate the number of days using a combination of logical steps and conditional statements. 1. Prompt the user to enter a month and a year. 2. Check if the year is a leap year or not. A leap year occ...
codefeedback
Construct a program to filter the list of names based on the given condition. names = ["Ada", "Bob", "Chris", "David", "Elsa", "Frank"] condition: length greater than 4 and contains at least one vowel.
codefeedback
Estimate how many unique words are present in the given text. Consider that each word may appear multiple times in the text, but should only be counted once. The text may contain punctuation marks, numbers, and special characters. Your solution should be able to handle large texts efficiently. Time Complexity Requirem...
codefeedback
Develop an algorithm that checks for balanced parentheses in a given string. The string can contain other characters besides parentheses. You need to consider three types of parentheses: round brackets (), square brackets [], and curly brackets {}. A string is considered balanced if every opening parenthesis has a corr...
codefeedback
Write a JavaScript function that counts the number of times a given character appears in a string, but do not use the built-in string method `count()` or any other built-in functions that directly solve the problem.
codefeedback
Design a machine learning model to classify an article into multiple categories, including sports, food, technology, politics, and entertainment.
codefeedback
Design a web scraper in Python to extract the text content from Wikipedia articles. Your scraper should be able to handle the case where the articles have dynamic content loaded through JavaScript. Additionally, the scraper should only extract the text content from articles that have been updated within the last 24 hou...
codefeedback
Design a neural network model to detect the sentiment of a given sentence. Additionally, the model should be able to handle noisy and unstructured data, such as misspelled words, grammatical errors, and slang language.
codefeedback
Design a data structure to store a list of courses with their corresponding details. The data structure should support the following operations: 1. Add a new course with its details to the data structure. 2. Remove a course from the data structure. 3. Update the details of a course in the data structure. 4. Retrieve t...
codefeedback
Write a code snippet to compute the median of a set of integers. #Difficulty Increased Explanation# The original test asked for the average of a set of integers, which is a relatively simple task. By changing it to compute the median, we are increasing the difficulty level. Finding the median requires additional steps...
codefeedback
Generate all possible permutations of a given list of numbers, including duplicates. The input list can contain duplicate elements, and the output should also include duplicate permutations. The time complexity of the solution should be less than O(n!).
codefeedback
Edit the following program to add 1 to each element of the list and print the result. Additionally, you must implement the solution using a recursive function and ensure that the final result is stored in a new list without modifying the original list.
codefeedback
Edit the following code to take in a list of numbers and output the sum of all numbers in the list. The code should also handle cases where the input list contains nested lists, and calculate the sum of all numbers within the nested lists as well. my_list = [5, 10, [15, 20], [25, [30, 35]]]
codefeedback
Write a Java program to take in 3 strings and combine them into one in reverse order. The program should also reverse the order of the characters within each string before combining them. Example: string1 = "hello" string2 = "world" string3 = "!" Output: "!dlrowolleh"
codefeedback
Implement a Vue component that displays a responsive table layout with the following additional constraints: - The table should have a fixed header that stays visible while scrolling through the table rows. - The table should have pagination functionality, allowing the user to navigate through multiple pages of data. -...
codefeedback
Create a Java program to determine whether a given string is a palindrome. A palindrome is a string which reads the same forwards and backwards. Additionally, the program should handle the following cases: 1. The input string may contain both uppercase and lowercase letters, and it should still correctly identify pal...
codefeedback
Given a list of strings, where each string represents a positive integer, convert the strings to integers and calculate their sum. lst = ["123", "456", "789", "987", "654", "321"] Note: The length of the list can be up to 10^6.
codefeedback
Read a sentence from the user, which will contain only letters and spaces. Reverse the words in place, but do not use any additional data structures or built-in functions for string manipulation.
codefeedback
Modify the following code to print the keys of a dictionary in reverse alphabetical order. Additionally, the code should only print keys that have a value greater than 1. d = {'a':1, 'b':2, 'c':3, 'd':0}
codefeedback
Write a JavaScript function to generate a random string of 12 characters using a combination of lowercase and uppercase alphabets, digits, and special characters. The special characters should include at least one of the following: !@#$%^&*()_+=-{}[]\|:;""'<>,.?/
codefeedback
Create an algorithm for finding the least common multiple of three numbers, using only prime factorization.
codefeedback
Write a SQL query to extract the top 5 occurrences of the city names from the following table, but only include cities that have at least 3 people living in them.
codefeedback
Rewrite the following Java code into SQL to select all the distinct elements from a table, where the elements must have a value greater than 100 and be sorted in descending order based on their values. The SQL statement should also include a limit of 10 for the number of results to be returned. String sql = "SELECT DIS...
codefeedback
Make a dictionary that contains the number of characters in each word from this list. Each word must be processed in parallel using multithreading or multiprocessing. Additionally, the dictionary should only include words that have at least 5 characters. The final dictionary should be sorted in descending order based o...
codefeedback
Write an assembly code to perform the task of incrementing a memory block by 16, but the memory block can only be accessed using indirect addressing mode.
codefeedback
Create a Go program to print out the cube of each integer in a given range of numbers from 1 to N, where N is a positive integer provided by the user. Example: Enter the value of N: 10 Expected Output: 1^3 = 1 2^3 = 8 3^3 = 27 4^3 = 64 5^3 = 125 6^3 = 216 7^3 = 343 8^3 = 512 9^3 = 729 10^3 = 1000
codefeedback
Provide a syntactically correct C++ function that takes a number and returns a string representation of the number. The function should not use any built-in library functions for converting numbers to strings (e.g., std::to_string). The function should also handle negative numbers and numbers with decimal places, retur...
codefeedback
Create a Java program that prints a 10x10 multiplication table, but the table should only display prime numbers.
codefeedback
Write a program that takes in a list of integers and returns a new list containing only the odd numbers in the original list. The program should also sort the odd numbers in descending order before returning the new list.
codefeedback
Write a python program to create a class called cube that includes the following methods: 1. `get_volume()`: This method should calculate and return the volume of the cube. 2. `get_surface_area()`: This method should calculate and return the surface area of the cube. 3. `get_face_diagonal()`: This method should calcul...
codefeedback
You are given a list of HTML elements as strings and a specific element to insert at the appropriate place in the list. The list may contain nested elements. Your task is to insert the given element in the correct position in the list, while maintaining the nested structure of the elements. For example, given the foll...
codefeedback
Write a code to find the maximum value in a numeric array using recursion. The array may contain negative numbers. You can assume that the array will always have at least one element. For example, given the array [1, -2, 3, -4, 5], the code should return 5 as the maximum value. Please make sure your code is efficient...
codefeedback
Create a regular expression to match all numbers of the form 1xx-xxx-xxxx, where xx cannot be greater than 50.
codefeedback
Create a simple calculator program in Python that only accepts two numbers as input and performs basic arithmetic operations (addition, subtraction, multiplication, division). The program should handle any invalid input gracefully and display an error message if necessary. Additionally, the program should include a men...
codefeedback
Construct a decision tree to classify a fruit as mango or apple based on its color, texture, size, weight, and taste.
codefeedback
Add a function to implement a basic calculator in C++ that supports addition, subtraction, multiplication, and division operations. The calculator should also handle parentheses and exponentiation. You are given a string expression as input, which can contain integers, operators (+, -, *, /, ^), parentheses, and white...
codefeedback
Write a React class component that renders a greeting with a personalized message based on the current time of day. The greeting should include the user's name, which is passed as a prop to the component. Additionally, the component should change the background color based on the time of day, with a specific color pale...
codefeedback
Write a program in a programming language of your choice that generates a random array of integers and sorts it using the Quicksort algorithm. Additionally, your program should also display the number of comparisons and swaps performed during the sorting process.
codefeedback
Design a Node.js program to send a push notification to users when the deadline of a task is reached. The program should be able to handle multiple tasks and multiple users concurrently. Additional requirements: 1. The program should use a database to store task and user information. You can choose any database system...
codefeedback
Write a multi-threaded application that calculates the sum of all prime numbers up to a given limit. The application should use a thread pool to divide the work among multiple threads for increased performance. Additionally, each thread should maintain a separate counter to keep track of the number of prime numbers fou...
codefeedback
Use a random number generator to generate random numbers between 1 and 10. Implement a function that calculates the sum of all the generated numbers and returns the result. Additionally, you must ensure that the sum is always divisible by 3.
codefeedback
Create a function to decrypt an encrypted string. The encrypted string will be passed as an argument to the function. The encryption method used is a simple substitution cipher, where each letter in the string is replaced with a corresponding letter from a given alphabet. The alphabet used for encryption is provided as...
codefeedback
For the given array, output true if the array does not contain duplicates, output false if it contains any. The time complexity should be less than or equal to O(n^2). The space complexity should be less than or equal to O(n). The input array can have duplicates and can be unsorted. arr = [1, 3, 5, 6, 1, 3, 4, 2, 7, 8,...
codefeedback
Given two sorted arrays, find elements that exist in both arrays. arr1 = [1, 2, 5, 8, 9, 10] arr2 = [2, 5, 6, 9] Please note that the arrays can have duplicate elements and the output should include all duplicates as well. Write a function called "find_common_elements" that takes in two sorted arrays as input and r...
codefeedback
Implement a function that breaks down a given text into individual words. The function should ignore punctuation marks and return a list of unique words in the text. The function should have a time complexity of O(n), where n is the length of the text.
codefeedback
Write CSS code to position a block at the top center of the page, but only using Flexbox and without using any positioning properties like 'position: absolute' or 'position: fixed'.
codefeedback
Write code to create an object with the key which will be incremented by a random prime number on every call of the code.
codefeedback
Print out the length of each string in the list, but only for strings that contain at least one uppercase letter. list_of_strings = ['hello', 'World', 'foobar', 'Test']
codefeedback
Swap the elements at index 2 and 4 only if the sum of the elements at index 0 and 1 is greater than the sum of the elements at index 3 and 4. arr = [1, 3, 5, 6, 8]
codefeedback
Create a responsive website using HTML, CSS, and JavaScript that includes the following features: 1. A navigation menu with at least five links that smoothly scroll to their respective sections on the page. 2. A hero section with a background image that covers the entire viewport and a heading with an animated typing ...
codefeedback
Fix this indentation error in the following Python code. The solution should be a recursive function.
codefeedback
Create a new array from the given array by replacing all the odd numbers with 0. However, you should also replace all even numbers with their square root rounded to the nearest integer. The new array should be sorted in descending order. arr = [3, 5, 7, 9, 1]
codefeedback
Create a function that prints a provided message 3 times, but each repetition should be in a different color. The message can only contain alphabetic characters and should have a maximum length of 20 characters. Additionally, the function should also print the length of the message before printing the repeated messages...
codefeedback
What data structure is most appropriate for fast searches when the number of elements is in the order of 10^6 and the search operation needs to be completed in less than 100 milliseconds?
codefeedback
Determine the time complexity of the code given below as a function of n. def foo(A, n): if n == 1: return A[0] else: return foo(A, n - 1) + A[n - 1] In the original problem, the code recursively calculates the sum of the first n elements in array A. To increase the difficulty, let's add more...
codefeedback
Create code that, given a string, returns the longest substring of consecutive characters. If there are multiple substrings with the same length, return the one that occurs first. str = "abcccccdef"
codefeedback
Create code that given two linked lists, determine if they intersect at a specific node. The intersection node must have a value that is a prime number. Two linked lists: list1 = [3, 7, 8, 10] and list2 = [99, 1, 8, 10]
codefeedback
Create a function that will find the maximum length of strictly increasing subarray in a list, where the elements must be in non-decreasing order. The list may contain duplicate elements. The function should handle both positive and negative integers. The length of the list should be at least 5.
codefeedback
Create code to find the longest subarray with equal number of 0's and 1's, where the subarray must also contain an equal number of even and odd numbers. list = [0, 0, 1, 0, 1, 2, 3, 4, 0, 1, 0, 0, 1]
codefeedback
Create a function that will add two numbers (represented as linked lists). Each linked list node contains a single digit from 0 to 9, and the digits are stored in reverse order (i.e., the head node contains the least significant digit). The function should return a new linked list representing the sum of the two input ...
codefeedback
Create a function that, given two binary search trees with integer values, determines if they are identical. The function should consider the following additional constraints: - The binary search trees can have duplicate values. - The nodes of each tree can have an additional attribute called "color", which can take va...
codefeedback
Create code that given a stack (i.e., a sequence of objects), returns the reversed stack without using any built-in functions or methods that directly manipulate the stack. The solution should have a time complexity of O(n), where n is the number of elements in the stack. stack = [1, 2, 3, 4]
codefeedback
Write a code snippet to store the output of an API call into a variable and then encrypt the data using AES encryption algorithm with a randomly generated key and IV. The encrypted data should then be stored in a file. The API call should include the following headers: 'Content-Type: application/json' and 'Authorizatio...
codefeedback
Get the top ten most used words within a string, excluding any words that contain numbers or special characters.
codefeedback
Create a function to build a queue (i.e., a sequence of objects) with the following requirements: 1. The queue should have a maximum capacity of 10 objects. 2. The queue should have the following methods: - `enqueue`: Add an object to the end of the queue. - `dequeue`: Remove and return the object at the front o...
codefeedback
Create a virtual machine using Terraform that automatically scales based on CPU usage and sends a notification to a specified email address when the scaling occurs.
codefeedback
Make a REST API call to get the latest version of Python. Your solution should use asynchronous programming techniques to improve performance and should handle any errors or exceptions that may occur during the API call. Additionally, you should implement a caching mechanism to store the retrieved version number so tha...
codefeedback
Construct an expression in javascript to reverse a string without using the built-in "reverse()" method or any other string manipulation methods like "split()" or "join()".
codefeedback
Generate a gradient descent algorithm to optimize a cost function with multiple variables and constraints.
codefeedback
Create an API endpoint in NodeJS that returns a JSON object containing the current time in UTC format, along with the current weather condition for a specific location. The location can be provided as a query parameter in the API request. The weather condition should be retrieved by making an external API call to a wea...
codefeedback
Implement the merge sort algorithm to sort a given array of integers in ascending order. The array will contain at least 10,000 elements.
codefeedback
Construct a pre-order traversal code to traverse a binary tree and print the nodes in reverse order.
codefeedback
Write a code to create a secure web server for a given web page, using SSL/TLS encryption and a valid SSL certificate.
codefeedback
Edit the code to make sure the program prints the correct output, without using any arithmetic operators such as +, -, *, or /.
codefeedback
Create an array of 10 unique numbers between -100 and 100, with the constraint that the sum of all the numbers in the array must be less than 500.
codefeedback
Modify the following code to kill a thread after 10 seconds. import threading from time import sleep def worker(): try: while True: print("Thread") sleep(1) except Exception as e: print(e) def kill_thread_after_10_seconds(thread): sleep(10) thread.ra...
codefeedback
Create an array of 100 unique values from 1 to 1000, where each value is a prime number.
codefeedback
Create an array of length 10 from a given list of values. The values in the array should be the cumulative sum of the original list, but only include the cumulative sum if it is a prime number. # Example given_list = [1, 2, 3, 4, 5] Output: [2, 5, 10, 17, 28, 41, 58, 77, 100, 0] Explanation: - The cumulative sum of [...
codefeedback
Write a Java program to output the first ten numbers of the Fibonacci sequence. Each number in the sequence should be calculated using a recursive function. Additionally, the program should implement a time complexity of O(1) for calculating each Fibonacci number.
codefeedback
Create an array from a given string containing only lowercase alphabets and sort it in ascending order. The output should not contain any duplicate elements. string = "cbaefd"
codefeedback
Write a code in Python for comparing two strings without using a built-in function. However, you are not allowed to use any loops or recursion. string1 = "apple" string2 = "orange" # Erroneous Code for Reference string3 = "apple" string4 = "orange" result = string3 == string4 print(result)
codefeedback
Write a function that takes two arguments, an array arr and a value x, and returns the number of times x appears in the array arr. The function should only iterate through the array once and should have a time complexity of O(n). Additionally, the function should not use any built-in methods or libraries to solve the p...
codefeedback
Generate the SQL command to insert a new item in an existing table. Table Name: users Columns: name (string), age (integer), gender (string) Values: ('Adam', 34, 'Male') Condition: Only insert the new item if the age is greater than the average age of all the users in the table.
codefeedback
Create a HTML5 webpage with a simple form that includes the following fields: 1. Name (text input) 2. Email (text input) 3. Password (password input) 4. Confirm Password (password input) 5. Date of Birth (date input) 6. Gender (radio buttons for Male and Female) 7. Country (dropdown/select input) 8. Agree to Terms and ...
codefeedback
Generate an HTML form with a text input box that only accepts email addresses and has a character limit of 50.
codefeedback
Write a JavaScript function to compare two strings without using any built-in functions. The function should also handle strings with different letter cases and remove any leading or trailing whitespaces before comparison.
codefeedback
Explain how to find the minimum value of a list using a recursive algorithm and without using built-in functions or libraries.
codefeedback
Convert a list of numbers to a 5x5 matrix where the numbers are arranged in a zigzag pattern. The zigzag pattern starts from the top left corner, moves down to the bottom left corner, then moves across to the bottom right corner, and continues in this manner until all numbers in the list have been placed in the matrix....
codefeedback
Write a function to sort a string containing several words alphabetically in descending order based on the length of each word. The function should also remove any duplicate words from the string and ignore any words that contain numbers or special characters.
codefeedback
Write a script that prints the first N prime numbers in a Fibonacci series. N = 10
codefeedback
Convert the following SQL statement into a Python def() and write the code. SELECT order_id, order_time, subtotal FROM orders WHERE order_time > NOW() AND subtotal > 100 #Explanation# The rewritten test now requires the Python code to include an additional condition in the WHERE clause, where the subtotal should be gr...
codefeedback