instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
What is the maximum number of elements that can be stored in an array in C++ if the array is allocated on the stack, assuming each element takes up 1 byte of memory? | codefeedback |
Develop a program to accept two positive numbers from the user and display the sum of their factorials using a Python function. The program should also validate that the input numbers are within a range of 1 to 10. | codefeedback |
Develop a DFS algorithm in Python that can find all possible paths from a starting node to a target node in a directed graph, but also include the constraint that each path must have a maximum length of K. | codefeedback |
Create an identifier in Python that starts with an underscore followed by the letter 'a', contains at least one uppercase letter, and ends with a number between 1 and 100 (inclusive). | codefeedback |
Develop a code in C for printing the elements of a linked list in reverse order without using any additional data structures or recursion. | codefeedback |
Write an algorithm to generate a random string of length n, where each character in the string can be a lowercase letter, an uppercase letter, a digit, or a special character from the following set: !@#$%^&*()-_=+{}[]|\:;"'<>,.?/~`.
To increase the difficulty:
1. Add a requirement that the generated string must contai... | codefeedback |
Create a function in JavaScript to convert RGB values to HEX values. The function should also validate that the input RGB values are within the range of 0 to 255 for each channel. Additionally, the function should handle the case when the input RGB values are not integers by rounding them to the nearest whole number be... | codefeedback |
Write a program in C# to sort an array of integers in ascending order using the Bubble Sort algorithm. The program should also track the number of comparisons made during the sorting process and display the total number of comparisons at the end. | codefeedback |
Write a function in JavaScript that returns the longest item in the array. However, you are not allowed to use the built-in array methods such as `sort()` or `reduce()`. The function should also handle cases where the array contains non-string elements, such as numbers or booleans, and return the longest string. Additi... | codefeedback |
Create a python function that takes a single integer as an argument and prints out the corresponding multiplication table. However, the function should only display the prime numbers in the table, skipping any non-prime numbers. Additionally, the function should handle cases where the input is not a positive integer an... | codefeedback |
In Python, you have a set called `my_set` containing the elements `1, 2, 3, 4, 5`. How do you retrieve the 3rd element of `my_set` and print it? | codefeedback |
How would you create a program in C++ to calculate the average of a set of numbers, where the set size is not known in advance, while also keeping track of the minimum and maximum values in the set? | codefeedback |
Create a function in Python that takes a list of positive integers as input and returns the maximum value. The function should have a time complexity of O(n), where n is the length of the list. | codefeedback |
Write a MySQL query to calculate the average rating of the items in the “items” table, where the items should have at least 10 reviews, the average rating should be greater than or equal to 4, and the average rating should be calculated only for items that have been reviewed in the last 30 days.
In addition, the query... | codefeedback |
Create a program that calculates the factorial of a given number using a recursive function and ensure that the function is implemented in a separate module.
The program should prompt the user to enter a number, validate the input to ensure it is a positive integer, and then display the factorial of that number.
To... | codefeedback |
What is the command line to create a gzipped tar archive with a specific compression level of 9 in Linux? Provide the command line with the option to include only files modified in the last 24 hours in the archive. | codefeedback |
Segregate a given array of numbers into three sections: prime numbers, perfect squares, and all other numbers. The prime numbers should be placed at the beginning of the array, followed by the perfect squares, and finally, the remaining numbers. Additionally, the order of the numbers within each section should be maint... | codefeedback |
Create a SQL query to select the customers that have placed orders of price greater than 1000 and have also placed orders in the last 30 days. Additionally, exclude any customers who have placed orders with a product category of 'Electronics' in the past year. | codefeedback |
Write a CSS rule to set a blue color for all text elements within a specific class, while excluding any text elements within nested classes. Additionally, set a red color for all text elements within the nested classes. | codefeedback |
Construct a JavaScript program that displays the current date and time in a specific timezone, considering daylight saving time adjustments. Additionally, the program should validate user input for the timezone and handle any errors or invalid input accordingly. | codefeedback |
Implement a function in AngularJS to register a new user with the following requirements:
1. The function should validate that the username is unique and not already taken by another user in the system. The validation should be done by making a GET request to an external API that checks for username availability.
2. Th... | codefeedback |
Design a HTML program to display a dynamic heading that changes its color every millisecond. | codefeedback |
Convert the given hexadecimal color code to RGB format, without using any built-in functions or libraries. The input will always be a valid hexadecimal color code and will be a 6-digit code without any leading "#" symbol. The output should be a string in the format "RGB(x, y, z)" where x, y, and z are integers represen... | codefeedback |
Write a Swift program to display the Fibonacci sequence up to a given number N. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1.
The program should prompt the user to enter a positive integer N (where N is greater than or equal to ... | codefeedback |
Create a table in the given MySQL database with 4 columns. However, the database connection is not established correctly and needs to be fixed before proceeding. Additionally, you need to implement error handling to catch any connection errors and display a meaningful error message to the user.
Database Name: my_db
Ta... | codefeedback |
Generate a Ruby loop to find the sum of prime numbers between 1 and 1000. | codefeedback |
Write a Python program to print the Pascal's triangle up to a given number of rows, where the number of rows must be provided by the user as input. The program should handle invalid input and display appropriate error messages. Additionally, the program should also calculate and print the sum of the numbers in the last... | codefeedback |
Code a calculation to find the mean of numbers stored in an array in Java, without using any built-in Java methods or libraries. The time complexity of your solution should be O(n) and the space complexity should be O(1).
numbers = {1, 2, 3, 4, 5}
In addition to the above requirements, your solution should handle neg... | codefeedback |
Write a function to transform a dataset into a matrix, where rows represent data points followed by their labels. The dataset consists of tuples, where each tuple represents a data point and contains three elements. The first two elements represent the features of the data point, and the last element represents the lab... | codefeedback |
Using list comprehension, create a list which contains multiples of 7 from 0 to 200 (inclusive) but only if the number is divisible by both 3 and 4 and ends with the digit 8. | codefeedback |
Generate an array containing the next n numbers in the Fibonacci sequence, but exclude any numbers that are divisible by 3 or 5. Additionally, your solution should have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Generate a SQL query to select all authors who have written at least 10 books and have an average rating of their books higher than 4.5. | codefeedback |
Create a function that takes in two integer values, x and y, and returns the larger one. The function should also check if x and y are prime numbers and within the range of 1 to 1000, and raise an exception if they are not. | codefeedback |
Write a SQL query to find the names of the top 10 earning authors, considering only the authors who have published at least 5 books. In addition, display the total number of books published by each author.
SELECT a.Name, COUNT(b.BookID) AS TotalBooksPublished
FROM Authors a
JOIN Books b ON a.AuthorID = b.AuthorID
GROU... | codefeedback |
Implement selection sort to sort a list in non-decreasing order, but the code you write should have at least one syntax error. Additionally, the code should be written in a way that it sorts the list in reverse order (non-increasing order) instead of non-decreasing order.
list = [9, 5, 3, 1, 8] | codefeedback |
Create a dictionary from a list of tuples, where the key is the first element of the tuple and the value is the second element of the tuple. However, if the first element of the tuple is a string, the value should be converted to uppercase before being added to the dictionary. If the first element is an integer, the va... | codefeedback |
Create a function to sort a list of dictionaries alphabetically in Python based on a specific key in each dictionary. Additionally, if two dictionaries have the same value for the specific key, sort them based on another key in the dictionary. | codefeedback |
Create a program that capitalizes the first letter of every word in a sentence, excluding any conjunctions such as "and" or "but". Additionally, exclude any prepositions such as "of" or "in". | codefeedback |
Suggest an efficient algorithm to filter out unwanted words from a given paragraph of text, but with the additional requirements of ignoring case sensitivity, limiting the use of built-in string manipulation functions, and handling large input sizes efficiently. | codefeedback |
Suggest an efficient approach to sort an array of numbers in ascending order using JavaScript, without using any built-in sorting functions or libraries. Your solution should have a time complexity of O(n log n) and should not use any additional memory. Additionally, provide a piece of erroneous code as a reference to ... | codefeedback |
Create a code to calculate the most frequent character in a given string, but exclude any punctuation characters and consider only alphabetic characters. Additionally, you need to consider both uppercase and lowercase characters as the same character.
For example, for the input string "Hello, world!", the expected ou... | codefeedback |
Print all the prime numbers in the range of 2 to n, where n can be as large as 10^6. However, you are not allowed to use any built-in functions or libraries for prime number generation or checking. You must implement your own algorithm to determine whether a number is prime or not. | codefeedback |
Split a string into its individual words and store it in a list, but exclude any words that start with a vowel. Ignore punctuation marks and special characters. Return the list of words in reverse order.
string = "Hello world, this is a test string!" | codefeedback |
Generate a SQL query to retrieve all active users whose last login was within the last 7 days, ordered by their registration date in descending order. Additionally, exclude any users whose email address ends with ".com" and have a user ID that is a prime number. | codefeedback |
Given an array of integers, write a function to check if the sum of any three of them equals the given parameter ‘n’. The function should also return the indices of the three numbers whose sum equals ‘n’. Additionally, the function should have a time complexity of O(n^2) and should not use any additional data structure... | codefeedback |
Write a function that calculates the power of a given number `n` raised to the exponent `m`. The function should handle the following edge cases:
1. If `n` is negative and `m` is not an integer, the function should return an error message.
2. If either `n` or `m` is greater than 1000, the function should use a more ef... | codefeedback |
Print the sum of the squares of the first 100 prime numbers that are greater than 100. | codefeedback |
Create a class called Cat to represent a type of pet. The Cat class should have the following attributes and methods:
Attributes:
- name: a string that represents the name of the cat
- age: an integer that represents the age of the cat
- breed: a string that represents the breed of the cat
- color: a string that repre... | codefeedback |
Construct a for loop to traverse an array of integers starting from the third element and ending at the second-to-last element. However, the loop should only iterate through the even-indexed elements in the range. Additionally, the loop should skip any even-indexed elements that are divisible by 3.
array = [1,2,3,4,5] | codefeedback |
Output the lexicographical order of a given array of strings. The array may contain duplicate strings, and the output should remove any duplicate values. Additionally, the output should be in descending order instead of ascending order. The input array may have a maximum length of 10^6. | codefeedback |
What is the minimum educational requirements, practical experience, and programming proficiency needed to become a highly skilled AI Engineer proficient in deep learning algorithms and natural language processing techniques? | codefeedback |
Write a Python function that takes a list of integers as input and uses the built-in function filter() to return a new list that only contains the odd prime numbers from the input list. | codefeedback |
Design an algorithm to calculate the maximum profit for buying/selling any number of shares of a company's stock. However, you are only allowed to make a maximum of two transactions.
Share Prices = [9, 11, 8, 5, 7, 10, 12, 6, 4]
Note: You can only make two transactions at most, and you must sell the shares before buy... | codefeedback |
Create a Python script to add a new field of "car color" to the given JSON object, but also check if the value of "car color" is a valid color name according to the RGB color model. If the color is not valid, raise a custom exception called "InvalidColorException" with an appropriate error message. Additionally, ensure... | codefeedback |
Construct a SQL query to find all the customers who live in California, have more than 5 reviews, and have made at least 3 purchases in the last month. Additionally, the query should return the total amount spent by each customer in the last month. | codefeedback |
Write a gem in Ruby to display the current time in UTC and in 24-hour format. Additionally, implement a method that allows the user to convert the time to a specified time zone and format (e.g. "EST", "PST", "dd/mm/yyyy", etc.). Ensure that the user input is validated and handle any potential errors gracefully. | codefeedback |
Create a Python program to find the average of the given numbers in the list. Additionally, handle any possible input errors or exceptions that may occur during the execution of the program.
Reference erroneous code:
```python
def find_average(numbers):
if len(numbers) == 0:
return "No numbers in the list"... | codefeedback |
How can we securely store a large amount of sensitive data on the user's machine while minimizing storage space usage and ensuring data integrity? | codefeedback |
Explain this JavaScript code snippet that utilizes higher-order functions and closures to create a reusable greeting function, with the added constraint that you are not allowed to use the `console.log` function.
```javascript
function createGreeting(greeting) {
return function(name) {
alert(greeting + ' ' + nam... | codefeedback |
Write a CSS style to change the text color to red for all elements with the class "important" only if the element is a direct child of a parent element with the class "container". Additionally, if the element has a sibling element with the class "highlight", change the background color to yellow.
#Reasoning Steps#
1. ... | codefeedback |
How can we prevent memory leaks in Java when using multi-threading and concurrent data structures? | codefeedback |
Create a Python script to convert the given JSON object into an XML document, while also encrypting the XML data using a symmetric encryption algorithm such as AES. The encrypted XML data should then be saved into a file with a dynamically generated name based on the current date and time. Additionally, implement the f... | codefeedback |
Write a JavaScript function that takes in two arrays of equal length, and returns a new array that contains only the unique elements from both arrays, in ascending order. Additionally, the function should ignore any elements that are divisible by 3.
Example:
Input: [1, 2, 3, 4], [3, 4, 5, 6]
Output: [1, 2, 4, 5, 6]
C... | codefeedback |
Write a JavaScript code snippet to add an event listener to a button with the ID 'submitButton' that triggers a function when the button is clicked. The function should perform the following steps:
1. Retrieve the value of an input field with the ID 'nameInput'.
2. If the input field is empty or contains only whitespac... | codefeedback |
Create a program in Java to create a scientific calculator that has the ability to perform advanced mathematical operations such as finding the square root, calculating exponential values, and performing trigonometric functions (sine, cosine, tangent). Additionally, the calculator should have a memory feature that allo... | codefeedback |
Write a function in Ruby that takes in two strings and returns a new string that contains both strings with a space in between them. However, you are not allowed to use any built-in string manipulation methods such as `+`, `concat`, or `<<` to concatenate the strings. Additionally, the function must have a time complex... | codefeedback |
Rewrite the `proxy` function in JavaScript to create a proxy object that adds an additional layer of validation to any target object. The proxy object should perform the following tasks:
1. Track the number of times a property on the target object is accessed.
2. Track the number of times a property on the target obje... | codefeedback |
Write a web crawler for a specific website that can handle dynamic content and can extract data from multiple pages. The crawler should also implement a mechanism to handle website authentication or login requirements before crawling. Additionally, it should introduce rate limiting or delays to simulate real-world scen... | codefeedback |
Write a JavaScript program that will console log the first 50 numbers of the Fibonacci sequence, where each number is a prime number and has a time complexity of O(n). | codefeedback |
You need to edit this given HTML code to apply a class name "example" to every even-indexed element, but you are not allowed to use any CSS or JavaScript. The solution should only involve manipulating the HTML code itself.
Additionally, please optimize your solution to have a time complexity of O(n), where n is the nu... | codefeedback |
Create a CSS stylesheet to style a responsive website with a black background and white text. Additionally, add a CSS rule to change the color of all links to red when hovered over. Ensure that the website layout is optimized for mobile devices and includes a navigation bar with a drop-down menu. The navigation bar sho... | codefeedback |
Construct a regular expression that will match only strings that contain a number, start with a lowercase letter, and end with a special character. | codefeedback |
You need to modify the existing code to implement a sorting algorithm. The code should take an array of integers as input and sort them in ascending order. However, you are not allowed to use any built-in sorting functions or libraries. The time complexity of your solution should still be O(nlogn), where n is the size ... | codefeedback |
Create a SQL query that counts the total distinct `customer_name` from a table called `Orders` where the `order_id` is greater than 3 and the `item_id` is divisible by 2. | codefeedback |
You need to generate an SQL query that will return records from a table called "users" where the name matches the given parameter. However, the parameter can be in uppercase or lowercase, and the query should be case-insensitive. Additionally, the name parameter can contain wildcards, such as '%' to match any number of... | codefeedback |
This program needs an array containing the first 20 prime numbers. The program should also calculate the product of all the prime numbers in the array and print it as the final output. | codefeedback |
Write MATLAB code to generate a 2-D array called "A" of size NxM, where N and M are user input integers. Fill it with random numbers between a specified range, also provided by the user. However, ensure that no two adjacent elements in the array have the same value. | codefeedback |
Write a code that prints the even numbers from 100 to 0 in descending order. Additionally, you need to skip any numbers that are divisible by 5. The code should also ensure that the sum of all the printed even numbers is less than 1000. | codefeedback |
Write an HTML program to display a table with a list of names and ages of people. The program should also include a button next to each person's name that, when clicked, will remove that person from the table. Additionally, implement a feature that allows users to add new people to the table by inputting their names an... | codefeedback |
Create a web application that allows users to input a sentence and display it in reverse order. The application should have a text input field, a submit button, and a result display area. The input sentence should be reversed and displayed when the submit button is clicked. Additionally, the application should have a r... | codefeedback |
Create a Python class called "Car" which has the "model" and "year" parameters. The "model" parameter must be a string with a maximum length of 50 characters. The "year" parameter must be an integer between 1900 and the current year. The class must also have a method called "start_engine" which prints "Engine started" ... | codefeedback |
Create a program to compare two strings and print the result. The strings should not be case-sensitive. Additionally, before comparing the strings, remove any leading or trailing spaces from both strings. If either string is empty after removing the spaces, print an error message stating that the string is empty. If th... | codefeedback |
Generate an HTML form with five fields: "first name", "last name", "email", "password", and "confirm password". Implement client-side validation for the following requirements:
1. The first name and last name fields should accept alphabetical characters only and should be between 2 and 20 characters long.
2. The email ... | codefeedback |
Develop a Java program that counts the frequency of a given word in a sentence, taking into consideration that the sentence can contain multiple lines and the word can be present in different cases (e.g., "Code", "CODE", "code"). The program should also handle special characters and punctuation marks, treating them as ... | codefeedback |
Read a given text and classify each sentence as true or false. The text may contain up to 100 sentences. Additionally, sentences may include punctuation marks such as commas, periods, exclamation marks, and question marks. | codefeedback |
Debug the following program and make it function correctly. Additionally, modify the program to count the number of unique words in the given text, where a word is defined as a sequence of alphabetic characters.
def count_unique_words(text):
words = []
word = ""
for char in text:
if char.isalpha():... | codefeedback |
Build a React component to render a header with the text "My Website" and a dynamic background color that changes every time the component is re-rendered. The background color should be randomly selected from a predefined list of colors. Additionally, implement a feature where the header text fades in slowly when the c... | codefeedback |
Given a string, find the length of the longest word that can be formed by rearranging the characters of the string. The time complexity of your solution should be O(n log n), where n is the length of the string. | codefeedback |
Parse a given JSON object and output the contents in a tabular format. The output should include the keys and values of the JSON object, but exclude any nested objects or arrays. Additionally, sort the output table in ascending order based on the keys.
Example Input:
json_object = {
'name': 'John',
'age': 20,
... | codefeedback |
Write a function that parses a given URL into its component parts, including the protocol, domain, path, query parameters, and any hash fragments.
Example:
Input:
url = "https://www.example.com/articles/first-article?category=tech&sort=desc#comments"
Output:
{
"protocol": "https",
"domain": "www.example.com",
... | codefeedback |
Generate a random string of length 10 consisting of letters (both uppercase and lowercase), numbers, and special characters, without using any built-in functions or libraries. Additionally, ensure that each character in the string is unique. | codefeedback |
Create a function that generates a list of prime numbers between 2 and n, where n is a positive integer greater than 2. The function should implement the Sieve of Eratosthenes algorithm to optimize the generation of prime numbers.
Additionally, the function should return a dictionary that contains the prime numbers as... | codefeedback |
Construct a code segment to find all unique characters in a given string, excluding any whitespace characters. Additionally, return the count of each unique character found.
String: "Hello World"
#Erroneous Code Reference#
int count = 0;
for(int i=0; i<str.length(); i++){
if(!Character.isWhitespace(str.charAt(i))... | codefeedback |
Design a distributed database with multiple nodes and partitions, each containing tables and columns representing customers, orders, products, and payment transactions. Implement a sharding mechanism to evenly distribute data across the nodes and partitions for efficient querying. The system should allow customers to p... | codefeedback |
Create a program that takes an angle in degrees as input and generates a 3x3 rotation matrix using the given angle. Additionally, implement a function to multiply two 3x3 matrices together.
To solve this problem, you need to understand the concept of rotation matrices and matrix multiplication.
1. Start by obtaining ... | codefeedback |
Create a function that takes a given sentence as input and outputs a list of all its words, while also removing any duplicate words in the sentence. The sentence can contain punctuation marks, special characters, and numbers, and the function should handle them appropriately. Additionally, the function should sort the ... | codefeedback |
How can you use a for loop to traverse a dictionary and print only the key-value pairs where the value is greater than 10? Additionally, you are required to sort the key-value pairs in descending order based on the values before printing them. | codefeedback |
Generate python code to replace each character in a string with the next character in the alphabet, but ignore vowels, only replace consonants, and also handle special characters and whitespace.
#Reasoning Steps#
1. Start by defining a function called `replace_consonants` that takes a string as input.
2. Inside the fu... | codefeedback |
Construct a code that takes a list of sentences as input and performs the following operations on each sentence:
1. Remove any duplicate words.
2. Change the case of each word in the sentence according to the following rules:
- If the word starts with a vowel, capitalize the first letter and convert all other letter... | codefeedback |
Write a code to sum all the values of the following dictionary, but only consider the values that are even numbers and are greater than 10. If there are no even numbers greater than 10 in the dictionary, return -1. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.