instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Write a Java program to read input from the console and perform the following operations: 1. Prompt the user to enter their name and read the input. 2. Display a greeting message that includes the user's name. 3. Prompt the user to enter their age and read the input. 4. Calculate and display the year in which the user...
codefeedback
Can you detect if a given number is a prime number?
codefeedback
Write a function that calculates the nth Fibonacci number using recursion.
codefeedback
Write a function in Python that takes in two strings as input and concatenates them together. The function should check if either of the input strings is empty, and if so, it should raise a ValueError. Additionally, the function should ignore any leading or trailing whitespace in the input strings before concatenating ...
codefeedback
Calculate the maximum of an input array, but with the following additional conditions: 1. If the array is empty, return None. 2. If the array contains duplicate maximum values, return the first occurrence of the maximum value. 3. If the array contains only negative values, return the maximum negative value. 4. If the a...
codefeedback
Use a programming language to generate the Fibonacci sequence up to the 100th number.
codefeedback
Write a function to extract all URLs from a given HTML document, but exclude any URLs that contain query parameters.
codefeedback
Edit the following while loop to fix the error. However, you should also modify the code to use a nested loop structure to print the numbers in a specific pattern. i = 0 while i <= 5: for j in range(i): print(j, end=' ') print() i = i + 1
codefeedback
Write a Python function that takes a list of integers as input and sorts it in descending order. Make sure to implement the sorting algorithm yourself and not use any built-in sorting functions or methods.
codefeedback
Create a HTML page to display a given list of items in a table format with alternating row colors. Implement a search functionality that allows the user to filter the items based on a keyword. Additionally, add pagination to display a limited number of items per page and provide navigation buttons to allow the user to ...
codefeedback
Output code for a function that accepts one argument and returns the square of the argument, but without using any arithmetic operators or built-in functions.
codefeedback
Construct a class Student which will take in attributes name, age, city, and grade upon initialization. The grade attribute should be a list of integers representing the student's grades in various subjects. The length of the grade list should be at least 5. The class should have the following methods: 1. `calculate...
codefeedback
Output code for a function that prints the multiplication table of a given number, but with the following additional requirements: 1. The multiplication table should only display numbers that are prime. 2. The multiplication table should be formatted in a grid-like structure, with each row and column labeled with the c...
codefeedback
Output code for a function that will remove all instances of an element from a given list, while preserving the order of the remaining elements. The function should also return the number of elements removed. The input list may contain duplicate elements. The element to be removed will be provided as an additional argu...
codefeedback
Provide an example of a valid JSON object that includes nested objects and arrays.
codefeedback
Write a function that finds the longest word in a given list of words and outputs it. The longest word should meet the following criteria: - It must start with a vowel. - It must contain at least one consonant. - It must have an even number of characters. - It must not contain any duplicate letters. words_list = ["app...
codefeedback
Write a program that takes an input integer n and generates the Fibonacci sequence up to the nth term. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones. It starts with 0 and 1. The function should include input validation to ensure that n is a positive integer. ...
codefeedback
Implement a machine learning algorithm from scratch that can accurately classify a dataset of images into multiple categories. The algorithm should use advanced mathematical models such as deep neural networks and convolutional neural networks to extract features from the images and make predictions. Additionally, the ...
codefeedback
How does a recursive function work in Python? Write a recursive function that calculates the factorial of a given number. The function should handle only positive integers and should return an error message for any other input. Additionally, the function should have a maximum recursion depth of 1000.
codefeedback
Implement a hash table class in any programming language of your choice. The hash table should support the following operations: 1. `put(key, value)`: Insert a key-value pair into the hash table. 2. `get(key)`: Retrieve the value associated with a given key from the hash table. Return `-1` if the key is not found. 3. ...
codefeedback
Generate a correct HTML code to create a hyperlink with the following requirements: 1. The link text should be a randomly generated string of length between 10 and 20 characters. 2. The link URL should be a randomly generated string of length between 20 and 30 characters. 3. The hyperlink should have a CSS class appli...
codefeedback
Utilizing the Java syntax, write a code snippet to find the maximum value in the given array. However, you are not allowed to use any built-in array sorting or max functions. Array: [4, 15, 11, 26, 2]
codefeedback
Create a Ruby method that takes two strings and concatenates them using a divide and conquer approach, with a time complexity of O(n log n).
codefeedback
Rewrite the Fibonacci sequence algorithm by including a memoization technique to improve its time complexity.
codefeedback
Implement a queue using two stacks in Python.
codefeedback
Utilizing the SQL language, write a query to select the longest word from the given table, but exclude any words that contain the letter 'e' in them. Table: words Column Names: id, name
codefeedback
Compose a Python code for computing the factorial of a given number, using recursion.
codefeedback
Write a Tensorflow code for building a neural network with three input layers, four hidden layers and two output layers.
codefeedback
Using Java, create a class that implements sorting of an array of integers. However, this time, you need to implement the sorting algorithm without using any built-in sorting methods or libraries. Also, the sorting algorithm needs to be efficient and have a time complexity of O(n log n). Provide a piece of erroneous...
codefeedback
Construct a SQL query to select all people who are 25 or older and have a valid email address. Table name: people Additional constraint: The email address must contain at least one special character.
codefeedback
Develop a function that converts an array of real numbers to its nearest integer values, while also rounding up the values if they are greater than 0.5 and rounding down if they are less than or equal to 0.5. Array: [3.5, 4.7, 7.9] Note: The function should have a time complexity of O(n), where n is the length of the ...
codefeedback
Write an SQL query to fetch the rows with the top 3 highest salary from the table, while excluding any employees with a salary below 75.
codefeedback
Utilizing the C language, write pseudo code for performing a binary search in an array of integers. The array is sorted in ascending order. 1. Define a function called binarySearch that takes in three parameters: the array to be searched, the starting index of the search range, and the ending index of the search range...
codefeedback
Generate a number in the range between 1 to 10 randomly without using any built-in random functions.
codefeedback
Write an algorithm to calculate the median of a given array. The array can contain duplicate elements and can have a length of up to 10^6. The algorithm should have a time complexity of O(nlogn) or better. The median should be calculated using the efficient median of medians algorithm.
codefeedback
Create a Python dictionary with key-value pairs (fruit-quantity) as listed below. The quantity of each fruit should be a randomly generated integer between 1 and 1000. The dictionary should contain at least 10 different fruits.
codefeedback
Write a function that takes in a nested array and returns a flattened version of the array. The function should handle arrays of any depth and size. Example: Input: [1, [2], 3, [4, [5, 6], 7]] Output: [1, 2, 3, 4, 5, 6, 7] Note: Your function should not use any built-in array flattening methods.
codefeedback
Find the subarray with the largest sum in an integer array of length n. The subarray must consist of consecutive elements. Time Complexity Requirement: O(n) Space Complexity Requirement: O(1) Example Input: [3, -2, 1, 5, 6, -1, 4] Example Output: [1, 5, 6]
codefeedback
Write a function to generate valid random passwords with the following criteria: - The password length must be specified as a parameter to the function. - The password must contain at least one uppercase letter, one lowercase letter, one digit, and one special character. - The password must not contain any repeated cha...
codefeedback
Insert a node at the end of a linked list. [10 -> 15 -> 20 -> 25]
codefeedback
Write a Python code snippet to display the multiplication table of 5 up to the number 10.
codefeedback
Create a function to print the elements of a singly linked list in reverse order without using any extra space.
codefeedback
Compute the minimum number of edits required to transform one string into another, where each edit is defined as either inserting a character, deleting a character, or substituting one character for another. The algorithm should return the sequence of edits required to transform str1 into str2. str1 = "I am eating" st...
codefeedback
Identify the longest consecutive sequence of zeros in a binary string and return the index of the first zero in that sequence. If there are multiple sequences of the same length, return the index of the first occurring sequence. Example: Input: "110010001" Output: 3 Explanation: The longest consecutive sequence of z...
codefeedback
Write a MySQL query to find all records with the last name "Smith" and the first name starting with the letter "J".
codefeedback
Formulate a loop in Python that prints the square of each number from 7 to 18.
codefeedback
Debug the following Java code to return the number of elements in the list. The code should also handle the case where the list is null and return 0 in that case. Additionally, the code should not use the length() method but should instead iterate through the list and count the elements manually. Finally, the code shou...
codefeedback
Write a JavaScript function that takes two parameters: a starting number and an ending number. The function should return a new array containing the squared values of all odd numbers within the range (inclusive). The function should have a time complexity of O(n), where n is the number of elements in the range.
codefeedback
Form a while loop using PHP that prints the odd numbers from 6 to 14 in descending order.
codefeedback
Write a SQL query that joins three tables and retrieves specific data based on multiple conditions. Table1: Id Name Age 1 John 30 2 Alice 20 Table2: Id Country 1 USA 2 England Table3: Id Salary 1 50000 2 60000 The query should retrieve the names and salaries of all individuals from Table1 who are above the age of 2...
codefeedback
Write a Java program to print the first 20 numbers in the Fibonacci series, where each number is a prime number and less than 100.
codefeedback
Rewritten Test: Write a Python function that takes a string as input and checks if it is empty. The function should return True if the string is empty and False otherwise. Example usage of the function: str1 = "My String" str2 = "" print(is_empty(str1)) # False print(is_empty(str2)) # True Additional Requirements: ...
codefeedback
Generate a random hexadecimal string of length 16. The generated string should not contain any repeating characters.
codefeedback
Evaluate the polynomial f(x) = 4x^3 + 7x^2 + 5x + 1 at x = -3.
codefeedback
Write a shell script to find the most used command in a specific log file within a specified time range.
codefeedback
Use Python to print a multiplication table for the numbers from 1 to
codefeedback
Modify the code below to calculate the sum of all prime numbers between 1 and 100 using a list comprehension. # Print the sum of prime numbers between 1 and 100 print(sum([num for num in range(2, 101) if all(num % i != 0 for i in range(2, int(num ** 0.5) + 1))]))
codefeedback
Write SQL query that create a table that contains four columns: a primary key integer, a string, a boolean, and a foreign key referencing another table. The table should also have a unique constraint on the string column. tablename = my_table
codefeedback
Edit this HTML form to make sure that the input data is validated. The name field should only accept alphabetic characters and have a maximum length of 50 characters. The form should also include a required email field that should be in a valid email format. The submit button should be disabled until all the required f...
codefeedback
Compute the median of a given set of integers [1, 6, 5, 8, 14, 9] by implementing a sorting algorithm from scratch, such as bubble sort or insertion sort, and then finding the middle element.
codefeedback
Design a class that can be used to represent books. Each book should have the following properties: title, author, publisher, publication year, genre, and ISBN number. Additionally, the class should have the following methods: 1. A method to display the book's information, including all its properties. 2. A method to ...
codefeedback
Using SQLite3, how can one create a table in an existing database while ensuring that the table has a primary key and at least two unique constraints?
codefeedback
Build a React component to add a text field, a submit button, and a character counter. The character counter should display the number of characters entered in the text field. Additionally, the submit button should be disabled if the number of characters entered is less than 5. Requirements: - The component should be...
codefeedback
Write a CSS code to apply different paddings to the left, right, top, and bottom sides of an element with class name "element". Additionally, the padding should be different for different screen sizes.
codefeedback
Write an Ansible playbook to install an Apache webserver and configure it to use a custom SSL certificate for secure HTTPS connections.
codefeedback
Create a JavaScript class that simulates a bank account with the following additional requirements: - The account should have a unique account number consisting of 10 alphanumeric characters. - The account should have a minimum balance of $1000. - Implement a method to deposit a certain amount into the account, which s...
codefeedback
Create an Angular component that consists of a dropdown menu filled with a list of countries. Implement a search functionality where the dropdown menu dynamically filters the list of countries based on the user's input. The dropdown menu should update in real-time as the user types in the search box. Additionally, add...
codefeedback
How can one parse a deeply nested JSON string in JavaScript while optimizing for performance and minimizing memory usage?
codefeedback
Create a Javascript function that will loop through an array of numbers and calculate the sum of all the elements. The function should return the sum. The time complexity of the function should be O(n), where n is the number of elements in the array.
codefeedback
Construct an algorithm to apply merge sort to an array of integers, but without using recursion. The algorithm should use an iterative approach to sort the given array. [1, 10, 2, 5, 8, 7]
codefeedback
Write a script in JavaScript to perform a bank transaction that includes multiple account types (such as checking, savings, and investment) and allows for complex transaction logic, including interest calculations and account transfers between different account types.
codefeedback
Write a function in Java to find the first and last occurrence of a given element in an array of integers and return their indices. Example: Input: [4, 8, 2, 4, 1], element = 4 Output: First occurrence: 0, Last occurrence: 3 Input: [1, 2, 3, 4, 5], element = 6 Output: Element not found. Note: - The input array can h...
codefeedback
Create a machine learning algorithm to classify emails as spam or not spam. In addition to this, your algorithm should also categorize the emails into different spam categories, such as phishing, malware, or advertising.
codefeedback
Create a function in Python that takes two list of strings as parameters and returns a third list of strings which are the elements common in both lists. The function should have a time complexity of O(n), where n is the length of the longer list. list1 = ["apple", "orange", "banana", "cherry", "mango", "pear", "peac...
codefeedback
Create a Bash function that takes an integer between 65 and 122 as input and prints out the corresponding ASCII character.
codefeedback
Implement a linked list data structure in the language of your choice. Ensure that your implementation includes the following methods: 1. `insert(value)`: Insert a new node with the given value at the end of the linked list. 2. `delete(value)`: Remove the first occurrence of a node with the given value from the linked...
codefeedback
Create a C++ class to simulate a stack data structure with the following additional functionalities: 1. Implement a method to check if the stack is empty. 2. Implement a method to check if the stack is full. 3. Implement a method to push an element onto the stack. 4. Implement a method to pop an element from the stack...
codefeedback
Create a class in C# to calculate compound interest, with the following additional requirements: 1. The class should have a constructor that takes in the principal amount, interest rate, and number of years as parameters. 2. Implement a method called "CalculateInterest" that returns the compound interest amount. 3. In...
codefeedback
Write an HTML page that takes an email address as input and displays a "Thank you" message after the submission. Additionally, the page should validate the email address to ensure it is in the correct format (e.g., username@domain.com). If the email address is not in the correct format, display an error message instead...
codefeedback
Create a C program that prints the number of times a character is present in a given string, but also include a condition that checks if the character is a digit or a letter. If the character is a digit, the program should print "Character is a digit" and if the character is a letter, the program should print "Characte...
codefeedback
Write a SQL query to select the 10th highest salary from an employees table, but exclude any employees whose job title is "Manager".
codefeedback
Create a Bash script that takes two sentences as arguments and outputs the unique words present in both sentences. The script should ignore case sensitivity and consider words with different cases as the same word. Write Code
codefeedback
Create a Java program to find the maximum number within a list of integers, excluding any negative numbers. Additionally, the program should handle the case where the list is empty and return an appropriate message.
codefeedback
Edit this program to print the output as "Hello World" while also ensuring that the program takes a user input, converts it to uppercase, and prints it before the greeting. Additionally, add a constraint that the program must be written using only a single line of code. name = input("Enter your name: ") ; print("Hello ...
codefeedback
Create a C++ program that multiplies two numbers and then calculates the factorial of the result.
codefeedback
Create a Java program to find the area and circumference of a circle with a given radius. The program should be able to handle multiple circles with different radii in a single run. Additionally, the program should allow the user to choose between calculating the area and circumference for each circle. The program sho...
codefeedback
Create a JavaScript function to format a date object into day, month, and year, while also accounting for different time zones and displaying the date in both 12-hour and 24-hour formats.
codefeedback
Use numpy to create a 1000x1000 matrix full of random integers between 1 and 100.
codefeedback
Create a CSS3 animation to move an element from left to right, but also make it scale up and change color gradually during the animation.
codefeedback
Transform the below SQL query into MongoDB. SELECT user_id, COUNT(*) FROM orders WHERE status = 'completed' GROUP BY user_id HAVING COUNT(*) > 1 ORDER BY COUNT(*) DESC;
codefeedback
Convert the below JSON data into an equivalent XML format. Additionally, handle the case where the address field is missing or invalid. { "name": "John", "age": 30, "address": { "street": "1 Main Street", "city": "London", "country": "UK" }, "contact": { "email": "john@example.com", "phon...
codefeedback
Create a JavaScript program that formats currency values in a given currency code and locale. ## Requirements: 1. The program should take two parameters: a currency value as a number, and a currency code as a string. 2. The currency code should be a valid ISO 4217 code (e.g., "USD" for US Dollar, "EUR" for Euro, "JPY"...
codefeedback
Using TensorFlow, create a model that predicts the price of an item from its features. Additionally, implement a custom loss function that penalizes overfitting and a regularization technique to improve the model's performance.
codefeedback
Create a machine learning model to classify the following dataset, but with the requirement that you can only use a binary classification algorithm and not a multi-class classification algorithm.
codefeedback
Write a function in Scala that processes a list of integers and returns the sum of all the prime numbers in the list.
codefeedback
Define a class in C++ to represent a movie theater that has a maximum capacity of 100 seats. The theater must also keep track of the availability of each seat, with the option to reserve and release seats. Additionally, the class should have a method to calculate the total revenue generated from ticket sales, taking in...
codefeedback
Create a program to check if two binary trees are identical in structure and have the same values in each corresponding node.
codefeedback
Create a program to find the maximum depth in a binary tree. The binary tree is represented by a root node, and each node can have at most two children nodes. Each node in the binary tree contains an integer value. The maximum depth of a binary tree is defined as the number of nodes along the longest path from the root...
codefeedback
Assign values to a given linked list with 4 nodes in such a way that the values are in ascending order.
codefeedback
Create a machine learning model to classify an email into spam and non-spam classes, taking into consideration the sender's IP reputation and the email's language. The model should also include a feature to detect and remove any potential malware attachments in the email.
codefeedback