instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Calculate the sum of all the multiples of 3 and 5 between 0 and n, where n is a positive integer less than or equal to 100. Your solution should be implemented using recursion. | codefeedback |
Generate pseudo code for a function that swaps two numbers x and y using bitwise operations. | codefeedback |
What type of loop can be used to iterate through the items of a list in Python and find the average of all the even numbers in the list? | codefeedback |
Write an HTML document with a table containing five columns: name, email, phone, address, and occupation. The table should have at least 10 rows of data. Additionally, the email column should be clickable and should open the default email client when clicked. The phone column should display the phone number in a specif... | codefeedback |
Create a JavaScript function to retrieve a deeply nested value from an object with a given key path.
#Difficulty Increase#
The key path can contain arrays as well, indicating the index to access in the object. The function should handle any level of nesting and return the value if found, or undefined if not found.
Ex... | codefeedback |
Write a Python program to create a dictionary containing students and their scores. The program should validate the input to ensure that the scores are within the range of 0 to 100, and prompt the user to re-enter any invalid scores. | codefeedback |
Write a Go program that prints the numbers from 1 to 100, replacing any number divisible by 4 with "Four" and any number divisible by 7 with "Seven". | codefeedback |
Read the following block of code. What is the main goal of the code? Implement a function called "first_duplicate" that takes an array of integers as input and returns the first duplicate element found in the array. If no duplicate is found, the function should return -1. The function should also have a time complexity... | codefeedback |
Write a JavaScript code snippet to track the mouse movement within a specified div element, and display the coordinates of the mouse cursor in real-time. | codefeedback |
Create a HTML form with two input fields called 'name' and 'age'. The form should also have a dropdown menu for selecting a gender. Additionally, the form should include a checkbox for agreeing to terms and conditions, and a submit button. The form should have client-side validation to ensure that the 'name' field is n... | codefeedback |
Construct a class in Java that creates methods for finding the area and circumference of a circle. The class should also include methods for checking if a point lies inside the circle, calculating the distance between two circles, and checking if two circles intersect. Additionally, implement a method for finding the s... | codefeedback |
Explain the concept of a state machine in software engineering, providing a detailed explanation of its components and how they interact with each other. Additionally, illustrate the process of creating a state machine diagram and discuss its significance in software development. | codefeedback |
Suggest a MySQL query that retrieves all students who are enrolled in the "Computer Science" program and have a GPA above 3.5 from the "Idaho" state. | codefeedback |
You are given two matrices, M1 and M2. Write a python code to multiply them. The number of columns in M1 should be equal to the number of rows in M2. The resulting matrix should have the same number of rows as M1 and the same number of columns as M2. Additionally, the input matrices should have a size of at least 2x2. | codefeedback |
Write a Java method that checks if a nested integer contains an even number. The nested integers can contain negative numbers and can be of any depth. The method should have a time complexity of O(n), where n is the total number of integers in the nested structure. | codefeedback |
Design a class in Java to represent a stack data structure, and implement operations such as push, pop, size, and peek. Additionally, ensure that the stack has a maximum capacity and implement functionality to handle overflow and underflow conditions. | codefeedback |
Generate a code to form a Pascal Triangle with the given input. The input will be a positive integer, n, where n represents the number of rows in the Pascal Triangle.
A Pascal Triangle is a triangular array of binomial coefficients. Each number in the triangle is the sum of the two numbers directly above it. The first... | codefeedback |
Retrieve the data in the given URL and calculate the average word length of the text content. | codefeedback |
Create a Java program that accepts two numbers and finds their greatest common divisor (GCD) using the Euclidean algorithm. Implement the algorithm recursively.
The program should:
1. Prompt the user to enter two integers.
2. Check if both integers are positive. If not, display an error message and prompt the user to ... | codefeedback |
Write code to convert JSON to XML with provided attribute and add a new element to the XML for each employee with the average salary of their department.
{
"employees":{
"employee":[
{
"name":"John Smith",
"id":123,
"department":"Finance",
"sala... | codefeedback |
Change the given singly linked list into an array while also ensuring that the array is sorted in ascending order. Linked list: 1->3->5->7->9 | codefeedback |
Write a code to create a list that preserves the order of the original input and contains only the odd numbers from it? Additionally, ensure that the code handles the case when the input list is empty and return an appropriate message.
[2, 4, 6, 8, 10, 11, 12, 13, 14, 15] | codefeedback |
Write a code that swaps the two numbers using a temporary variable and cannot use any arithmetic or assignment operators. a = 10, b = 20 | codefeedback |
Write a Python program that parses a JSON object and returns only the values of a specific key. The program should also handle nested JSON objects and arrays.
JSON object:
{
"name": "John",
"age": 42,
"location": {
"city": "New York",
"country": "USA"
},
"pets": [
{
... | codefeedback |
Using the input as a guide, write code that prints out a copy of the 2D matrix with its elements transposed. Additionally, calculate and print the sum of each row and column in the transposed matrix.
Original matrix:
matrix = [[1,2,3],[4,5,6],[7,8,9]]
Transposed matrix:
[[1, 4, 7],
[2, 5, 8],
[3, 6, 9]]
Sum of eac... | codefeedback |
Change the following list of strings into a single combined string, but with the following conditions:
1. Remove any duplicate words from the list.
2. Sort the words in descending order based on their length.
3. Only include words that have a length greater than or equal to 3.
4. Replace any vowels in the words with th... | codefeedback |
Write a code to generate a dictionary that contains the frequencies of all English alphabets in a given sentence. The code should handle case sensitivity, meaning that uppercase and lowercase letters should be treated as different letters. Additionally, punctuation marks should be ignored.
Sentence: "The quick brown f... | codefeedback |
Fix the code so that the loop terminates after 10 iterations. However, you are not allowed to use any comparison operators (such as "<", ">", "<=", ">=") inside the loop condition. | codefeedback |
Construct a SQL query to select the orders with order_num >= 1000 and order_date > '2020-01-01'. | codefeedback |
Generate a Python code to add two numbers using a lambda expression. The numbers should be stored in a list and the lambda expression should use a reduce function to compute the sum. The list of numbers is as follows:
numbers = [10, 25] | codefeedback |
Unwrap the function parameter with default argument and ensure that arg1 is a positive integer. If arg1 is not a positive integer, raise a ValueError with the message "arg1 must be a positive integer". The function should still have a default argument for arg2 with the value "default". | codefeedback |
Given a string s and an integer k, write a code to find the kth most frequent word with a length of at least 5 characters in the string.
String s: "hello world hello"
Integer k: 2 | codefeedback |
Create a list comprehension that prints each pair in a given list of tuples only if the first element of the pair is a string and the second element is a prime number.
my_list = [("apple", 2), ("banana", 3), ("carrot", 4), ("date", 5), ("eggplant", 6), ("fig", 7)] | codefeedback |
Create a function that takes in a list of integers and returns a new list that includes only the prime numbers from the original list. | codefeedback |
Rewrite the following code snippet so that it is compatible with Python 3 and also implement the functionality to calculate the sum of the squares of all numbers from 1 to 10.
sum_of_squares = 0
for num in range(1, 11):
square = num * num
sum_of_squares += square
print(sum_of_squares) | codefeedback |
Create a program to convert a given time in GMT form to local time, considering daylight saving time (DST).
# Requirements:
1. The program should take the GMT time as input and return the corresponding local time, accounting for DST if applicable.
2. The program should handle DST changes correctly for different time z... | codefeedback |
Create a dictionary with the key-value pairs of the given tuple, where the keys are strings and the values are integers. The tuple may contain duplicate keys.
my_tuple = (("a", 1), ("b", 2), ("c", 3))
Additional Instructions:
1. Ensure that the keys in the dictionary are sorted in ascending order.
2. Handle the case ... | codefeedback |
Write a Python algorithm to find the most common value in an array. The array will always contain at least 5 elements and the maximum size of the array is 100. The elements in the array are integers between -1000 and 1000. The algorithm should have a time complexity of O(n). Return the most common value along with its ... | codefeedback |
Suggest a vector representation for the following phrases using the word embedding model called FastText. | codefeedback |
Identify an efficient algorithm to find the longest palindrome in a given string, while considering that the string can have a maximum length of 10^6 characters and the algorithm should have a time complexity of O(n). | codefeedback |
Fill in the blanks to calculate the standard deviation of an array using the formula. Make sure to handle edge cases and provide appropriate error handling. | codefeedback |
Suggest a way to securely store and authenticate user passwords, ensuring a minimum password length of 8 characters, including at least one uppercase letter, one lowercase letter, one digit, and one special character. Additionally, implement a password hashing algorithm such as bcrypt to protect the passwords from unau... | codefeedback |
Develop an AI Assistant to identify questions in a given paragraph. The paragraph can contain multiple sentences, and the assistant should be able to correctly identify and extract all the questions present in the paragraph. The assistant should also be able to handle different question formats, such as yes/no question... | codefeedback |
Suggest and explain a technique to optimize memory usage in a programming language of your choice. Additionally, provide a piece of erroneous code that you have encountered in the past and explain how you would correct it to improve memory efficiency. | codefeedback |
Write a function that takes a list of integers as input and returns a list of unique prime numbers present in the input list, sorted in ascending order. The function should have a time complexity of O(n√m), where n is the length of the input list and m is the maximum value in the input list. | codefeedback |
Code a function in Java to search an array for a specific element and return the index of the first occurrence. If the element is not found, return -1.
The function should have a time complexity of O(log n) and a space complexity of O(1).
array x = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
element = 13 | codefeedback |
Create a softmax activation function in Python without using any libraries or built-in functions for exponentiation or logarithms. | codefeedback |
Write a MongoDB query to get the first 3 documents in a collection of documents, but only return the documents where a specific field "status" is set to "active". | codefeedback |
Create classes in Java to represent a school, its departments, courses, and students.
1. The School class should have the following attributes:
- Name: a string representing the name of the school.
- Departments: an array or collection of Department objects representing the various departments in the school.
2. The D... | codefeedback |
Write a SQL query to find the employees with an annual income greater than 10000 and who have been employed for at least 5 years. | codefeedback |
Suggest an edit to fix the following code snippet. Ensure that the fixed code snippet only uses a single line of code and does not include any semicolons. Additionally, the fixed code should utilize list comprehension to print only the odd numbers from 1 to 10, inclusive. | codefeedback |
Create a SQL query to display the details of all employees who have served more than 4 years in their current role and have received a promotion within the last year.
Sample table:
+------------+----------+------------+--------------+--------------------------+
| emp_id | name | department | doj | cur... | codefeedback |
Create a JavaScript class called "Person" with the following properties:
- name: a string representing the person's name
- age: a number representing the person's age
The class should have the following methods:
1. greet(): a method that logs a greeting message with the person's name and age to the console
2. changeNa... | codefeedback |
Create a function to add two integers in assembly language. Additionally, implement error handling to check if the sum of the two integers exceeds the maximum value that can be stored in a 32-bit signed integer. If the sum exceeds the maximum value, return an error code indicating an overflow. | codefeedback |
Create a user interface to display a chart showing the number of people of a certain gender and age group. The user interface should allow the user to filter the data based on multiple criteria such as gender, age range, and name. The chart should be interactive, allowing the user to hover over each bar to see the exac... | codefeedback |
Create an array in JavaScript of objects, each with a name key and a value of a random number between 1 and 100. Sort the array in ascending order based on the value of the random number. Then, iterate through the sorted array and print out the name and value of each object in the following format: "Name: [name], Value... | codefeedback |
Create a SQL query to find all the departments with more than 5 employees who have been with the company for at least 2 years. | codefeedback |
Create a CSS selector to target the fourth and fifth <div> elements with the class 'container' and apply a background color of red to them. | codefeedback |
Create a Java method that takes an array of integers as a parameter and computes their median.
Note: The median is the middle value in an ordered list of numbers. If the list has an odd number of elements, the median is the middle element. If the list has an even number of elements, the median is the average of the tw... | codefeedback |
Write a function to compare two lists and print out whether they are equal or not. The lists can contain integers, strings, or a combination of both. The function should also consider the order of elements in the lists.
list1 = [1, "hello", 3]
list2 = [1, 3, "hello"]
For the lists to be considered equal, they must ha... | codefeedback |
Create a Python class with an instance method that prints the number of objects created. Additionally, implement a class method that returns the total number of objects created across all instances of the class.
#Solution# | codefeedback |
How would you implement Skip-Gram model in TensorFlow, with the added requirement of handling out-of-vocabulary (OOV) words? | codefeedback |
Delete every third character in a string, but with a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Rewritten Test:
Which of the following is a valid way to declare a variable in Java, given the following conditions:
- The variable should be of type integer.
- The variable should be named "num".
- The variable should be initialized with the value 10.
- The variable should be declared as a constant. | codefeedback |
Write a code to format a number with two decimal places, but round down instead of rounding to the nearest decimal place.
23.19999 | codefeedback |
Take the following string and read it into a list in Python. Each element in the list should be a tuple consisting of the word itself and its length. The tuple should be sorted based on the length of the word in descending order.
Example: Input: "apple, banana, peach, orange"
Output: [('banana', 6), ('orange', 6), ('pe... | codefeedback |
How would you reverse the order of the elements in a given singly linked list in-place without using any extra space? | codefeedback |
Write a CSS selector that selects every second list item that has a class of "highlight". | codefeedback |
Sum all the numbers divisible by 3 and 7 in the list and calculate the average of those numbers. Additionally, find the maximum and minimum values among the numbers divisible by 3 and 7. Finally, display the number of occurrences of each unique number divisible by 3 and 7 in the list. | codefeedback |
Write a regex pattern to match a float number with at least one decimal place and with the following conditions:
1. The number can be positive or negative.
2. The number can have an optional leading plus or minus sign.
3. The number can have an optional integer part before the decimal point.
4. The number must have at ... | codefeedback |
Given a dictionary with keys representing different space companies and values representing their respective slogans, sort the slogans alphabetically and return a list of tuples containing the company and its corresponding slogan.
Example input:
{"SPACELINE": "Flight of the Future", "LUCY": "Rocket Science"}
Example ... | codefeedback |
Create an array in Javascript that contains elements of different datatypes and sort the array in ascending order based on the length of the string elements. | codefeedback |
Write a function to print a user's name and age from a given dictionary. However, if the age is greater than or equal to 18, print "Adult" next to the name. If the age is less than 18, print "Minor" next to the name. If the age is less than or equal to 0, raise an exception with the message "Invalid age". | codefeedback |
Suggest a JavaScript code to make an AJAX request to fetch data from a server, ensuring that the request includes a custom header and that the response is parsed as JSON. Additionally, the code should handle any potential errors and timeouts that may occur during the request. | codefeedback |
Parse and save the following article in a dataset. The program should be able to handle multiple articles and store them separately. Each article should be validated to ensure that it is grammatically correct, contains no profanity or offensive language, and does not exceed a certain word count. The program should also... | codefeedback |
Write a C++ function to remove all the duplicates in a given array, while maintaining the relative order of the remaining elements. | codefeedback |
Create a class in Python which models a bank account using the concept of class and object. The bank account should include the following functionalities:
1. Ability to deposit and withdraw funds.
2. Ability to check the current balance.
3. Ability to calculate and apply interest on the account balance.
4. Ability to ... | codefeedback |
Create a Javascript object that stores the number of cats and dogs in a given location. Implement methods to:
1. Add a cat or dog to the location.
2. Remove a cat or dog from the location.
3. Check if the location has more cats than dogs.
4. Get the total number of cats and dogs in the location.
5. Get the average numb... | codefeedback |
Design a reinforcement learning algorithm that can optimize the inventory management for an e-commerce business by dynamically adjusting the restocking quantity based on the seasonality, customer demand, and delivery lead times. | codefeedback |
Describe the step-by-step process of how deep learning can be used to diagnose and classify different types of cancer in medical images, such as mammograms or histopathology slides. | codefeedback |
Write a function that takes in a JSON object as input and changes the value of a specific key to the sum of the values of two other keys. The function should have a time complexity of O(n), where n is the number of keys in the JSON object.
The input JSON object will have the following structure:
{
"key1": 10,
"key... | codefeedback |
Design a natural language processing system for healthcare that can accurately predict the diagnosis of a patient based on their symptoms and medical history. The system should also be able to provide personalized treatment recommendations for each diagnosed condition. The time complexity of the system should be optimi... | codefeedback |
Rank a list of integers from high to low, but with the following additional requirements:
1. The sorting algorithm must be a modified version of quicksort.
2. The modified quicksort algorithm must use a pivot element that is randomly selected from the input list.
3. The sorting algorithm must be implemented recursivel... | codefeedback |
Develop a Java program that takes two strings as input and outputs the common characters in both strings. Additionally, your program should handle cases where the input strings may contain special characters, whitespace, and numbers.
String A: "ab c$de123"
String B: "d@efg7h"
Note: Special characters, whitespace, and... | codefeedback |
What are the significant differences between a Java applet and a Java application, considering factors such as deployment, security, and platform compatibility? | codefeedback |
Develop a program in Swift to check if three sides form a valid triangle. The program should also calculate and display the type of triangle (equilateral, isosceles, or scalene) if the sides are valid. | codefeedback |
Create a regex pattern to identify alphanumeric characters that are followed by exactly three digits. | codefeedback |
Write code to construct a doubly linked list in C++. Each node in the linked list should have the following attributes:
- An integer data value.
- A pointer to the next node.
- A pointer to the previous node.
Node data:
- 2
- 4
- 5
- 9
The linked list should be constructed in such a way that the nodes are sorted in a... | codefeedback |
Create a program that generates a large dataset for testing a supervised learning algorithm. The dataset should consist of 100,000 samples, each with 100 features and a corresponding label. The features should be randomly generated floating-point numbers between -1 and 1, and the labels should be either 0 or 1.
The pr... | codefeedback |
Create a C++ program for a university grading system that calculates and assigns grades based on the following criteria:
1. The program should prompt the user to enter the number of students in the class.
2. For each student, the program should prompt the user to enter the student's name, ID, and scores for three exam... | codefeedback |
Write a SQL query to select all the people between the ages of 18 and 25 who have at least one transaction in the past 30 days. | codefeedback |
Implement a web scraper in Python to fetch all the URLs from a given website and count the number of occurrences of each URL.
The website URL is https://www.example.com.
Please note that you should also handle any potential errors or exceptions that may occur during the scraping process, such as invalid URLs or connec... | codefeedback |
Generate a series of natural numbers from 1 to 50 using regex. Each number must be preceded by the word "Number" and followed by a comma and a space. | codefeedback |
Create an array of integers that contain all the prime numbers between 1 and 1000, using the Sieve of Eratosthenes algorithm. | codefeedback |
Rewritten Test:
Given a Python dictionary, write a function that recursively converts the dictionary into a valid JSON string. The function should handle the following types of values:
1. Integers
2. Floats
3. Booleans
4. Strings
5. Lists
6. Nested dictionaries
The function should also include the following requiremen... | codefeedback |
Write a function that returns the larger number from two numbers provided. However, the function should also handle cases where the two numbers are equal and return an appropriate message. Additionally, the function should handle cases where one or both of the numbers are negative and return the larger absolute value o... | codefeedback |
Create a dynamic HTML page with a table which contains data about the student population. Implement functionality to allow users to add, delete, and edit student data entries directly on the table. Add validation checks to ensure that required fields are filled, and data is in the correct format (e.g. valid email addre... | codefeedback |
Write a function that takes in a string and returns a list of all unique words in the string in alphabetical order, without using any built-in sorting functions or data structures. The time complexity of your solution should be O(n^2), where n is the length of the string. Additionally, the function should be case-insen... | codefeedback |
When given a list of strings, identify which strings are palindromes. However, the strings may contain punctuation marks and spaces, and should be treated as case-insensitive.
list = ['A man, a plan, a canal, Panama!', 'racecar', 'hello world'] | codefeedback |
Write a code that returns a 2-dimensional array of size n by m containing all prime numbers
n = 5 and m = 7 | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.