instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Construct a program which takes two numbers as input and returns the multiplication of these numbers. However, the program should only use bitwise operators to perform the multiplication. You are not allowed to use the multiplication operator or any other arithmetic operators.
Example input: 8, 4
Expected output: 32 | codefeedback |
Compress the following string using LZW compression.
Input: ‘ABBBBCCDDEEEFFFFGGGGGHHHHH’
(Note: The input string contains repeating characters in larger clusters) | codefeedback |
Create a C++ program to concatenate two string variables. The concatenated string must have the following requirements:
- The length of the concatenated string must not exceed 50 characters.
- The program must ignore any leading or trailing whitespace characters in both input strings before concatenating them.
- If th... | codefeedback |
Given a 2-dimensional array of size n x m, where n is the number of rows and m is the number of columns, create a code to transpose the array.
Note: The time complexity should be less than O(n * m) and the space complexity should be less than O(n * m). | codefeedback |
Write a method to find all duplicate elements in an array of integers and return them in ascending order.
Additional requirements:
1. Your method should have a time complexity of O(n).
2. Your method should use constant space, i.e., it should not create any additional data structures.
3. You are not allowed to modify ... | codefeedback |
Create a class in Java that encapsulates a student's name, grade point average (GPA), and a list of courses they have taken.
The class should have the following methods:
1. `addCourse(String courseName, int creditHours, double grade)` - adds a course to the student's list of courses, where `courseName` is the name of ... | codefeedback |
Write a code to create a function to rotate a given linked list by a given number of positions.
#Additional Context#
You are given a singly linked list and an integer k, where k represents the number of positions to rotate the linked list. A rotation means moving the elements of the linked list k positions to the righ... | codefeedback |
Write a boolean expression for the statement "4 is greater than 5" using only bitwise operators and without using any comparison operators. | codefeedback |
Using Java, write a program to find the sum of prime numbers from 1 to an input number. The input number will always be greater than 1. | codefeedback |
Implement a secure FTP server in Python that supports both active and passive mode.
The server should have the following features:
1. Support for multiple simultaneous connections.
2. User authentication using username and password.
3. Support for both download and upload operations.
4. Directory listing and navigatio... | codefeedback |
Given two strings, write a program to find the number of common characters. However, you are not allowed to use any built-in string methods or data structures such as lists or dictionaries. You can only use basic string manipulation operations such as indexing and concatenation.
string_1 = "computer"
string_2 = "scien... | codefeedback |
Generate a Ruby program which returns the sum of all even Fibonacci numbers between 0 and 10,000. | codefeedback |
Create a JavaScript function that calculates the average of the even numbers between 1 and n in an array. The function should handle scenarios where the array may contain non-numeric values, and should ignore those values when calculating the average. | codefeedback |
Write a Java code to read a string from the user and print it reversed. Ensure that your solution is case-insensitive, meaning it should handle both uppercase and lowercase characters correctly. Additionally, your code should ignore any leading or trailing whitespace in the input string. | codefeedback |
Write a Node.js code to get a list of the most starred Node.js repositories on github in the last month, while excluding repositories that have less than 1000 stars and have been forked more than 50 times. | codefeedback |
Write a function in Java to generate all possible strings of length n drawn from 0–9, where each digit can only appear once in each string. | codefeedback |
Create a HTML form with an email input field and a password input field. Add client-side validation to ensure that the email field is not empty and contains a valid email address format. Additionally, add server-side validation to check if the email address already exists in the database. If the email is valid and does... | codefeedback |
What MySQL query can be used to retrieve the most recent record in a table that satisfies a specific condition, while excluding records with null values, and ordering the results in descending order based on a timestamp column? | codefeedback |
Generate a code to take in a list of sentences, totaling no more than 100 words and output the longest sentence. The code should also exclude any sentences that contain numbers or special characters. | codefeedback |
Create a SQL query to find the names, addresses, and email addresses of customers who have purchased a product that is priced more than $50, and the quantity purchased is more than 3.
TABLE customers
Columns:
* customer_id
* first_name
* last_name
* email
* street
* city
* state
* zip
TABLE orders
Columns: ... | codefeedback |
Describe the purpose, syntax, and time complexity of the 'forEach' method in JavaScript. Provide an example usage of the method and explain its limitations compared to other iteration methods available in JavaScript. | codefeedback |
Write a Python program to calculate the sum of all multiples of 3 and 5 between 1 and a given number, excluding any multiples that are divisible by both 3 and 5. | codefeedback |
Create a Python script to scrape HTML data from a website and store it in a database. Additionally, implement error handling to gracefully handle any connection issues or parsing errors that may occur during the scraping process. | codefeedback |
Describe two ways to prevent SQL injection attacks in a multi-threaded web application while ensuring data integrity and minimizing performance impact. | codefeedback |
Create a JavaScript function that takes a string as input and stores it in localStorage. However, the function should also encrypt the string before storing it, using a strong encryption algorithm. Additionally, the function should check if localStorage is available and if it has enough space to store the encrypted str... | codefeedback |
Suggest a way to classify text documents into a certain number of topics, taking into consideration the semantic meaning and context of the documents. Additionally, provide a sample dataset of text documents and expected topics for evaluation. | codefeedback |
Write an algorithm for sorting a single-linked list in descending order. | codefeedback |
Create a function in Java to convert a given timestamp into a readable date and time, considering different time zones and daylight saving time adjustments. The function should handle both Unix timestamps and timestamps with milliseconds precision. The output should include the day of the week, the month, the day, the ... | codefeedback |
Explain how garbage collection works in Java, and discuss the advantages and disadvantages of using garbage collection compared to manual memory management. Additionally, provide examples of situations where manual memory management might be preferred over garbage collection and vice versa. | codefeedback |
Make a function which takes an array of numbers as an argument and returns the sum of all the numbers that are divisible by 3 and have a remainder of 1 when divided by 4. | codefeedback |
Compute the factorial of a given positive integer less than or equal to 10. | codefeedback |
Write a function to find the average of given numbers using a list, but you are not allowed to use any built-in functions or libraries that calculate the sum or average. You must implement the calculations manually. The list may contain duplicate numbers. nums = [2, 4, 6, 8] | codefeedback |
Suggest an efficient algorithm to implement a stack with two queues, ensuring constant time complexity for the push, pop, and top operations. Additionally, the stack should have a maximum capacity of N elements, where N is a positive integer. | codefeedback |
Implement a nested for loop in Python that prints out all the prime numbers between 1 and 100. | codefeedback |
Using SQL, write a query to find the total salary of employees whose salary is greater than the average salary of all employees in the Employee table. | codefeedback |
Develop a for loop to write a program that prints the first 10 prime numbers. Additionally, implement a function that checks whether a given number is prime or not, and use this function within your loop to determine the prime numbers. | codefeedback |
Create a recursive function in Java to print out the Fibonacci sequence up to the Nth term, where N is given as an input to the function. The function should have a time complexity of O(2^N). | codefeedback |
Implement a Wiki page title search using Python, where the search string is case-sensitive and must be at least 3 characters long. The program should display the top 3 search results based on relevance, considering the number of incoming links and the page views of each result. Additionally, the program should provide ... | codefeedback |
Parse an HTML table and extract all the rows. Each row should be stored as a dictionary, with the column headers as the keys and the cell values as the corresponding values.
Example input:
```
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Row 1 - Column 1</td>
... | codefeedback |
Create a user-defined function in C# to find the roots of a third-order polynomial with complex coefficients. | codefeedback |
Develop a class in Python to print the name and age of the user, where the name must be in uppercase and the age must be a random number between 18 and 35. | codefeedback |
Create a function to do a binary search on a sorted list of integers. The function should take two parameters: the list of integers and the target integer to search for. If the target integer is found in the list, the function should return its index. If the target integer is not found, the function should return -1.
... | codefeedback |
Create a script to count the number of vowels, consonants, digits and special characters in a string, while ignoring any whitespace characters.
String = "Hello World 123$%^&" | codefeedback |
Given the following list of strings:
list_str = ["one", "two", "three", "four", "five"]
Write a program that prints out the strings in uppercase without using built-in string manipulation functions (such as str.upper()) or list comprehension. | codefeedback |
Generate a random unique ID consisting of 10 alphanumeric characters (including both uppercase and lowercase letters) and store it in a variable. | codefeedback |
Preprocess a natural language text for text classification, considering multiple aspects of the text.
Text: "The food I ate yesterday was really amazing. I loved the entire experience. The service was impeccable, and the ambiance was delightful. I highly recommend this restaurant."
#Reasoning Steps#
1. Tokenize the te... | codefeedback |
Write a program that takes the current month as input and outputs the month that is 6 months after the given month. | codefeedback |
Generate a List Comprehension that returns a list containing the first 5 prime numbers, but exclude any prime numbers that are palindromic. | codefeedback |
Write a loop that prints the numbers from 10 to 1 in reverse order, each on its own line. | codefeedback |
Find the physical address of a given memory location in a virtual memory system, considering the memory hierarchy and the translation process from virtual to physical addresses. Implement a function that takes a virtual address as input and returns the corresponding physical address. The function should handle page fau... | codefeedback |
Generate a function to identify prime numbers between 0 and n, where n can be a large number (up to 10^9). The function should have a time complexity of O(n log log n). | codefeedback |
Generate a C++ code to filter out an array containing prime numbers. | codefeedback |
Write a code to filter out all even numbers from an array which contains both even and odd numbers. The filtered array should be sorted in descending order. Additionally, the code should return the sum of all the remaining odd numbers in the filtered array.
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
Note: The code should have ... | codefeedback |
In this C++ program, there is an error. Please identify and fix the mistake. Additionally, you need to implement error handling to display a custom error message if the program encounters any runtime errors. | codefeedback |
Generate a Fibonacci sequence with a given length that only contains prime numbers.
length = 10 | codefeedback |
Create a Python class to work with complex numbers. The class should have methods to add, subtract, multiply, and divide complex numbers. Additionally, the class should have a method to calculate the magnitude and phase angle of a complex number. The magnitude should be rounded to two decimal places. The phase angle sh... | codefeedback |
Explain how recursion works and provide a recursive function in Python that calculates the factorial of a given number. | codefeedback |
Write a Python code snippet that combines the elements of two lists into a single list. The resulting list should only include elements that start with a capital letter and are shorter than 5 characters in length. The elements should be sorted in descending order based on their length.
list_1 = ["Cat", "Dog", "Fish"]
l... | codefeedback |
Design a class in Java to represent a student, with their name and grade fields. The name field should be a string of maximum 50 characters and the grade field should be an integer between 0 and 100. Additionally, include a method to calculate the average grade of a group of students given their grades as input. | codefeedback |
Create a function in Python that adds a new item to the beginning of a list. However, the new item should only be added if it is not already present in the list. If the item is already present, raise a custom exception called "ItemAlreadyExistsError" with an appropriate error message.
Additionally, modify the functio... | codefeedback |
Create a class that detects if a given String contains the longest palindrome substring. The class should return the length of the longest palindrome substring found. The algorithm should have a time complexity of O(n^2) and a space complexity of O(1). | codefeedback |
Construct an algorithm to calculate the GCD of two numbers using recursion and without using any built-in functions or libraries. | codefeedback |
You need to design a database for a school where multiple students can have multiple tutors for multiple subjects. Additionally, each tutor can have multiple students for each subject they teach. What is the best way to design the database? | codefeedback |
Create a class in Python with methods "add" and "find" to add a value to a dictionary and find the value in it, respectively. The "find" method should be able to handle a nested dictionary structure, where the keys are strings and the values can be either strings or nested dictionaries. The "find" method should return ... | codefeedback |
You need to design a web page with a search bar that returns clickable results. Construct an algorithm to structure the web page. The search bar should support autocomplete functionality, suggesting search terms as the user types. Additionally, the search results should be dynamically updated as the user types, without... | codefeedback |
Write a function to find the closest pair of points in a given array of points. The function should have a time complexity of O(n^2) and should not use any additional data structures. | codefeedback |
Create a function that allows users to sign up for your feature using their username and password. The function should also include the following validations:
1. The username should be at least 8 characters long and should not contain any special characters.
2. The password should be at least 8 characters long, should... | codefeedback |
Write a code that takes a sentence as input and prints the longest word in that sentence. However, the code should ignore any words that contain duplicate letters. | codefeedback |
Create a function to delete the first occurrence of a specific item from a singly linked list given the head of the list and the item to be deleted. | codefeedback |
Construct an algorithm to find all possible combinations of a string of characters with a time complexity of O(n!). | codefeedback |
Construct a regular expression pattern to match a single word with the format "XX-XXX-XXX", where the first two characters must be uppercase letters, the next three characters must be lowercase letters, and the last three characters can be a mix of uppercase and lowercase letters. Additionally, the word must not contai... | codefeedback |
Implement a function to calculate the total amount of money earned from a given array of stock prices, with the additional requirement that the function should only include the stock prices that were bought and sold on consecutive days.
arr = [5, 7, 15.5, 6, 10, 11] | codefeedback |
Create a Python function that generates a random number between two specified numbers. However, the function should throw an exception if the lower bound is greater than or equal to the upper bound.
lower_bound = 20
upper_bound = 10 | codefeedback |
Write a function that finds the largest prime number in an array of integers. | codefeedback |
Create a function that takes in a string and returns a new string in which all the characters are reversed. However, the function should not reverse the order of the words within the string.
s = "Hello World" | codefeedback |
Create a function that takes two arrays and returns true if the first array contains all the elements in the second array in the same order, without any other elements in between. Return false otherwise.
array1 = [1, 2, 3, 4, 5, 6]
array2 = [2, 4, 6] | codefeedback |
Assume an array contains elements from 1 to 100. You need to find the missing element. However, the array may also contain duplicate elements. Find the missing element while accounting for duplicates.
arr = [1, 2, 4, 6, 7, 8, 10, 11, 12, 13, 15, 15, 15] | codefeedback |
Write a program that prompts the user to enter a number and then prints the number twice. Additionally, add error handling to ensure that the user can only input valid numbers. | codefeedback |
Write a SQL query to select the title, price, and average rating of books where the price is greater than $50, the average rating is greater than 4, and the number of ratings is greater than 100. The result should be sorted in descending order of average rating.
SELECT title, price, AVG(rating) as avg_rating FROM books... | codefeedback |
Change the following Python code to convert the list to a dictionary of key-value pairs. Each key should be the corresponding element in the list, and each value should be a list containing the index of the element in the original list, the square of the element, and the cube of the element.
mylist = [1, 2, 3, 4, 5] | codefeedback |
Create a JavaScript program to spread a given array into subarrays of the given size, without using any built-in array methods such as slice or splice. The program should also ensure that each subarray has exactly the given size, except for the last subarray which may have a smaller size if necessary. Additionally, the... | codefeedback |
Create an array of 10 non-repeating random integers between 1 and 1000, where each integer is divisible by 7 and not divisible by 3. | codefeedback |
Write a program that prompts the user to input a date in the format "YYYY-MM-DD" and a time in the format "HH:MM:SS", and then prints the inputted date and time in the format "Day, Month DD, YYYY HH:MM:SS AM/PM". | codefeedback |
Create a table of data about each object in the list. Each object in the list should have the following attributes: "name" (string), "age" (integer), and "gender" (string). The list should contain at least 5 objects.
my_list = [{"name": "John", "age": 20, "gender": "Male"},
{"name": "Laura", "age": 30, "g... | codefeedback |
Compare and contrast the features of the five programming languages: Python, Java, C++, Ruby, and JavaScript. Provide detailed explanations and examples for each language. | codefeedback |
Write a JavaScript program that creates an array with all the prime numbers from 1 to 100. | codefeedback |
Write a SQL query to find all customers who purchased more than 5 items from a specific store within the last 3 months and have a total purchase amount exceeding $500. | codefeedback |
Create a React component with the following features:
- Has two inputs
- On entering content in the first input, it will automatically update the content in the second input
- The component should also have a button that, when clicked, will reverse the content in both inputs
- The reversed content should be displayed i... | codefeedback |
Implement a linear regression algorithm from scratch to predict the housing prices based on a given dataset. The dataset contains multiple features such as the number of rooms, square footage, and location. You should print the coefficients for each feature in the regression model.
Note: You should not use any pre-bu... | codefeedback |
Construct a loop in Swift to find duplicate numbers in an array, but without using any built-in functions or data structures such as sets or dictionaries. | codefeedback |
Implement a method in Java to reverse a number. Provide a piece of erroneous code that you need to fix to correctly reverse the number. | codefeedback |
Write a detailed explanation of the Model-View-Controller (MVC) architecture pattern and its implementation in Django. | codefeedback |
Create a SQL query to select the column "name" from the table "Customers" where the "address" column contains the value "London" and the "age" column is greater than 30. | codefeedback |
How would you add the following list to a specific key in a nested JSON document using Python? The key should be located at a depth of at least 3 levels from the root of the JSON structure. | codefeedback |
Create an HTML table from a list of dictionaries and include the following additional requirements:
1. Add an extra column to the table displaying the years of experience for each employee. The years of experience can be calculated by subtracting the age of the employee from the current year.
2. Sort the table in asc... | codefeedback |
How do you represent a database table and its columns in an object-oriented programming language, while also ensuring that the table supports CRUD operations (Create, Read, Update, Delete) and has proper validation and constraints in place? | codefeedback |
Construct a generic Binary Search Tree in Swift, including the following methods:
- Insert a value into the tree
- Delete a value from the tree
- Search for a value in the tree
- Traverse the tree in-order and print the values | codefeedback |
Create a C++ program to input two numbers and print their sum. Additionally, implement error handling to handle cases where the user enters invalid input, such as a non-numeric value. | codefeedback |
Write a SQL query to find all customers from France whose orders were placed before a specific date. | codefeedback |
Write a function in JavaScript to truncate a string to a given length, but only if the length of the string is greater than the given length. If the length of the string is equal to or less than the given length, return the original string as it is. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.