instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Add a loop to the code to print out the Fibonacci sequence up to the 100th term. Additionally, the program should only use constant space complexity and execute in O(n) time complexity. | codefeedback |
Algorithmically classify a given sentence as either a declarative sentence, an interrogative sentence, an imperative sentence, or an exclamatory sentence. Additionally, determine the tense of the verb if it is identified as a verb.
sentence = "Please write a letter." | codefeedback |
Define a Python class called "Person" that has the following attributes and methods:
Attributes:
- name: a string representing the person's name
- age: an integer representing the person's age
- height: a float representing the person's height in meters
- weight: a float representing the person's weight in kilograms
... | codefeedback |
Create a SQL query that prints a list of customers who have made at least 5 orders within the last 30 days, with a total order amount exceeding $5000 and at least one order with a quantity greater than 10. | codefeedback |
Given a list of integers, reverse the order of its elements without using any built-in functions or methods for list manipulation. You can only use basic programming constructs like loops and conditional statements. The time complexity of your solution should be O(n), where n is the length of the list.
For example, gi... | codefeedback |
Write a JavaScript code snippet that displays the Fibonacci sequence up to the nth term on the webpage, where n is a positive integer provided by the user. However, you are not allowed to use recursion or the formula for calculating Fibonacci numbers. You must implement the Fibonacci sequence using a loop and without a... | codefeedback |
Write a Java method that takes an array of integers as input and returns the sum of all the even numbers in the array. The method should only use a single loop and have a time complexity of O(n), where n is the length of the array. Additionally, the method should not use any built-in Java methods or libraries for calcu... | codefeedback |
Create a function which takes two strings as parameters and return the concatenating of the two strings. Additionally, check if either of the input strings is empty and handle it accordingly by returning an error message. If both strings are not empty, convert the first string to uppercase and the second string to lowe... | codefeedback |
Write a Java method that takes two positive integers less than or equal to 1,000,000 and returns the sum of their digits. The method should also handle negative integers and zero as input, returning -1 for negative integers and 0 for zero input. | codefeedback |
Debug the following C code so that it compiles and runs successfully. Your solution should also include the following additional requirements:
1. The code should utilize at least one user-defined function and one library function.
2. The program should take user input to display a personalized greeting message, includi... | codefeedback |
Create a Python program to calculate the product of a list of integers, but the program should also handle negative integers, float numbers, and zero values in the list. Additionally, the program should ensure that the product does not exceed a specified upper limit and return an error message if it does. | codefeedback |
Create an HTML form that contains a text box and a submit button. The submit button should be disabled initially and only become enabled when the text box is not empty and the text box contains a minimum of 5 characters. Additionally, the form should have client-side validation to ensure that the text box only accepts ... | codefeedback |
Create a Keras model that can classify between three classes, each representing a different type of fruit (e.g., apple, orange, banana). Additionally, implement a data augmentation technique such as random rotation or zoom to enhance the model's ability to generalize and improve accuracy. However, the dataset provided ... | codefeedback |
Write a code to implement a scientific calculator that can perform addition, subtraction, multiplication, and division operations on two numbers. Additionally, the calculator should also be able to handle decimal numbers and display the result with a specific precision.
Furthermore, the calculator should allow the use... | codefeedback |
Write an HTML form that collects the name, email, address, and phone number of a customer. Additionally, include validation for each field to ensure that the name is at least 2 characters long, the email is in the correct format (e.g. example@example.com), the address is not empty, and the phone number is a valid US ph... | codefeedback |
Create a game of rock-paper-scissors-lizard-Spock using functions and conditionals. Implement the game logic without using if-else statements and without using any comparison operators (such as `==`, `!=`, `<`, `>`, `<=`, `>=`, `in`, `not in`, etc.).
Note: In the game of rock-paper-scissors-lizard-Spock, each player s... | codefeedback |
What is the most efficient and secure method to generate a random number within a specific range using the random module in Python, while also ensuring that the generated number is not repeated within a given session and the generated number must be a prime number? | codefeedback |
How would you print the contents of a 2D array in Python, ensuring that each element is printed on a new line and properly aligned? Additionally, the array contains both integers and strings, and you need to handle them differently when printing. | codefeedback |
Implement a modified version of quicksort in Python that uses a randomized pivot selection strategy and an additional constraint that only allows for in-place sorting, without using any additional data structures or recursion. The time complexity of the algorithm should be O(n log n), and the space complexity should be... | codefeedback |
Generate a unique alphanumeric string of length 10, where each character can be an uppercase or lowercase letter or a digit. The string should not contain any repeated characters. Additionally, the string should be in lexicographically increasing order, meaning that each character in the string should be greater than t... | codefeedback |
Create a C code to generate a custom encryption algorithm for a given string. The algorithm should replace each character in the string with its ASCII value multiplied by its position in the string. Additionally, the algorithm should add a randomly generated number to each character's ASCII value before performing the ... | codefeedback |
Implement a function which will take a list of numbers as an input and return a sorted list. The function should have a time complexity of O(n log n) and should not use any built-in sorting functions or libraries. Additionally, the function should handle duplicate numbers in the input list and should remove any duplica... | codefeedback |
Output the first 100 prime numbers in reverse order. | codefeedback |
You need to write a script in Java to reverse a given list of Strings. Additionally, you need to sort the reversed list in alphabetical order. You are not allowed to use any built-in functions or libraries for reversing or sorting the list. The time complexity of your solution should be O(nlogn), where n is the length ... | codefeedback |
Create a JavaScript code to find the frequency of each unique vowel in a string, excluding any special characters or whitespace. The code should output the result in descending order of character frequency. | codefeedback |
Create a function that takes in a list of strings and a target string. Iterate through the list and print only the strings that contain the target string as a substring. Additionally, the function should ignore case sensitivity when checking for the target string as a substring. The function should also return the coun... | codefeedback |
Write an SQL query to select the top 5 customers based on the sum of dollars spent within the last 30 days, excluding any customers who have made a purchase within the last 7 days. Additionally, display the total number of purchases made by each customer within the last 30 days. | codefeedback |
Write a program that takes two integers as input and calculates the sum of all the even numbers between them (inclusive). Display the result as output. | codefeedback |
Split a string of words into an array of words. The string will contain only alphabets and spaces. The words in the string are separated by a single space. The input string can have multiple spaces between words. The output array should not contain any duplicate words. Additionally, all words in the output array should... | codefeedback |
Create a HTML code to generate a three-column table from a given JSON object, where each column represents a different data type (string, number, boolean). The JSON object will contain a minimum of 20 key-value pairs. Additionally, you must implement a sorting functionality that allows the user to sort the table by any... | codefeedback |
Write an encryption function using Caesar Cipher that can handle both uppercase and lowercase letters. Additionally, the function should also be able to handle punctuation and spaces without altering them. The function should also support multiple encryption keys, where each key can be either a positive or negative int... | codefeedback |
Write an optimized SELECT query to retrieve customer details from a customer table that also includes their total number of orders, the average order value, and the total revenue generated by each customer.
#Explanation#
To increase the difficulty of the original question, we have added the requirement of retrieving t... | codefeedback |
Compute the median value of all the elements in an array of size n (1 <= n <= 10^6) of integers, where each integer is between -10^9 and 10^9 inclusive.
You must compute the median value in O(n) time complexity and O(1) space complexity.
Note: The median is the middle value of a sorted list of numbers. If the list ha... | codefeedback |
Given a JSON string, parse the string and convert it into an object. The JSON string may contain nested objects and arrays.
1. First, initialize an empty object to store the parsed JSON.
2. Iterate through each key-value pair in the JSON string.
3. For each key-value pair, check if the value is a nested object or an a... | codefeedback |
Write a query to find the nth highest salary from the table Employees, where n is a user-inputted parameter. | codefeedback |
Reverse the words of the English sentence "This is a pen" and convert all vowels to uppercase. Write a function called "reverseWordsAndConvertVowels" that takes a string as input and returns the modified string.
Sample Input: "This is a pen"
Sample Output: "sihT si A nEp"
Note: Assume that the input sentence will onl... | codefeedback |
Design a doubly linked list structure for storing integers. Implement the following additional methods:
- `prepend(value)`: Add a new node with the given value to the beginning of the linked list.
- `insert_after(node, value)`: Insert a new node with the given value after the specified node.
- `remove_at(index)`: Remov... | codefeedback |
Create a Python class for a 5×5 matrix that supports addition, subtraction, and multiplication operations. The class should also include methods to calculate the determinant, inverse, and transpose of the matrix. Additionally, the matrix values should be limited to integers between -1000 and 1000, inclusive. The class ... | codefeedback |
Given an array of integers, find all the pairs of numbers that can be expressed as the sum of two squares, such that the sum is also a prime number. If there are multiple pairs with the same sum, return all of them.
Example:
arr = [2, 3, 4, 6, 8, 10]
Output: [(2, 3)]
Explanation:
- 2 can be expressed as 1^2 + 1^2, w... | codefeedback |
Write a function to calculate the Average True Range of a given array of price data.
The Average True Range (ATR) is a technical indicator used to measure market volatility. It is calculated by taking the average of the True Range values over a specified period.
The True Range is the greatest of the following three v... | codefeedback |
Classify the following code as either a while loop or a for loop. Additionally, the code should output the sum of all the numbers printed during the loop. The output must be stored in a variable named "total". The code should also only print prime numbers during the loop.
i=0
while (i<10):
if i % 2 != 0:
if i % 3 !... | codefeedback |
Write a function that finds the longest substring without repetition in a given string, but with the following additional requirement: the substring must contain at least one vowel.
str = "pwwkew"
In this problem, we need to find the longest substring in a string without any repeating characters, while also ensuring ... | codefeedback |
Code a function in Python to send a web page request to a given URL and return the response status code, along with any specific error messages for different types of exceptions that may occur during the request. The function should also handle any connection timeouts and retry the request a certain number of times bef... | codefeedback |
Generate a code to execute a block of code 20 times in Python, and print the current iteration number within the block. However, you should use a list comprehension to achieve this, instead of a traditional loop. | codefeedback |
Create a code to save the first 100 prime numbers that are greater than 1,000,000 in a dynamically allocated array. | codefeedback |
Design a MongoDB collection Schema for stores' inventory records. In addition to the basic inventory data, the schema should include fields for tracking the following information:
1. The date and time the inventory record was created.
2. The date and time the inventory record was last updated.
3. The name of the user w... | codefeedback |
Write a JavaScript program to calculate the area of a triangle with the side lengths a, b, and c, where a, b, and c are inputted by the user. Ensure that the program can handle input of decimal values for the side lengths, and round the final answer to two decimal places.
Erroneous Code:
```
function calculateArea(a, ... | codefeedback |
Write a code to create a sentence from a given list of words. The words in the list may contain special characters, numbers, and white spaces.
words = ["Today","I","am","happy","!","123", " "]
#Erroneous Code#
```
def create_sentence(words):
sentence = ""
for word in words:
if word.isalpha():
... | codefeedback |
Modify the code snippet so that it prints the **second largest** element in the given list, without using any built-in sorting functions. Additionally, the solution should have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Given a list, print all its elements in reverse order. If the list contains any negative numbers, ignore them and continue printing the rest of the elements in reverse order. Additionally, the program should sort the elements in ascending order before printing them in reverse order.
list = [2, -3, 4, -5, 6] | codefeedback |
Given a list of integers, find the median of the list. Make sure to handle cases where the list is empty or has an even number of elements. | codefeedback |
Write a function in JavaScript that takes in two operands and checks if their values and types are equal or not. The function should return a boolean value indicating the result. You are not allowed to use any built-in comparison operators such as `==` or `===`. | codefeedback |
Create a class called Team that has the following attributes: name (string), players (list of Player objects), and captain (Player object). The captain attribute should represent the team captain and must be one of the players in the players list. Additionally, the captain must have a role attribute which can only be o... | codefeedback |
Write a code that inverts the case for each character in the given string. The code should not use any built-in functions or methods for case conversion. Additionally, the code should be implemented in a single line using a lambda function. | codefeedback |
Write a stored procedure in MySQL to subtract two numbers, where the numbers should be greater than zero, should not exceed 1000, and should be prime numbers. | codefeedback |
Write a code to construct a balanced BST with the elements 11, 18, 14, 6, 7, 4, 23, 15, 8, 10. The resulting tree should be height balanced and have the minimum possible height.
Note: You are not allowed to use any built-in data structures or libraries for implementing the BST. You need to write the BST implementation... | codefeedback |
Generate a unique random number in the range of 0 to 100, such that it is not divisible by any prime number less than | codefeedback |
Clone the repository from the given remote url, ensuring that the cloned repository is placed in a directory with a specific name. The name of the directory should be the concatenation of the first 3 letters of the repository owner's username (excluding any numbers) and the last 3 letters of the repository name (exclud... | codefeedback |
If a given string contains five consecutive identical characters and the string is at least 10 characters long, write a code to print the string and the count of the consecutive characters. Additionally, the code should ignore any consecutive characters that are followed by a space character. | codefeedback |
Given a list of integers, remove all elements that are divisible by 4 and are not prime numbers. Additionally, the solution should have a time complexity of O(n) and a space complexity of O(1).
list = [8, 5, 6, 8, 9, 3, 10, 13, 16, 17, 20, 23, 25, 28, 31]
Note: You are not allowed to use any built-in libraries or fun... | codefeedback |
Print a text in reverse order without using any built-in function or loop. The text can contain any printable ASCII characters. The solution must have a time complexity of O(n), where n is the length of the text, and must not use any additional data structures. Additionally, the solution must be implemented using only ... | codefeedback |
Compute the length of a given string without using in-built length function, without using any looping constructs (such as for, while, etc.), and without using recursion. The solution must have a time complexity of O(1). | codefeedback |
Design a SQL query to find the average age of your group's members who have joined in the last month and have made at least 10 posts in the past week. | codefeedback |
Request the average temperature of the city 'Boston' from the Weather API and calculate the standard deviation of the temperatures for the past month. Additionally, provide a list of days with temperatures that are more than two standard deviations above or below the average temperature. | codefeedback |
Insert the missing code to print the list of numbers in reverse order, while also ensuring that the program only uses a single loop and does not use any built-in functions or methods for reversing the list. Additionally, you are not allowed to use any temporary variables or create new lists.
nums = [1, 2, 3, 4, 5] | codefeedback |
Create a TCP server program using Python that can handle multiple concurrent connections.
Requirements:
1. The server should be able to handle a minimum of 20 concurrent connections.
2. Each connection should be handled in a separate thread.
3. The server should have a timeout mechanism to close idle connections after... | codefeedback |
Print out the lyrics of a song with 4 verses, where each verse has exactly 4 lines and each line should have a maximum of 10 words. | codefeedback |
Create a program to calculate the Greatest Common Denominator (GCD) of two numbers, but you are not allowed to use any built-in mathematical functions or libraries for calculating the GCD. Additionally, the program should have a time complexity of O(log(min(a, b))) and a space complexity of O(1), where a and b are the ... | codefeedback |
Generate a query to return copies of the records in a table, but exclude any records where the value of a specific column is within a given range and where another specific column satisfies a complex condition.
Table Name: Products
Column Name: Price
Range: $100 - $500
Complex condition: Exclude records where the valu... | codefeedback |
Construct a doubly linked list using the given data in ascending order. The doubly linked list should also support the following operations:
1. Insert a new node at the beginning of the list.
2. Insert a new node at the end of the list.
3. Insert a new node at a specific position in the list.
4. Delete a node from the... | codefeedback |
In a given list of integers, find the value that appears most frequently. The list may contain negative numbers and the list may also contain non-integer values. The list will always contain at least one repeated value. Also, the list may be very large with millions of elements. The algorithm should have a time complex... | codefeedback |
Insert a node at a specific position in a singly linked list. The linked list is represented by a head pointer. Implement the function `insertNodeAtPosition` that takes in the head pointer of the linked list, the value of the node to be inserted, and the position at which the node should be inserted. The position is 1-... | codefeedback |
Write a Pascal program to convert a number from decimal to hexadecimal. Additionally, the program should handle negative numbers, floating-point numbers, and include error handling for invalid input. Implement the conversion algorithm without using any built-in functions or libraries for number conversion. | codefeedback |
For the given text, write a program that prints the position and letter of each vowel. Additionally, count the total number of vowels and print it at the end.
Example:
Input:
text = "Programming is fun"
Output:
Vowel found at position 1: o
Vowel found at position 5: a
Vowel found at position 11: i
Vowel found at posi... | codefeedback |
Design a deep learning model using convolutional neural networks (CNNs) in Python to predict the sentiment of movie reviews. The model should take into account both textual and visual features extracted from the movie reviews, such as word embeddings and frame-level visual features from video clips. Additionally, the m... | codefeedback |
Write SQL code to count the number of unique customers who have made at least 5 orders from the orders table and have placed their orders in the last 3 months. | codefeedback |
Write an SQL query to get the rows which contain the values 'Apple' and 'Banana' in the same row in the table fruits. Additionally, the query should only include rows where the value of 'Apple' appears before the value of 'Banana' in the item column. The query should be case-insensitive and should only consider the fir... | codefeedback |
Write a Python function that determines if a given number is prime. The function should also output the smallest prime number that is larger than the given number. The input number will be a positive integer less than or equal to 10^6.
To increase the difficulty, add the following erroneous code as a reference:
```py... | codefeedback |
Create a program that checks for duplicates in a list of strings and removes them. Additionally, the program should also keep track of the count of each unique string in the list and display the top 3 most occurring strings in descending order. If there are multiple strings with the same count, display them in lexicogr... | codefeedback |
Write an SQL query to find the names and scores of the top 10% of students in a class. Display the students in descending order of their scores. If two or more students have the same score, prioritize the student with the higher ID.
Table Name: students
Table Schema: id INT, name VARCHAR(20), score INT
Erroneous Code... | codefeedback |
Given a list of numbers, write a Python function to find out the sum of the squares of all the numbers, but only if they are positive integers. If the list contains any negative numbers, non-integer elements, or any number greater than 100, raise a ValueError with the message "Invalid input. The list should only contai... | codefeedback |
Write Java code for converting a string to an array, but exclude any vowels from the resulting array. Additionally, remove any duplicate elements from the array.
String: "Hello World" | codefeedback |
Write a Java program to create a thread which prints the prime numbers between 1 and 1000 in ascending order. Additionally, the program should display a message "Thread is interrupted" if the thread is interrupted before completing its task. | codefeedback |
Create a HTML table that lists the 10 most populous cities in the world, but exclude any cities from China and the United States.
#Reasoning Steps#
1. Start by creating an HTML table structure with appropriate table headers.
2. Use an API or dataset that provides information about the population of cities in the world... | codefeedback |
Implement a function to convert USD dollars to Euro. The function should take in an amount as a parameter and return the converted amount rounded to 2 decimal places. If the amount is negative, the function should return the converted amount as negative as well.
#Example:
convert_usd_to_euro(100)
#Expected Output: 92... | codefeedback |
Write a program to calculate the area of a triangle given its base and height. The program should take the base and height as input from the user and output the calculated area.
The program should adhere to the following requirements:
1. The program should be implemented using only bitwise operations.
2. The program s... | codefeedback |
Given a 2-D array, write a C++ code snippet to find the maximum sum of all the numbers that are strictly increasing in a diagonal pattern. The array may contain negative numbers. The diagonal pattern must follow a specific rule: the numbers in the diagonal pattern must be prime numbers.
Example:
Input:
[[1, 2, 3],
[4... | codefeedback |
Create a React component that displays information about the user's recent activities, including their last 5 logged-in dates and times, on the screen. The dates and times should be displayed in a table format with columns for the date and time.
In addition to the original requirements, implement the following feature... | codefeedback |
Given a string and an array of strings, write a JavaScript code snippet to check if the string is an anagram of any string in the array. An anagram is a word or phrase formed by rearranging the letters of another word or phrase.
To solve this problem, you can follow these steps:
1. Create a function called `isAnagram... | codefeedback |
Create a JavaScript function to validate if a given string is a valid URL. The function should check if the URL has at least one query parameter, if the domain name is a valid registered domain, and if the URL is using a secure protocol (https).
Additionally, the function should handle cases where the URL includes sub... | codefeedback |
Find the maximum subarray sum in an array of integers, but this time, the array may contain both positive and negative numbers. Additionally, the maximum subarray sum must include at least one negative number. The array may also be empty.
arr = [1, -2, 3, 4, -5, 6] | codefeedback |
Design a class to represent a person's name, including their first name, middle name (optional), last name, and suffix (optional). Implement methods to set and get each component of the name. Additionally, include a method to generate a full name string in the format "Last Name, First Name Middle Name Suffix" (with opt... | codefeedback |
Convert the HTML code to valid XML, ensuring that the resulting XML adheres to the specified DTD, which includes the following requirements:
- The XML document must include a root element called "root" with an attribute called "version" set to "1.0".
- The "root" element must contain a "head" element and a "body" eleme... | codefeedback |
Create an HTML document with a table containing book information. The table should include the following columns: "Title", "Author", "Genre", "Year Published", and "Price".
The book information should be stored in an array of objects, where each object represents a book and contains the relevant information. You shoul... | codefeedback |
Generate a regular expression that matches the given example, '100', with the added constraint that the digit '1' must be followed by exactly two '0's, and the entire string must be enclosed within parentheses. | codefeedback |
Construct an SQL query that returns records from a table with an "orders" field that contains any number between 1000 and 3000, and the corresponding customer's name from another table called "customer_info". Additionally, the query should only return records where the customer's name starts with the letter "A" and the... | codefeedback |
Construct a query in MySQL to update the email of customers in the given database, but only for customers who have made a purchase in the last 30 days and have a total purchase amount greater than $100.
Database name: customers
Table name: orders
Columns: customer_id, purchase_date, purchase_amount
Email field name: em... | codefeedback |
Develop a C program to reverse a string, but you are not allowed to use any loops or recursive functions. Additionally, you should not use any built-in string manipulation functions such as `strrev()`, `strncpy()`, or `strcpy()`. | codefeedback |
Write a Java program to compare two strings lexicographically and return the index of the first different character. Two strings: string1="GeeksforGeeks" and string2="GeeksGforGeks". Use a nested loop to compare each character of the two strings. If a different character is found, return its index. If the strings are e... | codefeedback |
Implement a doubly-linked list insert function that accepts a value and inserts it at a specific position in the list. The position must be a valid index within the list, and the function should handle cases where the index is out of bounds. Additionally, the function should check for duplicate values in the list and n... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.