instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Generate a function that computes the sum of the prime numbers between a given range of numbers. | codefeedback |
Given a complex data structure containing objects with the following properties:
- Name: a string of length at most 100 characters.
- Age: an integer between 0 and 100.
- Height: a float representing height in meters, accurate to two decimal places.
- Weight: a float representing weight in kilograms, accurate to two d... | codefeedback |
Create a class to store student names, ages, grades, attendance records, and extracurricular activities.
1. The class should have a constructor that takes in the student's name, age, grade, and a list of extracurricular activities as parameters and initializes the corresponding attributes.
2. Add a method called "add_... | codefeedback |
Parse a JSON object and print out the elements. Additionally, the program should check if the 'name' key exists in the object and, if it does, print the value of the 'name' key. If the 'name' key does not exist, the program should print 'Name not found'.
The program should handle the case if the 'age' key is missing a... | codefeedback |
Write a virtual assistant in Python to gauge the sentiment of a given string. The string will be a paragraph of text, and the virtual assistant should be able to determine the sentiment of each sentence within the paragraph. The sentiment can be classified as either positive, negative, or neutral. Additionally, the vir... | codefeedback |
Given a list of time strings in 24-hour format and a time zone offset, convert each time string to the corresponding 12-hour format based on the given time zone offset.
Example:
Input:
times = ["12:30", "15:45", "08:00"]
offset = -3
Output:
["9:30 AM", "12:45 PM", "5:00 AM"] | codefeedback |
Write a Python program to find all the Armstrong numbers between the given two numbers. An Armstrong number is a number such that the sum of its digits raised to the power of the number of digits is equal to the number itself. The program should also display the total count of Armstrong numbers found. The program shoul... | codefeedback |
Write a Python function to check if a number is a perfect number or not. A number is said to be a perfect number if the sum of its proper divisors is equal to itself.
Proper divisors of a number are all the divisors excluding the number itself.
Your function should take in a positive integer as input and return a boo... | codefeedback |
Calculate the square root of a number using Newton's method. However, your code should also handle negative numbers and raise an error if the input is not a number.
number = "9" | codefeedback |
Construct a loop to print prime numbers from 1 to 1000 using a while loop in Python. | codefeedback |
Complete the following code to fetch data from the "employees" table using an SQL query. The query should retrieve the following columns: employee_id, first_name, last_name, email, phone_number, hire_date, and job_id. The results should be ordered by the hire_date in descending order and only include employees who were... | codefeedback |
Rewrite the following C program so that it prints the frequency of each character in a given string, excluding any digits present in the string. The program should have a time complexity of O(n), where n is the length of the string, and should not use any extra space apart from the result array.
Example:
Input: "abcab... | codefeedback |
Sort a given list of numbers in descending order and print the result. The list should contain at least 5 numbers and no more than 10 numbers. Each number in the list should be unique and within the range of 1 to 100. Additionally, the sorting algorithm used should be a custom implementation and not a built-in function... | codefeedback |
Create a Python script that finds the number of occurrences of a specific word in a given sentence, while also considering variations in capitalization and punctuation. Additionally, the script should be able to handle multiple words and return the count of each word in the sentence. The script should also handle the c... | codefeedback |
Change the following Python program so that it prints out all the distinct palindromic substrings of length greater than 1. The program should ignore case sensitivity and non-alphabetic characters. The program should also ensure that the substrings are not repeated and should be printed in lexicographical order. The in... | codefeedback |
Design a solution in JavaScript to find the kth smallest element in an unsorted array. The array may contain duplicate numbers as well. Additionally, you are not allowed to use any sorting algorithms or built-in JavaScript functions to solve this problem. If the kth smallest element does not exist in the array, return ... | codefeedback |
Multiply every element of a list and print the result. However, you are not allowed to use the '*' operator or any built-in multiplication functions. You can only use addition, subtraction, and bit shifting operations. The list may contain positive and negative integers.
myList = [3, -4, 5] | codefeedback |
Design a web page using HTML and CSS that displays a leaderboard for a gaming competition. The leaderboard should include the following components:
1. A heading at the top of the page with the title "Gaming Leaderboard".
2. Two paragraphs below the heading that provide information about the competition.
3. A table wit... | codefeedback |
Make a class in Python which will represent a binary search tree. The tree should support the following operations: inserting a node, deleting a node, searching for a node, finding the minimum value in the tree, and finding the maximum value in the tree. Additionally, the tree should enforce the property that each left... | codefeedback |
How do you create a MySQL query to find a specific employee by their name and department in a table named 'employees'? Additionally, display the employee's salary and date of hire in the result set. Apply the following constraints:
1. The query should be case-insensitive when searching for the employee's name.
2. The ... | codefeedback |
Create a function in golang that takes in two parameters: a string and an integer. The string parameter should have a default value of "Hello". Inside the function, print the string parameter the number of times specified by the integer parameter. Additionally, if the integer parameter is less than or equal to zero, th... | codefeedback |
Given an array of integers, find the maximum sum of a subarray and print the result. Additionally, the subarray must contain at least two elements. array = [2, -7, 4, 5, -2, 6, -3]
#Difficulty Increased Test#
Given an array of integers, find the maximum sum of a subarray and print the result. Additionally, the subarr... | codefeedback |
Design a responsive HTML page using standard HTML tags which contains an input box, a button, and an output section. The input box should have the following requirements:
1. It should only allow alphanumeric characters and special characters such as @, #, $, %, etc.
2. It should have a maximum character limit of 150.
... | codefeedback |
Design a database schema for a retail store that tracks customers, purchases, and items. The system should also track the sales representative responsible for each purchase and the commission earned by the representative for each sale. Additionally, the system should store information about the suppliers of the items, ... | codefeedback |
Rewrite the random_arr function to include an additional constraint that the returned tuple must contain only even values. | codefeedback |
What is the syntax for filtering a DataFrame using multiple OR conditions in Pandas, while optimizing for time complexity, and also ensuring that the filtering is case-insensitive? | codefeedback |
Given an array of strings and an integer, write a function in Java to return a new array that contains the strings at each index less than or equal to the specified integer. The new array should also be sorted in descending order based on the length of the strings. If multiple strings have the same length, they should ... | codefeedback |
How can we extract the first 2 characters from a string in Perl while also ensuring that the extracted characters are all lowercase, without using any built-in string manipulation functions or regular expressions? | codefeedback |
Write a function in Python that accepts an array of positive integers as an argument and returns the index of the first occurrence of the item with the maximum value. If there are multiple occurrences of the maximum value, return the index of the occurrence with the lowest index value. If there are no occurrences of th... | codefeedback |
Write an algorithm that takes a set of positive numbers and returns the sum of all numbers in the set. The algorithm should also handle the case when the set is empty and return 0 in such cases. Additionally, the algorithm should have a time complexity of O(n), where n is the size of the set. The set can contain duplic... | codefeedback |
Create a function that takes two integer arguments, subtracts the second one from the first one, and returns the result. However, the function should return an error message if the second argument is greater than the first argument or if either of the arguments is negative. The function should also check if the result ... | codefeedback |
## Given Test (Rewritten) ##
Create a function in Python that takes a date in the format "YYYY-MM-DD" as an argument and displays the corresponding day of the week from Monday to Sunday.
The function should handle leap years correctly.
You should not use any built-in date or time libraries in your solution.
The tim... | codefeedback |
Create a function to generate a random number within the range of 0 and 1000, but with the additional constraints that the generated number should be divisible by both 7 and 13. | codefeedback |
Using a single 'for' loop, iterate through an array and print out the indices and values of each element to the console. However, in addition to printing the correct indices and values, also print the indices and values of the previous element and the next element in the array.
For example, if the array is [2, 5, 8, ... | codefeedback |
Design a class BankAccount that represents a bank account with the attributes name, balance, and interest_rate. The balance attribute should be restricted to only positive values, and the interest_rate attribute should be restricted to a range between 0 and 10. Additionally, implement a method that allows for withdrawi... | codefeedback |
Create a method that takes a string as a parameter and returns the number of unique characters present in the string. However, the method should not consider characters that are surrounded by quotation marks as part of the string. Additionally, the method should also ignore characters that are surrounded by both single... | codefeedback |
Implement a function that takes in a list of integers and returns the sum of all the unique integers in the list. The function should have a time complexity of O(n), where n is the length of the input list.
Example:
Input: [1, 2, 2, 3, 4, 4, 5]
Output: 15
Note: In the given example, the unique integers in the list ... | codefeedback |
Identify all the variables in this C++ program and display their names, data types, and memory addresses. Additionally, add a new constraint that the program should only display variables of type "int" and "double".
#include <iostream>
int main()
{
int number = 10;
double decimal = 3.14;
char character = ... | codefeedback |
Update the given code to sort an array of strings based on their lengths in descending order. Additionally, you should implement the sorting algorithm from scratch instead of using built-in sort functions.
arr = ["dogs", "cat", "lion", "elephant", "tiger", "giraffe", "zebra", "monkey", "snake", "crocodile", "bear", "w... | codefeedback |
Create a function that takes in two parameters, a list of integers and a target sum. The function should return a list of all pairs of integers from the input list that add up to the target sum. If there are no such pairs, the function should return an empty list.
The function should have a time complexity of O(n), wh... | codefeedback |
Write a Swift program to calculate the factorial of a given integer, but without using any loops or recursion. Additionally, your solution should have a time complexity of O(1) and utilize only a constant amount of space. | codefeedback |
Using the input provided, generate a random string consisting of 12 characters, where each character can be any uppercase letter, lowercase letter, digit, or special character (!, @, #, $, %, ^, &, *) with the following requirements:
- The string must contain at least one uppercase letter, one lowercase letter, one dig... | codefeedback |
Write a comprehensive test suite to thoroughly test an arithmetic function that takes two arguments and returns the sum. The function should handle positive and negative integers, floating point numbers, and zero as inputs. Additionally, the function should correctly handle edge cases such as very large or very small n... | codefeedback |
Create a MySQL query to return the employee details from the "employees" table with the highest salary among those whose job position is "Manager" and have been with the company for at least 5 years. Additionally, the query should also return the average salary of all the employees whose job position is "Manager" and h... | codefeedback |
Write a JavaScript program to compare two Strings for equality, ignoring case. The program should return true if the Strings are equal and false otherwise.
String1: 'Hello'
String2: 'heLLo'
Write a piece of erroneous code that attempts to compare the two Strings using the strict equality operator (===) instead of the... | codefeedback |
Create a MySQL table named "customers" with 5 columns: "CustomerID", "Name", "Address", "Phone", and "Email". The "CustomerID" column should be set as the primary key and have an auto-incrementing value. The "Name" column should not accept NULL values and have a maximum length of 50 characters. The "Address" column sho... | codefeedback |
Insert records into a MySQL table named "Products" with the specified columns: "ProductID", "Name", "Price" and "Category". The "Category" column should only accept values from a predefined list of categories: "Electronics", "Stationery", "Books", and "Clothing". Additionally, the "Price" column should only accept posi... | codefeedback |
Compile a given C program and link it with a shared library, ensuring that the program dynamically loads the shared library at runtime. The shared library must contain a function that takes a string as input and returns the string reversed. Additionally, the shared library should contain a function that calculates the ... | codefeedback |
Write a Java code to create a HashMap and add elements into it. The key must be a string of maximum length 20 characters and the value must be an integer between -1000 and 1000 (inclusive). The HashMap should have a maximum capacity of 1000 elements.
Additionally, the code should include the following features:
1. The... | codefeedback |
Given an input string consisting of words, numbers, and special characters, separate the words and numbers into separate lists. The input string can contain multiple special characters. The words should be separated into a list of strings, while the numbers should be separated into a list of floats. Any special charact... | codefeedback |
Using SQL, write a query to find the employee names, their job titles, the departments that they work in, and the number of years they have been with the company. Include only the employees who have a job title of "Software Engineer" or "Data Scientist" and are assigned to the "Engineering" or "Data Science" department... | codefeedback |
Design a function to find the number of common keys between two arrays, where the keys are objects and each object has a name and age property. Additionally, the function should only consider objects with an age greater than 18 and should return an array of the common keys sorted in descending order based on the name p... | codefeedback |
Create a responsive website using HTML, CSS, and JavaScript that displays "Hello, World!" in a stylish font, with a background color that changes every 3 seconds. Additionally, implement a button that allows users to toggle between displaying the text in uppercase, lowercase, and title case.
Note: You are not allowed ... | codefeedback |
Create a bash script that asks a user to type in their full name and prints out a personalized greeting. Additionally, the script should prompt the user to enter their age in years and validate that the input is a positive integer between 1 and 100. If the user enters an invalid age, the script should display an error ... | codefeedback |
Suggest a completion to the following SQL command and explain.
SELECT column1, column2, COUNT(*) AS total_count
FROM table1
WHERE column3 = 'value'
GROUP BY column1
HAVING total_count > 10
ORDER BY column2 DESC, column1 ASC; | codefeedback |
Construct an optimized SQL query that significantly improves the performance of a given query by including an additional condition that filters out students who have already graduated, adding an index on the age column, and utilizing a recursive query to find the average score of all the students who have not graduated... | codefeedback |
Create a console application in C++ that computes the sum of two numbers that are user input. However, you must restrict the use of basic arithmetic operators (such as +, -, *, /) in your code. Instead, you are required to implement the addition algorithm using bitwise operations only. Additionally, you should handle t... | codefeedback |
Design a cryptocurrency exchange program using JavaScript that allows the user to instantly receive the exchange rate for a particular cryptocurrency. The program should also provide historical exchange rate data for the past year. Additionally, implement a feature that allows users to place limit orders for buying or ... | codefeedback |
Write a Ruby program to print the Fibonacci series up to a given number N. The program should take input from the user for the value of N and then print the Fibonacci series up to that number. Additionally, the program should also calculate and print the sum of all the even numbers in the Fibonacci series up to N. | codefeedback |
Create a SQL query that updates the age of a user with a given ID, but only if the age is below a certain threshold, and also updates the corresponding timestamp column to the current time. | codefeedback |
Write a Java program which prints out the maximum element in an array, but you are not allowed to use any built-in Java sorting or max functions. The array can contain both positive and negative integers. The program should also handle cases where the array is empty or contains only one element. Finally, you should min... | codefeedback |
Explain the role of the "break" keyword in a switch statement in Java. Also, discuss the difference between using "break" and not using "break" in a switch statement, and provide an example to illustrate the difference.
In addition, write a piece of erroneous code that mistakenly uses "continue" instead of "break" in ... | codefeedback |
Analyze and improve the following shell script to include multiple user inputs and multiple conditional statements.
#!/bin/bash
# improved bash script
echo "Enter your name:"
read name
echo "Enter your age:"
read age
if [ "$name" == "John" ]; then
echo "Hello John!"
if [ "$age" -ge 18 ]; then
echo "You are an... | codefeedback |
Design an interactive game using HTML, CSS, and JavaScript that incorporates a real-time multiplayer feature, allowing multiple players to compete against each other simultaneously. The game should include a leaderboard to display the top scores of all players. Additionally, the game should have a chat feature where pl... | codefeedback |
Develop a program to split a string by a specific delimiter while also ignoring any delimiter that appears within double quotes in the string. Additionally, handle cases where the double quotes are not properly closed.
Example:
String = 'This is a "test" but "ignore-this-one and "this-one-too'
Delimiter = ' '
Expected... | codefeedback |
Create a responsive web page that displays a dynamic message in different languages. The message should be fetched from a remote API that provides translation services, but the API has a rate limit of 100 requests per hour. Additionally, the page should allow users to select their preferred language from a dropdown men... | codefeedback |
Analyze the syntax and semantics of the sentence. Determine whether the sentence is an example of an imperative statement or not, considering the presence of both direct and indirect objects. Provide a detailed explanation justifying your answer, taking into account the syntactic structure and the intended meaning of t... | codefeedback |
Write a code to find the nth Fibonacci number using a recursive approach, without using memoization.
Note: The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones. The sequence starts with 0 and 1.
Example:
Input: 6
Output: 8
Constraints:
- 0 <= n <= 30 | codefeedback |
Create a web application that allows users to create an account and login. The application should include the following features:
1. Registration Page:
- Users should be able to enter their name, email, and password to create a new account.
- Validate the input fields to ensure that all required information is p... | codefeedback |
Write a Ruby program that takes user input and checks if the input is a prime number. The program should also calculate and display the sum of all prime numbers from 1 to the input number, as well as the total number of prime numbers within that range. The program should handle inputs up to 1 million.
Additionally, th... | codefeedback |
Write C++ code to search for a particular element in a circular doubly linked list, but the linked list is sorted in descending order. Each node in the linked list contains a pointer to the next node as well as a pointer to the previous node. The time complexity of the algorithm should be O(log n), where n is the numbe... | codefeedback |
Suggest a functional Node.js program to output the unique elements of an array, without using any built-in JavaScript methods like `filter()` or `reduce()`. However, you must now also implement the program without using any loops or iteration structures. | codefeedback |
Write a CSS program to create a 3D rotating cube with multiple sides, each side having a different gradient background. The cube should also have a drop shadow and a border. Additionally, the cube should animate smoothly upon hover, rotating in 3D space with a perspective effect. | codefeedback |
Write a code to define a function to multiply two numbers passed as arguments. However, the function should only work for numbers that are both prime and even.
Additionally, the function should handle an edge case where one or both of the numbers passed are negative. If one or both of the numbers are negative, the fu... | codefeedback |
Create a function that takes a string as an argument and checks if all the characters in the string are unique and lowercase alphabets only, and returns a boolean. Additionally, the function should have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Increase the difficulty of the given programming test by modifying the grading scale to include plus and minus grades, and also requiring the program to calculate the GPA (Grade Point Average) for each student based on their letter grade.
The modified grading scale is as follows:
- A+: 97-100
- A: 93-96
- A-: 90-92
- ... | codefeedback |
Write a code to identify palindromic numbers between 1 and a given number n, where n can be up to 1 billion.
Additional Requirements:
1. Implement the solution without using any built-in functions or libraries to check for palindromic numbers.
2. Optimize the solution to have a time complexity of O(n log n).
3. Ensure... | codefeedback |
Create a class and a method to convert a decimal number to a binary string representation. The method should take in a decimal number as input and return a string representation of its binary equivalent. Your implementation should also handle negative decimal numbers and return a two's complement binary string represen... | codefeedback |
Write a code to find the number of singular and plural words in a given paragraph. The paragraph may contain complex sentences, punctuation marks, and multiple occurrences of the same word. You should also handle cases where words are capitalized or in different forms (e.g., "run" and "running"). Additionally, consider... | codefeedback |
Create a function that takes a list of strings and returns a new list of strings with the first letter of each string as capital and the rest of the letters in lowercase. The function should have a time complexity of O(n), where n is the total number of characters in all strings combined. Additionally, the function sho... | codefeedback |
Modify the given code to sanitize the user input. The sanitized text should only contain alphanumeric characters and spaces. Additionally, the input must not exceed 100 characters in length.
The input should be checked for any special characters and punctuation marks, and these should be removed from the sanitized tex... | codefeedback |
Write a JavaScript function that takes two numbers as parameters and returns the sum of the squares of those numbers. Additionally, the function should also check if the input parameters are valid numbers and throw an error if they are not. | codefeedback |
Draft a Javascript function that takes a single argument, a string of length n, and returns the string in reverse order. The function should have a time complexity of O(n) and should not use any built-in reverse functions or array methods.
Additionally, the function should handle cases where the input string contains ... | codefeedback |
Create a C++ class called "TV" that simulates a television. The TV class should have the following attributes:
1. A private integer variable called "channel" to represent the current channel of the TV. (Value range: 1-100)
2. A private boolean variable called "isOn" to indicate whether the TV is turned on or off.
3. A... | codefeedback |
Write an HTML page to display a form for user registration. The form should include the following fields: First Name, Last Name, Email Address, Password, Confirm Password, Phone Number, Date of Birth, and About Me.
The First Name and Last Name fields should have a minimum length of 2 characters and a maximum length o... | codefeedback |
Explain the purpose and usage of the Array.prototype.reduceRight() method in JavaScript, providing an example code snippet that demonstrates its functionality. | codefeedback |
Create a program that simulates a student management system. The program should be able to perform the following operations:
1. Add a new student:
- Prompt the user to enter the name, age, and grade level of the student.
- Generate a unique student ID for the student.
- Allow the user to enter a list of subje... | codefeedback |
Construct a SQL query to find the total salary spending of an organization by employees in the month of June, excluding any overtime pay. The query should also include a breakdown of the salary spending by department, and only consider employees who have been with the organization for at least one year. | codefeedback |
Find the sum of all even numbers in the following list, but exclude any numbers that are divisible by 3 or 5 and are also prime numbers (Python code):
[1, 4, 6, 7, 8, 12, 19, 25, 36, 49, 60] | codefeedback |
Create a program that prints a given 2D array in a spiral form. The elements in the array will always be integers. The size of the array will be at least 3x3. The program should print the elements in clockwise direction starting from the top left corner of the array and ending at the center element. The program should ... | codefeedback |
Create a CSS style to position a logo in the top right corner of a webpage, but only when the webpage is viewed on a device with a screen width greater than 1200 pixels and a screen height greater than 800 pixels. Additionally, the logo should change its color to red when hovered over by the mouse cursor, and the logo ... | codefeedback |
Explain the concept of prototypal inheritance in JavaScript and how it is different from classical inheritance. Provide examples to demonstrate the differences between the two approaches. | codefeedback |
Create a program to detect whether a given string contains only vowels or not, where the time complexity should be less than O(n log n) and the space complexity should be O(1). Let str = "hello". | codefeedback |
Create a for loop for copying an array of integers, where the array size is in the range of 10^6 to 10^7. Additionally, you are not allowed to use any built-in array functions or methods for copying the array.
In this case, you need to manually iterate through the entire array and copy each element to a new array. You... | codefeedback |
Reverse the order of the elements in a list using only recursion. Additionally, the algorithm should have a time complexity of O(n) and should not use any additional data structures. | codefeedback |
Rewrite the following program snippet according to the PEP8 guidelines and add error handling for invalid inputs. Additionally, modify the function to calculate the product of the two inputs instead of the sum:
```python
def calculate_product(a, b):
try:
a = float(a)
b = float(b)
return a *... | codefeedback |
Given an item with an original price and a discount percentage, format a string for the discounted price with the following constraints:
- The original price should be rounded to two decimal places.
- The discounted price should be rounded to two decimal places.
- The discounted price should be displayed with a dollar ... | codefeedback |
Create a function to sort a list of numbers without using python's built-in sort function, without using any other built-in functions or libraries, and without using any loops or recursion. The function should implement a sorting algorithm of your choice. | codefeedback |
Write a Python function that prints the frequencies of even and odd numbers in a given array, and also the frequencies of negative and positive numbers in the array. The array can contain both positive and negative integers.
The function should also return the two most frequent even numbers and the two most frequent o... | codefeedback |
Create a MySQL query to calculate the total price paid by customers with ID 1 and 2, excluding any cancelled orders, in the last month. The query should also include the total quantity of products purchased by each customer and display the results in descending order of the total price. Additionally, the query should o... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.