instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Design a ML algorithm to classify a given handwritten digit using a limited amount of training data (e.g., 100 samples per class). Additionally, the algorithm should be able to handle a large number of classes (e.g., 1000 classes) efficiently.
codefeedback
Create a SQL query to delete duplicates from a table and keep only one row. Additionally, you must ensure that the row to be kept has the highest user_id value among the duplicates. Table name: user. Columns: user_id (integer), email (string).
codefeedback
Change this code to print the reversed version of a string, but without using any built-in string reversal functions or methods. string s = "Hello World!"; #Expected Output# !dlroW olleH
codefeedback
Given the following Node.js code, explain its functionality and modify it to implement a basic RESTful API for managing a collection of books. ```javascript const express = require("express"); const app = express(); // Define a basic route app.get("/", (req, res) => { res.send("Welcome to the Book API"); }); // De...
codefeedback
Write a function that takes an array and removes all duplicates in place, returning the length of the new array. The function should also remove any duplicates that occur more than twice. The input array will be sorted in ascending order. [1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 6, 7, 7, 8, 9, 9, 9, 9]
codefeedback
Classifying whether an email is a spam or not based on the presence of specific keywords and the sender's reputation. This email contains the message "Try our latest offers - discount up to 50%" and must also not be from a known spam domain.
codefeedback
Write a code that checks if two String are anagrams, considering that the input strings can contain both uppercase and lowercase letters. s1 = "Listen", s2 = "silent"
codefeedback
Write a function to check if an array is sorted in ascending order, with the additional constraint that all even numbers must come before all odd numbers. arr = [2, 4, 6, 3, 7, 5]
codefeedback
You are tasked with designing a scalable database schema for a blog platform. The platform should be able to handle a large number of users and blog posts efficiently. Please consider the following requirements and design the schema accordingly: 1. Users: - Each user should have a unique username and email address....
codefeedback
Write a function that takes in a string and returns a dictionary with each unique word as a key and the number of times it appears in the string as its value. The function should ignore punctuation marks and treat uppercase and lowercase letters as the same. Example: Input: "The quick brown fox jumps over the lazy dog...
codefeedback
Discuss the potential performance impacts and memory usage of using a Numpy array with a minimum size of 100,000 elements and at least 5 dimensions for a given task. Additionally, provide insights on the optimal use of broadcasting and vectorization techniques to optimize the performance.
codefeedback
Design a series of methods that would be used to implement a card game. The card game should include a deck of 52 cards with four suits (hearts, diamonds, clubs, and spades) and thirteen ranks (Ace, 2-10, Jack, Queen, King). Additionally, the game should have a shuffling method to randomly order the cards in the deck b...
codefeedback
Edit the following code to find the maximum of three numbers. However, you are only allowed to use conditional statements (if, else if, else) a maximum of two times in your solution. a = 3 b = 5 c = 7
codefeedback
Change the following code so that it can reverse a list without modifying the original list and has a time complexity of O(n) and space complexity of O(1). Input: A list of integers Output: A new list with the elements of the input list reversed Example: Input: [1, 2, 3] Output: [3, 2, 1]
codefeedback
Compile a program to check whether an array is a subset of another array, considering that the array elements can be negative integers as well. The program should handle cases where the arrays have duplicate elements. Additionally, the program should also return the count of occurrences of each element in the subset ar...
codefeedback
Generate a function that swaps two given numbers without using a temporary variable and must have a time complexity of O(1).
codefeedback
Develop a program for HTML input validation that can handle nested HTML tags and attributes.
codefeedback
Summarize the concept of content-based filtering by implementing a program that takes into consideration a user's preferences and a dataset of items. The program should use a weighted cosine similarity algorithm to recommend the top 3 items that best match the user's preferences, with the additional requirement of excl...
codefeedback
Determine if the given string matches the given regular expression pattern, where the pattern may contain nested groups. String: this is a sample string Pattern: ((.*) sample (.*))
codefeedback
Rewrite the given code so that it uses Java 8 features and the sum of the numbers is calculated only for strings containing even numbers.
codefeedback
Rewrite the given recursive Python program as a loop, without using the built-in factorial function. The loop should only iterate a maximum of 100 times.
codefeedback
Write a program that extracts the URL from a given text and validates if it is a valid website address. The extracted URL must start with either "http://" or "https://" and end with a valid domain extension such as ".com", ".org", or ".net". The program should also handle cases where the URL contains query parameters o...
codefeedback
Given a list of positive integers, sort it in descending order without using the built-in sort function. The solution should have a time complexity of O(n^2) and should not use any additional data structures or recursion. The original list should be modified in place. The list will have at most 10^5 elements. Example: ...
codefeedback
Write an SQL query to display the maximum and minimum values of the "amount" column for each unique "user_id" in the following table. transactions columns: id, user_id, amount
codefeedback
Suggest an appropriate input for the following ReactJS program to display the provided output. import React from 'react'; const App = (props) => { return ( <div> {props.title} </div> ) } Output: My App Additional requirements: 1. The input should include at least one additional prop besides "title"...
codefeedback
Write a function that takes a string as an input and returns a list of all the unique substrings of the given string, excluding single characters. The function should handle cases where the input string contains special characters and numbers. Additionally, the function should return the substrings in ascending order o...
codefeedback
Produce a code to change the case of a given string. The code should have a time complexity of O(n), where n is the length of the string. The code should also be implemented without using any built-in functions or methods specifically designed for changing the case of strings. Example: Input: "Hello World" Output: "...
codefeedback
Take a list of numbers and remove the numbers that are greater than 100 and less than 1000. numbers = [1, 20, 300, 4000, 50000, 600000, 7000000, 80000000, 900000000, 1000000000, 11000000000, 120000000000, 1300000000000, 14000000000000, 150000000000000]
codefeedback
Create code to check if the given number is a power of three and if so, find the largest power of three that is less than or equal to the given number. The code should also output the number of digits in the binary representation of the largest power of three. Finally, the code should handle numbers up to 10^9.
codefeedback
Design a program to reverse a string without using the built-in 'reverse' method. However, you are not allowed to use any additional variables or data structures (such as arrays or lists) to store the reversed string. The program should only reverse the characters of the original string in place. string = "Hello World"
codefeedback
Modify the code to add a class called Animal that accepts a name and an age as arguments. The name should be a string consisting of at most 20 characters, and the age should be a positive integer less than or equal to 100. The Animal class should also have a method called eat() which increases the animal's age by 1 and...
codefeedback
Create a code to insert an item in a given position in a circular linked list. Insert "Hello" at position 2 in the list {1->2->3->4->5->1} #Erroneous Code Reference# Create a code to insert an item in a given position in a linked list. Insert "Hello" at position -1 in the list {1->2->3->4->5}
codefeedback
Determine the most frequent character in the provided string, considering only alphabetic characters and ignoring letter case. Hello World
codefeedback
Develop an algorithm to delete all nodes with a specific value from a linked list. Delete all nodes with the value 3 in the list {1->2->3->4->5}.
codefeedback
Generate a JavaScript solution to print all prime numbers between 1 and 1000000.
codefeedback
Create a hash function that assigns a unique number to each character of the input string, where the hash values are generated using a specific prime number algorithm.
codefeedback
Write a function that takes a string as input and returns the number of times the character 'a' appears in it. However, there are some additional requirements: 1. The function should not be case-sensitive, meaning it should count both 'a' and 'A' as occurrences of the character 'a'. 2. The function should also count ...
codefeedback
Create a robust log in security system in Java that includes a password strength checker and a two-factor authentication feature.
codefeedback
Construct a class that can be used to check if the braces in an expression are balanced. The expression should also contain square brackets and curly braces, in addition to parentheses. The class should be able to handle nested braces as well. The expression can also include other characters and numbers. Return True if...
codefeedback
Create a function in Python which takes two strings as arguments and returns true if the first string contains the second string, false otherwise. The function should not be case sensitive and should only consider alphanumeric characters when comparing the strings. Additionally, the function should only return true if ...
codefeedback
Calculate the Fibonacci sequence of the number 1000. Provide the solution in a recursive approach.
codefeedback
Evaluate the following arithmetic expression with Python, where the result should be rounded down to the nearest integer. 15 * (2 + 7) The solution should be implemented using a recursive function.
codefeedback
Make a C++ program to delete a node from a doubly linked list at a given position, but without using any extra variables or loops. Linked List: 84 -> 13 -> 25 -> 48 -> 50 Position: 3
codefeedback
Write a SQL query which returns the number of customers from the following "customers" table that are from France and have made at least 5 purchases in the past month.
codefeedback
Write a SQL query to select the names of all employees who work at company 'Apple' and have a salary greater than $100,000.
codefeedback
Implement a function in JavaScript which returns the nth element from the end of an array. The function should also handle error cases where the input array is empty or the value of n is greater than the length of the array. array: [2, 5, 8, 6, 9, 0] n: 7
codefeedback
Create a Java program which will print the following pattern: Input: An integer n Output: A pattern of n lines, where each line consists of n characters Conditions: 1. The first character in each line should be 'A'. 2. The last character in each line should be 'Z'. 3. The characters in between should be random upper...
codefeedback
Given two dictionaries, dict1 and dict2, merge them into a single dictionary. However, in the merged dictionary, the keys from dict1 should be converted to uppercase and the keys from dict2 should be converted to lowercase. The merged dictionary should contain the values from dict1 and dict2 as a tuple for each key. If...
codefeedback
Create a function in Python that takes in a list of strings as input and returns a dictionary where the keys are the strings from the input list and the values are the number of times each string appears in the list. The function should not use any built-in Python functions or libraries.
codefeedback
Write a Regular Expression that matches all strings starting with a lowercase 'a', followed by any number of lowercase letters, followed by an uppercase 'Z'.
codefeedback
Translate the given Ruby code into Javascript. Implement the code inside a class called "Greeting" and add a constructor that takes a parameter "name". Modify the "print_hello" method to print "Hello, [name]!" where [name] is the value passed to the constructor. Call the "print_hello" method with the name "John".
codefeedback
Write a program that prompts the user for a number n and then generates and prints the first n prime numbers.
codefeedback
Given a 3-dimensional numpy array of shape (n, m, k), where n, m, and k are positive integers, reduce the array to a 2-dimensional numpy array of shape (n*m, k), such that the resulting array contains all the elements from the original array.
codefeedback
Implement a web scraper in Python to extract all headlines from a web page and store them in a database. Additionally, filter out any duplicate headlines and only store the unique ones in the database.
codefeedback
Write a class in Python to represent an entry in a contact book. The contact book should be able to store not only the name and phone number of a contact, but also their email address and birthday. Additionally, the contact book should have a method to search for a contact by their name and return all their details.
codefeedback
Find the maximum and minimum values of a given list of integers in Python, while also keeping track of the second maximum and second minimum values.
codefeedback
Write Python code to create a list of prime numbers from 1 to 100 (including 100).
codefeedback
Given a string, find the length of the longest substring containing no repeated characters. The substring must be contiguous and the characters must appear in the same order as in the original string.
codefeedback
Given a range of numbers [a, b], write a program to find the sum of all prime numbers within that range.
codefeedback
Write a C++ program that takes a string, removes all duplicate characters from the string, sorts the remaining characters in descending order, and prints the resulting string. text = "abracadabra"
codefeedback
Given a starting number and an additional number, write a program to generate the Fibonacci sequence up to the nth number, but exclude any number that is divisible by the additional number.
codefeedback
Make an API request to fetch the top 10 trending topics from Twitter. Store the data in a list and sort it in descending order based on the number of tweets for each topic. Display only the top 5 trending topics with their corresponding number of tweets.
codefeedback
Write a code to filter the even numbers from the following array and return them in descending order: my_array = [1,2,3,4,5,6]
codefeedback
Write a SQL query to combine two tables into one and delete the duplicate rows. The resulting table should also include a column indicating from which original table each row came from. Table A: id | name | age 1 | John | 20 2 | Mary | 22 3 | Jane | 19 Table B: id | name | age 4 | Mark | 25 5 | John | 20 6 | Jack | 15...
codefeedback
Write a SQL query to calculate the standard deviation of student grades for each subject from the following table. Student | Subject | Grade John | Math | 75 Mary | Math | 85 Bob | Math | 80 Jane | Math | 90 John | Science | 70 Mary | Science | 90 Bob | Science | 85 Jane | Science | 95
codefeedback
Enhance the following code to find the average of all the even numbers in the array: my_array = [1,2,3,4,5,6] Constraints: - The input array can have up to 10^6 elements. - The elements of the array can be positive or negative integers. - The elements of the array can be in any order. Note: You are not allowed to use...
codefeedback
Write a SQL query to find the first name and last name of all students enrolled in course "CSCI-203" whose student ID is greater than 100 and whose GPA is above 3.5.
codefeedback
Create a Java program to list all duplicated words in the given string, ignoring case sensitivity and special characters. Additionally, you should also remove any stopwords such as "the", "and", "in", and "a" before identifying the duplicates.
codefeedback
Create an HTML page that displays the Date and Time in the header. Additionally, add a button that allows the user to toggle between displaying the date and displaying the time.
codefeedback
Process this CSV string into an array of objects. Each object should contain the following properties: "name" (string), "age" (number), "gender" (string), and "country" (string). The CSV string should be processed using a custom delimiter instead of the comma (,).
codefeedback
Formulate a regular expression to identify prime numbers up to 100.
codefeedback
Explain the concept of hoisting in JavaScript and how it affects the handling of undeclared variables. Provide an example to demonstrate the behavior of hoisting in relation to undeclared variables.
codefeedback
Find the type of an object for the given object, but only using bitwise operations. Object: "Hello World"
codefeedback
Write a JavaScript program to create an array of elements, representing the Fibonacci sequence, up to the given number n. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. For example, if n is 10, the program should return [0, 1, 1, 2...
codefeedback
Code an SQL query to insert new records into the Students table with the following requirements: 1. Only insert records if the grade is 'A'. 2. Check if the name already exists in the table before inserting a new record. If it does, update the grade of the existing record instead of inserting a new record. 3. Retrieve...
codefeedback
Remove comments from a given HTML page while maintaining the original formatting and structure, using only recursion and without using any built-in HTML parsing libraries or regular expressions.
codefeedback
Identify the Python statement used for looping and explain its syntax.
codefeedback
Generate a query to count the number of unique values in a SQL table, but exclude any null values from the count.
codefeedback
Write a code to validate an email entered by the user. The code should check for the presence of an "@" symbol, followed by a domain name with at least one period, and ensure that the email address does not contain any special characters. Additionally, the code should verify that the email address is not already regist...
codefeedback
Write a function that takes in a dictionary as input and prints out the contents of the dictionary in a formatted manner. The dictionary may contain nested dictionaries and lists as values. # Example # Input: {'name': 'John', 'age': 23, 'address': {'street': '123 Main Street', 'city': 'New York'}, 'phone_numbers': ['1...
codefeedback
Parse the data in the given json to a list of key-value dictionaries. The json may contain nested dictionaries and arrays. The final result should include all the key-value pairs in the json, including the ones in nested dictionaries and arrays.
codefeedback
Write a code to group the elements in a list into a dictionary with the list element as the key and the number of times the element is repeated in the list as the value. The input list can contain any type of element, including nested lists and dictionaries. The code should be able to handle any number of nested levels...
codefeedback
Generate a function to convert an infix expression to a postfix expression. The infix expression can include the following operators: "+", "-", "*", "/", "%". The expression can also include parentheses, which indicate the order of evaluation. The expression can contain variables (single letters) and constants (positi...
codefeedback
Edit this code to create a recursive function which prints the Fibonacci series in reverse order, while also calculating the sum of all the Fibonacci numbers within the series. Additionally, your function should take an integer input as the starting point for the series and should handle cases where the input is negati...
codefeedback
Create a function to compute the depth of a binary tree. The function should have a time complexity of O(n), where n is the number of nodes in the tree.
codefeedback
Create a function to find a pair of elements in an array whose sum matches the given target. If multiple pairs exist, return the pair with the highest sum. If no such pair exists, return an empty array. # Example # numbers = [1, 2, 3, 4, 5], target = 6 Output: [4, 2] Explanation: The pairs that sum up to the target ...
codefeedback
Format the given list of numbers in such a way that the element at the i'th index is the product of all elements in the list except the i'th element. The input list will not contain any zeros. Example: Input: [1, 2, 3, 4] Output: [24, 12, 8, 6] Explanation: For the element at index 0, the product of all other element...
codefeedback
Create an HTML table that contains 1 million rows and 100 columns.
codefeedback
Observe the given piece of code and suggest the possible data structure to use. Additionally, provide a more efficient solution with a lower time complexity. for (int i = 0; i < input.length; i++) { if (input[i] == 0) { output[output_index] = i; output_index++; } } **Question:** You are give...
codefeedback
You are given a file containing a million records, where each record consists of a key-value pair. The keys are unique and consist of integer values ranging from 1 to 1 million. The goal is to sort the records based on their keys in ascending order. Please provide an efficient algorithm to sort the records in memory. ...
codefeedback
Create discrete buckets in a given array using the following algorithm, where each bucket must contain at least two elements and the sum of the elements in each bucket must be a prime number. [2, 3, 6, 7, 8]
codefeedback
Construct a JavaScript function that implements a fibonacci sequence. The function should not use recursion and should have a time complexity of O(n).
codefeedback
Create a program to generate all subsets of a set, where each subset must contain at least one element from the original set. input_set = {1, 2, 3} #Difficulty Increase Methods: 1. Increase the size of the input_set to include more elements. 2. Add constraints to the subsets, such as each subset must have a maximum si...
codefeedback
Increase the difficulty of the given programming test question by adding a specific requirement: In the string_formatter function, modify the code to split the string into a list of words, remove any duplicate words, and then return the list of unique words in alphabetical order. The output should be a sorted list of ...
codefeedback
Generate code for a for loop to iterate through the odd numbers from 1 to n, where n is a positive integer. n = 10
codefeedback
Write a function to make an API call to the Yelp API to return the list of top 10 restaurants near a given address within a specific price range. Address: 1234 Main Street, San Francisco, CA Price range: $ - $$$ In addition to retrieving the list of restaurants, also display the average rating and the number of review...
codefeedback
Write a function that takes an integer as input and prints out all the prime numbers up to and including the provided number.
codefeedback
Create a Python function to generate a random hex color code with a specific length of n. The function should also include an optional argument to specify whether or not the color code should be a light or dark shade.
codefeedback
Find the longest substring containing only consecutive digits from within the given string. The substring must contain at least k digits, where k is a parameter provided to the function. Function Signature: `def find_longest_substring(string: str, k: int) -> str:`
codefeedback
Train a classification model to classify the sentiment of the given sentence, taking into account the length of the sentence. The model should accurately classify the sentiment of sentences with a minimum length of 10 words. Sentence: I absolutely adore this fantastic new book that I recently purchased!
codefeedback