instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Create a program that can output the current date and time in a user-friendly format, but the output must include the current day of the week, the current week number of the year, and the current month as a word (e.g. "Monday, Week 27, July"). | codefeedback |
Write a function to parse a string of HTML and replace all occurrences of <b> with <strong>. Additionally, convert all occurrences of <i> to <em> and all occurrences of <u> to <ins>. The function should also handle nested tags correctly.
html_string = "<h1> This is a heading </h1> <b> This is a bold text </b> <i> This ... | codefeedback |
Write a function that takes in a sentence and returns a new sentence with each word reversed. The order of the words should remain the same.
Example:
Input: "Hello world"
Output: "olleH dlrow" | codefeedback |
Given a string, rearrange the characters in the string such that no two consecutive characters are the same. If it is not possible to rearrange the string to meet this condition, return an empty string.
Implement the function `rearrange_string(my_str: str) -> str` which will rearrange the characters in the input strin... | codefeedback |
Increase the efficiency of the following code by implementing a binary search algorithm to find a specific target value in a sorted list. | codefeedback |
Create a program that can output all possible permutations of a given string. The string may contain duplicate characters.
Example:
Input: "ABA"
Output: ["AAB", "ABA", "BAA"] | codefeedback |
Generate a character frequency histogram of a sentence. Only consider alphabetical characters and ignore case sensitivity. Include the number of times each character appears and sort the histogram in descending order of frequency. Distribution of characters in the sentence "The quick brown fox jumps over the lazy dog." | codefeedback |
Write a machine learning model to classify whether a given email is spam or not using a convolutional neural network (CNN). | codefeedback |
Design a program to find out how many times a pattern occurs in a given string. The pattern can be of any length and can consist of any combination of letters and numbers. The program should be able to handle patterns of varying lengths and should be case-sensitive.
Find the number of times the pattern "ab12" occurs i... | codefeedback |
Find all top-level domains for the TLD ".org" that have at least one domain name registered with more than 100 subdomains. | codefeedback |
Create a class in C++ called "Vehicle", and make it inherit from the class "Object". Additionally, the "Vehicle" class should have a pure virtual member function called "drive" that takes a string parameter indicating the destination and returns a float value representing the distance traveled. The "drive" function sho... | codefeedback |
Write a C++ program to sort a list of strings lexicographically in descending order. | codefeedback |
Build a decision tree model using Scikit-Learn to predict the type of iris plant based on the color of the petal, petal length, petal width, sepal length, and sepal width. Additionally, incorporate feature engineering techniques to enhance the accuracy of the model. | codefeedback |
Write a Java function that classifies a given set of numbers into even and odd, but the function should also separate negative numbers from positive numbers and return the results as separate lists. | codefeedback |
Implement a function in JavaScript that copies the contents of an array to another array. The function should have a time complexity of O(n) and a space complexity of O(n), where n is the length of the array. | codefeedback |
Write a MySQL query to find the title, author, and publication year of the books with the least number of pages. Also, include the average rating of those books. | codefeedback |
How can you convert a given object to a JSON string in JavaScript, while also handling circular references and preserving the order of the object properties? | codefeedback |
Explain the concept of parameter estimation in machine learning and provide a real-life example where parameter estimation is used to optimize a complex neural network model for image recognition, considering additional constraints such as limited computational resources and high accuracy requirements. | codefeedback |
How can one improve the performance of a machine learning algorithm using feature engineering techniques? | codefeedback |
Explain the difference between unidirectional and bidirectional recurrent neural networks and provide an implementation example for each. | codefeedback |
Explain the concept of transfer learning and provide a real-world example of how it can be implemented in a deep learning model. | codefeedback |
Implement a function to traverse a binary tree in post-order and return the sum of all the values in the tree. | codefeedback |
Explain the concept of tail recursion and its advantages over regular recursion in programming. Provide an example code snippet demonstrating the use of tail recursion. | codefeedback |
Explain the concept of reinforcement learning and provide a step-by-step explanation of how it works in practice. Additionally, discuss the different types of reinforcement learning algorithms and their applications in various domains. | codefeedback |
Write a program that generates a random password consisting of 8 characters, where each character is a lowercase letter or a digit. The program should also ensure that the generated password contains at least one uppercase letter and one special character (e.g. !@#$%^&*). | codefeedback |
Write a JavaScript statement to delete the key-value pair of age in the following object and return the updated object.
let person = {
name: "John",
age: 30
} | codefeedback |
Construct a SQL query to return all rows in the table where the value of column A is a prime number and column B is a Fibonacci number.
Table Name: myTable; Columns: A,B | codefeedback |
Create a loop to print the following array values in reverse order, without using any built-in reverse or sort functions.
arr = [3, 6, 9, 12] | codefeedback |
Explain the difference between static and dynamic polymorphism in Python. Provide code examples to illustrate each concept. | codefeedback |
Write a JavaScript function to count the number of occurrences of each character in a given string. The function should return an object where each key-value pair represents a character and its corresponding count.
Example:
Input: "Hello World!"
Output: { "H": 1, "e": 1, "l": 3, "o": 2, "W": 1, "r": 1, "d": 1, "!": 1 ... | codefeedback |
Construct a Tensorflow model to classify the following inputs.
Images with labels “cat”, “dog”, and “bird”. | codefeedback |
Write a JavaScript function that sorts an array of strings alphabetically. The function should ignore the case of the strings and should also handle strings that contain special characters. Additionally, the function should return a new array instead of modifying the original array. The sorting should be done in ascend... | codefeedback |
Write a JavaScript function to check if a string ends with the given substring, but the function should be case-sensitive and should not use built-in string methods like endsWith() or slice(). | codefeedback |
Translate the following polar equation into a Cartesian equation.
r = 2 sin(θ) + cos(θ) | codefeedback |
Write a C++ function that takes an array of strings and prints them out in reverse order. The function should have a time complexity of O(n) and should not use any additional data structures. The input array should be modified in-place.
For example, if the input array is ["cat","apple","dog"], the function should pri... | codefeedback |
Write an HTML form to collect a user's name, email address, password, and phone number. Include client-side validation to ensure that the email address is in the correct format and the password is at least 8 characters long. Implement server-side validation to check if the email address and phone number are unique in t... | codefeedback |
Write a SQL query to display the name, country, and total number of products purchased in the last 24 hours for each customer. | codefeedback |
Create an algorithm to find all pairs of elements in a given array that sum up to a given target, where the elements in the array can be negative and the target can be any integer.
array = [-1, 6, -4, 5, 3, 2]
target = 0 | codefeedback |
Edit this HTML document so that the <h1> tag at the top of the page is aligned to the center, but only using CSS. The <h1> tag should have a font size of 30 pixels, a font weight of bold, a background color of light blue, a text color of white, and a padding of 20 pixels on all sides. The page title should also have a ... | codefeedback |
Write an SQL query that finds the most popular product sold today (in terms of quantity), along with the quantity sold. The query should exclude any products that have been returned or cancelled. Additionally, the query should only consider products that have been sold in the past 30 days. | codefeedback |
Create a HTTP GET request using Python, but ensure that the request is sent with a specific User-Agent header and a custom cookie. Additionally, the response should be parsed to extract specific data from a JSON payload and display it in a formatted manner. | codefeedback |
Write a script that prints out the first 100 prime numbers in reverse order. | codefeedback |
Create a function in Java that returns the number of days between two given dates. However, in this version, the input dates can be in different time zones and the function should take that into account when calculating the number of days. | codefeedback |
Merge the following two sorted arrays into a single sorted array in Java, but you are not allowed to use any built-in sorting functions or libraries. You must implement your own sorting algorithm. | codefeedback |
Create a function to sum all the even numbers in an array.
arr = [1, 2, 3, 4] | codefeedback |
Implement a function in JavaScript that takes in an array of integers and returns the maximum sum of a subarray within the given array.
The time complexity of your solution should be no more than O(n), where n is the length of the input array. Additionally, the space complexity of your solution should be no more than ... | codefeedback |
Develop an algorithm for shuffling an array of numbers, ensuring that no two adjacent numbers are the same.
#Further Explanation#
In addition to shuffling the array, you must also take into account the constraint that no two adjacent numbers should be the same. This means that after shuffling the array, you need to ch... | codefeedback |
Using the array, sort it using insertion sort in descending order.
arr = [10, 7, 12, 8, 3] | codefeedback |
Rewrite the given function in C++ and include the following additional requirements:
1. Validate the inputs: check if the inputs are valid integers. If not, throw an exception.
2. Implement a check for overflow: before performing the addition operation, check if the result will exceed the maximum or minimum value that ... | codefeedback |
Create a recursive algorithm to solve the Tower of Hanoi problem with the following additional constraints:
1. The number of disks is at least 10.
2. The maximum number of moves allowed is 2^(n-1), where n is the number of disks.
3. The algorithm should have a time complexity of O(2^n) and a space complexity of O(n), ... | codefeedback |
Apply a filter to the following array of objects so that the output contains only the elements that have a value greater than 5 and a type string. Also, sort the resulting array in descending order based on the value property.
[{type: 'string', value: 3}, {type: 'number', value: 4}, {type: 'number', value: 6}, {type: ... | codefeedback |
Modify the following code so that the output is the sum of the square root of the given number and the square root of the number plus one, rounded down to the nearest integer.
import math
def f(x):
return int(math.sqrt(x) + math.sqrt(x+1))
print(f(3)) | codefeedback |
Create a HTML tag to display a hyperlink that opens in a new tab and has a different color when hovered over. The hyperlink should also change its color when clicked and return to its original color after a second. The hyperlink should be styled using CSS and the color should be specified using a hexadecimal color code... | codefeedback |
Convert the following list of numbers into a comma-separated string, ensuring that the string is sorted in ascending order.
[25, 32, 63, 18, 22] | codefeedback |
Create a Java program that reads an array of integers from the console and prints out the largest number. The program should also check if the input array contains any negative numbers and display an error message if it does. Additionally, the program should ensure that the array contains at least 5 integers. | codefeedback |
Write a C program to print the following pattern:
```
*
***
*****
*******
*********
``` | codefeedback |
Write a React component that is a form with five input fields (first name, last name, email, password, and confirm password). The form should have validation to ensure that the email is in a valid format and that the password and confirm password fields match. Additionally, the form should have a submit button that is ... | codefeedback |
Write a function that converts Fahrenheit to Celsius, taking into account decimal values and rounding to the nearest tenth. The function should also include error handling for invalid input, such as non-numeric values or values outside the valid temperature range of -459.67°F to 1000°F. | codefeedback |
Compute the Euclidean distance between two points p1 and p2 in a 2D plane, where p1 = (3, 4) and p2 = (6, 8). The distance should be computed using the formula sqrt((x2-x1)^2 + (y2-y1)^2). Additionally, the program should handle inputs in the form of decimal numbers and provide the output rounded to two decimal places. | codefeedback |
Generate a random number from 1 to 1000, without using any built-in random number generation functions or libraries. The generated number should be evenly distributed and have a time complexity of O(1). | codefeedback |
Find the longest increasing subsequence of a given array of numbers. The length of the subsequence should be greater than 2.
[10,22,9,33,21,50,41,60] | codefeedback |
Create a C# function that takes 2 input strings and returns true if one string is a permutation of the other.
A permutation is defined as a rearrangement of the characters in a string.
In this revised test, you need to consider the following additional cases:
1. Ignore whitespace characters and consider them as pa... | codefeedback |
Write a code that finds all the prime numbers from 1 to n and prints them in descending order. | codefeedback |
Parse a JSON document, validate its structure, and display its contents. Additionally, the program should handle nested JSON objects and arrays. | codefeedback |
Create a repeatable random number generator in Python that generates numbers within a specific range. The generator should have a time complexity of O(1) for generating each random number. | codefeedback |
Implement a stack using a doubly linked list, where each node contains an integer value. The stack should have a maximum capacity of 1000 nodes and should throw an exception if a push operation is attempted when the stack is full. Additionally, the stack should have a method that returns the minimum value currently sto... | codefeedback |
Create a function in C++ that inserts a new student name and score in the given 2D vector. The function should also handle cases where the new student name is already present in the vector and should update the corresponding score instead of adding a new entry.
students = [
["Sam", 70],
["Tom", 85],
["Jess... | codefeedback |
Write an algorithm in python to find the second largest number of an unsorted list. Additionally, the algorithm should handle edge cases such as an empty list or a list with duplicate numbers.
arr = [1, 3, 4, 5, 9, 10, 11]
# Increase in Difficulty #
1. Handle edge cases:
- If the list is empty, return an error mes... | codefeedback |
Create a search algorithm in Python to find the median of a sorted array in less than log(n) time.
arr = [1, 2, 3, 4, 5, 6, 7, 8] | codefeedback |
List the different access modifiers in Java and provide an example of each. Additionally, you must explain the difference between the "default" access modifier and the "protected" access modifier and provide a use case scenario for each. | codefeedback |
Create a function in JavaScript to convert a given string to a positive integer.
However, the string may contain non-digit characters in between the digits.
For example, if the string is "3a2b3", the function should return 323.
If the string is "1a0b0c5", the function should return 1005. | codefeedback |
Construct an algorithm in python to find the length of the longest common substring between two strings. The input strings are str1 and str2. The algorithm should return the length of the longest common substring.
# Example
str1 = "abbcdefg"
str2 = "zabxdefujh"
output: 4
# Additional Requirements
1. The algorithm sho... | codefeedback |
Generate a sentence that consists of repeated words with different properties, where each repeated word must have a length greater than 5 characters and start with a vowel. | codefeedback |
Create a program in Python to find the longest common contiguous subarray between two integer arrays. The program should have a time complexity of O(n) and space complexity of O(1).
int arr1[8] = {1,2,4,4,4,4,7,9}
int arr2[6] = {1,4,4,5,5,9}
Note: The given arrays are sorted in ascending order. | codefeedback |
Implement a function to convert a given string into a list of words. The string may contain punctuation marks and numbers. Your function should remove all punctuation marks and numbers from the string before splitting it into words. For example, given the string "My name is Anna. I am 25 years old!", the function shoul... | codefeedback |
You need to generate a list of all the prime numbers between two given numbers. | codefeedback |
Write a function to compute the product of all elements in a matrix, but return -1 if any element in the matrix is zero.
[[1, 2, 3],
[4, 5, 6],
[7, 8, 0],] | codefeedback |
Create a function in JavaScript to create a subset of a given array, but the subset must contain all possible combinations of k elements from the original array, where k is an even number. The output should be an array of arrays, where each inner array represents a unique combination of k elements. | codefeedback |
Write a SQL query to delete the record of a person whose id is 1234, but only if their age is greater than 18 and they have a salary above $50,000. | codefeedback |
Generate a PHP array containing 20 random prime numbers in the range 0 to 100. | codefeedback |
You need to compute the sum of all odd elements in a given matrix, but the matrix can now have negative numbers as well. The matrix will always have at least one row and one column. | codefeedback |
Create a Swift code to find the maximum number from an array of integers. Your solution should also return the index of the maximum number in the array. Additionally, you must implement the solution using a recursive approach. | codefeedback |
Write a function in Javascript to check if a given list of strings is a palindrome. The function should return true if the list is a palindrome, and false otherwise. A palindrome list is defined as a list where the concatenation of its elements in reverse order is the same as the original list.
Example:
let list = ['r... | codefeedback |
Design a data structure to hold a user's name, age, and city. Additionally, include a field for the user's email address and phone number. Ensure that the email address follows a specific format: it must contain the user's first name, followed by a dot, followed by their last name, followed by the domain "@example.com"... | codefeedback |
Create a C++ object class that stores information about different people. Each person should have the following attributes:
- name (string)
- age (integer)
- address (string)
Implement the following methods in the class:
1. A constructor that initializes the object with default values for all attributes.
2. A construc... | codefeedback |
Define a function in Ruby that takes two arguments, both of which are non-negative integers, and returns their sum. The function should handle the case where one or both of the arguments are not provided, and return a helpful error message. Additionally, the function should check that the sum of the two arguments does ... | codefeedback |
Use Python to call an API to get the current temperature in New York City and convert it from Fahrenheit to Celsius. Additionally, display the temperature in both Celsius and Kelvin. | codefeedback |
Design an algorithm to check if a number is a palindrome, where the number can be of any size. The algorithm should have a time complexity of O(log n), where n is the number of digits in the input number. | codefeedback |
Given a table named "students" with the following columns:
- id (integer)
- name (string)
- age (integer)
- score (float)
Write a MySQL query to calculate the median of the "score" column for all students.
In addition to calculating the median, also include the following requirements:
1. Only consider students who ar... | codefeedback |
Create a React component to display a list of 5 user names. Each user name should be displayed inside a clickable button. When a button is clicked, an alert should be displayed with the corresponding user's name. The user names should be fetched from an API endpoint: https://example.com/users. The endpoint returns an a... | codefeedback |
Create a shell script to find the size of all folders in a directory, but exclude any folders that have the word "temp" in their name. | codefeedback |
Create a function that takes a string and returns the first letter of each word in the string, but exclude any vowels in the first letters. The returned letters should be in uppercase. The string will only contain alphabetic characters and spaces. string = "This is an example" | codefeedback |
What is the average of the numbers in list l?
l = [1,2,3,4,5,6,7,8,9,10] | codefeedback |
Write a function in Python to shuffle an array, ensuring that no two adjacent elements in the shuffled array have a difference greater than 1. The shuffled array should also have the smallest possible difference between its minimum and maximum values. [1, 2, 3, 4, 5, 6] | codefeedback |
Build a mobile app with React Native to display the current temperature and weather conditions (e.g., sunny, cloudy, rainy) of a given city. Additionally, the app should include a feature to display a 5-day forecast for the selected city. | codefeedback |
Parse and convert a string containing a valid JSON to a Python dictionary. Additionally, check if any of the values in the dictionary are prime numbers. If a value is prime, add an extra key-value pair to the dictionary indicating that the value is prime.
Example input:
string = '{ "a": 1, "b": 2, "c": 3, "d": 4 }'
E... | codefeedback |
Find the maximum element in a Binary Search Tree without using recursion or any built-in functions or libraries. | codefeedback |
Create a dictionary comprehension to capture all the unique words in a sentence and count the number of times each word appears.
The quick brown fox jumps over the lazy dog. | codefeedback |
Create a function that takes two parameters, an array and an object key, and returns an object containing all the elements in the array whose value is the same as the given object key. The function should also check if the array contains any duplicate values and remove them before returning the result. Additionally, th... | codefeedback |
Develop a Java method to calculate the square root of a given number n without using any built-in math functions or libraries. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.