instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Create a program that takes a string as input and outputs an array of words. Each word should be in uppercase and sorted in alphabetical order. The program should ignore any punctuation marks or special characters in the string. The input string should have a minimum length of 10 characters.
codefeedback
Implement a password validator in Java that meets the following requirements: - The password must contain at least one uppercase letter. - The password must contain at least one lowercase letter. - The password must contain at least one digit. - The password must contain at least one special character (!, @, #, $, %, ^...
codefeedback
Create a for loop to iterate over a list of words and print their length. However, exclude any words that contain the letter "e". words = ["happy", "sad", "tired", "energetic"]
codefeedback
Write a program in Python that connects to a MySQL database, selects a specific table, and deletes a specific row from that table based on a given condition.
codefeedback
What is the most efficient way to check if a given number is a prime in Python, while also ensuring that the solution has a time complexity of O(sqrt(n)) and does not use any built-in libraries or functions for prime number generation or factorization?
codefeedback
Replace the last occurrence of a given word in a string, making sure the replacement is case-insensitive and maintaining the original capitalization of the word in the replaced string. str = "Welcome to the world of Python, where PYTHON is widely used" word = "python"
codefeedback
Write a code in Java to find all the prime numbers between 0 and n, where n can be as large as 10^9. Additionally, the code should be optimized to run within a time complexity of O(nlog(logn)).
codefeedback
Programmatically calculate the sum of the first 20 prime numbers.
codefeedback
Using the given array, write a function to return the count of elements next to each other that are equal. Also, handle the case where the array is empty or contains only one element. a = [1,1,1,2,2,3,4,4,4,4]
codefeedback
You are working on a Java application and need to implement a method that reads data from a file and performs some operations on it. However, there is a possibility that the file may not exist or may be corrupted. In such cases, you need to cleanly exit from the method using exceptions. Write a Java method that takes ...
codefeedback
Using a unique function in JavaScript, remove the duplicate values in the given array. However, you are not allowed to use any built-in JavaScript functions or libraries to achieve this. You must implement the removal of duplicates yourself.
codefeedback
Construct a RegEx pattern to identify a number followed by three uppercase letters, with the condition that the number must be divisible by 5.
codefeedback
Using the given array, create a function that returns a new array that contains elements that are greater than the given number. However, there is a bug in the code that needs to be fixed. Find and correct the error before running the code. arr = [2, 3, 6, 9, 5] num = 4
codefeedback
Find the first occurrence of a repeated letter in the given string. ## Example ## ### Input ### string = "abcde" ### Output ### Index: -1 ### Explanation ### There are no repeated letters in the given string, so the output is -1.
codefeedback
Create an array of numbers that is a random combination of integers from 1 to 50. Additionally, ensure that the array does not contain any duplicate numbers.
codefeedback
Find all possible permutations of the string "ABC" that start with the letter "A".
codefeedback
Estimate the complexity (Big-O) of this algorithm. arr = [3, 4, 7, 5, 6] def find_average(arr): total = 0 for num in arr: total += num num_squared = num ** 2 # additional requirement: calculate the square of each number return total / len(arr)
codefeedback
Design a CSS stylesheet to color alternate rows in a table grey, but ensure that the colors alternate in a zigzag pattern starting from the first row being grey.
codefeedback
Find the longest substring of a string without repeating characters and with at least one uppercase letter and one special character. string="aB$cAbcbb"
codefeedback
What is tail recursion optimization and how does it differ from regular recursion?
codefeedback
Convert the following XML code to JSON, while ensuring that the output JSON format follows the naming conventions specified in a separate configuration file. Additionally, the solution should handle XML elements with attributes and include them in the JSON output.
codefeedback
Write Python code to return the count of all occurrences of substrings in a given string. string= "hi world bye world" Example output: hi: 1 world: 2 bye: 1
codefeedback
Design a React JS component to render a button that displays the text "Click Me" only if the user has successfully authenticated with a back-end server and has the necessary permissions. If the user is not authenticated or lacks the necessary permissions, the button should be disabled and display the text "Unauthorized...
codefeedback
Develop a MATLAB function to calculate the product of two matrices, but without using the built-in matrix multiplication function (e.g., `*` or `matmul()`). Instead, you must implement your own algorithm to compute the matrix product.
codefeedback
Create a Dictionary where the list items are the keys and the square of the items are the values, but you are not allowed to use any built-in Python functions or operators to calculate the square of a number. myList1 = [1, 2, 3, 4, 5, 6]
codefeedback
You are given an expression tree, where each node represents either an operator or an operand. The operators can be one of the four basic arithmetic operations: addition (+), subtraction (-), multiplication (*), and division (/). The operands are integers. Your task is to write a function that takes the expression tre...
codefeedback
Sort the given list in ascending order without using any built-in sorting functions. myList = [3, 1, 8, 2, 6, 5]
codefeedback
Create a function that takes 2 strings as arguments, and returns the longest string. The function should also remove any duplicate characters in the returned string.
codefeedback
Design a function with three inputs that returns the maximum of the three.
codefeedback
Modify the below code so that it swaps two variables without the use of a temporary variable and without using any arithmetic operators or bitwise operations. The solution should only use logical operations and the assignment operator. int a = 10, b = 20; int temp; temp = a; a = b; b = temp;
codefeedback
Given a string, replace all vowels in the string with a specified letter. The specified letter should be obtained by shifting the original vowel's ASCII value by a given number of positions. The ASCII values of vowels are as follows: 'a' = 97, 'e' = 101, 'i' = 105, 'o' = 111, 'u' = 117. The given number of positions ca...
codefeedback
Write a number of HTML tags such that their end tags are mismatched and the total number of opening and closing tags is greater than 10.
codefeedback
Create a function that returns the sum of two numbers passed as arguments, with the additional requirement that the function must handle floating point numbers and round the result to the nearest integer.
codefeedback
Find the index of the element that occurs only once in the array. However, you are not allowed to use any built-in functions or libraries to solve this problem. You must implement the solution using only basic data structures and algorithms provided by the programming language. arr = [1, 1, 5, 5, 6, 8];
codefeedback
Describe the necessary steps to debug a complex multi-threaded python program, ensuring that the program executes without any errors or race conditions, and include techniques to handle exceptions and handle memory leaks efficiently.
codefeedback
Create a function to sort an array of objects by the value of a certain key in descending order. The key will always be a string containing a valid Python identifier. The array will always contain at least one object, and each object will always have the key specified. Example: arr = [{'name': 'john', 'age': 20}, {'na...
codefeedback
Given an array of integers, find the pair of elements that have the greatest difference. The pair must also satisfy the condition that the larger element is located at an index greater than the smaller element. The array can have duplicates, and the solution must handle them correctly. If multiple pairs have the same m...
codefeedback
Create a function that takes in a 2D list and prints the contents of the list in a 2D format. However, you are not allowed to use any built-in functions or libraries in your solution. The input list will always be rectangular, meaning that all inner lists will have the same length. matrix = [ [1, 2], [3, 4], ...
codefeedback
Write a C# program to remove all adjacent duplicates from a string, while also considering case sensitivity. string str = "aabbA";
codefeedback
Given a dictionary of words, write Python code to find out the longest word in the dictionary that starts with a vowel and ends with a consonant. The dictionary should contain at least 10 words and each word should be at least 5 characters long. dictionary = ["apple", "orange", "pineapple", "banana", "elephant", "umbre...
codefeedback
Write a JavaScript function that converts a given time in the format HH:MM (24-hour format) to the 12-hour format, including the AM/PM indicator. The function should return the converted time as a string. For example, if the input is "15:30", the function should return "3:30 PM".
codefeedback
Write an HTML webpage to display a table with employee details. The employee details should be fetched from an API endpoint and dynamically populated in the table. Additionally, provide a search functionality where the user can filter employees based on their names.
codefeedback
Construct an SQL query to delete a row from a table named "Employees" where the value of the column "Salary" is greater than the average salary of all employees in the table.
codefeedback
Design a function in Java that rotates a N x N matrix 90 degrees counterclockwise.
codefeedback
Create a program that dynamically generates an HTML table with the following specifications: - The table should have a header row with 5 columns. - Each column should have a unique name. - The background color of the header row should be set to lime. - The table should have 10 rows of data, excluding the header row. - ...
codefeedback
Construct a webpage that displays a list of 100 hyperlinks. Each hyperlink should have a randomly generated text of length between 5 and 20 characters, and a link that redirects to a randomly generated URL. The webpage should be able to handle at least 1000 concurrent user requests without any performance degradation.
codefeedback
Create a function in PHP that takes two numbers as input: a starting number and an ending number. The function should calculate the sum of all the cubes of the odd numbers between the starting and ending numbers (inclusive).
codefeedback
Create an algorithm in MATLAB for sorting an array of integers in ascending order using the bubble sort algorithm. arr = [8, 3, 5, 9, 4] #Hint 1# The bubble sort algorithm works by repeatedly swapping adjacent elements if they are in the wrong order. This process is repeated until the array is fully sorted. #Hint 2# ...
codefeedback
Can you draft an algorithm in C# for computing the factorial of a number? The input number can be a large integer, up to 10^6. The algorithm should be able to handle this large input efficiently.
codefeedback
Suggest an efficient algorithm to count the number of unique three-letter words in a given string. The algorithm should have a time complexity of O(n), where n is the length of the string. Additionally, the algorithm should use constant space, i.e., O(1) space complexity.
codefeedback
Suggest a line of code in Rust for generating a random number within a given range, but ensure that the generated number is always a prime number.
codefeedback
Generate the first 10 prime numbers that are also palindromes.
codefeedback
We would like you to suggest a method written in TypeScript for reversing a string. The method should be able to handle strings containing alphanumeric characters, punctuation, and white spaces. Additionally, you should not use any built-in string manipulation functions or methods. Store the reversed string in a new va...
codefeedback
Modify the code to print the second largest number in a list of positive integers less than 100. Ensure that the code handles cases where the list contains duplicate numbers. The code should also return an error message if the list is empty or contains less than two numbers. num_list = [3, 6, 8, 4, 12, 20, 7]
codefeedback
Design an HTML form with 2 input fields: name and email and submit button. Upon submitting the form, validate the input fields to ensure that: 1. The name field is not empty and contains only alphabetic characters. 2. The email field is not empty and contains a valid email address format (e.g. example@example.com). If...
codefeedback
What will be the output of this code snippet? a = [1, 2, 3, 4, 5] b = [x**2 for x in a if x%2 == 0] print(b)
codefeedback
You are given a 2D array. The task is to double each item in the array and then square each doubled item. arr = [[1,2], [3,4]]
codefeedback
You need to generate an API which returns the first 10 Fibonacci numbers that are divisible by 3.
codefeedback
Rewrite this program in C language without using any arithmetic operators. int x = 5; int y = 7; int z = 0; for(int i=0; i<x; i++){ z++; } for(int i=0; i<y; i++){ z++; } printf("%d", z);
codefeedback
Create a function to calculate the Fibonacci number at the inputted index, but the function should have a time complexity of O(2^n), where n is the inputted index.
codefeedback
Write Python code to reverse the letters in a given sentence.
codefeedback
Create a function that takes an array of positive integers and returns an array where each index is the product of all the numbers except for the number at that index. The input array will not contain any negative numbers or zeros. lst = [2, 4, 6, 8, 10]
codefeedback
Create a function that returns an array of the five most common elements in an array. Additionally, the function should handle cases where there are ties for the most common elements. lst = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5] # Expected output: [4, 3, 2, 5, 1]
codefeedback
Write a function that takes in two numbers in Roman numerals and outputs the product.
codefeedback
Create a function to detect whether a given character is a vowel or not, while also considering additional rules for certain cases.
codefeedback
Implement a "while" loop in JavaScript that prints all prime numbers between 1 and 100.
codefeedback
Given two strings, create a function to find the total number of occurrences of the second string in the first string. The function should also account for overlapping occurrences. For example, if the first string is "hellollo" and the second string is "lo", the function should return 2, as "lo" appears twice in the f...
codefeedback
Generate a random hexadecimal color code in Ruby that meets the following requirements: 1. The time complexity of generating the color code should be O(1). 2. The space complexity of generating the color code should be O(1). 3. The generated color code should be unique and not repeat within a certain number of consecut...
codefeedback
Construct a SQL query to find the maximum salary from a table named "employees", where the employees are grouped by their respective departments and only considering employees who have been working for at least 5 years. Additionally, display the department name and the number of employees in each department who have a ...
codefeedback
Construct a SQL query to count the number of occurrences of a certain value in a particular column of a table, but the column contains data of type JSON and you need to extract the value using a specific JSON path expression.
codefeedback
Write a program that generates an Apache configuration file for a web server. The program should prompt the user to enter the name of the index document and the root directory of the website. The program should then generate a configuration file that sets the specified index document as the default for the web server a...
codefeedback
Write a function that takes a list of integers and returns a new list with all duplicate numbers removed, while maintaining the original order of the remaining elements. [5, 9, 7, 2, 7, 4, 3, 4, 2, 9, 1, 6, 8, 5] #Additional Constraints# - The function should have a time complexity of O(n). - The function should have...
codefeedback
Create an array from 0 to n-1, where n is a positive integer. n can be as large as 10^6.
codefeedback
Implement a function in JavaScript that can accurately determine the type of a given variable, including but not limited to primitives, objects, arrays, and functions. The function should be able to handle nested structures and return the precise type for each element within the structure. Additionally, the function sh...
codefeedback
Find the length of the longest increasing subsequence in an array where the elements are distinct and greater than 0. Additionally, the length of the array should not exceed 10^6. Consider an array arr = [10, 22, 9, 33, 21, 50, 41, 60].
codefeedback
Explain the concept of a hash table and its usage in programming. Provide an example of implementing a hash table in a programming language of your choice and demonstrate its functionality.
codefeedback
Write a SQL query to count the number of employees in a department with id “IT-006” and whose salary is above the average salary of all employees in the department.
codefeedback
Write a function that takes a sentence as an argument and returns a Dictionary of all the unique words and their counts in the sentence. The function should not be case-sensitive, meaning that 'The' and 'the' should be considered the same word. The function should also ignore any punctuation marks. For example, in the ...
codefeedback
Convert the following number from binary to decimal form: 110111011011. #Difficulty Increase Reasoning# The original test question was relatively simple as it only required converting a 4-bit binary number to decimal form. By increasing the number of bits in the binary number to 12, the difficulty is significantly inc...
codefeedback
Optimize this SQL query to reduce the runtime and limit the number of returned rows to only the latest 10 orders for a specific customer.
codefeedback
Create a function that takes in an input string and a delimiter, and returns a list of words that were separated by the delimiter. The function should ignore any delimiter that is surrounded by double quotes. Additionally, if a word is enclosed in double quotes, it should be treated as a single entity and not be split ...
codefeedback
Write a Python program to calculate the median of a given list of numbers. The list may contain an odd or even number of elements.
codefeedback
Create a regular expression pattern to match a string composed of lowercase letters "a" through "e", with no other characters. Additionally, the string must not contain any consecutive duplicate letters.
codefeedback
Create an algorithm to evaluate a given expression with multiple nested parentheses and complex mathematical operations. (3 + 5) * 2 - 4 / 2 + 10 % 3 * (6 - 2)
codefeedback
Create a Python class with methods that accept a value and increase the stored value by 5. The class should also have a method that returns the current value and a method that checks if the current value is divisible by 3. Additionally, the class should implement a counter that keeps track of the total number of times ...
codefeedback
Generate a SQL query to select all students who are in the 'Computer Science' program and have a GPA above 3.5. table_name = 'students' #Updated Difficulty Reasoning# Adding an additional condition to the query requires the candidate to understand and utilize the WHERE clause in SQL to filter results based on multiple...
codefeedback
Reverse the elements of a given array without using any additional storage. The input array should be modified in-place. int[] array = {1, 2, 3, 4, 5};
codefeedback
Create an assembly program that takes an integer as input and displays the sum of digits of that number. Additionally, the program should validate that the input number is within the range of -100 to 100 (inclusive) and display an error message if the input is outside this range.
codefeedback
Create a C++ program that takes a string as input, and returns the most frequently occurring character. Additionally, the program should ignore any occurrences of whitespace characters and only consider alphabetical characters in the calculation.
codefeedback
Create an HTML page to display the attendance of students in an academic year. The attendance data is provided as an array of objects in JSON format. Each object represents a student and contains the following properties: - `name`: the name of the student (string) - `attendance`: the attendance percentage of the studen...
codefeedback
Create a responsive HTML page to display a weather forecast for the selected city, with an additional requirement of including an interactive map displaying the location of the city. The page should also include a search functionality to allow the user to select a different city and view its weather forecast. The weath...
codefeedback
Create a C Program that takes an array of integers and returns an array of the prime numbers present in the array, using only bitwise operators for all calculations. The program should also implement a custom sorting algorithm that sorts the prime numbers in descending order. The program should be able to handle arrays...
codefeedback
Explain why the use of a loop with a time complexity of O(nlogn) is often the best solution for a problem involving the sorting of an array of size n.
codefeedback
Implement a linked list class in Python with the following functionalities: - Insert a node at the beginning of the list - Insert a node at the end of the list - Insert a node after a specific node in the list - Delete a node from the list - Get the size of the list - Check if a value exists in the list - Reverse the ...
codefeedback
Implement a function to rotate a list by k elements in reverse order. list = [1,2,3,4,5], k = 2
codefeedback
You are given two strings and you need to output true if they are anagrams of each other, false otherwise. An anagram is a word or phrase formed by rearranging the letters of another word or phrase. The anagram should also contain at least one vowel and one consonant. If both strings are empty or do not meet the requir...
codefeedback
Create an HTML page that displays a table with names, ages, and phone numbers of 10 people. The table should be sorted in ascending order based on their ages. Each name should be a hyperlink that redirects to a separate HTML page displaying more details about that person, including their address and email. The email sh...
codefeedback
Write an SQL query to select all employees whose last name is Johnson and whose salary is greater than $50,000.
codefeedback
Write a PHP program to flatten a multi-dimensional array, but without using any built-in functions or methods for flattening arrays.
codefeedback
Write a function to concatenate two strings in Python. The function should have a time complexity of O(1) and should not use any built-in string concatenation methods such as the + operator or the join() function.
codefeedback