instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Provide a comprehensive list of all the key features and functionality available to a React Native application, including a detailed explanation of each feature, its use cases, and the specific code implementation required to achieve it. | codefeedback |
Create a code to search a given string for a specific keyword and return the index of the keyword. The keyword should be case insensitive. Additionally, the code should handle multiple occurrences of the keyword in the string and return a list of all the indices. | codefeedback |
Given a positive integer n, write a recursive function to compute the nth Fibonacci number.
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. Therefore, the Fibonacci sequence begins as follows: 0, 1, 1, 2, 3, 5, 8, 13, 21, ...
Your... | codefeedback |
Develop a code to rotate a given list by a given value without using any built-in functions or libraries.
my_list = [1, 2, 3, 4, 5]
k = 3
Additional requirement:
1. The code should have a time complexity of O(n), where n is the length of the list.
2. The code should have a space complexity of O(1), meaning it should n... | codefeedback |
Suppose you have a list of integers. Write a program in R language to compute the minimum of the list, but with a twist. Your program should also handle the scenario where the list contains non-numeric values, such as strings or logical values. If the list contains any non-numeric values, your program should return a s... | codefeedback |
Consider the following code. Explain the purpose of the for loop in the code and modify the code to only print the squared values if they are divisible by 3 and the square root of the value is a prime number. Additionally, the code should keep track of the number of squared values that meet this condition and print the... | codefeedback |
Create a function to flatten a 2D array and sort the elements in ascending order. The function should also remove any duplicate elements from the flattened array. The input array will always contain at least one sub-array and each sub-array will contain at least one element.
Additionally, the input array can have nest... | codefeedback |
Write a script in Ruby for calculating the sum of two numbers and displaying the result as a formatted string, but with the following additional requirements:
1. The script should prompt the user to input two numbers.
2. The script should handle invalid input gracefully, displaying an error message and prompting the u... | codefeedback |
Construct a SQL query to find the names, states, and salaries of the top 10% highest paid employees located in California, sorted in descending order of salary. | codefeedback |
Implement a function in Java to find the frequency of each character in a given string and return a map where the keys are the characters and the values are their frequencies. The string will only contain lowercase alphabets and will have a maximum length of 10^6. The function should have a time complexity of O(n) and ... | codefeedback |
Refractor the given code using SQL query commands.
Rewrite the SQL query to retrieve customer data from the "customers" table based on the following conditions:
- The customer's age must be greater than 18.
- The customer's state must be either 'NY' or their experience must be greater than 3.
- The customer's country ... | codefeedback |
Write a code to collect the name, email address, and phone number from the user. The code should validate the email address using regular expressions and the phone number using a custom algorithm that checks for a specific pattern. Additionally, the code should encrypt the collected user data before storing it in a dat... | codefeedback |
Design a database schema for a "Products" table that meets the following requirements:
1. The "Products" table should have the following columns:
- Product ID (integer)
- Product Name (string)
- Product Price (decimal)
- Product Quantity (integer)
- Product Description (text)
2. The "Product ID" colum... | codefeedback |
Suppose you have two dictionaries, A and B. Write a code in Java to find the intersection of A and B. The intersection should only include key-value pairs where the value in A is a substring of the value in B. A = {1: 'aa', 2: 'bb', 3: 'cd'} B = {2: 'bbb', 3: 'cc', 4: 'abcd'}
In addition to finding the intersection, a... | codefeedback |
Create a class in Ruby that stores a student's name, age, and GPA. The class should have methods to calculate the student's letter grade based on their GPA, as well as a method to display the student's information in a formatted string. The class should also have a class variable to keep track of the total number of st... | codefeedback |
Write a Java program to find the length of a string without using the length() method or any other built-in string manipulation methods or functions, and without using any loops or recursion. | codefeedback |
Construct a C++ program to convert miles to kilometers. Your program should also display the equivalent distance in meters, centimeters, millimeters, inches, feet, and yards. Additionally, implement a user-friendly interface that allows the user to input the distance in miles and select the desired units of conversion. | codefeedback |
Implement a program that calculates the factorial of a given number using a stack data structure to simulate recursion. The program should not use any built-in recursive functions or loops. Additionally, the program should handle negative numbers by throwing an exception. | codefeedback |
Sanitize the following user input by removing any characters that could potentially be used for SQL injection attacks, such as quotes, semicolons, and backslashes. Additionally, ensure that the sanitized input does not exceed a maximum length of 50 characters. If the input exceeds the maximum length, truncate it to the... | codefeedback |
Create an HTML page design for displaying a website homepage. Implement a responsive design that adapts to different screen sizes and resolutions. Additionally, include a navigation menu with dropdown functionality and a slideshow showcasing multiple images. Ensure that all elements are properly aligned and styled usin... | codefeedback |
Create a function that will return the total number of specific items in a list, but the list can contain duplicate items. For example, if the input list is ['apple', 'apple', 'banana', 'cherry', 'cherry', 'cherry'], the function should return a dictionary with the count of each item, where the key is the item and the ... | codefeedback |
Extract the value "qux" in the following nested dictionary. The dictionary can have an arbitrary number of nested levels. You are not allowed to use any built-in functions or methods that directly extract values from dictionaries. You can only use loops and conditional statements to navigate through the dictionary. Add... | codefeedback |
Create a function that will calculate the cumulative sum of a list, but only for positive integers greater than 1. If the list contains any negative numbers or non-integer elements, the function should return an error message. Additionally, the function should return the cumulative sum in reverse order. The function sh... | codefeedback |
Describe in detail how a given convolutional neural network model works, including the step-by-step process of forward propagation, backpropagation, and weight updates. Additionally, provide a comprehensive explanation of the different activation functions that can be used in each layer and their respective advantages ... | codefeedback |
Edit a JSON object so that it stores information about a person in a defined format. The name field should only accept alphabetic characters and have a maximum length of 20 characters. Additionally, the JSON object should contain an array field called "hobbies" that can store up to 10 unique strings representing the pe... | codefeedback |
Given a list of positive and negative numbers, round each number to the nearest thousandth decimal place and format it as a string. The list should be sorted in ascending order based on the rounded values. Return the sorted list of formatted strings. Ensure that the resulting strings have a minimum length of 6 characte... | codefeedback |
Sort the following dictionary objects by the value of the "age" field in descending order, while excluding any objects where the "age" is less than 30. Additionally, if two or more objects have the same age, sort them by the value of the "name" field in ascending order.
Time Complexity Requirement: The solution shoul... | codefeedback |
Write a code in Python that returns an inversion of a given string, but you are not allowed to use any built-in string manipulation functions or methods. Additionally, you are not allowed to use any built-in data structures such as lists or arrays.
You can only use basic operations such as accessing individual charact... | codefeedback |
Write an XML tag which will display a hyperlink that opens in a new tab, has a custom CSS class, and includes an image before the link text. The image should have a specific width and height. The hyperlink should also have a tooltip that displays additional information when hovered over. The link text should be underli... | codefeedback |
Create a new dictionary that contains the intersection between the following two dictionaries. However, the intersection should only include keys that are present in both dictionaries and have the same values in both dictionaries. Otherwise, return an empty dictionary.
d1 = {'a': 1, 'b': 2, 'c': 3}
d2 = {'b': 2, 'c': ... | codefeedback |
Write a Python class that has two variables 'name' and 'age' and a method to print the values of both variables. Additionally, the class should have a method that calculates and returns the average age of all instances of the class created so far. The average age should be rounded to the nearest integer.
However, the... | codefeedback |
Write a code in PHP for finding the longest word in a string. The string can contain alphanumeric characters as well as punctuation marks. The longest word should be returned without any punctuation marks.
Example:
Input: "This is a test string! With various punctuation marks."
Output: "punctuation"
Note: The string ... | codefeedback |
Write a JavaScript code snippet to concatenate an array of strings. The array will contain at least 10,000 strings, each with a length of 100 characters. The resulting concatenated string should be returned. However, you are not allowed to use the built-in array methods such as join() or reduce(). You must implement yo... | codefeedback |
Create a function that takes a list of strings as input and returns a string of the list sorted in the alphabetical order. However, the function should ignore case when sorting the strings and remove any duplicate strings from the final result. Additionally, the function should also sort the strings based on their leng... | codefeedback |
Define a JavaScript class called Person that has a constructor for setting the name and age of the person. The name should be a string and the age should be a positive integer.
Additionally, add a method called "getInfo" to the Person class that returns a string containing both the name and age of the person.
Note: T... | codefeedback |
Write a PHP code snippet to create an array containing the prime numbers from 1000 to 2000, excluding any prime numbers that are palindromic. | codefeedback |
Write the SQL query to find the product name, prices, ratings, and categories of all products with a rating greater than 4, prices lesser than 10, belonging to the 'Electronics' category, and ordered by their ratings in descending order. | codefeedback |
Implement a three-way quicksort algorithm in Java that only works for arrays of integers. | codefeedback |
Rewritten Test:
You are given a JavaScript object called `myObj`. Your task is to convert this object into a JSON string.
1. Start by creating a new empty JSON object, let's call it `jsonObj`.
2. Loop through each key-value pair in `myObj`.
3. For each key-value pair, create a new property in `jsonObj` with the same ... | codefeedback |
Using PHP, write a program to generate a string containing the nth Fibonacci number. The program should not use recursion and should have a time complexity of O(n).
Additionally, the program should be able to handle large values of n (up to 10^9) efficiently and accurately, without causing any memory issues or overflo... | codefeedback |
In JavaScript, write a function to calculate the nth term in the Lucas series, where the Lucas series is defined as follows:
The first two terms are 2 and 1. Each subsequent term is the sum of the previous two terms.
Your function should take an integer n as input and return the nth term in the Lucas series.
Additio... | codefeedback |
Write an SQL query to find all students who have passed at least 3 courses with grades higher than 90, and order the results by the student's name in ascending order. | codefeedback |
Modify the code to make sure it is valid according to Java language specification. The program should take two user inputs as command line arguments and print them along with "Hello World!". Additionally, the program should check if the second input is a valid email address before printing it. If the second input is no... | codefeedback |
Write a code in Python to print out the common elements of two lists which are [2, 4, 6, 8] and [3, 6, 9, 12]. However, you are not allowed to use the built-in Python functions like `set()` or `intersection()`. Additionally, you are not allowed to use any loops or conditional statements. | codefeedback |
Convert this SQL statement into a LINQ query that only selects products whose price is greater than 100, are currently in stock, and have a product category of "Electronics". | codefeedback |
Write a JavaScript method that takes an array of numbers and checks if all values in the array are prime numbers. Additionally, the method should return the sum of all prime numbers found in the array. | codefeedback |
Fix the code by making changes with the appropriate syntax and error handling.
The function should accept two parameters, a and b, which are both integers. It should return the sum of a and b.
The function should also handle the following scenarios:
1. If either a or b is not an integer, raise a custom exception calle... | codefeedback |
Write a Python code to calculate the total price of a given list of items, including taxes. Each item in the list is represented by a dictionary with keys "name", "price", and "quantity". The tax rate is provided as a separate variable.
1. Create a function named "calculate_total_price" that takes two parameters: "ite... | codefeedback |
Create a Ruby script that calculates and returns the nth Fibonacci number, where n is a positive integer less than or equal to 10^9. The script should use an iterative approach instead of recursion and should have a time complexity of O(log(n)).
Note: You may need to use advanced mathematical techniques such as matrix... | codefeedback |
Check this code and add an if statement to print out “even” if the number is divisible by 2 and “odd” if not. Additionally, modify the code to only iterate through odd numbers from 1 to 10. Implement the solution using recursion and ensure that the program terminates after printing the result. | codefeedback |
Create a function in R to generate a random prime number between the given range, where the generated prime number must also be a palindromic number. | codefeedback |
Write a program that parses a user input in the following format: x - 10, y - 20, and prints out the sum of x and y. The program should handle inputs in the range of -10^9 to 10^9. The time complexity of the solution should be O(1) and the space complexity should be O(1).
Additionally, the program should handle inputs... | codefeedback |
In Java, write a program that finds the sum of two linked lists representing integers. However, you are not allowed to use any built-in classes or methods for linked lists, including the use of any Java collection classes or data structures. You must implement your own custom linked list class and all necessary methods... | codefeedback |
Write an SQL query to rank the products by their sales, only considering products that have a sales value greater than 1000. Additionally, the query should exclude any products that have a stock quantity less than 50. | codefeedback |
Perform sentiment analysis on the given text using the Stanford CoreNLP library in Python, but only consider the sentiment of the adjectives used to describe the food in the text. | codefeedback |
Update the following HTML page so that it refreshes the page every 5 seconds and displays a counter that starts from 10 and counts down to 0. Additionally, the page should display an alert message when the counter reaches 0, and the counter should be displayed in a different color for each second (e.g., starting from b... | codefeedback |
Deploy the following ML model on the Cloud using Kubernetes and create a RESTful API to interact with the model. Additionally, implement authentication and authorization mechanisms to ensure that only authorized users can access the API. | codefeedback |
Write a Scala program to print the Fibonacci sequence up to a given number, n. The Fibonacci sequence is a series of numbers in which each number (starting from the third number) is the sum of the two preceding ones. Implement the following steps:
1. Prompt the user to enter a positive integer, n.
2. Validate the user... | codefeedback |
Write a Node.js program to accept a user input and print it in the console, but only if the input is a valid email address. Otherwise, display an error message. The program should also check if the email address is from a popular email provider such as Gmail, Yahoo, or Hotmail, and display a specific message for each p... | codefeedback |
Add a constructor to the above class to make sure that firstname and lastname are provided when creating a new instance. Additionally, the firstname should have a maximum length of 50 characters and can only contain alphabetic characters. The lastname should have a maximum length of 100 characters and can only contain ... | codefeedback |
Create a function which takes an array and removes all duplicates using a set. The function should also return the number of unique elements in the array.
For example, given the array [1, 2, 3, 3, 4, 4, 5], the function should remove the duplicates and return [1, 2, 3, 4, 5] with a count of 5.
In addition, your func... | codefeedback |
Create a Python class with the following attributes: firstname, lastname, address, and email. The email attribute should be a valid email address and should include a domain name. Additionally, the class should have methods for validating the email address and retrieving the domain name. The validation method should ch... | codefeedback |
Modify the 'Bike' class so that when instances are created they are assigned a unique ID. The ID should be a combination of the first three letters of the bike's brand name, a randomly generated four-digit number, and a randomly generated two-letter suffix. Additionally, implement a method called 'get_info' that return... | codefeedback |
Design the structure of a distributed database for a hotel booking system that can handle multiple hotel chains, each with multiple hotels and multiple room types. The system should be able to handle a high volume of bookings and provide efficient searching and retrieval of booking information across geographically dis... | codefeedback |
Create a class for a bike which has a color, make, description and serial number as attributes. Additionally, the bike should have a method to calculate its speed based on the number of gears it has and the gear it is currently in. The bike's speed should be calculated using the formula: speed = (number of gears - curr... | codefeedback |
Rewrite the following function which calculates the factorial of a given number without using any loops:
```
def factorial(n):
result = 1
if n == 0:
return result
else:
for i in range(1, n+1):
result *= i
return result
```
You are not allowed to use any loops or recursi... | codefeedback |
Design a C++ class to represent a student's information such as name, student ID, grade, and course schedule. The course schedule should store the courses the student is enrolled in, including the course name, course ID, instructor name, and the semester the course was taken. The class should include methods to add and... | codefeedback |
Find the smallest missing positive number in an array of size N, where N can be up to 10^6. The array can contain integers ranging from -10^9 to 10^9. You need to find the missing positive number in O(N) time complexity and O(1) space complexity. If there is no missing positive number, return N+1.
Rewritten Test:
You... | codefeedback |
Design an HTML form that allows the user to submit his/her contact details. The form should include the following fields:
- First name (required, maximum 50 characters)
- Last name (required, maximum 50 characters)
- Email address (required and should be validated using a regular expression pattern that checks for a va... | codefeedback |
Write a Python function that takes in two lists of integers and returns a new list that contains the elements that are present in both lists, but only if they are divisible by 3 and not divisible by 5. The function should also remove any duplicate elements from the result.
list1 = [3, 5, 7, 8, 10, 10, 12, 15]
list2 = ... | codefeedback |
Write a function that takes a two-dimensional array and flattens it into a one-dimensional array. The function should remove any duplicate elements from the resulting array and sort it in ascending order.
Time Complexity Requirement: O(n log n)
Space Complexity Requirement: O(n)
#Example#
Input:
[[4, 2, 6], [1, 3, 5]... | codefeedback |
Given an array of integers, find the maximum difference between two elements in the array such that the larger element appears after the smaller element in the array and the smaller element is at an odd index. If there are multiple pairs that satisfy this condition, return the maximum difference among all such pairs.
... | codefeedback |
Create a web page using HTML, CSS, and JavaScript which displays a user interface for a scientific calculator. The calculator should have the following functionalities:
1. Addition: Allow the user to add two numbers and display the result.
2. Subtraction: Allow the user to subtract one number from another and display t... | codefeedback |
Write a function that takes a list of strings and detects if they are anagrams. The function should return a dictionary where the keys are the input strings and the values are lists of anagrams for each string.
Example:
Input: ["listen", "silent", "enlist", "tinsel"]
Output: {'listen': ['silent', 'enlist'], 'tinsel': ... | codefeedback |
Override the "toString" method for a given class in Java, ensuring that the returned string contains only alphabetic characters, has a length of at least 10 characters, and does not contain any repeated characters. | codefeedback |
Write a function to convert a Roman numeral to an integer.
The Roman numeral system is based on a combination of seven symbols: I, V, X, L, C, D, and M, representing the numbers 1, 5, 10, 50, 100, 500, and 1000 respectively.
The rules for converting Roman numerals to integers are as follows:
1. The symbols I, X, an... | codefeedback |
Create a Python program to analyze a given list of URL requests and count the number of unique requests. The program should ignore requests that have the same URL but different query parameters. Additionally, the program should display the total number of requests for each unique URL and sort the URLs in descending ord... | codefeedback |
Using Python, parse a given XML document and output the names of all elements with the “class” attribute. Additionally, for each element, if the value of the "class" attribute contains the word "active", output the value of the "id" attribute as well. Ensure that the program handles XML documents with nested elements c... | codefeedback |
Write a bash script that prints the given input string in reverse order, but without using any built-in string manipulation functions or commands.
String to be printed='Hello World' | codefeedback |
Write a Python function to convert a given number of days into years, months, weeks, and days. The function should handle negative numbers as well. Additionally, the function should consider leap years and account for the correct number of days in each month. | codefeedback |
Write a Python function that takes a list of n strings and a number k and returns the longest string with length of k or less. Additionally, the function should handle cases where multiple strings have the same length and return the lexicographically smallest string among them. The function should also have a time comp... | codefeedback |
Write a Python code snippet to sum up all the positive elements in a given dictionary, where the keys are strings and the values are positive integers. The dictionary should contain at least 5 key-value pairs and have a maximum of 10 key-value pairs. Additionally, the code should handle cases where the dictionary may c... | codefeedback |
Write a Python function that takes a list of strings as an input and returns a new list with the strings sorted by length. The function should have a time complexity of O(n log n), where n is the total number of characters in all the strings combined.
Additionally, modify the function to handle the case where multiple... | codefeedback |
Write a Python function that takes two lists as input and returns a new list which contains only the unique elements from both of the lists. The function should also remove any duplicates within each list before combining them.
Example:
Input:
list1 = [1, 2, 3, 4, 4, 5, 6]
list2 = [3, 4, 5, 6, 6, 7, 8]
Output:
[1, 2,... | codefeedback |
Write a SQL query to find all users who are younger than 25 years old, have a minimum of 1000 followers, and have posted at least 10 times in the last 30 days. | codefeedback |
Write a SQL query to update the age of a certain user and also update the age of all other users who have the same last name as the certain user. Additionally, update the age of all users who have the same first name as the certain user.
name = "John Doe"
age = 25 | codefeedback |
Implement a sorting algorithm in Python to arrange the given array in descending order. The algorithm should have a time complexity of O(n log n) and should not use any built-in sorting functions. Additionally, the implementation should be able to handle arrays containing duplicate elements and should remove any duplic... | codefeedback |
Create a function in Ruby for performing the following string manipulations on the given text:
1. Reverse the order of the words in the text.
2. Capitalize the first letter of each word in the text.
3. Replace all occurrences of the letter 'o' with the number '0' in the text.
4. Remove all punctuation marks from the te... | codefeedback |
Create a function that takes in an array of strings containing the names of the seven days of the week, but the names should be in reverse alphabetical order. The function should return the modified array. | codefeedback |
Write a query to count the number of movies released in 2020 in each genre from the database. Additionally, exclude genres with less than 10 movies released in 2020 and sort the results in descending order of movie count. | codefeedback |
Write a SQL query to find out the names of users who have a special character, such as an exclamation mark (!), as the third character in the name and have a digit as the last character in the name. | codefeedback |
Write a function in Swift for generating a specified number of distinct prime numbers within a given range. The function should have the following signature:
```swift
func generateDistinctPrimesInRange(min: Int, max: Int, count: Int) -> [Int]
```
The function should return an array of `count` distinct prime numbers t... | codefeedback |
Create an HTML webpage that includes a form with the following elements:
- A heading that says "Welcome to my webpage!"
- A paragraph that says "This is my first webpage!"
- A button that says "Change Color"
When the button is clicked, the heading and paragraph should change color to a randomly generated color. Ad... | codefeedback |
Write an HTML form which includes a text field, a submit button, a check box labeled "Remember Me", and the following additional constraints:
1. The text field should have a minimum length of 8 characters.
2. The submit button should be disabled until the text field contains at least 8 characters.
3. Upon submitting th... | codefeedback |
Given an array of positive integers, write a JavaScript function to find the second largest number in the array. Your solution should have a time complexity of O(n) and should not use any built-in sorting functions or libraries. Additionally, your solution should not use extra space beyond a few variables for tracking ... | codefeedback |
Explain what is a non-deterministic algorithm and provide an example of a real-world problem where a non-deterministic algorithm could be used. In your explanation, discuss the advantages and disadvantages of using a non-deterministic algorithm for that particular problem. Additionally, provide a detailed step-by-step ... | codefeedback |
Create a Python class named "Bicycle" which has the following attributes: "color", "wheels", "brand", and "frame_material". The "color" attribute should be a string indicating the color of the bicycle. The "wheels" attribute should be an integer indicating the number of wheels on the bicycle. The "brand" attribute shou... | codefeedback |
Create a function sumEvenToN that takes a single argument and returns the sum of the even numbers from 2 to the argument. However, you should ensure that the function returns the sum of only the prime even numbers from 2 to the argument. | codefeedback |
Given a string s = 'Hello, World!', create a function called "string_length" that takes a string as an input and returns its length.
However, the input string can contain multiple lines and special characters. The function should also be able to handle Unicode characters.
Example:
s = 'Hello, World!\nHow are you?'
st... | codefeedback |
Explain the concept of recursion with an example, while also implementing a recursive function in a programming language of your choice. Your implementation should include at least two base cases and demonstrate the proper use of recursive calls. Additionally, the recursive function should involve manipulating a multi-... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.