instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
Create a function that takes in a string as input and returns a new string where every word is reversed. The function should also capitalize the first letter of every word in the resulting string. Additionally, the function should ignore any punctuation marks or special characters within the words and only reverse the ... | codefeedback |
Implement a function that calculates the total number of prime digits in a given number.
#Updated Prompt#:
* A prime digit is a digit that is a prime number (2, 3, 5, or 7).
You should write a function with the following signature:
```python
def count_prime_digits(number: int) -> int:
pass
```
### Input
- `num... | codefeedback |
Write C++ code to search for a particular element in a circular doubly linked list, but the linked list is sorted in descending order. Each node in the linked list contains a pointer to the next node as well as a pointer to the previous node. The time complexity of the algorithm should be O(log n), where n is the numbe... | codefeedback |
Refactor the following condition to use the ternary operator instead of an if-else statement, and add the requirement that the solution must be written in a single line of code. Additionally, introduce a new variable "z" that should be assigned the value of 2 if "x" is equal to 0, and 3 if "x" is greater than 0. The so... | codefeedback |
What is the output of the following code?
def foo(n):
for i in range(n):
for j in range(n):
print(i, j)
foo(3)
#Answer options
a) Prints nothing
b) Prints "0 0, 0 1, 0 2, 1 0, 1 1, 1 2, 2 0, 2 1, 2 2"
c) Prints "0 0, 0 1, 0 2, 1 0, 1 1, 1 2"
d) Prints "0 0, 0 1, 0 2" | codefeedback |
Please create a function that will validate if a given date is in the correct format and also checks if the date is a valid date in the Gregorian calendar. The function should meet the following requirements:
1. The function should return a boolean value indicating whether the date is valid or not.
2. The function sho... | codefeedback |
Search for the first and last index of a given element in a given array, but the array may contain duplicates and the array must be sorted in ascending order.
array = [1,2,3,3,3,4,5,6]
element = 3 | codefeedback |
Devise a Python function that not only identifies but also calculates and provides the frequency rate of a certain word within a gathered assortment of string literals. | codefeedback |
Rewritten Test:
Formulate a query to select the first names and last names of customers from the customers table, sorted in descending order of the number of orders they have made. Additionally, exclude any customers who have not made any orders.
Table Name: customers
Expected Output:
- The first name and last name ... | codefeedback |
You are tasked with implementing a class that represents the supported OAuth flows for an OpenAPI specification. The class should allow for the configuration of various OAuth flows and be capable of being encoded into a specific format. Your task is to create the `OpenAPIOAuthFlows` class with the necessary properties ... | codefeedback |
You are given a 2D array representing a logo, where each element in the array represents a color (N for navy, G for green, and R for red). The logo is represented as a 8x8 grid. Your task is to write a function that takes this 2D array as input and returns the number of pixels that are part of the logo, i.e., the count... | codefeedback |
Write a function to search in a 2D array of integers, and return the coordinates (row and column) of the target if it is present. The target must be found using a binary search algorithm.
The 2D array is structured as follows:
array = [
[1, 3, 5, 7, 9],
[2, 4, 6, 8, 10],
[11, 13, 15, 17, 19],
[12, 14, 16, 18, ... | codefeedback |
You are tasked with implementing a class method that retrieves a list of members belonging to a specific group. The method should handle two different scenarios: one where the member information is retrieved from an LDAP server, and another where it is retrieved from a mock member list.
The class `CSHMember` has the f... | codefeedback |
Modify the following HTML code to open the page with a single button in the center that says "GO!" and change the background color of the button to blue when it is clicked. Additionally, ensure that clicking the button triggers an alert message saying "Button clicked!". However, you must implement this functionality us... | codefeedback |
If you already been following some of the best practices in Deep Learning, [Facebook's Hydra](https://hydra.cc/docs/1.0/intro/) might be a familiar name to you. Going through the [Hydra Documentation](https://hydra.cc/docs/advanced/override_grammar/basic/), I came across two important operators + and ++. The documents ... | codefeedback |
Write a code to delete all the items whose value is lower than 5. Additionally, if an item's value is equal to 5, delete it as well. | codefeedback |
Write code to implement a priority queue in Python. | codefeedback |
Rewritten Test:
Implement a Python function that takes in a list of integers and returns the sum of all the numbers using the reduce() function.
The function should have the following signature:
```python
def calculate_sum(numbers: List[int]) -> int:
pass
```
The input list `numbers` will contain at least one int... | codefeedback |
You are given a square matrix of size `n x n` filled with zeros. Starting from the top-left corner, you need to fill the matrix with consecutive numbers in a spiral pattern, moving in the directions of right, down, left, and up. If the next cell in the current direction is already filled or out of bounds, change the di... | codefeedback |
You are tasked with implementing a custom inspector for a Unity script called `Comments`. The `Comments` script likely represents an object in a game or application that allows users to leave comments or feedback. Your goal is to create a custom editor for this script that provides a specialized interface for editing a... | codefeedback |
Devise a sophisticated schematic for a system deeply entrenched in the realm of quantum computing, fortified to counter potential obstacles emerging from the progression of artificial intelligence (AI). Incorporate your chosen programming language and harmonize it with a recurrent neural network (RNN) to enhance the ef... | codefeedback |
Create a function that can transform a string of text into an object containing the number of occurrences of each letter and digit in the string. The function should handle both uppercase and lowercase letters. The function should also consider whitespace characters and special characters. The output object should be s... | codefeedback |
Taking into consideration that all procedures in this programming code, including addition and array referencing, are subject to constant time complexity, O(1), please provide an analysis by identifying not only the overall Big O notation complexity but also the worst-case, best-case, and average-case scenarios for bot... | codefeedback |
Given a binary search tree and a target value, write a python function to search for the closest node value to the target. The binary search tree is not guaranteed to be balanced. The time complexity of the solution should be O(log n) on average, where n is the number of nodes in the tree. The space complexity should b... | codefeedback |
You are working on a project that involves storing and manipulating a large list of numbers. As the data set is quite large, you need to choose the most suitable data structure to efficiently store and access these numbers. Which data structure would you select and why? | codefeedback |
Generate random numbers in the range of 1 to 100 using a for loop in Python, ensuring all generated numbers are prime and no number is repeated more than once within the loop. | codefeedback |
Write a shell script to perform a binary search of a sorted array [2, 4, 6, 8, 10] and return the index of the first occurrence of the target element. The array may contain duplicate elements and the target element may also be a duplicate. | codefeedback |
Construct a SQL programming statement to retrieve the lexeme that holds the record for the maximum string length contained within the indicated database. Perform this task using the "Lexicon" table and corresponding column labels "identifier" and "denomination", examining the existence of both simple and complex charac... | codefeedback |
Create a Python script that utilizes try-except blocks to handle multiple error types (TypeError, ZeroDivisionError, ValueError) concurrently when attempting to perform multiple mathematical operations (addition, subtraction, multiplication, division) on user-provided inputs. The script should also include custom error... | codefeedback |
You are tasked with implementing a class for ending a transform feedback operation in a graphics library. The class, `GLOperationEndTransformFeedback`, is responsible for managing the end of a transform feedback process in OpenGL. It contains properties and a constructor for setting up the necessary objects and buffers... | codefeedback |
how can i express this logic in php?
def advanced_vowel_counter(s):
last = -1 if len(s) and (s[-1] in "aeiouyAEIOUY" or s[-1].isalpha() and unicodedata.decomposition(s[-1])[0]) else 0
s = s[:-1]
return sum([1 if c.lower() in "aeiou" or (c=='y' and c.isupper())
else 0 for c in s if c.isalpha()... | codefeedback |
You are tasked with creating a Python class that processes Twitter data to generate a graph representing interactions between users. The class should be able to extract relevant data from a Twitter stream and convert it into a graph format. Your task is to implement the `Tweets2Graph` class with the following specifica... | codefeedback |
Find the longest palindromic substring of this string.
string = "carrace"
# New Problem #
Given a string, find the longest palindromic substring within the string. A palindromic substring is a substring that remains the same when its characters are reversed.
Example:
Input: "carrace"
Output: "race"
# Reasoning #
To ... | codefeedback |
this python code was scanned using ocr and has some issues. can you fix it for me?
d€t descriptive_stats(l:_|izt):
n = lem(l)
l.s0n7() _# sorting th3 arrav 1n ascending onder
# calcula+ing m3diar
median = (1[n//2] +_l[=(n//2 +_1)]) / z
# computimg mOde
fr€q dict = []
fon l in l:
!f i ir freq dict:
tr€9_0ic+[i] += 1
e... | codefeedback |
Use pandas to load a CSV file from a given URL. After loading the data, perform the following tasks:
1. Clean the data by handling missing values. If the missing values are numerical, fill them with the mean of the respective column. If they are categorical, fill them with the most frequent element of the column.
2.... | codefeedback |
Construct a multi-class classification model to forecast neighborhood attractiveness using various factors: pollution levels, availability and frequency of public transportation, crime rates, population density, and number of public facilities (like schools, parks, hospitals). Your model will have to handle non-uniform... | codefeedback |
Write a SQL query to retrieve the title, genre, and the date published of books created by the author "Smith", sorted in descending order based on the number of copies sold, where the number of copies sold is greater than 100. Additionally, only retrieve books that have a rating higher than 4.5 and were published in th... | codefeedback |
Create a randomized 3D matrix with dimensions 2x2x2, where the elements range between -0.5 and 0.5, using only native Python (i.e., not external libraries like NumPy). In addition, ensure that diagonals of each 2x2 square in the 3D matrix (8 diagonals in total) sum up to a value greater than 0. If not, generate another... | codefeedback |
Create an array of prime numbers in descending order starting from 1000 to 2 using a for loop. | codefeedback |
Given the following AngularJS directive, describe its purpose and detail how you would modify it to include isolated scope, transclusion, and bi-directional data binding.
<my-directive></my-directive> Additionally, write a unit test to confirm its functionality. | codefeedback |
You are tasked with implementing a method to asynchronously copy the contents of a `ZipArchive` to a specified `Stream`. The `ZipArchive` class represents a package of compressed files in a single container, and the method should copy the entire contents of the archive to the provided stream.
Your task is to complete ... | codefeedback |
A cube of a certain number equals to the term $2^{15}\cdot3^6$. Can you identify this number from the choices below?
A) 288
B) 27
C) 125
D) 121 | codefeedback |
Write a SQL query to list the names, salaries, and years of experience of the employees who work in the finance department and have a salary greater than $50,000. Additionally, order the results by years of experience in descending order. The query should only include employees who have at least 5 years of experience a... | 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 |
You are tasked with implementing a method to sort a list of polygons based on their total perimeter. The method should take an ArrayList of Polygon objects as input and return a new ArrayList containing the polygons sorted in ascending order of their total perimeter. The total perimeter of a polygon is the sum of the l... | codefeedback |
Create a program to create a list of all the prime numbers between 1 and 10,000, and then find the sum of all the prime numbers in the list. Additionally, the program should calculate the average of all the prime numbers in the list and display the number of prime numbers found. | codefeedback |
Calculate the total of the numbers in the array below, but only include numbers that are greater than 10 and less than 20 in the calculation.
[5, 10, 15] | codefeedback |
Create a nested for loop that prints the prime numbers from 0 to 100. | codefeedback |
You are given a list of integers and a target sum. Your task is to write a function that finds all unique combinations in the list that sum up to the target. Each number in the list may only be used once in the combination. The solution set must not contain duplicate combinations.
Write a function `combinationSum2` th... | codefeedback |
Please debug the following code to print all the elements of a 2D array in reverse order while excluding any duplicate elements. Additionally, the code should skip any negative values present in the array.
int[][] arr = {{1,2,3},{4,5,6},{7,8,9}};
Set<Integer> seenElements = new HashSet<>();
for (int i = arr.length - 1... | codefeedback |
Write a different style of a given JavaScript code snippet that calculates the sum of two numbers without using the addition operator (+) or any other arithmetic operators. Additionally, your solution should have a time complexity of O(1). However, you are not allowed to use any bitwise operators or any built-in JavaSc... | codefeedback |
You are tasked with creating a script to automate the setup of Datadog monitoring in a PHP environment. The script should modify an INI configuration file to include specific settings related to Datadog monitoring. Your task is to implement a function that processes the given code snippet and determines the changes mad... | codefeedback |
Create a nested dictionary in Python where the outer dictionary has two keys and each key corresponds to an inner dictionary. Each inner dictionary should have three keys and each key corresponds to a list of values. | codefeedback |
Create a Java program to compute the total price of a customer's order based on item prices and quantities, with the additional constraint that the program should only allow the user to input positive integer quantities for each item. The program should also check that the length of the item_price and quantity arrays i... | codefeedback |
Given three distinct textual strings, design an efficient algorithm to identify the lengthiest shared subsequence of characters within them. The solution should work optimally for strings of varying sizes (i.e., from few characters to several thousands). Your algorithm needs to consider character case (uppercase and lo... | codefeedback |
You are given a code snippet that calculates the cosine and sine of an angle, and then uses these values to compute a rotation matrix and translation vector. Your task is to implement a function that takes a set of 2D point pairs, performs the calculations described in the code snippet, and returns the resulting rotati... | codefeedback |
Can you explain the function and significance of a Structured Query Language (SQL) when utilized in managing relational database management systems? | codefeedback |
Write a Python program to simulate a biased coin toss. The bias is determined by a given probability of landing on heads (0.0 to 1.0). Generate the results of the tosses in a list. Additionally, count the number of times each side of the coin appears and display the percentage of times each side occurs out of the total... | codefeedback |
Design a Haskell program that utilizes the sophisticated merge sort algorithm to effectively categorize information elements. | codefeedback |
Describe the process of writing a recursive program to calculate the factorial of a given number. Include additional reasoning steps to demonstrate your understanding of recursion and its implementation. | codefeedback |
| | # | Episode | Writer | Director | Original air date | Viewing figure |
|---:|----:|:-----------------------------------------|:-----------------|:-----------------|:--------------------|:-----------------|
| 0 | 11 | "Episode 1"(75-minute Christmas speci... | codefeedback |
Write a function that takes in a list of strings. The function should return not only the words that are made up of the same letter, but also the words that use each letter of the alphabet an equal number of times. Additionally, the function should ignore case when considering letter equality. If there are no words sat... | codefeedback |
You are tasked with creating a program that analyzes the frequency of words in a given text. Your program should take a string of text as input and output the frequency of each word in the text. For the purpose of this problem, a word is defined as a sequence of characters separated by spaces. Punctuation marks should ... | codefeedback |
Removes all odd elements from an array in JavaScript, while keeping the original order of the remaining elements intact. The resulting array should contain only even numbers.
let arr = [1, 2, 3, 4, 5]; | codefeedback |
You have to read a set of numbers and report the number of positive numbers, while also keeping track of the average of all the positive numbers. Additionally, you need to find the maximum, minimum, and median of the positive numbers in the set.
Constraints:
- The set of numbers can contain up to 10^7 elements.
- Each... | codefeedback |
You are tasked with implementing a Long Short-Term Memory (LSTM) neural network for time series prediction. The LSTM class is provided with a configuration file "settings.ini" that contains all the necessary hyperparameters and settings for the LSTM model. Your goal is to complete the implementation by defining the LST... | codefeedback |
Write a code to print out the list of the numbers from 0 to 10 in descending order. | codefeedback |
You are tasked with creating a stored procedure for a database that retrieves the nearest postcodes to a given geographical point within a specified distance. The database contains a table named `[Address].[Postcode]` with columns `[Postcode]` and `[Coordinates]`, where `[Coordinates]` represents the geographical coord... | codefeedback |
Using SQL, write a query to get the last five rows from a table named "customer", ordered by the creation date in descending order. Additionally, exclude any rows where the customer's age is less than 25 and their country of residence is not "United States". | codefeedback |
You are tasked with creating a Python function that interacts with a monitoring service to retrieve and process metrics data. The function should be able to handle dynamic tags and perform specific actions based on the received data.
Write a Python function `process_metrics_data` that takes in three parameters:
1. `ag... | codefeedback |
You are given a 2D array and you need to rotate it 90 degrees clockwise. The array may contain duplicate values. Additionally, you are required to implement the solution in a recursive manner without using any built-in functions or libraries. The solution should only use basic Python operations and data structures. | codefeedback |
Write a code to decode a given URL encoded string. The code should handle all special characters, including those that are not typically URL encoded, such as emojis and foreign characters. The decoded string should maintain its original encoding format and should be returned in its entirety. Additionally, the code shou... | codefeedback |
Create a function to format a given list of numbers with commas as thousands separators and round each number to the nearest hundredth decimal place. Additionally, exclude any numbers that are divisible by 5 from the final formatted list. | codefeedback |
Implement a function to find the minimum value in an unsorted array of integers without using any built-in sorting functions or data structures.
Time Complexity: O(n)
Space Complexity: O(1)
#Example#
Input: [9, 2, 5, 1, 6]
Output: 1 | codefeedback |
Write a function in Java to take a string and convert it to an integer without using the parseInt()method.
"1337" | codefeedback |
Please help me clean up this Python code, it's an output from an OCR scan.
lmpor7 re
o€f fimd_p4l1ndromes(text]:
+ekt_paragraphs - text.split("\m")
palir0romes_neport = {}
# functior 7o pnepro(e5s 7he text_for Nana<her's AlgOrit#m
03f_pr€pro(e$s(s):
return '#' + 'H'.join[s} t '#'
fon p, paragnaph in €nvmerat3[text_... | codefeedback |
Implement the JavaScript programming language to determine if every element located within a specific data structure, the linked list, is of the same numerical value.
linked_list = [3,3,3] | codefeedback |
Generate a sequence of strings according to the following pattern:
1. The first string in the sequence should be "1".
2. For each subsequent string in the sequence, concatenate the previous string with its length.
3. Repeat step 2 until the desired number of strings in the sequence is reached.
4. Additionally, each str... | codefeedback |
Design and implement a web-based task management system that ensures real-time synchronization as tasks are added, modified, or removed from a Firestore collection. This system must not only guarantee impeccable immediate synchronization, but also be equipped to handle large-scale data changes, maintain data integrity,... | codefeedback |
Incorporate matplotlib.pyplot, numpy, pandas, and seaborn libraries in Python. Utilize the 'tips' dataset from seaborn. Your task is to construct a joint regression plot (type='reg') using seaborn, with 'total_bill' and 'tip' as variables from the tips dataframe. Modify the color scheme of the line and scatter plot to ... | codefeedback |
Can you elucidate the step-by-step operations necessary to exploit the functionalities of DynamoDB, a service provided by Amazon Web Services, as the primary storage infrastructure for my MongoDB NoSQL database? Furthermore, could you identify the specific elements that require careful scrutiny to guarantee improved ef... | codefeedback |
Generate an array with the prime numbers between -10 and 10 in incremental order. | codefeedback |
You are tasked with creating a Python function that interacts with a database using HTTPS and handles various authentication and certificate options. Your goal is to implement the `execute_query_https` function, which takes a SQL query string and optional parameters for user authentication and SSL certificate validatio... | codefeedback |
You are tasked with implementing a Python class that manages zone numbers for a transportation system. The zone numbers are represented as integers and have a maximum internal value of 6000. Additionally, the zone numbers are stored in a colon-separated format. Your task is to create a class that enforces these constra... | codefeedback |
You are presented with a challenge titled "Path with Maximum Probability". The task involves an undirected weighted graph consisting of `n` nodes (0-indexed), which is depicted by an edge list where `edges[i] = [a, b]` signifies an undirected edge linking the nodes `a` and `b` with a certain probability of successful t... | codefeedback |
Create an Objective C function that is capable of constructing a ternary tree, specifically by employing depth-first search algorithm to bring about such tree formulation. Its nodes would comprise of: 13, 7, 6, 15, 19, 4, 9, 22, 1, 11, 3. Also, take into consideration the efficiency and computational complexity in the ... | codefeedback |
You are tasked with creating a program that simulates a simple banking system. The program should allow users to create accounts, deposit money, withdraw money, and check their balance. Each account should have a unique account number, and the program should be able to handle multiple accounts.
Your task is to impleme... | codefeedback |
What algorithms can be utilized to efficiently search through a digital thesaurus and why are they effective? | codefeedback |
You are tasked with creating a custom annotation processor in Java. Your goal is to implement a program that processes classes annotated with `@Reactant` and generates a new class that contains a method to react with other reactants.
Your program should perform the following tasks:
1. Define a custom annotation `@Reac... | codefeedback |
Using the "for" loop and conditional statements, find and display all prime numbers that are also odd within the range of 1 to 100 inclusively. Also, write a function that verifies if these primes are indeed prime and odd. What is the time complexity of your solution? | codefeedback |
Help me convert this snippet into C++:
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from nltk.stem import WordNetLemmatizer
import spacy
from transformers import AutoTokenizer
nltk.download('punkt')
nltk.download('wordnet')
nltk.download('stopwords')
class Preprocessor:
de... | codefeedback |
Implement a program that transforms the given dictionary into a balanced binary search tree without using any inbuilt Python data structure, library functions for binary search tree or recursive methods. Further the program should keep the balance of the tree whenever a new node is inserted. The dictionary is:
dictiona... | codefeedback |
You are given a function `grayCodeGenerator()` that generates a sequence of Gray codes. Gray codes are a binary numeral system where two successive values differ in only one bit. Your task is to implement the function `grayCodeGenerator()` and write a program to demonstrate its usage.
The `grayCodeGenerator()` functio... | codefeedback |
Develop a recursive function that not only checks if a numerical sequence has any symmetrical pairs but also finds and returns these pairs. The pairs should be ranked in order of their appearance in the series. For instance, within the numerical sequence [1, 2, 3, 3, 2, 1, 4, 5, 5, 4, 6, 7, 8, 9, 9, 8, 7, 6], the pairs... | codefeedback |
Implement the Caesar Cipher algorithm that shifts the characters in a string by a specified number of spaces. The input string can contain uppercase and lowercase letters, digits, and special characters. The shift value can be any integer between -100 and 100. The output should maintain the case sensitivity of the inpu... | codefeedback |
Develop a function in C++ language that allows a user to apply a Fourier transform operation on a given complex number array.
B = [(1,2), (3,4), (5,6)] | codefeedback |
Refine a script to integrate a GPT-3 model with PyTorch for text translation on extensive text datasets, considering error handling and optimization of performance on a distributed system utilizing multi-GPU and grid computing environment. For reference, resolve the issues present in the erroneous script provided. | codefeedback |
Create a recursive function that takes three parameters: a number, a base, and a precision value, and returns the result as a string. The number can be positive or negative and the base can be any positive integer. The precision value indicates the number of decimal places to include in the result.
To increase the dif... | codefeedback |
You are tasked with creating a Python function that processes a list of URL patterns and extracts the view names associated with each URL. The URL patterns are provided in the format `url(regex_pattern, view_name)`. Your function should return a dictionary where the keys are the unique view names and the values are lis... | codefeedback |
How can I use weather and time data to generate the perfect word to complete the sentence "The sun was _____ bright" for a given moment? For example, if the time is 2pm and the weather condition is sunny, what word would best describe the brightness of the sun in XML format? Can you provide a code example that takes in... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.