instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write a TensorFlow code to build a convolutional neural network to predict the digits from the MNIST dataset. Additionally, include a custom loss function that penalizes misclassifying odd numbers more heavily than even numbers. | codefeedback |
Design an HTML form to register users on a website. Include the following fields:
- Full name (required)
- Email address (required)
- Password (required, minimum 8 characters)
- Confirm password (required, must match the password field)
- Date of birth (required, must be at least 18 years old)
- Phone number (optional... | codefeedback |
Create a Swift program to make a request to an API using URLSession and display the response in the console. The program should include error handling for network errors and API errors. Additionally, the program should implement authentication using OAuth 2.0 with the API's provided client ID and secret. | codefeedback |
Create a program to detect the type of a given character, but the program should only consider characters from the Unicode Basic Multilingual Plane (BMP) range. | codefeedback |
Write a PHP script to create a contact form with the following fields: name, email, subject, and message. The script should validate that all fields are filled in correctly before submitting the form. Additionally, the script should include a CAPTCHA verification to prevent spam submissions. | codefeedback |
Design an algorithm for multiplying two matrices.
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
B = [[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]
Please implement the matrix multiplication algorithm with a time complexity of O(n^2), where n is the size of the matrix. Additionally, please provide an optimize... | codefeedback |
Can you print out a multiplication table of size 15 by 15, but only include the even numbers in the table? | codefeedback |
Design a code to generate Fibonacci numbers within a given range of values, where the range is specified by the user as the maximum and minimum values. The code should also validate the input range to ensure that the minimum value is smaller than the maximum value. | codefeedback |
Write a Java program to sum the elements of an array except for the maximum and minimum, and also excluding any negative numbers.
Array: [1, -2, 3, -4, 5] | codefeedback |
Create an efficient algorithm in Java to search for a given value in a sorted array of integers. The algorithm should have a time complexity of O(log n), where n is the size of the array. Additionally, you are not allowed to use any built-in search functions or libraries in your implementation. | codefeedback |
Compose a JavaScript function to detect whether two strings are punctuated versions of the same word. The function should be case-insensitive and ignore any leading or trailing spaces. Both strings must have at least 2 characters and should not contain any special characters or numbers. String1: 'apple' String2: 'Apple... | codefeedback |
Find the derivative of the given equation with respect to x and output the simplified form. Ensure that the resulting derivative equation is in the form of ax^n + bx^(n-1) + cx^(n-2) + ... + k, where a, b, c, ..., k are coefficients. | codefeedback |
Implement a C# program that reads an array of strings and sorts them in alphabetical order. However, you are not allowed to use any built-in sorting functions or libraries. You must implement your own sorting algorithm. | codefeedback |
Develop a JavaScript function to convert a date string from the ISO-8601 format to a human-readable format. The function should also handle time zone conversions and display the date and time in the user's local time zone. Date String: '2020-06-15T12:30:00+03:00' | codefeedback |
Write a Python function that takes in a string and returns a float representation of the string, without using any built-in conversion functions or libraries. The string will only contain a valid positive decimal number with up to 2 decimal places. The function should handle leading and trailing whitespace in the strin... | codefeedback |
Write a program that takes an array of integers as input and prints all the unique elements in the array, sorted in ascending order. The program should have a time complexity of O(nlogn), where n is the size of the input array. | codefeedback |
Create a GCP Cloud Function that sends an email with input "name" and "message". Additionally, ensure that the email is sent asynchronously and provide a retry mechanism in case of failures. | codefeedback |
Create a graphql mutation that adds a new user to the system with the following requirements: the user's name must be between 5 and 20 characters long, the email must be a valid email address, and the user's password must be at least 8 characters long and contain at least one uppercase letter, one lowercase letter, one... | codefeedback |
What do the following two lines of code do? Write a function called "string_operations" that takes in two parameters: a string called "string" and a boolean called "capitalize". The function should replace all occurrences of the word 'old' with the word 'new' in the input string. Additionally, it should remove any whit... | codefeedback |
Create a permutation of characters in a string with the additional constraint that the permutation must include all uppercase letters of the English alphabet. The string must have at least 3 characters and at most 10 characters. | codefeedback |
Write a Java program to calculate the compound interest.
Principal (P): 1000
Time (T): 2
Rate of Interest (R): 10
Number of Compounds (N): 4
The program should also be able to handle the following scenarios:
1. The user should be able to input different values for P, T, R, and N.
2. The program should validate the us... | codefeedback |
Change the following PHP code to use the new syntax from PHP 7 and also add error handling to handle any potential exceptions thrown during execution.
```php
<?php
try {
$joined = implode(['a', 'b', 'c']);
echo $joined;
} catch (Throwable $e) {
echo 'An error occurred: ' . $e->getMessage();
}
```
In addit... | codefeedback |
Implement the Levenshtein distance algorithm in Python, but with the additional constraint that you are not allowed to use any built-in string manipulation functions or libraries. | codefeedback |
Given an array of English words, find all pairs of words which are anagrams of each other in the same array. Return the list of these pairs.
["listen", "pot", "part", "opt", "trap", "silent", "top", "opts", "pear"] | codefeedback |
Perform K-Means Clustering on this dataset using the Euclidean distance metric.
dataset = [[5,7], [1,2], [7,9], [10,2], [2,5]]
Cluster the dataset into two clusters.
The algorithm should terminate when the centroids of the clusters do not change by more than 0.01 for five consecutive iterations. | codefeedback |
Replace the character on odd index positions with '#' in a string that may contain uppercase letters, lowercase letters, spaces, and special characters. The string should not exceed 100 characters in length. Return the modified string. | codefeedback |
Using the given code snippet, reverse the words of the string and ensure that all vowels within each word are capitalized.
string = "this is a string" | codefeedback |
Given an array containing words and a string, find the shortest word in the array that is a substring of the string. The array may contain duplicates. The string may contain special characters and spaces.
words = ["apple", "banana", "cat", "dog", "banana", "apple", "dog"], string = "a quick brown fox jumps over the la... | codefeedback |
Identify the salient feature in the given piece of code and optimize the function to only use a single line of code. | codefeedback |
Use set operations to obtain the intersection of two given sets. The program should also remove any duplicates from the resulting intersection set and sort the elements in descending order.
SetA = {1, 2, 3, 4}
SetB = {2, 4, 6, 8} | codefeedback |
Explain the use of webhooks in server-side applications and provide a code example using a specific programming language of your choice. Additionally, your solution should include error handling and demonstrate how the webhook payload can be securely transmitted using encryption. | codefeedback |
Write a SQL query to select all employees who have a salary greater than the average salary of all employees in the department with the code 'IT'. | codefeedback |
Given a sentence, classify it into positive or negative sentiment.
Rewrite the test by increasing the difficulty in the following ways:
1. Add a requirement to handle neutral sentiment: Instead of just classifying the sentence into positive or negative sentiment, also consider a neutral sentiment category. This will... | codefeedback |
Create a function that prints the multiplication table for a provided integer x = 8.
In the original test, the task was simply to create a function that prints the multiplication table for a given integer. To increase the difficulty, we can add more reasoning steps and make the task more complex.
Here is the rewritte... | codefeedback |
Create an HTML page with an <h1> heading "Welcome!" and a <p> paragraph with the text "I am happy to be here."
In addition, add the following requirements:
1. Add a CSS file to the HTML page and use it to style the <h1> heading with a font size of 24px, font color of blue, and center align it.
2. Change the font fam... | codefeedback |
Create a PHP script to generate a multiplication table until 15, but exclude any numbers that are divisible by 3. | codefeedback |
Write an R script to generate a random number sequence between 1 and 10, but with the constraint that no two consecutive numbers in the sequence should be the same. | codefeedback |
Rewrite the following function to use a ternary operator instead. Additionally, add error handling to account for negative bill amounts.
```javascript
function calculateTip(bill) {
if (bill < 0) {
throw new Error("Bill amount cannot be negative");
}
return bill < 50 ? bill * 0.2 : bill * 0.15;
}
``` | codefeedback |
Create an SQL query to select all columns from the table "Employees" in a database named "CompanyDB" where the salary of the employee is greater than $100,000 and their hire date is within the last 5 years. | codefeedback |
Given a sentence, quantify the sentiment expressed in the sentence using a scale of 1 to 10, where 1 indicates extremely negative sentiment and 10 indicates extremely positive sentiment. The sentiment should be based on the words and phrases used in the sentence, as well as the overall context.
For example, in the sen... | codefeedback |
Rewrite the following HTML page to an Angular web page. Implement a component that displays the title, header, and paragraph in the HTML template.
You should also include the necessary imports and module declarations in the Angular code. | codefeedback |
Write a PHP function named "calculateArea" to calculate the area of a rectangle. The function should validate that the length and width inputs are positive integers. If any of the inputs are not positive integers, the function should throw an exception with an appropriate error message. Otherwise, the function should c... | codefeedback |
Create a Newsfeed Aggregator Django web application that displays the latest news from different sources. Additionally, implement a feature that allows users to filter the news based on their preferred categories. | codefeedback |
Write a PHP program to print a Christmas tree pattern on the console using recursion.
Requirements:
- The program should prompt the user to enter the height of the tree.
- The height of the tree should be an odd number greater than or equal to 3.
- The program should validate the user's input and display an error mess... | codefeedback |
Create a Python script that takes an integer as input and prints the first n prime numbers, where n is the input integer. The script should also calculate and print the sum of all prime numbers. Additionally, the script should implement an efficient algorithm for prime number generation, such as the Sieve of Eratosthen... | codefeedback |
Create a web API in Node.js which can fetch and extract data from a website. Additionally, the API should have the following requirements:
1. Implement rate limiting: Limit the number of requests a client can make within a specified time interval. For example, allow a maximum of 100 requests per hour per client.
2. I... | codefeedback |
Create a React application with a registration form that includes server-side validation to check for unique usernames and email addresses. Additionally, implement a password strength meter that enforces a minimum of 8 characters, including at least one uppercase letter, one lowercase letter, one number, and one specia... | codefeedback |
Create a Mastermind game in any language of your choice. The game should have a timer that limits the player's response time to 30 seconds. Additionally, implement a feature that allows the player to choose the number of attempts they have to guess the secret code, with a minimum of 5 attempts. | codefeedback |
Explore the data_df dataframe and build a visualization that answers the following question: what is the correlation between the number of tweets sent and the positive sentiment for a specific date range? The date range should be provided as an input parameter to the visualization function. Additionally, the visualizat... | codefeedback |
Create a machine learning model to predict the probability of a patient having a certain type of cancer based on their medical records. The medical records include the following features: height, weight, age, gender, family medical history, smoking history, alcohol consumption, and previous medical conditions. | codefeedback |
Given a large string S, find the total number of non-overlapping occurrences of a pattern p in S. S and p will only contain lowercase letters.
S = "aaaabbbbccccdddd", p = "ab" | codefeedback |
Write a Python function that prints out a staircase pattern with a given height.
# Example
```
Input: 4
Output:
#
##
###
####
```
# Constraints
- The input height will be a positive integer between 1 and 10. | codefeedback |
Create a Java program to read in a number n (1 ≤ n ≤ 15), and print out the first n lines of Pascal's triangle. | codefeedback |
Design a data structure for efficiently finding the k closest inputs to a given input in a set of inputs, where k is a constant. | codefeedback |
Create an object syntax in JavaScript to represent an animal, with the following properties and methods:
- Properties:
- name: a string that stores the name of the animal
- species: a string that stores the species of the animal
- age: a number that stores the age of the animal
- gender: a string that stores th... | codefeedback |
Print all powers of 2 less than or equal to n, along with their binary representations.
n = 20 | codefeedback |
Implement an algorithm in Python to find the size of a Binary tree, where the nodes have a parent pointer in addition to left and right child pointers. | codefeedback |
Write a JSON string containing a list of three employee names, where each name is between 5 and 10 characters long. Additionally, each employee name should start with an uppercase letter and can only contain letters and spaces. | codefeedback |
Compute the n-th Fibonacci number using a recursive approach without using memoization. | codefeedback |
Create an Angular component named "FormInput" with a text field and a submit button. Implement the following additional functionalities:
1. Validation: Add a validation feature to the text field. The input should only accept alphabets and should show an error message if any other character is entered.
- The error ... | codefeedback |
Given two arrays of integers, find the common elements. The arrays may contain duplicate elements and the common elements should be returned in ascending order without any duplicates. Additionally, the time complexity of the solution should be less than O(n^2), where n is the length of the longer array.
arr1 = [1, 2, 3... | codefeedback |
Create a HTML page to show a list of employees, their departments and corresponding salary ranges.
Each employee should have an additional field called "Position" that shows their job title.
Also, add a button next to each employee's information that allows the user to edit the employee's salary range.
When the user... | codefeedback |
Given a list of numbers, determine whether each number is a perfect square or not. Return a new list with the corresponding results.
# Example
## Input
[1, 2, 3, 4]
## Output
[True, False, False, True]
# Constraints
- The input list can contain up to 10^5 integers.
- Each integer in the list will be between 1 and 1... | codefeedback |
Given a string, write a Python program to remove all special characters, except for the '@' symbol, from it. | codefeedback |
Given a string of words, generate the n-grams of the string where n is the gram size. The gram size represents the number of consecutive words in each n-gram.
For example, given the string "Dogs are the best pet" and a gram size of 2, the output should be:
- "Dogs are"
- "are the"
- "the best"
- "best pet"
Note t... | codefeedback |
Write a function to check whether a given number can be expressed as the power of some other number.
You are given a number, n. The task is to determine if there exist two integers, a and b (where a > 1 and b > 1), such that a^b = n. If such integers exist, return True. Otherwise, return False.
Example:
Input: 8
Out... | codefeedback |
Given a string, identify the count of each unique letter in the string while ignoring case sensitivity. The string may contain punctuation marks and spaces. Return the count in descending order. String: "Hello World!" | codefeedback |
Develop a code to check whether a number is a palindrome, considering the following constraints:
- The code should have a time complexity of O(log n), where n is the number of digits in the input number.
- The code should use a constant amount of additional space, regardless of the size of the input number. | codefeedback |
Design a data structure to store information about a student, including their personal details (such as name, age, and address), academic information (such as grade point average and courses taken), extracurricular activities (such as sports and clubs participated in), and any awards or achievements they have received.... | codefeedback |
Using React, write a component that displays a table containing the user's profile information. The table should include sortable columns, allowing the user to click on a column header to sort the data in ascending or descending order. Additionally, implement pagination functionality, limiting the number of rows displa... | codefeedback |
Using React, write a component named "CommentItem" that renders a single comment from a list of comments. The comment should include the author's name, the comment content, and the date it was posted. Additionally, the component should have a feature that allows users to like or dislike the comment by clicking on butto... | codefeedback |
Explain how you would use a nested for loop to iterate through a two-dimensional array and calculate the sum of all its elements. | codefeedback |
Take two non-negative numbers as input and calculate the sum of them using a Java program. The program should handle cases where the numbers can be up to 10^9 and output the sum modulo 10^9+7. | codefeedback |
Generate a dataframe with 1000 rows and 10 columns, where each cell contains a randomly generated integer between 1 and 100. | codefeedback |
Explain why selecting a suitable web framework that supports real-time data streaming and integrates with a cloud-based database is important for building a scalable and responsive web application. | codefeedback |
Write a query in SQL to list the items, the corresponding customer names, and the order dates of all orders with a value greater than $100. | codefeedback |
How does error handling work in Java, considering the use of custom exceptions for specific error scenarios? | codefeedback |
Write a SQL query to list all customers who have purchased items more than twice in the same year and have a total purchase amount greater than $500. | codefeedback |
Create an API in Node.js to accept JSON data and add it to a database. Additionally, implement error handling to catch any database connection errors and provide appropriate error messages to the client. | codefeedback |
Create a regex expression to extract names from the following sentence: "John, Jessica and David went to the store." However, the regex expression should only extract names that are followed by the word "went" and preceded by the word "and". | codefeedback |
Find the greatest common divisor for two integer inputs using the Euclidean Algorithm.
Increase the time complexity requirement to O(log(min(a,b))), where a and b are the input integers.
Increase the space complexity requirement to O(1), meaning that no additional data structures can be used.
Inputs:
5678934, 987231... | codefeedback |
Design a REST API in Python that would return a list of customer information. Additionally, the API should support filtering the customer information based on specific criteria such as age, location, and order history. The API should also provide sorting options for the returned data based on different attributes such ... | codefeedback |
Find the sum of the series n^4/(4n+2).
14 | codefeedback |
Write a Python function that takes in two lists and returns a set containing the common elements between the two lists. The function should have a time complexity of O(n), where n is the length of the longer list.
Example:
Input: [1, 2, 3, 4, 5], [4, 5, 6, 7]
Output: {4, 5}
Note:
- The function should handle lists of... | codefeedback |
Given a list of strings, create a function that returns a list of strings that occur exactly once in the given list. If a string occurs more than once, it should not be included in the output list.
["this", "is", "a", "list", "of", "strings", "this", "list", "has", "some", "duplicates"] | codefeedback |
Create a function that takes a string as input and returns the string with all vowels replaced by the corresponding uppercase consonant in the alphabet, and all consonants replaced by the corresponding lowercase vowel in the alphabet. Disregard any non-alphabetical characters and preserve the case of the original conso... | codefeedback |
Write a function that takes an integer n and prints the n x n grid with stars. Each row of the grid should contain exactly n/2 stars. The function should have a time complexity of O(n^2) and a space complexity of O(n). | codefeedback |
Create a boolean function in Java to check if a year is a leap year. Additionally, the function should also check if the input year is a valid year (i.e., not a negative number) and display an error message if it is not valid. | codefeedback |
Summarize the features, differences, and limitations of Python and Java, and provide an example of erroneous code in either language. | codefeedback |
Parse the following HTML string and find the ingredients for the recipe. The HTML string may contain nested elements and the ingredients may be scattered across different levels of nesting. Your solution should be able to handle this complex HTML structure and correctly extract all the ingredients. | codefeedback |
Return a dictionary containing the number of occurrences of each word in the given string. The string may contain multiple words, separated by spaces, and may also contain punctuation marks. You need to consider all possible cases, including uppercase and lowercase letters.
For example, for the input string "This stri... | codefeedback |
Write a PHP code snippet to display the current date and time in the format "Month day, Year Hour:Minute:Second".
#Further Explanation#
In addition to displaying the current date, modify the code to also display the current time in the format "Hour:Minute:Second". | codefeedback |
Given a linked list, design an algorithm to reverse it in place without using any extra space. | codefeedback |
Design an efficient algorithm to find the median of two sorted arrays with a time complexity of O(log(min(n, m))), where n and m are the sizes of the two arrays respectively. | codefeedback |
Create a switch statement in Java to determine the character type of each character in a given string and print the count of each character type (uppercase, lowercase, digit, special character) in the string. The input string can have a maximum length of 1000 characters. Aim for an efficient solution with a time comple... | codefeedback |
Generate a list of 8 random numbers between -10 and 10, without duplicates. Then, sort the list in ascending order and print the sum of all the numbers in the list. | codefeedback |
How can you count the number of unique elements in an array in Java, without using any built-in functions or libraries, and ensuring a time complexity of O(n)? | codefeedback |
Given a set of nouns, pronouns, verbs, and objects, output a random sentence based on the given grammar. The sentence should be grammatically correct and make sense.
The time complexity should be O(1), meaning the program should be able to generate a sentence in constant time, regardless of the number of inputs or the... | codefeedback |
Create a class in C++ that represents a binary search tree. The class should have the following functionalities:
- Ability to insert a new element into the tree.
- Ability to search for a given element in the tree.
- Ability to delete a given element from the tree.
- Ability to perform an in-order traversal of the tree... | codefeedback |
Create a program to find the closest string to the given string from a list of strings. The closest string is defined as the string that requires the minimum number of character modifications (insertions, deletions, or substitutions) to transform it into the given string. If there are multiple closest strings, return t... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.