instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Write an SQL query to insert a new record with values 'name': 'Jack', 'age': 25, 'address': 'New York' into a table named 'Employees'. The 'age' field should be a positive integer less than or equal to 100 and the 'name' field should not exceed 50 characters. Additionally, the 'address' field should not exceed 100 char...
codefeedback
Reverse the order of the given array, but instead of using inbuilt functions, implement your own reverse function that takes an array as input and returns a new array with the reversed order of elements. The reverse function should also have a time complexity of O(n), where n is the length of the input array. nums = [...
codefeedback
Given a string, remove all consecutive duplicates in the string. However, you are only allowed to use a constant amount of additional space. The original string must be modified in-place. string = "aabbccddeeff"
codefeedback
Randomly rearrange the elements of the given array and ensure that no two adjacent elements have the same value. nums = [12, 23, 34, 45]
codefeedback
Write a code to replace all the "A"s in the string with a "#" and all the "W"s with a "$". Then, reverse the order of the characters in the string. sentence = "Hello WAAorld"
codefeedback
Design a responsive UI layout in HTML and CSS for an About Us page that includes a navigation bar, a hero image with text overlay, a team section with member cards, a contact form with validation, and a footer with social media icons. The layout should be visually appealing and follow modern design principles.
codefeedback
Create a linear regression model in R from the given datasets, Advertising.csv. Perform the following steps: 1. Import the dataset into R and examine its structure, including the types of variables and the number of observations. 2. Preprocess the data by checking for missing values and outliers. If any are found, dec...
codefeedback
Write a code to find the longest substring of the given string with a length greater than or equal to 2 without repeating letters. Additionally, the code should return the starting and ending indices of the longest substring. The input string will only contain lowercase letters and its length will not exceed 10,000.
codefeedback
Write a code to update the content on the web page with the current time and date. The code should also display the time and date in a specific timezone, which should be determined by the user input.
codefeedback
Write a Python function that takes a list of integers as a parameter and returns the sum of all the odd numbers in the list. The function should have a time complexity of O(n) and a space complexity of O(1).
codefeedback
Write a code snippet to query the Internet Movie Database for the release date of the movie "The Dark Knight", ensuring that the code is asynchronous and uses a callback function to handle the response. Additionally, the code should handle any potential errors that may occur during the API request and provide appropria...
codefeedback
Given a string of characters, write a function in Python that returns only the uppercase characters. The function should ignore any punctuation or whitespace characters in the input string. Additionally, the function should not use any built-in Python functions or libraries that directly solve the problem (e.g., `str.i...
codefeedback
Write a function in Python that takes a 2D array and returns the product of all elements in it. However, the array can contain elements of different data types, including integers, floating-point numbers, and strings. In the case of strings, the function should concatenate them instead of multiplying them. If there are...
codefeedback
Write a Python function that generates a key-value pair for the given array. The key should be the sum of all the elements in the array, and the value should be a list of all the even numbers in the array, sorted in descending order. arr = [1, 2, 3, 4, 5, 6]
codefeedback
Write a function in Python that takes an integer and returns a boolean value specifying whether the number is a prime number or not. The function should have a time complexity of O(sqrt(n)), where n is the given integer.
codefeedback
Write a function in Python that takes a list of strings and checks whether the list is empty or not. If the list is not empty, check whether all strings in the list are of equal length.
codefeedback
Edit the given code to return the elements in the reversed order. You are not allowed to use any built-in reverse or slicing functions. Additionally, you need to optimize the code to use a time complexity of O(N/2) and a space complexity of O(1).
codefeedback
Generate a random password with at least 12 characters that contain both upper and lowercase letters, numbers, and special characters. Additionally, the password should not contain any repeating characters.
codefeedback
Write a function that takes two arguments, a number and a list of integers, and returns all pairs of indices in the list where the sum of the corresponding elements equals the given number. The function should return the pairs in ascending order of their first index. The function should have a time complexity of O(n^2...
codefeedback
Given a sentence, classify each word in the sentence as a noun, verb, adjective, or adverb. The sentence is: "The cat quickly climbed up the tree."
codefeedback
Given a list of positive integers, write a program which partitions the list into two non-empty parts, such that the sum of the elements in the first part is greater than or equal to twice the sum of the elements in the second part. Additionally, the difference between the sums of the two parts should be minimized.
codefeedback
Count the number of words in a sentence that begin with a consonant and end with a vowel.
codefeedback
Given an array of integers, create a program that finds the longest subarray with a sum of 0. Additionally, the program should handle negative numbers and zero in the array, and find the longest subarray with a sum closest to zero.
codefeedback
Design a function which takes a parameter and returns the sum of the cubes of its digits. The parameter can be a positive integer or a string representing a positive integer. The function should handle both cases. #Constraints# - The parameter can have a maximum of 10^6 digits. - The parameter can be any positive inte...
codefeedback
Implement a function in Python that prints a given string character by character, but ensure that the time complexity of your solution is O(n^2), where n is the length of the input string. Additionally, use only constant space complexity (i.e., O(1)).
codefeedback
Write code to implement a double-ended priority queue in Python, where elements can be inserted and removed from both ends of the queue.
codefeedback
Write a code snippet that computes the sum of all prime numbers between 1 and 100, excluding the number 2.
codefeedback
Convert the given English sentence into a Python function definition that takes a string as an input and prints it on the screen. The function should also validate if the input is a valid string and raise an exception if it is not.
codefeedback
Implement a nested for loop in Python that iterates over a 2-dimensional list and prints out each element in a specific format.
codefeedback
Write an R script that performs multiple linear regression to predict a response variable, considering at least three predictor variables and handling any missing data appropriately.
codefeedback
Write a Python function to convert a dictionary into a list of tuples. The dictionary may contain nested dictionaries as values. The output list should contain tuples where each tuple represents a key-value pair from the dictionary. If a nested dictionary is encountered, it should be flattened and represented as a sing...
codefeedback
Write a JavaScript function to generate a random strong password with length 12-15, and must contain at least one uppercase letter, one lowercase letter, one number, and one special character.
codefeedback
Write a MySQL query to display the name and total salary of employees who earn more than the average salary of department 10, and have been employed for at least 2 years. Table "Employees": Name | Department | Salary | Years Employed ------ | ---------- | ------ | -------------- John | 10 | 20000 | 3 Davi...
codefeedback
Write a SQL query to find the mean, median, and mode of all salaries of employees. Table "Employees": Name | Salary ---- | ------ John | 20000 David| 32000 Anne | 15000 Jane | 26000 Note: The mode is the value that appears most frequently in a set of data.
codefeedback
Write a script to delete elements that appear three or more times consecutively in a list.
codefeedback
Explain how Python List Comprehensions work, providing examples and discussing their time and space complexity.
codefeedback
Write a C program to implement a calculator that can perform addition, subtraction, multiplication, and division operations on two numbers. Additionally, the program should be able to handle floating-point numbers and display the result up to a specified number of decimal places.
codefeedback
What is the maximum depth of a binary tree of size n if the binary tree is balanced?
codefeedback
Design an algorithm to check for missing numbers in an array of size n, where the array contains both positive and negative integers, and the missing numbers can be either positive or negative. Additionally, the algorithm should have a time complexity of O(n).
codefeedback
Name a data structure to store a large set of strings efficiently. Explain the advantages and disadvantages of using this data structure.
codefeedback
Design a function for creating an array with n elements, where each element is the sum of its two preceding elements. The first two elements of the array should be 0 and 1.
codefeedback
Design an algorithm that prints all the permutations of a given string, but without using recursion.
codefeedback
Convert a given array of numbers into a square matrix, ensuring that the sum of each row and column is equal to a given target number. Given array = [1, 2, 3, 4], target number = 10.
codefeedback
Create an algorithm to find the longest substring of a given string with distinct characters, where the substring must also contain at least one uppercase letter and one special character. Given string = "abcabcabc".
codefeedback
Write a program that takes an input array of integers and prints out every third element in the array. However, if the third element is divisible by 2, the program should print out the element multiplied by 2 instead. Additionally, if the third element is divisible by 3, the program should skip printing that element al...
codefeedback
Write a Java program for binary search that operates on a sorted array of integers. The program should take an input array and a target integer as parameters and return the index of the target integer in the array. If the target integer is not found in the array, the program should return -1. The program should have a ...
codefeedback
Develop a function to calculate the total amount of the order for an online store, taking into account discounts and taxes. ProductA: 15 ProductB: 10 PriceForProductA: 5 PriceForProductB: 10 DiscountForProductA: 10% DiscountForProductB: 20% TaxRate: 8%
codefeedback
Convert the following floating-point number to its binary representation, using the IEEE 754 standard. Number: 12.25 #Additional Reasoning Steps# 1. Explain the IEEE 754 standard for representing floating-point numbers in binary format. 2. Discuss the different components of the binary representation, such as the sign...
codefeedback
Create a Python dictionary to store employee details for a company that has multiple departments. The first department is the Sales department, and it has one employee named John Doe, who is 25 years old and holds the role of Sales Manager. The second department is the Marketing department, and it has one employee name...
codefeedback
Create an HTML page to display the employee details with a form that allows users to update the employee information. The form should have input fields for the employee's name, age, and role. The employee details should be displayed in a table format. Additionally, implement form validation to ensure that the input fie...
codefeedback
Rewrite this program to use an embedded loop instead of recursion. Additionally, the program should now include a constraint that the solution must have a time complexity of O(n) and a space complexity of O(1).
codefeedback
You are given a string and you want to sort all characters in the string alphabetically in descending order.
codefeedback
Create a SQL table with the following schema: id (integer), name (string), city (string), and email (string). The email field should only accept valid email addresses in the format "example@example.com".
codefeedback
You are given a string that consists of words separated by spaces. Your task is to count the number of unique words in the string. The words are case-sensitive, so "hello" and "Hello" are considered different words. You should ignore any punctuation marks or special characters that may be present within the words. Addi...
codefeedback
Provide the big-O complexity for a binary search algorithm with the additional constraint that the input array must be sorted in ascending order before performing the search.
codefeedback
Implement an efficient algorithm that takes as input two positive integers and calculates their greatest common factor. The algorithm should run in O(log(min(a, b))) time complexity, where a and b are the input integers.
codefeedback
Write a function that uses regular expressions to match two strings, where the second string must be a palindrome and contain at least one digit.
codefeedback
Write a MIPS code that adds two numbers and stores the result in a given memory address, but you are not allowed to use the add instruction. You can only use the bitwise operations to perform the addition. The two numbers to be added are stored in the registers $t1 and $t2, and the memory address to store the result is...
codefeedback
Write an SQL Query to print a list of all employees who have a higher salary than their managers, considering that each employee can have multiple managers and each manager can have multiple employees. The query should also include the department name of each employee.
codefeedback
Create the following function that parses a valid IP address from a string and returns the address string without delimiters and periods. However, the function should also handle cases where the input string may contain multiple IP addresses separated by commas. In such cases, the function should return a list of the p...
codefeedback
Write a code to compute the XOR of two 64-bit integers, each represented as an array of 64 bits. The XOR operation should be performed bit by bit. Example: A = [1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1,...
codefeedback
Write Swift code to get the sum of all the prime numbers from 1 to 1000.
codefeedback
Create a function to format a given phone number in the format "123-456-7890" and output a string with the canonical format of "+1-123-456-7890". The function should also handle cases where the phone number is passed in as a string or with additional characters such as spaces or parentheses.
codefeedback
Given a single linked list, reverse it in place. The linked list can contain duplicates. Additionally, you are not allowed to use any extra data structures or recursion in your solution. Head -> 1 -> 2 -> 3 -> 4 -> 5 -> 3 -> 2 -> 1 -> None
codefeedback
Use the requests library to make an API call to the endpoint "https://api.example.com/v1/users" with a POST request, passing a JSON payload containing a user's name, email, and password. Return the response as JSON.
codefeedback
Generate a SQL query to retrieve all records from the USERS table where the gender is 'Male' and the age is greater than 30.
codefeedback
Make a function in Python which calculates the covariance between two given lists. list1: [1, 2, 3, 4, 5, 6] list2: [3, 4, 2, 4, 5] Please note that the length of the two lists is not the same.
codefeedback
Write a for loop that prints out the series: 1, 5, 9, 13
codefeedback
Write a formula in Excel to calculate the total cost of a trip given the cost and quantity, but with the following additional conditions: - The cost of hotel can vary depending on the day of the week. You need to retrieve the cost of hotel for each day from a separate sheet in the Excel workbook. - The quantity of room...
codefeedback
Create a method in JavaScript that takes a comma-separated list of values as an argument and returns an array containing those values. However, the method should also handle cases where there are leading or trailing spaces before or after each value in the list. Additionally, if any value in the list is a string enclos...
codefeedback
Convert the following string to an array of characters in Java, but exclude any vowels from the array. String str = "Hello World!"
codefeedback
You need to read a code and check if it uses the best practices for writing code. Output true if it does, false if it does not. The code should be implemented using recursion. Ensure that the code handles edge cases, such as empty arrays and arrays with duplicate elements, correctly.
codefeedback
Create a list of all prime numbers between 0 and 100.
codefeedback
Write an assembly language code to find the sum of two values stored in memory. The code should also check if the result exceeds a certain threshold value and display an error message if it does.
codefeedback
Generate a random array of size n in Python. The array should only contain unique elements and should be sorted in ascending order. Size of array: 5
codefeedback
Given a string, you need to write a regular expression that finds all the words that start with a caret (^) symbol and have at least 3 characters. The regular expression should ignore any leading or trailing spaces in the string. String: "This is a ^test string with ^multiple ^words and ^characters of different lengths...
codefeedback
Create a Ruby script to output the first 20 fibonacci numbers, but without using recursion.
codefeedback
Simplify the following expression by applying the distributive property and then combining like terms: (3x + 2y)(5x - 3)
codefeedback
Compute the GCD of two numbers without using any built-in functions from your language. The numbers can be positive or negative, and can have up to 10^9 digits. Number1: -123456789123456789 Number2: 987654321987654321
codefeedback
Given a linked list, swap the positions of the two nodes at the specified positions in the list. Linked List: 1->2->3->4->5 Positions: 2, 4
codefeedback
Find the most common word in the given paragraph and replace all occurrences of it with a synonym. Additionally, ensure that the replacement maintains the same grammatical form as the original word. The paragraph may contain punctuation and multiple lines of text. The solution should be case-insensitive and should cons...
codefeedback
Create a random password generator in Python that outputs 15 characters of random alphanumeric characters, including at least one uppercase letter, one lowercase letter, and one special character.
codefeedback
Write a code in Python to convert the following string to an integer and calculate its factorial. "12345"
codefeedback
Write a Python code to count the number of uppercase characters in the given string. The string should contain at least one lowercase character.
codefeedback
Write an SQL statement that creates a table named 'students' with the following columns: "name" (string), "id" (integer), "major" (string), "age" (integer), and "gpa" (float). The table should also have a primary key constraint on the "id" column and a foreign key constraint on the "major" column, referencing a table n...
codefeedback
Return the maximum number from a given array of integers, but with the following additional conditions: 1. You are not allowed to use any built-in functions or methods that directly give you the maximum value in the array (e.g. max() in Python). 2. You are not allowed to sort the array in any way. 3. You must find the ...
codefeedback
Create a function using Ruby that takes in a string, and returns a new string that only consists of the vowels from the original string. Additionally, the function should only consider vowels in the string that are in alphabetical order. For example, if the input string is "aeiou" or "aeiouy", the function should retur...
codefeedback
Write an SQL query to list all customers who are over the age of 25 and have made a purchase within the last month.
codefeedback
Write a PHP function that takes a string and returns the same string with all vowels replaced with the letter 'x'. The function should also remove any consecutive occurrences of the letter 'x' in the resulting string.
codefeedback
Generate a best-fit line for a set of data points in Python. The data points are represented as a list of tuples, where each tuple contains two values: the x-coordinate and the y-coordinate. The number of data points can be up to 10^6. Additionally, the time complexity of the solution should be O(n), where n is the nu...
codefeedback
Create a function in Node.js that prints out the numbers between 0 and a given limit, but also adds a "0" before each even number. For example, if the limit is 10, the output should be: "0, 1, 02, 3, 04, 5, 06, 7, 08, 9, 010".
codefeedback
Calculate the result of the following expression: (63 × 42) + 17 ÷ 4 - 8 × 2
codefeedback
Create a code in C# that takes an array of numbers and prints out the second smallest number in the array. A = [9, 8, 12, 4, 7, 10, -2, 6, 11, 5] In addition, handle the case when the array is empty or contains only one element by printing an appropriate message.
codefeedback
Write a C++ program that takes two 2D arrays and compares them for equality, considering that the arrays can have a maximum size of 100x100 and each element can range from -100 to 100. Additionally, the program should display the number of elements that are equal and the number of elements that are different between th...
codefeedback
Design a module in JavaScript that sorts an array of integers starting from the smallest number. The sorting algorithm should have a time complexity of O(n log n). Additionally, the module should be able to handle arrays with a maximum size of 10^6 elements and integers with a maximum value of 10^9. The module should...
codefeedback
Write a function in Python that returns the greatest common divisor (GCD) of two numbers. The function should have a time complexity of O(log(min(n1, n2))) and a space complexity of O(1). n1 = 7894, n2 = 12463
codefeedback
You are given a list of float numbers. Write a code to sort them in ascending order. The code should not use any built-in sorting functions or libraries. The algorithm should have a time complexity of O(n^2) or better. arr = [2.5, 3.2, 2.1, 4.6, 1.6]
codefeedback
Write a code that generates a random password of 8 characters including at least one uppercase letter, one lowercase letter, one numerical digit, and one special character.
codefeedback
Generate a valid SQL query to delete all the records from the 'Employee' table where the employee's salary is above a certain threshold. The threshold should be a parameter that can be easily modified.
codefeedback
Given an array of integers, write a method to return the indices of the two numbers such that they add up to a specific target. For example, consider the array nums = [2, 5, 11, 15] and the target value is 9. The indices of the two numbers that add up to the target are 0 and 1. Your task is to implement a function th...
codefeedback