instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Create a class that represents a banking system in Python. The class should have the following attributes and methods: Attributes: - account_number (a randomly generated alphanumeric string of length 10) - account_balance (a floating-point number representing the current balance of the account) Methods: - deposit(amo...
codefeedback
Create a stack that supports the following operations: 1. Push: Add an element to the top of the stack. 2. Pop: Remove and return the element from the top of the stack. 3. Peek: Return the element at the top of the stack without removing it. 4. isEmpty: Check if the stack is empty. Add two elements to the stack and th...
codefeedback
Create a function that takes two strings as parameters, compares them, and returns 0 if they are equal, 1 if the first string is greater (based on lexicographic order), and -1 if the second string is greater. In addition, you need to handle the following edge cases: 1. If either of the strings is empty, return -2. 2...
codefeedback
How do you develop a software application through agile using the Test-Driven Development (TDD) methodology?
codefeedback
Design a memory efficient algorithm for a given problem. Given a list of integers, find the average of all the elements. The algorithm must have a time complexity of O(n) and use only a constant amount of extra space.
codefeedback
Explain one of the most significant applications of neural networks in computer science, and include a demonstration of a working neural network model that solves a specific problem in the chosen application.
codefeedback
How is artificial intelligence (AI) used in high-frequency trading in finance to optimize trading strategies and increase profitability? Provide specific examples and discuss the potential risks and limitations associated with the use of AI in financial markets.
codefeedback
How would you code a spell-checker that can handle multiple languages and suggest appropriate corrections based on the context of the misspelled word?
codefeedback
Sort a given array of integers using Quick Sort and make sure that the algorithm has a time complexity of O(nlogn) in all cases.
codefeedback
Find the angle between two given vectors in a three-dimensional space. The time complexity of your solution should be O(1) and you should not use any trigonometric functions.
codefeedback
How can you use recurrent neural networks with long short-term memory (LSTM) units for sequence prediction in natural language processing tasks, such as language modeling or machine translation? Explain the architecture and training process of an LSTM-based RNN, and discuss how it overcomes the vanishing gradient probl...
codefeedback
What is the difference between static binding and dynamic binding in object-oriented programming? Provide an example of each and explain the advantages and disadvantages of using each binding method.
codefeedback
Rewrite: Explain the various data structures that can be used to store a matrix in Python. Compare and contrast these data structures, highlighting their advantages and disadvantages in terms of memory usage, time complexity for common operations, and ease of implementation. Additionally, provide an example of how eac...
codefeedback
Write code to calculate the total number of votes for a candidate in an election, but only consider the votes from registered voters who are aged 18-30. The age of each registered voter is stored in a separate list called "ages" in the same order as the votes. Only include the votes for candidates who have at least 100...
codefeedback
Create a virtual environment in Python using only built-in modules and without using any third-party tools or libraries.
codefeedback
Write a code snippet to find all the Pythagorean triplets whose sum of the squares of the three numbers is equal to the given number. The code should have a time complexity of O(n^2) and a space complexity of O(1).
codefeedback
Create a Python program that generates an array of size N, where N is a randomly generated number between 1 and 10. The array should contain unique values, and each value should be a randomly generated number between 1 and 100.
codefeedback
Make an API call to get the current weather in a given city. Implement rate limiting functionality to restrict the number of API calls to a maximum of 10 per minute.
codefeedback
Create a function in JavaScript to take a given number and add 10 to it. However, you are not allowed to use any arithmetic operators (+, -, *, /, %) or the increment operator (++). The function should only use bitwise operators and logical operators. The time complexity of the function should be O(1) and the space com...
codefeedback
Write a program in Java to print the first n terms of the Fibonacci sequence using a recursive approach.
codefeedback
Create a random list of 10 prime numbers in the range of 100 to 1000 in Python.
codefeedback
Write a Java class to define a student object that includes a name, grade, and a list of subjects they are enrolled in. Each subject should have a name and a corresponding grade for that subject. The class should have methods to add a subject and its grade, calculate the average grade for all subjects, and retrieve the...
codefeedback
Create a bar chart in Python, plotting the following integer data set. Data set: [1, 2, 4, 8, 16, 32] Additional Requirements: 1. The chart should have proper labels for both x-axis and y-axis. 2. The bars should be color-coded, with each bar having a different color. 3. The bars should have a width of 0.5 units. 4. ...
codefeedback
Write a regex pattern to check if the given string is a US phone number. Additionally, validate that the phone number is in the format (XXX) XXX-XXXX, where X represents a digit from 0 to 9.
codefeedback
Implement a custom machine learning algorithm in Python to make predictions on a given dataset.
codefeedback
Rewritten Test: Generate a SQL statement to retrieve the title, author, and publication year of all books in the library table, sorted in ascending order of publication year. Additional Requirements: 1. Exclude any books that have been marked as "out of stock" in the library table. 2. Only include books that were publ...
codefeedback
Identify the wrong code in this JavaScript snippet. let a = "Hello World!"; console.log(a); console.log(b); #Reasoning# In the rewritten test, an additional incorrect code line `console.log(b);` is added. This requires the test taker to not only identify the original incorrect code line but also identify the newly add...
codefeedback
What is the time complexity of the function "len()" in Python?
codefeedback
Modify the code below to create a new function called "addSquares()" that adds the squares of two numbers and returns the result. The function should only accept positive integers as input and throw an error message if any other data type or negative integers are passed as arguments.
codefeedback
Convert the string "Hello World" to upper case using a Java program. Ensure that the program can handle strings containing special characters and digits, and the converted string should be sorted in reverse alphabetical order.
codefeedback
Write a C program to calculate the factorial of a number using recursion. The factorial of a number is the product of all positive integers less than or equal to the number. For example, the factorial of 5 is 5 * 4 * 3 * 2 * 1 = 1
codefeedback
Print all the numbers in a given string while ignoring any leading or trailing non-numeric characters using Java. String str = "123XYZ456ABC789" #Erroneous Code# ``` String str = "123XYZ456ABC789"; String[] nums = str.split("[^\\d]+"); //splitting the string by any non-digit character for (String num : nums) { Sys...
codefeedback
Write a Java function to compare two strings and print the longer string. The function should have a time complexity of O(n), where n is the length of the longer string.
codefeedback
Create an HTML element that displays the text "Welcome" with the color blue, but also ensure that the element is centered on the page and has a font size of 20 pixels.
codefeedback
Create a C++ program for printing a pyramid pattern up to a given number n, where n is an odd number greater than or equal to 5. The pyramid pattern should be constructed using a recursive function. The pyramid pattern should be printed in the following format: * *** ***** ******* ********* The progra...
codefeedback
Compute the maximum amount of money X which can be obtained using two given coins of denomination A and B, where A and B are prime numbers. A = 7 B = 11 X = 79
codefeedback
Write an SQL query to identify the most frequently occurring value in a given column. Your solution should also exclude any values that occur less than X times, where X is a positive integer input parameter to the query.
codefeedback
Write a MongoDB query to find documents where a given field contains a substring, but exclude any documents where the substring appears within a specified nested field.
codefeedback
Create a function that groups a given set of numbers into continuous ranges. A continuous range is defined as a sequence of numbers where each number is exactly one greater than the previous number. Example: Input: [1, 3, 4, 6, 7, 8, 10] Output: [[1], [3, 4], [6, 7, 8], [10]] Explanation: The input set contains four...
codefeedback
Create a function to register a new user using a given username, email and password. The username must be unique and contain only alphanumeric characters. The email must be a valid email address and should not already be registered in the system. The password must be at least 8 characters long, contain at least one upp...
codefeedback
Rewrite the given test to implement a program that calculates the sum of all prime numbers from 1 to a given positive integer, excluding the number itself. The program should use 'break' and 'continue' statements in a for loop to efficiently skip non-prime numbers and terminate the loop when the desired sum is reached....
codefeedback
Write SQL query to calculate total rental fees for customers who have rented a movie in the past 30 days, grouping the results by month and customer. Additionally, exclude any customers who have rented less than 3 movies in the past 30 days. Table Name: "Rentals" Columns: "CustomerId", "RentalDate", "RentalFee"
codefeedback
Create a function that converts an arbitrary number from any base between 2 and 16 to its decimal representation, without using any built-in conversion functions or libraries. The function should be able to handle numbers with up to 100 digits.
codefeedback
Design a data structure that will store name, phone number, address, email, and age of a person. Additionally, the data structure should have the following functionalities: 1. Add a person to the data structure. 2. Remove a person from the data structure. 3. Update the details of a person. 4. Search for a person by th...
codefeedback
Write an SQL query that returns the sum of inventories in the Inventory table, but only for items that have a quantity greater than 100.
codefeedback
Write a function in JavaScript to check if the given string contains at least two consecutive vowels or not.
codefeedback
Explain the concept of color models in web development and specifically focus on the HSL color model. Discuss the advantages and disadvantages of using the HSL color model compared to other color models. Provide examples of how the HSL color model can be implemented in web design, including the use of CSS properties an...
codefeedback
A website requires a logo to be displayed in the header. Design a logo with an animated effect and write the HTML code to display it.
codefeedback
You receive an array of numbers as input and you need to calculate the median number. However, you are not allowed to use any built-in functions or libraries to sort the array. The input array will always contain an odd number of elements.
codefeedback
Create a data structure to store records of students' attendance with the following constraints: each record should include the student's name, ID, date and time of attendance, and attendance status (present, absent, late). The data structure should also be able to handle multiple records for each student and provide f...
codefeedback
You need to write a function that validates a given password. It should only be valid if it contains at least one lowercase letter, one uppercase letter, one number, and one special character. Additionally, the password should be at least 8 characters long and should not contain any consecutive repeating characters.
codefeedback
Write a Java program to insert a new node at a specified position in a singly linked list. The position should be provided as input by the user. Additional Requirements: 1. The program should handle the case where the specified position is out of bounds (i.e., greater than the length of the list or negative) by either...
codefeedback
Devise a data structure to store an inventory of items in a store. Additionally, implement a method that allows the user to add an item to the inventory, considering that each item has a unique identifier. The method should handle the scenario where the user tries to add an item with an identifier that already exists i...
codefeedback
Convert the given list of integers to a string of comma separated values, ensuring that all even numbers are doubled and all odd numbers are squared. [1, 2, 3, 4, 5]
codefeedback
Create a code to print the items from a given array in reverse without using any built-in functions or methods for reversing an array. The code should only use logical steps and operations to achieve the desired result.
codefeedback
Reverse a given array without using a loop. The solution must have a time complexity of O(1) and must not use any built-in array manipulation functions such as reverse(). Additionally, you are not allowed to create a new array to store the reversed elements. The original array must be modified in-place. The array can c...
codefeedback
Create a code to raise a number to a given power p, using only basic arithmetic operations (addition, subtraction, multiplication, and division) and without using any built-in exponentiation functions or operators.
codefeedback
Write a function that takes in a list of strings and returns True if any of the strings contains the letter `a`. Additionally, the function should ignore any strings that start with a lowercase letter.
codefeedback
Write a JavaScript function to convert a given decimal number to its Roman numeral equivalent. The decimal number will be within the range of 1 to 3999.
codefeedback
Create a PHP function that sorts the elements of an array in ascending order using the bubble sort algorithm.
codefeedback
Write a Java program to remove comments from the Java program. However, your program should also handle nested comments properly. Erroneous code: public class HelloWorld { /* This is a multiline comment. */ /* public static void main(String[] args) { System.out.println("Hello World!"); // This ...
codefeedback
Create a MongoDB query to find all documents that have an array "items" with a field "name" equal to "pen" and a field "quantity" greater than or equal to 10.
codefeedback
Filter the array based on the following condition: only include elements that are prime numbers and greater than 2. Return a new array of elements that satisfy the condition. arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
codefeedback
Suggest a way to search for a target element in a binary search tree in less than O(log n) time.
codefeedback
Write a function to sum the values stored in a nested dictionary using a recursive approach. The nested dictionary can have an arbitrary number of levels. mydict = {'a': {'x': 1, 'y': 2}, 'b': {'z': 3}, 'c': 4} The function should return the sum of all the values in the nested dictionary, including the values in the i...
codefeedback
Format the strings given in the list so that only the first letter of each word is in upper case. The solution should have a time complexity of O(n) and a space complexity of O(1). ["Hello world", "Wonderful DAY", "this is a test"]
codefeedback
You are given an array of positive and negative integers. Find the maximum sum of any subarray of the given array. The subarray must have a length of at least 2. #Clarification# - The array can contain both positive and negative integers. - The subarray must have a length of at least 2. - The maximum sum can be negati...
codefeedback
Describe a machine learning algorithm that uses supervised learning and has a requirement of achieving a minimum accuracy of 90% on the training data.
codefeedback
Design an algorithm to check if two given binary trees are identical, where each node contains an integer value and an additional character value. The algorithm should also compare the character values of the corresponding nodes and return true only if both the integer values and character values are identical in both ...
codefeedback
Generate code to display a progress bar in HTML that dynamically updates based on user input and includes additional features such as animation and customization options.
codefeedback
Use Java to generate a string containing 10000 random characters of length 100.
codefeedback
Generate code to call an API using JavaScript, pass parameters to the API endpoint, handle authentication, and print the results. API Endpoint: 'www.example.com/api/v1/data' Parameters: - Query parameter: 'type' with possible values of 'A', 'B', or 'C' - Header parameter: 'Authorization' with a valid token value - Bo...
codefeedback
Create a C# program to sort a given array of integers using a custom sorting algorithm. The algorithm should be based on the following rule: - If the integer is even, it should be sorted in ascending order. - If the integer is odd, it should be sorted in descending order. int[] nums = {8, 5, 1, 3, 9};
codefeedback
Create an Angular 10 service to fetch data from a remote API and print the results to the console. The API requires authentication using a JWT token, which needs to be included in the request headers. Additionally, implement a caching mechanism to store the fetched data locally and only make a new API request if the da...
codefeedback
Create an SQL query to sum all values in the "amount" column, but exclude any rows where the "status" column is set to "cancelled".
codefeedback
Create an HTML form element to store a password with the following validations: 1. The password must be at least 8 characters long. 2. The password must contain at least one uppercase letter, one lowercase letter, one digit, and one special character. 3. The password cannot contain any spaces. 4. The form should displa...
codefeedback
Using JavaScript, create an input field to store a hexadecimal value that must be between 4 and 8 characters long, and validate that it contains only valid hexadecimal characters (0-9, A-F).
codefeedback
Develop a React Native application to display a list of recent news articles. Implement a search functionality that allows users to search for specific articles by title. Additionally, implement a filter feature that allows users to filter articles based on their category.
codefeedback
Using HTML and JavaScript, create a select option field with five given options. The options should be dynamically generated from an array of objects, where each object has a label and a value. The select field should only display options that have a value greater than or equal to 3. Additionally, the select field shou...
codefeedback
Edit the following code so that it prints out an upside-down right triangle of size n. Additionally, add a condition that only prints the triangle if n is an odd number. Otherwise, it should print a message saying "Invalid input: n must be an odd number". int n = 6; if (n % 2 == 0) { System.out.println("Invalid inpu...
codefeedback
Create a Python program to extract the URLs from a given list of strings, where the URLs must be in a specific format: - They must start with "http://" or "https://" - They must contain at least one dot (.) after the domain name - They must not contain any special characters or spaces
codefeedback
Write a JavaScript function to check whether a string contains all the vowels in alphabetical order. Additionally, the function should also check for consecutive vowels in the string.
codefeedback
Generate a correct Java program to swap two given numbers without using any temporary variables.
codefeedback
Write a code to find the most frequently occurring item in a list of integers, where the length of the list is n and each integer is in the range of 1 to m. Additionally, the code should have a time complexity of O(n) and a space complexity of O(m).
codefeedback
Write Python code to merge two given dictionaries into a single dictionary. The keys in the merged dictionary should be sorted in descending order based on their values. In addition, the merged dictionary should only include keys that have values greater than or equal to 5. If there are duplicate keys with different va...
codefeedback
Explode a string with a given delimiter, while also removing any whitespace characters before and after each element in the resulting list. given_str = "apple, banana, orange"
codefeedback
Program a binary search algorithm. data: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20] target: 16 In addition to finding the target number, your algorithm should also return the number of comparisons made during the search process. To further increase the difficulty, you should implement the binary search algorithm recursivel...
codefeedback
Write a Bash script to check if the number of arguments supplied is equal to 3 or not, and if they are all positive integers.
codefeedback
Write a Python program to convert a given binary string to its equivalent hexadecimal representation. However, you are not allowed to use any built-in functions or libraries to perform the conversion. You must implement the conversion logic from scratch using only basic operations and data structures.
codefeedback
Construct a Python class for a camera object that includes the following methods: 1. `capture_photo()` - captures a photo and returns the image data. 2. `record_video(duration: int)` - records a video for the specified duration (in seconds). 3. `zoom_in(level: int)` - zooms in the camera by the specified level. 4. `zoo...
codefeedback
Consider the formula z = (x1^n + x2 + x3)(2x2 + 3x3), where n is a positive integer. Find the value of y. Given that x1 = 2, x2 = 4, and x3 = 6. To find the value of y, we need to evaluate the expression z. 1. Calculate x1^n: - Determine the value of n. - Raise x1 to the power of n. 2. Calculate (x1^n + x2 + ...
codefeedback
Write a Python program to calculate the sum of the digits in a positive integer N, where N can have up to 1000 digits.
codefeedback
Implement a modified version of the selection sort algorithm to sort the given array in descending order. The array may contain duplicate elements.
codefeedback
Insert the missing code in the function below to sort an array of strings in descending order: arr = ["hello", "apple", "cat"] def sort_str(arr): # Insert code here
codefeedback
Design a Java program to display the given integer in reverse, but you are not allowed to use any built-in functions or data structures (such as arrays or strings) to store or manipulate the digits of the integer. You can only use basic arithmetic operations and control structures (such as loops and conditionals).
codefeedback
Write a Python program to read a list of numbers, sort them in descending order, and print them as a single string without any space.
codefeedback
Write a JavaScript function that takes in two arrays as parameters and returns a new array containing only the elements that are common to both input arrays. The order of the elements in the resulting array should match the order in which they appear in the first input array.
codefeedback
Generate a C program to encrypt a sentence using Vigenère cipher with a user-defined key. The quick brown fox jumps over the lazy dog
codefeedback
Write a program that makes an HTTP request using AJAX and XMLHttpRequest, and displays the response data on the webpage.
codefeedback
Explain the differences between the for loop, while loop, and do-while loop in Java, and provide examples of when each loop would be most appropriate to use. Additionally, discuss the time and space complexity of each loop and how it can impact the performance of a program.
codefeedback