instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Create a C# class that contains two private fields, one public method, and one property. The class should also implement an interface that requires the implementation of a custom event. The event should be triggered whenever the property's value is changed. Additionally, the class should include a static method that ca... | codefeedback |
Write an Angular directive to make a text field required and validate that the input follows a specific format.
Requirements:
1. The directive should add a red border to the text field when it is empty or does not match the specified format.
2. The specified format should be a regular expression pattern that can be co... | codefeedback |
Design a data structure to store a list of numbers and their frequencies, where each number can only occur once in the list. Additionally, the data structure should support the following operations:
1. Add a number to the list.
2. Remove a number from the list.
3. Update the frequency of a number in the list.
4. Get t... | codefeedback |
Create a class called 'Person' which has a constructor that creates a person with a given name and age. The name should be a string and must not contain any special characters or numbers. The age should be an integer between 18 and 100, inclusive. If the age is not within this range, raise an exception with a custom er... | codefeedback |
Produce a program to print out the frequency of characters in a word. However, your program should ignore any characters that are not letters (a-z or A-Z) and should not be case sensitive.
Example:
Input: "Hello World"
Output:
h: 1
e: 1
l: 3
o: 2
w: 1
r: 1
d: 1 | codefeedback |
Re-write the following method to use a single loop instead of two, and also calculate the sum of all even indices in the array.
def sum_special(arr):
temp = 0
for i in range(len(arr)):
temp += arr[i] * arr[i+1]
return temp | codefeedback |
Construct an HTML form with 10 fields, one for each of the following: name, email address, age, gender, job title, phone number, address, city, state, and zip code. Additionally, implement form validation to ensure that the email address field follows a specific format: it must contain a valid domain name and end with ... | codefeedback |
Write an HTML code to create a table with three columns containing the headers "ID", "Name", and "Group". Additionally, each cell in the "ID" column should only accept numeric values between 1 and 1000 (inclusive), the "Name" column should only accept alphabetical characters (both lowercase and uppercase), and the "Gro... | codefeedback |
Suggest a Python code to match all occurrences of the substring "is" in the given string "This is a programming task", and return the number of occurrences. Additionally, your code should be case-insensitive and should only consider complete word matches (i.e., ignore substrings within larger words). | codefeedback |
Generate an array of random integers between 1 and 100 inclusive, where no two adjacent numbers in the array are the same. | codefeedback |
Suggest a JavaScript code to validate a username if it contains only alphabets and digits while ignoring the special characters. Additionally, the code should also check for the minimum and maximum length of the username, which should be between 6 and 20 characters. | codefeedback |
Generate a random list containing 10 elements, where each element is a prime number between 0 and | codefeedback |
Write a code to find the longest consecutive sequence inside of a given list of numbers, where the sequence must be strictly increasing and contain at least three elements. Additionally, the code should output the start and end indices of the longest consecutive sequence. | codefeedback |
Create a sorting algorithm to sort a given list of numbers from lowest to highest.
However, you are not allowed to use any built-in sorting functions or methods such as `sort()` or `sorted()`. You must implement your own sorting algorithm from scratch.
Also, make sure your algorithm has a time complexity of O(n^2). | codefeedback |
Write a Python class for a Rectangle object with the following instance attributes and methods:
- length (a positive integer)
- width (a positive integer)
Methods:
- `get_area()` - returns the area of the rectangle
- `get_perimeter()` - returns the perimeter of the rectangle
- `is_square()` - returns True if the recta... | codefeedback |
Write a PHP function that takes in a string as input and returns a new string where each word in the input string has its first letter capitalized. The function should preserve the original case of the remaining letters in each word.
Example:
Input: "the quick brown Fox"
Output: "The Quick Brown Fox"
Note:
- You can ... | codefeedback |
Check if a given string contains all the alphabets in a specific order. The alphabets must appear consecutively and in the same order as they do in the English alphabet.
Example:
Input: "abcdefghijklmnopqrstuvwxy"
Output: False
Input: "abcdefghijklmnpqrstuvwxyz"
Output: False
Input: "abcdefghijklmnopqrstuvwxyz"
Outp... | codefeedback |
Design a query in MongoDB to select documents based on a particular value in an array and the total marks should be greater than 80. | codefeedback |
Write a PHP program to build a dynamic HTML table with the details of 10 students. However, the program should also include the ability to add, delete, and update student details dynamically. Additionally, the program should have a search functionality to search for specific students based on their details such as name... | codefeedback |
Design a C program to create a scientific calculator that supports advanced mathematical functions such as trigonometric operations (sin, cos, tan), logarithmic operations (log, ln), exponential operations (e^x), and factorial calculation. | codefeedback |
Implement a non-recursive depth-first search (DFS) algorithm to traverse a binary tree in Python. The algorithm should return a list of values in the order they are visited. The time complexity of the algorithm should be O(n), where n is the number of nodes in the tree. You should not use recursion in your implementati... | codefeedback |
Write a Java program to find the kth smallest element in an unsorted array of integers. | codefeedback |
Write a C++ code to create a vector of integers and then sort them in increasing order. The vector should contain unique elements only.
vector<int> v = {3, 1, 5, 4, 7, 2};
Additionally, you are required to implement your own sorting algorithm instead of using any built-in sorting functions or libraries. | codefeedback |
How will you modify the following Ruby code to convert a given number to its corresponding alphabetical letter? The number should be within the range of 1 to 100, inclusive. The alphabetical letter should be in uppercase.
num = 56 | codefeedback |
Write code to create a function in JavaScript to reverse a given array without using the built-in reverse() method. The function should take an array as input and return a new array with the elements in reverse order.
Example:
Input: [1, 2, 3, 4, 5]
Output: [5, 4, 3, 2, 1]
You are not allowed to use the reverse() met... | codefeedback |
Using HTML5, create a canvas element with a width of 1000px and a height of 500px. Implement a JavaScript function that allows users to draw on the canvas using their mouse. The drawing should consist of multiple shapes, such as lines, rectangles, and circles, and users should be able to choose the color and size of th... | codefeedback |
Write a function in Python that takes a number n as its parameter and returns the sum of the cubes of the first n natural numbers. | codefeedback |
Design a function to calculate the standard deviation of a set of data that may contain duplicates and negative numbers. The function should have a time complexity of O(n) and a space complexity of O(1).
Example:
Input: [2, -4, 1, 6, 8, -4]
Output: 4.05516335416411 | codefeedback |
Construct a regex expression to capture words starting with 'cat' and ending with 's', with a minimum length of 5 characters. | codefeedback |
Extract the extension from a given filename string, but the program should also validate if the filename meets the following requirements: it must start with a letter, can only contain alphanumeric characters and underscores, and the extension must be either "txt", "csv", or "xlsx".
filename = "input.txt" | codefeedback |
Given a sentence, write the code to extract the third word from the sentence and reverse it.
sentence = "I am a coder"
#Additional Step#
1. Split the sentence into a list of words.
2. Check if the list has at least three words.
3. If the list has at least three words, access the third word.
4. Reverse the third word.
... | codefeedback |
Generate a responsive HTML layout for a basic website page that includes a header, a navigation bar, a main content section, and a footer. The header should contain a logo and a heading. The navigation bar should include at least three links. The main content section should have two columns, with an image on one side a... | codefeedback |
Write a function that takes an array of numbers and returns an array whose elements are the product of all the elements except the element at the current index. However, you are not allowed to use division in your solution.
arr = [2, 3, 4, 5] | codefeedback |
Use a for loop to sum the numbers in the list [4, 6, 5, 8] and calculate the average of the sum. | codefeedback |
Given an array of numbers, provide a nested for loop to calculate the sum of elements in the array, while ensuring that the sum does not exceed a given limit. | codefeedback |
Use TensorFlow to create a convolutional neural network to classify handwritten digits using only 10% of the original training dataset. | codefeedback |
Generate code to create a Numpy array with 3 rows and 4 columns, but with the values of each element squared. | codefeedback |
Develop a C++ code snippet to swap two variables, but you are not allowed to use a temporary variable. | codefeedback |
Write a SQL query to select all the names, department, and salary of employees whose age is over 35, and their salary is above $50,000. | codefeedback |
Calculate the result of XORing two binary numbers, each represented as a string of 0s and 1s.
For example, given the binary numbers "1010" and "0101", the XOR operation can be performed as follows:
1. Convert the binary numbers to decimal form: 1010 (10) and 0101 (5).
2. Perform the XOR operation on the decimal values... | codefeedback |
Create a function in Python which takes a string and reverses each word in the string without using any built-in string manipulation methods or libraries. | codefeedback |
Design an HTML form to enter student name, age, course, and email. Also, add validation to ensure that the email entered is in a valid format. | codefeedback |
Create a program to execute a given command-line argument, but restrict the execution to only commands related to manipulating image files (e.g., resizing, rotating, cropping). | codefeedback |
Develop a program that prints all the prime numbers between 0 and n, and also calculates the sum of these prime numbers.
Additional instructions:
1. Implement the Sieve of Eratosthenes algorithm to find the prime numbers.
2. Optimize the algorithm to minimize unnecessary calculations and improve efficiency.
3. Handle ... | codefeedback |
Write an SQL query to count the number of people with a given last name and age between 18 and 30 in a table of people. | codefeedback |
Create a JavaScript function that iterates through a given array and returns the first value that is not a number. If the array contains nested arrays, the function should recursively search through all elements until it finds a non-numeric value.
For example:
array = [3, 5, [1, 2, 3, "hello", 4], 10]
In this case, th... | codefeedback |
Write a JavaScript function to retrieve all users from an API endpoint and store them in a database. | codefeedback |
Create an array of 10 unique positive integers in JavaScript, each with a value between 1 and 100, with no repeating values. | codefeedback |
Develop a function in Java that takes a string argument and returns it with the first letter capitalized. Additionally, handle the case where the string may contain leading or trailing spaces, and ensure that these spaces are ignored when capitalizing the first letter. | codefeedback |
Create a GUI with a button in Python that performs a specific action upon being clicked. The action should involve making a request to a web API, retrieving data, and displaying it in a table format within the GUI. Additionally, the GUI should have a search bar that allows the user to input a keyword and filter the dis... | codefeedback |
Output the 50th Fibonacci number. | codefeedback |
Identify and fix the vulnerabilities in the given program while ensuring that the updated balance is properly validated and not susceptible to any form of injection attacks. Additionally, implement a logging mechanism to record all transactions made by the users. | codefeedback |
Write a Python code that turns the given input into a list of dictionaries, where each dictionary should have a 'name' key and an 'age' key. The 'name' key should store a string and the 'age' key should store an integer. The input should be a list of strings in the format 'name,age' and the output should be a list of d... | codefeedback |
Write a Python script to send an email using the smtplib module, but with the following additional requirements:
1. The email should be sent using a secure SSL/TLS connection.
2. The script should allow the user to input the email subject and message body.
3. The script should allow the user to input multiple recipien... | codefeedback |
Write an algorithm that prints out all prime numbers in an array in reverse order. | codefeedback |
Create a HTML program to simulate a digital clock that supports multiple time zones. The program should allow the user to switch between different time zones and display the corresponding time accurately. The program should also include additional features such as displaying the date, allowing the user to set alarms, a... | codefeedback |
Create a new class in JavaScript called 'Classroom' that should have the following features:
1. The 'Classroom' class should have a constructor that takes in the following parameters:
- 'name' (string): representing the name of the classroom.
- 'capacity' (number): representing the maximum number of students the... | codefeedback |
Write a React component that implements a toggle button with the following requirements:
- The toggle button should have a default state of "OFF".
- The toggle button should display the text "ON" when in the "ON" state and "OFF" when in the "OFF" state.
- Clicking on the toggle button should toggle its state between "O... | codefeedback |
Write an algorithm that finds the longest palindromic substring of a given input string. Additionally, the algorithm should have a time complexity of O(n) and should not use any extra space other than a constant amount of additional memory. The input string will have a length of at most 10^5. | codefeedback |
Write a function that, given a binary tree, prints all of its element "level by level". The function should also return the total number of levels in the tree.
Example Input:
1
/ \
2 3
/ \ / \
4 5 6 7
Expected Output:
Level 0: 1
Level 1: 2, 3
Level 2: 4, 5, 6, 7
Total number of lev... | codefeedback |
How would you modify the following code to add a time delay of 1 second between each iteration of the loop?
Requirements:
- The time delay should be implemented using the `time` module.
- The loop should continue for a total of 10 iterations.
- The program should print the value of `i` on each iteration.
for i in ran... | codefeedback |
Write an algorithm that finds the least common ancestor of two given nodes in a binary search tree.
The binary search tree has the following properties:
- Each node in the tree has a unique integer key.
- The key of each node is greater than the keys of all nodes in its left subtree.
- The key of each node is less tha... | codefeedback |
Create a MySQL table to store users with the following columns: user_id (int), first_name (varchar), last_name (varchar), email (varchar), and password (varchar). Additionally, add a foreign key constraint on the user_id column referencing a separate table called "roles" with a primary key column called "role_id". | codefeedback |
Break the following string into three pieces, where the first piece contains only consonants, the second piece contains only vowels, and the third piece contains any other characters.
"HelloWorld" | codefeedback |
Edit the following code to add an item to the 'fruits' list, but make sure to avoid using the built-in 'append()' function.
fruits = ["apple", "banana", "orange"] | codefeedback |
What is the correct syntax for making an HTTP POST request using cURL, including setting a custom header and sending JSON data in the request body? | codefeedback |
Write a Java method to swap the values of two integer variables without using a temporary variable. | codefeedback |
Write a Ruby program to print out all the prime numbers between 1-100. | codefeedback |
Create a function 'fibonacci' which takes an argument 'n' and returns the nth term in the Fibonacci series.
The Fibonacci series is a sequence of numbers where each number is the sum of the two preceding ones. The series starts with 0 and 1.
For example, if the function is called with n=5, it should return the 5th te... | codefeedback |
Find the maximum pair sum of four integers in an array.
[2, 10, -4, 3, 14, 8, 9, -2, 6, 1] | codefeedback |
Given a singly linked list, write a function to reverse it in-place without using any additional data structures or recursion. The time complexity of the function should be O(n), where n is the number of nodes in the linked list. | codefeedback |
Edit this program to print the product of two numbers, but the product should only include the digits that are prime numbers.
a = 10
b = 5
print("The product of a and b, including only prime digits, is ", a * b) | codefeedback |
Provide a Java program that searches for a certain element in an array and returns the indices of all occurrences of the element. The program should also handle cases where the array is multidimensional or contains null values. The search should be case-insensitive if the array contains strings. The program should use ... | codefeedback |
Implement a recursive function to find the index of a target element in a sorted array using the binary search algorithm. Your function should have the following signature:
```python
def binary_search(arr: List[int], target: int) -> int:
pass
```
You should assume that the input array `arr` is sorted in ascending... | codefeedback |
Create an HTML page that has a table and populates the table with the given data. The table should have the following columns: "Country", "Capital", "Population", and "Language".
Data to populate the table:
Country | Capital | Population | Language
---------------------------------------------------
India ... | codefeedback |
Segregate the negative numbers to the left side, positive numbers to the right side, and keep zero values in the middle of an array. | codefeedback |
Write a CSS code that changes the color of all paragraphs with a class of "content" to blue, but only when they are within a div element with an id of "container". | codefeedback |
Create a class in Java which computes the sum of squares of even prime numbers between k and n. | codefeedback |
Write a function to compress a string by counting the consecutive occurrences of each character and storing it as a tuple with the character and its count. | codefeedback |
Given a pair of same-length strings, identify character matches in the same position. However, there is a twist - you are not allowed to use any loops or built-in functions in your solution.
str1 = 'Hello'
str2 = 'World' | codefeedback |
Write a function to traverse a dictionary recursively and print all the keys and values.
#Explanation#
The original problem only required printing the keys of a dictionary. To increase the difficulty, we now need to print both the keys and values. This requires modifying the original solution to include the values as ... | codefeedback |
Construct an SQL query to select all employees from the `employee` table whose age is less than or equal to 30 and whose department is "IT". | codefeedback |
Create a multiple linear regression model using TensorFlow, where the model should have at least three independent variables and the input data should include categorical variables that need to be converted into numerical representations before training the model. | codefeedback |
Write an algorithm in pseudocode to reverse the order of numbers in a given array without using any additional data structures. | codefeedback |
Train a deep learning model using convolutional neural networks to accurately predict the labels of a large-scale handwritten digits dataset, while also minimizing overfitting and achieving a test accuracy of at least 98%. | codefeedback |
Create a compiler that can check the validity of Python code in a given string. The compiler should not only check if the code is syntactically correct but also evaluate the code for any potential runtime errors.
Additionally, the compiler should be able to handle the following scenarios:
1. Check for correct indentat... | codefeedback |
Given a list of strings and an input string, find the index of the input string in the list. However, the list may contain duplicates and the input string may appear multiple times. In such cases, return the index of the first occurrence of the input string.
list = ["red", "blue", "green", "yellow", "green", "green"]
s... | codefeedback |
Write a JavaScript function called "findLargestNumber" that takes in two input numbers as parameters. The function should first check if both numbers are positive. If not, it should return the string "Both numbers must be positive."
If both numbers are positive, the function should compare the absolute values of the t... | codefeedback |
Evaluate the following expression: (2 + 5) * 3 / 4 - 2. | codefeedback |
Write a Bash script that prompts the user to enter their name and then displays a personalized welcome message along with the current date and time. The script should also check if the entered name is in uppercase and display an error message if it is. | codefeedback |
Create a list of 10 randomly generated integers from 1 to 1000 in Python. | codefeedback |
Create a web browser automation script in Python to scrape the data from a website. Additionally, implement error handling to gracefully handle any exceptions that may occur during the scraping process. | codefeedback |
Write a function which takes a string as an argument and returns the same string with the first letter capitalized. The function should also capitalize the first letter after each punctuation mark ('.', '!', '?', ':'). The function should have a time complexity of O(n), where n is the length of the string.
Example:
In... | codefeedback |
Create a function to check if a string is an anagram in C++ with a time complexity of O(n log n). | codefeedback |
Create a function to solve a quadratic equation in JavaScript. The function should handle cases where the equation has complex roots. | codefeedback |
Create a for loop to print every other letter in a given string, but only if the letter is not a vowel. The string should also be reversed before printing. Only consider lowercase letters.
string = "Logic speaks to reason, not to the imagination" | codefeedback |
Design an algorithm to find the two numbers in an array that have the largest sum, where the array can contain both positive and negative numbers. The array will have at least two elements and can have up to 10^6 elements.
Example:
Input: [2, -3, 5, 1, -7, 9]
Output: [9, 5]
Explanation: The two numbers with the larges... | codefeedback |
Describe the specific steps and implementation details of the Bottom-Up Dynamic Programming approach used to solve the 0/1 Knapsack problem, where each item has a weight and a value, and the goal is to determine the maximum value that can be obtained without exceeding the weight capacity of the knapsack. | codefeedback |
Design an algorithm to delete all occurrences of a given key k in a singly linked list. The algorithm should have a time complexity of O(n) and a space complexity of O(1), where n is the number of nodes in the linked list. | codefeedback |
Generate a function which takes a two-dimensional array of integers as an argument and prints out the elements in a clockwise spiral order. The function should have a time complexity of O(N), where N is the total number of elements in the array. The space complexity should be O(1), meaning no additional data structures... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.