instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
Design a function that employs the Levenshtein Distance method, an algorithm to determine the minimum amount of single-character operations, specifically those of insertion, deletion, and substitution, necessary to transform one given alphanumeric sequence into another distinct sequence. For this task, instead of usi...
codefeedback
Design a class that can generate unique IDs with time-stamped attributes.
codefeedback
Suggest a code to print the last two elements of a list in reverse order, convert them to uppercase, and then calculate the sum of their lengths. list_of_items = ["apple", "banana", "cherry", "orange"]
codefeedback
Design a data structure to store the details of a student (Name, Age, Course).
codefeedback
Create an array of the first 10 natural numbers in JavaScript.
codefeedback
Implement a program that calculates the real and complex roots of a given cubic equation: Ax^3 + Bx^2 + Cx + D = 0. The program should handle cases such as multiple roots, complex roots, and should throw appropriate errors in case of invalid inputs.
codefeedback
Reverse the following string without using any loops and also without using any built-in string reversal functions or libraries. Code: ```python def reverse_string(string): # your code here pass print(reverse_string("Hello World")) # should print "dlroW olleH" ``` Table: | Input | Output | |--------|--------|...
codefeedback
Given an array of numbers, find the maximum product of any three distinct numbers in the array. The array will have at least 6 numbers. You may not use sorting or nested loops to solve this problem. arr = [2, 5, 6, 9, -2, -7, -1]
codefeedback
Implement an iterative binary search algorithm that searches for a target element in a sorted array. The algorithm should have a time complexity of O(log n) and a space complexity of O(1), where n is the size of the array. Additionally, the algorithm should handle the case where the array contains duplicate elements. I...
codefeedback
You are tasked with implementing a simplified version of an Abstract Syntax Tree (AST) visitor for a compiler. The AST represents a program's source code in a tree structure, and the visitor pattern allows operations to be performed on the nodes of the tree. Your task is to create a class `AotStmtVisitor` that visits ...
codefeedback
what are all the open 1st viii with u15 4th iv being gt | | Crew | Open 1st VIII | Open 2nd VIII | Open 3rd VIII | U16 1st VIII | U16 2nd VIII | U16 3rd VIII | U15 1st IV | U15 2nd IV | U15 3rd IV | U15 4th IV | U15 5th IV | U15 6th IV | |---:|-------:|:----------------|:----------------|:-...
codefeedback
You are tasked with creating a custom Angular directive that allows users to drag and drop elements within a web application. The directive should utilize the Angular CDK (Component Dev Kit) DragDropModule to enable this functionality. Your goal is to implement the directive and ensure that it can be seamlessly integra...
codefeedback
Increase the complexity of the following coding test: The teacher is grading students using a custom algorithm, but the code was misplaced. Now, write a function taking a vector of student GPAs and outputting corresponding letter grades as per the provided GPA-grade table. Extend this to also determine the average gra...
codefeedback
You are tasked with creating a custom authentication system for a web application using Django. The system should include a custom user model and a view to display a list of users. Your task is to implement a custom user model and a view that lists all the users using Django's class-based views. Create a custom user m...
codefeedback
Suppose I have a list of numbers as shown below: [288, 320, 384, 416, 448] What would be the most efficient way to find the greatest common divisor of this list using Python code? Can you provide a Python function that takes in a list of numbers and returns their greatest common divisor?
codefeedback
Create a webhook in Python to listen to webhook requests and validate the incoming requests using HMAC-SHA512 authentication. Additionally, implement rate limiting functionality to allow only 5 requests per minute from each unique IP address, and block any IP address that exceeds this limit for a period of 1 hour.
codefeedback
You are tasked with implementing a generic data structure in Rust that can store elements of any type. The data structure should support adding elements, removing elements, and checking if it contains a specific element. You need to implement the `GenericDataStructure` module with the following methods: 1. `new()`: Cre...
codefeedback
Please write a program that scans a network and retrieves a list of all devices connected to it. The program should be able to run on Windows and should be implemented using a programming language of your choice. The program should have the following requirements: 1. The program should be able to scan both IPv4 and IP...
codefeedback
Develop a code that determines the number of actual business hours, excluding weekends, holidays and breaks, between two specific timestamps.
codefeedback
Precomputed and stored aggregated data, such as sums or averages, can be a result of...
codefeedback
Create a webpage that contains multiple HTML components such as headers, paragraphs, and images. Use CSS to not only align the textual content to the center but also distribute your elements evenly across the webpage. Implement a light/dark mode switcher on the webpage. When the switcher is toggled, it should: - Chan...
codefeedback
Using a database query, count the number of employees in a company database and display the count in descending order based on the number of projects they are assigned to.
codefeedback
async getAlbum() { const { AlbumComponent } = await import("./album/album.component"); this.viewContainer.createComponent(AlbumComponent); } I do have a working function to load a standalone component (Angular 15). I would like to add a CSS class dynamically to my viewContainer - for example class='fade'. ...
codefeedback
Write a code snippet to loop over the characters in a string and add only the vowels to an array in Python.
codefeedback
I'm developing a performance critical application for Intel Atom processor. What are the best gcc optimization flags for this CPU?
codefeedback
Write a function that calculates the power of a given number `n` raised to the exponent `m`. The function should handle the following edge cases: 1. If `n` is negative and `m` is not an integer, the function should return an error message. Additionally, if `n` is zero and `m` is negative, the function should return an...
codefeedback
You are tasked with implementing a custom serializer and deserializer for a Python application that handles Jaeger tracing metadata propagation. The provided code snippet includes a method `deserialize_context` and a class `ProfilerRequestContextSerializer` that needs to be extended to support the serialization and des...
codefeedback
You are given a 2D board representing a game state. The board consists of cells, each of which can be empty or occupied by a player's piece. The goal is to determine if there is a winning sequence of pieces on the board. A winning sequence is defined as a horizontal, vertical, or diagonal line of consecutive pieces bel...
codefeedback
How can you write a JavaScript function using regular expressions to validate email addresses not only follow a standard email format, but also are from specific domains (e.g., '@gmail.com', '@yahoo.com', etc.) and do not contain any numeric characters in the username part of the email address?
codefeedback
Create a .NET Core web application that reads and displays data from a database.
codefeedback
A positive integer $n$ is considered to be cubefree if it is not divisible by any cube of a prime number. For example, $1, 2, 3, 5, 6, 7, 10, 11$ are cubefree, while $8, 27, 125$ are not. Can you calculate the total number of such cubefree numbers that exist below the value of $2^{60}$?
codefeedback
Create a class in Python that will allow us to initialize and store a given list of positive integers. The class should also have a method that returns the sum of all the numbers in the list. Additionally, the class should have a method that returns the product of all the numbers in the list. Finally, the class should ...
codefeedback
Create a class in Python which contains three attributes and two methods. One of the attributes should be a private attribute and should only be accessible within the class. Additionally, the class should implement data encapsulation and enforce the use of getters and setters for accessing and modifying the private att...
codefeedback
Write the code for a recursive function that generates the Fibonacci sequence up to a given number n. Additionally, implement a mechanism in your code to handle very large numbers within the Fibonacci sequence without exceeding Computing limitations in Python.
codefeedback
Given an array of integers, determine the maximum and minimum value of the array. The array can have duplicate values and can be of any length between 1 and 10^6. Additionally, the array can be unsorted. However, you are not allowed to use any built-in sorting functions or data structures (e.g. sort() function, arrays...
codefeedback
Create a function to find the cube of any number, using only addition and multiplication operations. The function should handle both positive and negative numbers. #Example Code# ```python def cube(number): result = 0 if number < 0: number = abs(number) for i in range(number): resul...
codefeedback
## Given Test (Rewritten) ## Create a function in Python that takes a date in the format "YYYY-MM-DD" as an argument and displays the corresponding day of the week from Monday to Sunday. The function should handle leap years correctly. You should not use any built-in date or time libraries in your solution. The tim...
codefeedback
You are tasked with creating a program to determine whether a given number is a prime number or not. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your task is to implement a function that takes an integer as input and returns a boolean value indicating whether...
codefeedback
Could you construct an algorithm to sort a nested JSON data set, where the primary sorting parameter is 'public_id' in a descending order and the secondary sorting parameter is 'name' in ascending order? This dataset contains multiple entries for each person, with different 'public_id's, and your solution must group e...
codefeedback
What does the position argument of the re.sub() method do, and what is the time complexity of using this argument in a large input string? Additionally, provide an implementation of the re.sub() method that utilizes the position argument to replace all occurrences of a pattern starting from a specific index, while excl...
codefeedback
How can I implement a depth-first search algorithm in Python without using recursion? Explain the iteration process and demonstrate how to manage the stack manually. Additionally, illustrate your solution using a complex graph, depicting node relationships.
codefeedback
I'm designing an open database in which users can upload geographical data (a sort of Open Street Map). For simplicity below I'll describe an example in which users can upload the position of the zebra crossing for a city. My database table of the is something like (id_zebra_crossing, latitude, longitude, id_user) in w...
codefeedback
Conceptualize an effective database structure for the accommodation of a comprehensive thesaurus, incorporating a catalogue system that allows proper association of synonyms and antonyms for each specified lexical term.
codefeedback
Code a function in C that takes an integer array and its size as two arguments and returns the median of these numbers. Additionally, provide a piece of erroneous code as a reference to increase misdirection. array = [1,2,3,4,5] size = 5
codefeedback
Devise a modular Flutter-based mobile application, serving as a Content Aggregator, that amalgamates and renders the most recent podcasts from a diverse assortment of singular broadcasting platforms, whilst maintaining effective performance and an intuitive user interface.
codefeedback
With Python, write a code to calculate the product of elements in a three-dimensional array. Your array should look like this: arr = [[[2, 3], [4, 5]], [[6, 1], [7, 0]], [[8, 2], [3, 9]]]
codefeedback
Write a program that not only determines the lowest prime number in a given set, but also checks and returns the indices of the prime numbers in a 2D array. You should also include a functionality that handles cases where there's no prime number in the set. The set can include negative numbers and zeros. Test your prog...
codefeedback
Write a SQL query to get all employees' name, hire date and the name of their direct manager who are from department "Finance", have a salary greater than 50000 and their managers also belong to the same department. Further, sort the list in descending order based on the manager's name.
codefeedback
Write a function that takes an array of integers and returns the maximum and minimum values in the array. The function should not use any conditional statements, comparison operators, or any built-in functions or methods that directly solve the problem. You can only use basic arithmetic operations and logical operators...
codefeedback
Write a function to check for palindrome Given a string, the task is to determine whether it is a palindrome or not. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward. Example: Input: "abcba" Output: True To solve this problem, we can follow these steps...
codefeedback
Compute the factorial for each individual integer encompassed within a JavaScript array, then apply a modulus operation with a prime number provided as input. Specifically, the array consists of these integers: [3, 5, 7]. Also handle potential overflow errors.
codefeedback
Write an SQL query to find all the customers with first names starting with "A" and last names ending with "s", whose phone numbers contain exactly 10 digits and are not in the format "555-555-5555", and have made at least 3 purchases in the past month, from the customers table.
codefeedback
I'm curious to see this code in PHP: string int_to_mini_roman(int number){ vector<int> val = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; vector<string> roman = {"m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix", "v", "iv", "i"}; string res = ""; for(int i=0; i<val.size(); i++){ w...
codefeedback
Devise a function that metamorphoses a linked list into a binary search tree (BST), ensuring the final product complies with the BST data structure. This function should possess the ability to manage nested linked lists and transmute them into nested BSTs. It should also be proficient in dealing with a blend of linked ...
codefeedback
Invent a cipher that requires the blending of ten characters, explicitly making use of both special symbols and digits.
codefeedback
You are given a piece of Java code that is attempting to find the median of a list of integers. However, the code contains errors and does not return the proper median value. The current code only works with sorted lists and disregards empty or single-element lists. Your task is both to identify and correct the mistak...
codefeedback
Use PyTorch to write a function that predicts a class label based on five numerical features. The function should include a data preprocessing step that scales the input features between -1 and 1 using the tanh function. Additionally, the function should output both the predicted class probabilities and the predicted c...
codefeedback
You are tasked with implementing a simple transaction scheduler for a banking system. The system maintains a schedule of transactions and processes operations based on the type of operation. The code snippet provided is a part of the transaction scheduler's implementation. The `schedule.transactions[transaction_id] = ...
codefeedback
I am trying to install and initiate the Typeorm but it gives me an error; I have tried to search about it but nothing seems to work. First I ran this in the cmd `npm i typeorm -g` and then `typeorm init --name backend-proj-one --database postgres` typeorm : The term 'typeorm' is not recognized as the name of a cmdlet,...
codefeedback
Design a Java code that allows for the implementation of an optimized version of the Bubble Sort algorithm (consider using the Cocktail Shaker Sort) on a randomly generated numeric matrix. The matrix should be filled with sequences of 20 distinct integers ranging from -50 to 50. Also, ensure that the algorithm has the ...
codefeedback
You are tasked with creating a program that generates a formatted ASCII art representation of a given input string. The ASCII art will be displayed using a specific font style, and the program should support a variety of font styles for the output. Your task is to implement a function `generateAsciiArt` that takes in ...
codefeedback
Use the scikit-learn library to perform K-means clustering on the MNIST dataset and display the resulting cluster centroids as images. Additionally, quantify the quality of the clustering using silhouette coefficient and compare the results with a hierarchical clustering algorithm.
codefeedback
What is the time complexity of the following python snippet for binary search when the input array is sorted in descending order?
codefeedback
Convert an array from its x-coordinate values to an array of polar coordinates. The input array may contain up to 10^6 points.
codefeedback
Examine the given faulty WebGL (Web Graphics Library) code, originally designed to render a detailed 3D model of a human heart. Identify the inherent issues and correct them. Additionally, upgrade the script to not only display the various chambers and structures of the heart, but also to simulate the flow of blood thr...
codefeedback
Create an HTML page that includes a form. The form should have inputs for a first name, last name, email, favorite color, and a submit button. Add client-side validation to ensure that the email entered is in a valid format (e.g., contains "@" and ".com"). On submission of the form, display an error message if any of t...
codefeedback
You are tasked with implementing a report generation system that supports multiple output formats. The system should be able to generate reports in LaTeX, Markdown, JSON, and HTML formats. To achieve this, you need to create classes for each report builder type: LatexReportBuilder, MarkdownReportBuilder, JsonReportBuil...
codefeedback
Convert this SQL query into MongoDB and only return the user names in ascending order. Additionally, the user names should only be returned if the corresponding user's email address ends with "@gmail.com" and the user has logged in at least 5 times. Furthermore, only users who have made a purchase within the last 30 da...
codefeedback
Create a hashtable in Python of size 10^7 and insert 10^6 randomly generated elements, each element being a string of length 10.
codefeedback
Please create a function in Python that executes the below pseudocode. Input: A list of integers For each integer: If the integer is divisible by 4, multiply it by 3 and subtract 2 from the list If the integer is divisible by 6, divide it by 3 and add 2 to the list If the integer is divisible by 9, add 7 ...
codefeedback
Create a Python function which takes a given string and replaces all its characters with the next consecutive character. The function should handle both uppercase and lowercase letters separately, and should wrap around from 'z' to 'a' or 'Z' to 'A' when necessary. The function should also ignore any non-alphabetic cha...
codefeedback
Create a Macros in Excel to transpose a given set of data. The data set contains a combination of numbers, strings, and formulas. The macros should be able to handle any size of data set, with a maximum of 1 million cells. Additionally, the macros should be able to transpose the data in-place without using any addition...
codefeedback
Write a JavaScript code for the following action: When the user types "I'm hungry!" in the text box and presses the enter key, the system will check if the user has entered a valid number in the adjacent number input field. If the entered number is greater than or equal to 5, the system will display an alert saying "Go...
codefeedback
Complete the code provided below: from typing import List def sort_numbers(numbers: str) -> str: """ The input is a space-separated string of numerals written in words, ranging from 'zero' to 'nine'. Acceptable inputs include 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', and 'nine'. ...
codefeedback
Develop a neural network model to forecast the landing position of a flipping coin on an irregular and movable surface. Model should also take into consideration the environmental variables such as wind speed and angle of the surface.
codefeedback
Write a SQL query to sort a table based on the values in four columns: 'gender', 'age', 'salary', and 'date_of_birth'. The sorting should be done in the following order: 1. First, sort the table based on the values in the 'gender' column in ascending order. 2. For rows with the same 'gender' value, sort them based on...
codefeedback
You are tasked with creating a program to manage a database of books using Android's content provider and loader framework. Your program should retrieve book information from a content provider and display it in a list view. Each book entry should include the title, author, and publication year. You are provided with ...
codefeedback
Write a function that will create an array with a given size filled with zeroes, then provide a way to edit the size and content of the array without creating a new one. Your solution should work for different sized arrays, not only of size 5 or 10. It should also retain the original order of non-zero elements after th...
codefeedback
I have this problem : Contains Duplicate II Description are as below: Given an integer array `nums` and an integer `k`, return `true` if there are two distinct indices `i` and `j` in the array such that `nums[i] = nums[j]` and the absolute difference of `i` and `j` is at most `k`. Example 1: Input: nums = [1,2,3,1], k...
codefeedback
You are tasked with creating a program that simulates a photo album management system. The system should allow users to add, view, and delete photos, and it should include modal pop-ups for confirming photo deletion and adding new photos. Your task is to implement a class `PhotoAlbum` with the following functionalitie...
codefeedback
You are tasked with implementing a function to determine whether a given path contains a cycle. A path is represented as a sequence of pairs, where each pair consists of a source port and a destination port. A cycle exists if there is a repeated pair within the path. You are given a code snippet that attempts to solve...
codefeedback
What feature of an Object-Oriented Programming language allows its objects to share tasks and data? Provide a detailed explanation of how this feature works, its importance in object-oriented programming, and discuss the potential drawbacks and challenges associated with implementing this feature in large-scale project...
codefeedback
Describe the functionality and use cases of a stack and a queue. Compare and contrast the data structures in terms of their operations, properties, and applications. Additionally, provide a detailed implementation of a program in any programming language that solves a specific problem using a stack and a queue. Your pr...
codefeedback
Increase the level of the programming test question as follows: Program two different functions, `is_palindrome` and `make_palindrome` using recursion. The function `is_palindrome` should return a boolean value indicating if the input string is a palindrome or not, considering the word boundaries (beginning and end of...
codefeedback
Devise a structured library command utilizing advanced window functions available in the PostgreSQL database management system to accurately compute the mean remuneration across every unique business division, while neatly handling any anomalies present and efficiently managing data processing time.
codefeedback
Develop a logistic regression model utilizing Python code to predict the outcomes of a dichotomous genomic dataset, specifically within the realm of oncological diagnostics or binary genetic disorder susceptibility studies.
codefeedback
Write a function in Java to find the intersection of 2 arrays. The intersection is defined as the common elements between the two arrays. Return the intersection as a new array. Example: Input: Array 1: [1, 2, 3, 4, 5] Array 2: [4, 5, 6, 7, 8] Output: [4, 5] Input: Array 1: [10, 20, 30, 40, 50] Array 2: [20, 40, 60, ...
codefeedback
How do I create a trail or motion effect behind this SVG shape? <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M2 6C2 3.79086 3.79086 2 6 2H26C28.2091 2 30 3.79086 30 6V26C30 28.2091 28.2091 30 26 30H6C3.79086 30 2 28.2091 2 26V6Z" fill="#00A6ED"/> <path d="M10....
codefeedback
You are tasked with implementing a caching mechanism for a web application's configuration settings. The application has a class `API` that provides access to various settings, and a class `Cache` that handles caching. The `API` class has a method `GetValueOrDefault` to retrieve settings, and the `Cache` class has a me...
codefeedback
Implement a multi-threaded Java program that simulates a bank transaction system. The program should support the following functionalities: 1. Create a bank account with an initial balance. 2. Allow multiple threads to withdraw or deposit funds into the account simultaneously. 3. Ensure thread safety and avoid race con...
codefeedback
Write a JavaScript program to create an array of the first 1000 Fibonacci numbers that are prime and have a prime index.
codefeedback
Create a React component for a form with three text boxes. Each text box should have the following requirements: - The first text box should only accept alphabetic characters (A-Z, a-z) and have a minimum length of 8 characters. - The second text box should only accept numeric characters (0-9) and have a maximum length...
codefeedback
You are tasked with creating a Python class to manage and plot CPMG (Carr-Purcell-Meiboom-Gill) data for chemical exchange processes. The CPMG experiment is a widely used NMR (nuclear magnetic resonance) technique for studying chemical exchange phenomena in solution-state NMR spectroscopy. Your class should be able to ...
codefeedback
Construct an if condition in Python to check if a given number is a prime number, and optimize the solution to have a time complexity of O(sqrt(n)).
codefeedback
You are presented with a challenge: Identify the Central Node of a Star Graph. The details are as follows: You are dealing with an undirected star graph composed of `n` nodes, each labeled from `1` to `n`. A star graph is defined as a graph with a single central node, and precisely `n - 1` edges that link this central ...
codefeedback
So I have a project that has multiple files regular python, and I'm using a jupyter lab python file as the 'main' file that imports and runs all the rest of the code. But if I make changes to those python files, the jupyter lab file does not automatically respond to updates in those files, and it takes a long time befo...
codefeedback
Write a program that accepts a string as input and assesses if every word in the string begins and ends with the same letter, managing case-sensitivity and ignoring punctuation, returning a boolean value.
codefeedback
At the esteemed Euler University, each of the $n$ scholars (numbered sequentially from 1 to $n$) claims a bed in the dormitory and utilizes a desk in the academic hall. Some of the sleeping arrangements are in private chambers which a scholar occupies solitarily, while the rest are in shared chambers occupied by two sc...
codefeedback
Write a program in Python to reverse not only a single string but a list of strings without using the reverse() function. Each reversed string should maintain the original character case. Additionally, implement your function to handle Unicode characters properly.
codefeedback
Create a program which takes an integer input n (1 <= n <= 20) and prints its factorial. The program should be able to handle large input values efficiently. Additionally, the program should calculate the sum of all the digits in the factorial and print it. The program should also calculate the product of all the digi...
codefeedback