instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Given an array of integers, find and print all the prime numbers in descending order. The time complexity of the solution should be less than O(n^2), where n is the size of the input array. | codefeedback |
Write a program to find the maximum and minimum elements in a given array, and swap their positions. Additionally, the program should also remove any duplicates from the array and sort it in descending order. | codefeedback |
Write a TensorFlow program to compute the element-wise product of two tensors, sum the resulting tensor, and multiply the sum by a scalar value. Additionally, the sum of the resulting tensor must be greater than a specified threshold value.
x = [[1,2],[3,4]]
y = [[5,6],[7,8]]
scalar = 2
threshold = 10 | codefeedback |
Create a method to transform a string from lowercase to title case while preserving the original capitalization of certain words.
Title case rules:
1. The first letter of every word should be capitalized.
2. All articles (a, an, the), conjunctions (and, but, or), and prepositions (in, on, at, etc.) should be lowercas... | codefeedback |
Make a program to determine if the elements of the array are in strictly increasing order. The array may contain both positive and negative integers. The program should return True if the elements are in increasing order and False otherwise.
Additionally, the program should also handle cases where the array contains d... | codefeedback |
Write a Java program to calculate the area of a square given the length of a side. The program should also calculate and display the perimeter of the square. Additionally, you should implement error handling to handle cases where the user enters negative values for the length of the side. | codefeedback |
Create an object to store the variables that are necessary for the following code snippet. The object should be implemented as a custom data structure with specific methods for performing mathematical operations on the variables stored in it. The data structure should support addition, subtraction, multiplication, and ... | codefeedback |
Implement a min-heap data structure from scratch in any programming language of your choice. The min-heap should support the following operations:
1. Insertion of an element into the heap with a time complexity of O(log n) in the worst-case scenario.
2. Removal of the minimum element from the heap with a time complexit... | codefeedback |
Generate a list of all prime numbers between 200 and 400.
#Reasoning Steps#
1. Initialize an empty list called "primes".
2. Create a loop that iterates through all numbers between 200 and 400 (inclusive).
3. For each number, check if it is divisible by any number between 2 and its square root (rounded up).
4. If the n... | codefeedback |
Generate a unique ID string of length 12 using a Python function. The ID should only contain alphanumeric characters (letters and numbers), and the first character must be an uppercase letter. The remaining characters can be a combination of uppercase letters, lowercase letters, and numbers. The ID must also be unique ... | codefeedback |
Suggest a code snippet to detect a cycle in a linked list that has at least 100 nodes and cannot use any additional data structures. Additionally, optimize the time complexity to O(n) and space complexity to O(1). | codefeedback |
In Python, how can you iterate a list in reverse order and print each element along with its index position, but only for elements that are divisible by 3? | codefeedback |
Reverse an array of size n in Python, where n is a positive integer not exceeding 10^6. The array elements are integers between 1 and 10^9 (inclusive). Implement an efficient algorithm with a time complexity of O(n) and a space complexity of O(1).
In addition, ensure that the algorithm does not use any built-in functi... | codefeedback |
Write a Python program to create a dictionary that stores information about the students in a class. The dictionary should have 3 key-value pairs, where the keys represent the student names and the values represent their corresponding grades. The program should also validate the input for the student names, ensuring th... | codefeedback |
Find the two missing numbers in an array in C++.
You are given an array of n-2 integers, where all the integers are in the range from 1 to n inclusive. It is guaranteed that the array contains two missing numbers. Your task is to find and return these two missing numbers in ascending order.
Implement the following fu... | codefeedback |
Design a data structure to store the details of multiple students (Name, Age, Course) and their academic performance (Grade, GPA) with the following constraints:
1. The name of the student should be a string of at least 2 characters and not exceed 50 characters.
2. The age of the student should be a positive integer be... | codefeedback |
Convert a given positive integer less than or equal to 3999 to its corresponding Roman numeral representation, but with the following additional requirements:
- The solution must be implemented using recursion.
- The solution must be implemented in a language that does not have built-in support for Roman numeral conver... | codefeedback |
Write a SQL query to select the distinct cities from a table of customer data, but exclude any cities that have less than 10 customers. Additionally, include the number of customers in each selected city as a separate column in the result set. | codefeedback |
Create a React component for a button that takes four props: an onClick event handler, an id, a label, and a disabled boolean.
- The button should display the label passed in as a prop.
- The button should have a unique id passed in as a prop.
- When the button is clicked, it should trigger the onClick event handler pa... | codefeedback |
Create a Java method that computes the factorial of a non-negative integer, but with the following additional requirements:
1. The method should use a recursive approach to calculate the factorial.
2. The method should handle negative input values by throwing an IllegalArgumentException with a meaningful error message... | codefeedback |
Develop a bash script that will take 2 arguments as input. The arguments should be positive integers and the maximum value of each argument should be limited to 100. The script should print "Arguments are equal" if both arguments are equal, "Arguments are not equal" if both arguments are not equal, and "Invalid input" ... | codefeedback |
Please write a Python program that takes a URL as input and retrieves the title and description meta tags from the HTML of the webpage at the given URL. If the title or description meta tags are not present in the HTML or are empty, the program should return "N/A" for the respective field. Additionally, the program sho... | codefeedback |
Create a function in C to check whether a given string contains exactly three consecutive punctuations (i.e., !, ?, or .) or not. However, you are not allowed to use any built-in string or regular expression functions.
#Difficulty Increased Test# | codefeedback |
Classify the type of the expression 5 + 4 * 3 - 7 / 2 modulo 3. | codefeedback |
Design and implement a C++ program to calculate the Yield to Maturity (YTM) of a bond. The program should take into account the following considerations:
1. The bond has a fixed coupon rate, face value, and maturity date.
2. The YTM is the discount rate that equates the present value of the bond's cash flows (coupons ... | codefeedback |
Create a function in Python that can compute the volume of a rectangular room in cubic feet. The function should also handle any potential errors or invalid inputs. The room's length, width, and height should be positive integers. The function should also check if the calculated volume exceeds a maximum allowed value o... | codefeedback |
Write a function that takes in a string and a character and returns the first index at which the character appears. The string will not contain any leading or trailing whitespace. The character will always be a lowercase alphabet. The string can have a maximum length of 1000 characters.
However, you should not use any... | codefeedback |
Write an SQL query that returns all the students along with their marks and the subject name from the following tables. Additionally, include the average marks for each subject and the highest marks among all the students.
Student (id, name)
Subject (sub_id, subject_name)
Marks (id, sub_id, marks)
Hint: You may need ... | codefeedback |
#!/bin/bash
echo " Enter an integer "
read num
# If the number is positive and even, print "Positive and Even"
# If the number is positive and odd, print "Positive and Odd"
# If the number is negative and even, print "Negative and Even"
# If the number is negative and odd, print "Negative and Odd"
# If the number is ... | codefeedback |
Write a function called `bitwise_addition` that takes in two integers `a` and `b` as input. The function should use bitwise operations to add `a` and `b` together and return the result.
Note: You are not allowed to use any arithmetic operators (+, -, *, /) or the `+` operator in this task. Only bitwise operations such... | codefeedback |
Write a program that takes a string input representing an HTML document and outputs the name of all font styles available within the document.
The program should consider the following font style tags: <b>, <i>, <u>, <s>, <strong>, <em>, <ins>, <del>.
The program should correctly handle nested font style tags, meani... | codefeedback |
Write a code that takes a list of integers as input and returns a list of every permutation of that list, where each permutation must have the largest integer as the first element. Additionally, the code should ensure that no two permutations have the same integer at the second position. | codefeedback |
Train a machine learning model without using any frameworks with the following input and output data.
Input Data: A, B, C, D
Output Data: 0, 1, 0, 1
Provide a piece of erroneous code as a reference to increase misdirection:
```python
def train_model(input_data, output_data):
model = MyModel()
model.fit(input_... | codefeedback |
What changes can you suggest in order to optimize the following Java code?
You have been given a class called "Student" with three private variables - "name", "age", and "grade". Your task is to optimize the code by implementing the following requirements:
1. Create a constructor for the "Student" class that accepts ... | codefeedback |
Write a code that takes a positive integer and returns the sum of all prime numbers less than or equal to that number.
Example:
Input: 10
Output: 17
Note:
- The input number will be within the range of 2 to 1000.
- You are not allowed to use any built-in prime number functions or libraries.
- Your code should have a... | codefeedback |
Design a MySQL Table to store company employees with the following requirements:
- Each employee should have a unique employee ID.
- Each employee should have a first name, last name, and email address.
- The email address should be unique for each employee.
- Each employee should have a job title.
- Each employee shou... | codefeedback |
Develop a web page that displays the current temperature, humidity, and wind speed in various cities, with an option to view the weather forecast for the next 10 days. The page should also allow the user to search for a specific city and display its weather information. Additionally, the web page should have a feature ... | codefeedback |
Merge the following two linked lists in ascending order. Additionally, remove any duplicate elements from the merged list.
Linked List 1: 1->3->5->5->7
Linked List 2: 2->4->4->6 | codefeedback |
Write a code that takes a string and a character as an argument and counts the number of occurrences of that character in the string. The string can contain both uppercase and lowercase letters. The code should be case-sensitive. The string can also include special characters and numbers. The code should only count the... | codefeedback |
Write a query to find all employees whose age is between 25 and 30, whose department is Marketing, and whose salary is above the average salary of all employees in the company.
## Additional Requirements:
1. Sort the result by employee name in alphabetical order.
2. Include the department name in the result.
3. Calcul... | codefeedback |
Create a code that edits a list by adding a prime number to each element. The code should find the next prime number greater than the current element and add it to the element. The prime number generator function should have a time complexity of O(n^2 log n) and the code should have a space complexity of O(n).
Example... | codefeedback |
Create a recursive function in Java to calculate the Fibonacci numbers up to the number 10000. The function should have a time complexity of O(2^n), where n is the input number. | codefeedback |
Write a SQL query to find the count of all the books published in the last year and listed in a library catalog, excluding books that have been borrowed more than 5 times. Additionally, sort the books by their popularity (number of times borrowed) in descending order. | codefeedback |
Using only JavaScript, determine the length of a given string "Hello World" and reverse the string without using any built-in string manipulation methods or array methods. | codefeedback |
Create a method which receives a list of names and outputs the name which occurs the most in that list. If there is a tie for the most occurring name, return all the names in a list, sorted alphabetically. If there is a tie for the most occurring name and the list is empty or contains only one name, return an empty lis... | codefeedback |
Create a JavaScript function called "calculateFactorial" that takes a positive integer as input and returns its factorial. The function should handle input validation to ensure that the number is within the range of 1 to 20 (inclusive). If the input is not within this range, the function should throw an error with a de... | codefeedback |
Using HTML, CSS, and JavaScript, create a web page that displays a grid of 100 cells. Each cell should initially have a random color. When a cell is clicked, its color should change to a random color. Implement a button that, when clicked, changes the color of all cells in the grid to a random color simultaneously. Add... | codefeedback |
Create a program to determine the type of triangle given 3 side lengths. The program should also check if the triangle is valid.
For a triangle to be valid, the sum of any two sides must be greater than the third side. Additionally, the program should check if the triangle is a right triangle.
The program should dete... | codefeedback |
Write a program in Java that removes all duplicate characters from a string and returns the remaining characters in the order they appear in the original string. Your program should only consider alphabetic characters (A-Z and a-z) and ignore any non-alphabetic characters. Additionally, the program should also ignore d... | codefeedback |
Create a method to join an array of strings together, but only include strings that start with a vowel and have at least 3 characters in length. The resulting string should be in reverse order and separated by commas. The method should also count the total number of vowels in the resulting string. arr = ['one', 'two', ... | codefeedback |
Calculate the factorial of n using a recursive function. The function should also check if n is a positive integer and raise an exception if it is not. Additionally, implement a caching mechanism to store previously calculated factorial values in order to optimize the recursive function. | codefeedback |
Given the following array and a number k, write a program to determine if it contains exactly two distinct pairs of numbers that add up to k. The array may contain duplicates and negative numbers. Each pair of numbers must consist of one positive number and one negative number. | codefeedback |
Create a functional HTML form that includes the following attributes: name, email, country, and password.
In addition, add the following requirements:
1. The name field should only accept alphabetic characters and should not be left blank. It should also not accept any special characters or numbers.
2. The email fiel... | codefeedback |
Write the definition of a function to calculate the perimeter of a triangle, which takes as input the lengths of all three sides of the triangle as parameters. The function should also include a validation check to ensure that the lengths provided form a valid triangle according to the triangle inequality theorem. If t... | codefeedback |
Given a large text document, develop an algorithm to automatically generate a concise summary of the main ideas and key points within the text. The summary should be a shorter version of the original document, capturing the most important information.
However, there is a bug in the algorithm that causes it to randomly... | codefeedback |
Create a dictionary in which keys are characters and values are the occurrences of that character in a given string. However, exclude any characters that are vowels from the dictionary. Additionally, the occurrences should be case-sensitive, meaning that uppercase and lowercase versions of the same character should be ... | codefeedback |
Create a method to sort a given array of integers in descending order without using any of the built-in sorting functions in JavaScript. The method should also remove any duplicate integers from the sorted array. Additionally, ensure that the time complexity of the solution is O(n*log(n)).
Provide a piece of erroneou... | codefeedback |
How could Big data analysis be used to provide better services and products by considering the privacy concerns, implementing real-time analysis, and ensuring data accuracy and reliability? | codefeedback |
Implement a k-means clustering algorithm from scratch in a programming language of your choice. The algorithm should be able to group a given dataset into k distinct clusters. You are not allowed to use any built-in libraries or functions that directly implement the k-means algorithm. Additionally, provide a detailed e... | codefeedback |
Prompt the user to enter a positive integer, then output it in a sentence while also stating whether it is a prime number or not. Additionally, calculate and output the sum of all prime numbers up to the given input. | codefeedback |
Write a Python code to initialize a 100 x 100 matrix with random integer values ranging from -100 to 100, but ensure that the sum of the values in each row is equal to a specific target value.
The target value should be a random integer ranging from -1000 to 1000, and it should be different for each row. | codefeedback |
Implement a sorting algorithm that can sort a variety of data types, including integers, floating-point numbers, strings, and arrays of objects. The sorting algorithm should be able to handle duplicate values and should be stable. Additionally, the algorithm should have a time complexity of O(n log n) and should be abl... | codefeedback |
Describe the recursive approach for solving a problem, and provide an example of a problem that can be solved using recursion. Additionally, ensure that the recursive function uses at least two base cases and handles at least two recursive calls within its implementation. | codefeedback |
Create a list of 10,000 strings in Java, but ensure that none of the strings have any repeating characters. | codefeedback |
Develop a C program to print a pattern like a pyramid with a given number of rows, where each row contains an increasing number of asterisks, starting from 1 and ending with the maximum number of asterisks in the middle row. The program should take an input from the user to determine whether the pyramid should be print... | codefeedback |
Write a function to calculate all the possible paths for a N x M matrix, where N and M are positive integers.
The function should return the total number of unique paths from the top-left corner to the bottom-right corner of the matrix. You can only move down or right in each step.
Additionally, you are now given a l... | codefeedback |
Create a code in Python to get the historical stock prices of a company from Yahoo Finance for a given time period.
The code should accept the following inputs:
- Ticker symbol of the company (e.g., "AAPL" for Apple)
- Start date and end date of the time period for which the historical prices should be retrieved
The c... | codefeedback |
Create a JavaScript function to convert a string to pig-latin, while handling both upper and lower case letters. The function should also handle punctuation marks and special characters within the string. | codefeedback |
Write a command line program in C++ which takes a string as input and prints all its characters in reverse order. The program should also handle cases where the input string contains special characters and whitespace. The output should exclude any duplicate characters in the reversed string. Additionally, the program s... | codefeedback |
Design a database schema for an online banking system with support for multiple currencies. Additionally, the system should have the following features:
1. Generate monthly bank statements for each account holder.
2. Allow account holders to transfer funds between their accounts.
3. Implement a transaction history feat... | codefeedback |
Implement a quicksort algorithm in JavaScript that takes an array of numbers as input and returns a sorted array. The algorithm should have a time complexity of O(n log n) and must be implemented without using any built-in sorting functions or libraries. Additionally, the algorithm should be able to handle arrays with ... | codefeedback |
What is the complete syntax of a nested if-else block in Java, including the required keywords and brackets, and at least two condition statements? | codefeedback |
Create a matrix of size 10000 x 10000 in Python, where each element is a random integer between 1 and 1000. | codefeedback |
Write a Spark program to count the number of distinct words for a given text and calculate the average length of those words. The program should also track the frequency of each word and print the top 5 most frequently occurring words.
Text: This is a test text.
Time Complexity Requirement: O(n), where n is the numbe... | codefeedback |
Construct a HTML table with six columns and five rows. Each cell in the table should contain a random number between 1 and 100. Additionally, every alternate row should have a background color of light gray. | codefeedback |
Write a SQL query that joins four tables on multiple conditions, selects distinct records, and includes aggregate functions.
TableA:
id | name | type | category_id | status
TableB:
id | age | gender | category_id | status
TableC:
id | category_id | location | status
TableD:
id | category_id | size | status
The quer... | codefeedback |
Find the length of the longest palindromic subsequence in the given string, but the function should not use any built-in string manipulation functions (e.g. reverse(), slice()).
s = "abbaba"
#Difficulty increased by requiring the function to find the length of the palindrome rather than printing the palindrome itself... | codefeedback |
Write an algorithm to find the k-th prime number, where k is given as input and N is a large number.
Note: The algorithm should be efficient and optimized for large values of N. | codefeedback |
Fill in the blanks to correctly identify the type of the following variable.
The variable x is a ____________ that can only hold integers and must be initialized with a value greater than or equal to 100, and it must have a custom validation method that checks if the value is divisible by 5. | codefeedback |
Construct a python list comprehension that generates a list of prime numbers from 2 to 50. | codefeedback |
Generate an HTML element with a maximum of 10 attributes, where each attribute must have a unique name and value and adhere to the HTML attribute naming conventions. Additionally, the attributes must be generated randomly, without any specific order or pattern. | codefeedback |
Write a PHP script to generate a random password with at least 15 characters. The password should contain a combination of uppercase and lowercase letters, numbers, and special characters. Additionally, the script should ensure that the generated password includes at least one uppercase letter, one lowercase letter, on... | codefeedback |
Using HTML and CSS, create a responsive web page layout that includes a sidebar, main content area, and footer. The sidebar should be fixed and take up 20% of the screen width, while the main content area should take up 60% of the screen width and be scrollable if the content exceeds the available space. The footer sho... | codefeedback |
Write a query to find the names of all employees who have a salary higher than the average salary of all employees, have been working for more than 5 years, and are currently employed in the Sales department. Table Name: Employees Columns: Name, Salary, Years_of_Experience, Department | codefeedback |
Count the number of quadruples that sum up to zero in a given array. A quadruple is defined as a set of four distinct numbers in the array. The array will only contain unique positive and negative numbers.
For example, if the array is [-2, -1, 0, 1, 2], there are two quadruples that sum up to zero: (-2, -1, 1, 2) and ... | codefeedback |
Generate a React class component that handles three different event types, but with the following specific requirements:
1. The onMouseLeave event should only trigger when the mouse pointer leaves a specific div with the id "container".
2. The onDragStart event should only trigger when the user starts dragging an eleme... | codefeedback |
Create a SQLite database table called "Students" with the following columns: "Name" (string), "Age" (integer), "GPA" (float). Additionally, add a primary key column called "ID" (integer) that auto-increments for each new record. Ensure that the "Name" column only allows a maximum of 50 characters, the "Age" column only... | codefeedback |
Create a Bash script that runs a Python code and passes an argument to the Python function. The Python function should only accept lowercase alphabets as the name argument. | codefeedback |
Create a function that takes in a list of integers and returns a new list containing only the even numbers from the original list, in ascending order. The function should have a time complexity of O(n), where n is the length of the input list. Additionally, the function should not use any built-in functions or librarie... | codefeedback |
Write a Python script that takes in a positive integer as input and determines whether it is a prime number. The script should also print the sum of all the prime digits in the input number. The input number should be greater than or equal to 100 and less than or equal to 10^9. | codefeedback |
Suggest an algorithm to search for a matching string in a large text, but with the following additional requirements:
- The algorithm should be case-sensitive, meaning it should differentiate between uppercase and lowercase letters.
- The algorithm should return the index position of the first occurrence of the matchin... | codefeedback |
Write an HTML page including a form element with the following controls:
1. Text area control
2. Dropdown menu control
The form should also have a submit button.
Additionally, include the following requirements:
1. The text area control should have a character limit of 1000 characters.
2. The dropdown menu control sh... | codefeedback |
Generate a distributed programming workflow for analyzing a large text dataset, ensuring efficient parallel processing and fault tolerance.
Dataset size: 100 million words
Each processing node should handle a maximum of 1 million words at a time.
The workflow should include a data sharding mechanism to evenly distribut... | codefeedback |
Implement a function in Python that sorts a singly linked list in ascending order. The function should use the Radix sort algorithm instead of a commonly used sorting algorithm. Explain the advantages and disadvantages of using the Radix sort algorithm for linked lists compared to other sorting algorithms. Provide a re... | codefeedback |
Construct a list of integers from m to n, inclusive, where m and n are both positive integers greater than 1. The list should only contain prime numbers and each prime number should be repeated twice. m = 3 n = 8 | codefeedback |
Capitalize the letters A - Z in the given string and reverse the order of the words in the string. Additionally, remove all vowels from the string.
text = "We are learning natural language processing" | codefeedback |
Write a code to print out an array of the first ten prime numbers where each prime number is a palindrome. | codefeedback |
Create a function to check if a given triangle is a right-angled triangle.
The function should take three parameters, representing the lengths of the three sides of the triangle.
The function should return True if the triangle is a right-angled triangle, and False otherwise.
Additional Requirements:
- The time complex... | codefeedback |
Identify the type of a given function f(x) = 2^x + 1/2 * sin(x) with the additional constraint that the function must be implemented using recursion. | codefeedback |
Write a code to process a given array and add 10 to each even value stored in the array. If the value is odd, subtract 5 from it. If the value is a prime number, multiply it by 2. Return the modified array.
arr = [1, 2, 3, 4, 5, 7, 8, 11] | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.