messages listlengths 2 2 |
|---|
[
{
"role": "user",
"content": "You are given some HTML code, write a function to strip the tags from it. Additionally, make sure that the function handles nested tags correctly."
},
{
"role": "system",
"content": "To strip HTML tags from a given HTML code while handling nested tags correctly, we ... |
[
{
"role": "user",
"content": "Create a data structure to store an employee's details including his personal details, such as name, address, and contact information, as well as his salary information including basic salary, bonus, and deductions. Additionally, design a method to calculate the net salary afte... |
[
{
"role": "user",
"content": "Write a regex pattern to extract all words containing the letter 'a' or 'e' from a given string."
},
{
"role": "system",
"content": "The regex pattern to extract all words containing the letter 'a' or 'e' from a given string can be written as:\n\n\\b\\w*[ae]\\w*\\b\... |
[
{
"role": "user",
"content": "Define a function which takes two strings as arguments and returns a list containing all characters that appear in either string, excluding any duplicate characters.\nstring_1 = 'Apple'\nstring_2 = 'Banana'\n\n# Test Case 1:\n# The characters 'A', 'p', 'l', and 'e' appear in st... |
[
{
"role": "user",
"content": "Generate an array containing numbers between 1 and 100 that are divisible by both 5 and 7, with a time complexity of O(n) and space complexity of O(1)."
},
{
"role": "system",
"content": "To generate an array containing numbers between 1 and 100 that are divisible b... |
[
{
"role": "user",
"content": "You are given two strings of lowercase letters, find the minimum number of operations required to make them equal. You can perform three types of operations:\n\n1. Insert a character\n2. Delete a character\n3. Replace a character\n\nThe cost of each operation is equal to 1. You... |
[
{
"role": "user",
"content": "Create a class to represent a student's report card. The report card should store the student's grades for multiple subjects, as well as calculate the average grade. The class should have the following methods:\n\n1. `add_grade(subject: str, grade: float)`: Adds a grade for a s... |
[
{
"role": "user",
"content": "Design a data structure to track the frequency of words in a given text, while also maintaining the order of the words in the text."
},
{
"role": "system",
"content": "To design a data structure that tracks the frequency of words in a given text while maintaining th... |
[
{
"role": "user",
"content": "Explain the importance of using functions in programming and provide a practical example where the use of functions greatly simplifies the code."
},
{
"role": "system",
"content": "Functions are essential in programming as they allow for code reuse, modularity, and ... |
[
{
"role": "user",
"content": "Find the maximum value of an array without using any built-in functions and with a time complexity of O(n) and a space complexity of O(1).\n[7, 9, -2, 15, 3]"
},
{
"role": "system",
"content": "To find the maximum value of the array without using any built-in functi... |
[
{
"role": "user",
"content": "Create a hashtable in Python of size 10^6 and insert 10^5 elements."
},
{
"role": "system",
"content": "Here's an example of how you can create a hashtable in Python of size 10^6 and insert 10^5 elements:\n\n```python\n# Importing the `hashlib` module to generate ha... |
[
{
"role": "user",
"content": "Write a code snippet to produce an XML result for a given input data structure. The input data structure may contain nested dictionaries and lists. \n\nFor example, given the following input data structure:\n{\n \"key1\": \"value1\",\n \"key2\": {\n \"key2.1\": \"v... |
[
{
"role": "user",
"content": "Write a predicate function to check whether the given string is palindrome. A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. The function should ignore any spaces and punctuation marks in the string."
},
{
... |
[
{
"role": "user",
"content": "Construct a code to get the last index of a given substring in a string. The substring should be case-sensitive and must be at least two characters long. The input string should contain at least one occurrence of the given substring. If there are multiple occurrences of the sub... |
[
{
"role": "user",
"content": "Create a loop in Python with the given requirements.\nPrint out the numbers from 1 to 10, inclusive.\n\nHowever, modify the program to only print the even numbers in the range from 1 to 10."
},
{
"role": "system",
"content": "Here is a Python code snippet that fulfi... |
[
{
"role": "user",
"content": "How would you reverse the elements in this array without using any additional data structures and in-place?"
},
{
"role": "system",
"content": "To reverse the elements in an array without using any additional data structures and in-place, you can follow the steps be... |
[
{
"role": "user",
"content": "Write a Python function that prints the square of each number in a given list of integers."
},
{
"role": "system",
"content": "Here is a Python function that prints the square of each number in a given list of integers:\n\n```python\ndef print_square(numbers):\n ... |
[
{
"role": "user",
"content": "Given a text string, write a function in Python to identify all the words that have more than 5 characters and are not repeated within the same sentence.\ntext = \"Python is an easy to learn language, but Java is also a widely used language.\""
},
{
"role": "system",
... |
[
{
"role": "user",
"content": "Given two arrays of integers, write a Python function which is able to identify common elements. However, you are not allowed to use any built-in functions or libraries, such as set() or intersection(), to find the common elements. You must come up with your own algorithm to so... |
[
{
"role": "user",
"content": "Design a class named \"Rectangle\" that prints out the length, width, area and perimeter of a given rectangle. Additionally, implement a method called \"isSquare\" that returns true if the rectangle is a square and false otherwise."
},
{
"role": "system",
"content":... |
[
{
"role": "user",
"content": "Construct a while loop that continuously adds all elements of a list until reaching a certain number. The sum must be calculated using a recursive function. The list must contain only positive integers. The maximum length of the list is 100. The sum_num must be a positive integ... |
[
{
"role": "user",
"content": "Create a function to update the existing item of a dictionary with a new value. Additionally, if the value is a list or a dictionary, the function should check for any nested values and update them as well.\n\nFor example:\nmydict = {\n \"name\": \"John\",\n \"age\": 25,\n \... |
[
{
"role": "user",
"content": "Create a loop which prints out the ASCII values of each character in a given input, a = 'Hello World!'"
},
{
"role": "system",
"content": "Here is a loop in Python that prints out the ASCII values of each character in the given input:\n\n```python\na = 'Hello World!... |
[
{
"role": "user",
"content": "Design a function which can check if a given year is a leap year and also determine if it falls on a Gregorian calendar."
},
{
"role": "system",
"content": "To design a function that checks if a given year is a leap year and also determines if it falls on a Gregoria... |
[
{
"role": "user",
"content": "Construct a function that converts a given temperature from Celsius to Fahrenheit. However, the function should also be able to handle input temperatures in Kelvin and Rankine. If the input temperature is in Kelvin, the function should convert it to Fahrenheit by first converti... |
[
{
"role": "user",
"content": "Given a JSON object containing an array of fruits, each with a type and count, find the total count of each type of fruit and display them in descending order based on the count.\n\n{\n \"fruits\": [\n { \"type\": \"apple\", \"count\": 10 },\n { \"type\": \"ora... |
[
{
"role": "user",
"content": "Create a loop that prints 'hello' 10 times when ran. However, each time the word 'hello' is printed, it should be capitalized every other time starting from the second iteration."
},
{
"role": "system",
"content": "Here's an example of a loop that prints 'hello' 10 ... |
[
{
"role": "user",
"content": "Create a while loop that prints all the lowercase letters of the alphabet in reverse order."
},
{
"role": "system",
"content": "Here is an example of a while loop that prints all the lowercase letters of the alphabet in reverse order:\n\n```python\nletter = ord('z')... |
[
{
"role": "user",
"content": "Given a matrix of integers, delete the row or column that contains the least number of prime numbers."
},
{
"role": "system",
"content": "To solve this problem, we need to count the number of prime numbers in each row and column of the given matrix. We can create a ... |
[
{
"role": "user",
"content": "Parse a JSON string and transform it into an array. Handle cases where the JSON string is nested or contains arrays as values.\n\nExample:\n'{\"name\": \"John Doe\", \"age\": 30, \"city\": \"New York\", \"hobbies\": [\"reading\", \"painting\"], \"friends\": {\"1\": \"Alice\", \... |
[
{
"role": "user",
"content": "Use Python to generate a random string of length 8 using lowercase alphabetic characters. Additionally, the string should contain at least one uppercase alphabetic character and at least one numeric digit."
},
{
"role": "system",
"content": "You can use the `random`... |
[
{
"role": "user",
"content": "Write a code snippet to implement bubble sorting in an array of 100 numbers. Additionally, handle the case where the array is already sorted in ascending order and return immediately without any unnecessary iterations."
},
{
"role": "system",
"content": "Here's a co... |
[
{
"role": "user",
"content": "Write a code snippet for a function that deletes all occurrences of a specific element from an array."
},
{
"role": "system",
"content": "Here is a code snippet for a function that deletes all occurrences of a specific element from an array in Python:\n\n```python\n... |
[
{
"role": "user",
"content": "Given an array of integers, print the elements at odd indices. If the array has an even number of elements, consider the last element as the \"middle\" element and exclude it from the output. \n\nFor example, for the input [2, 5, 9, 8, 6], the output should be 5 and 8. \n\nTo s... |
[
{
"role": "user",
"content": "Given an XML string, parse the string and print the tag names and their corresponding values. Additionally, implement error handling to handle cases where the XML string is invalid or if a required tag is missing.\n\nExample input:\n<xml><title>HelloWorld!</title><body>This is ... |
[
{
"role": "user",
"content": "Determine the sum of the first n elements in a given array.\nAn array containing [2, 4, 6, 8, 10]\n\n#Updated Test#\nDetermine the sum of the first n odd elements in a given array.\nAn array containing [2, 4, 6, 8, 10]"
},
{
"role": "system",
"content": "To determin... |
[
{
"role": "user",
"content": "Write a code to generate a random password with a given length. The password should contain at least one uppercase letter, one lowercase letter, one digit, and one special character."
},
{
"role": "system",
"content": "Here's an example code in Python that generates... |
[
{
"role": "user",
"content": "How would you use a for loop to print the index and item of a list, but with the following additional conditions:\n\n1. Only print the index and item if the item is a string.\n2. Print the index in ascending order, starting from 1.\n3. Only print the index and item if the index... |
[
{
"role": "user",
"content": "Write a Python function that takes in two parameters, `n` and `m`, and prints a string of length `n` filled with `m` asterisks.\n\nThe function should first check if `n` is a positive integer greater than 0. If it is not, the function should raise a ValueError.\n\nThe function ... |
[
{
"role": "user",
"content": "How would you use a while loop to sum up numbers from 0 to n, while also ensuring that the sum is only calculated for odd numbers?"
},
{
"role": "system",
"content": "To use a while loop to sum up odd numbers from 0 to n, you can follow these steps:\n\n1. Initialize... |
[
{
"role": "user",
"content": "Convert a given number from degrees to radians.\n\nWrite a function called `degrees_to_radians` that takes in an integer representing the number of degrees and returns a float representing the corresponding value in radians. \n\nYou should assume that the input will be a valid ... |
[
{
"role": "user",
"content": "Write code for a substring search with the following constraints and requirements:\n- The substring should be case-insensitive.\n- The substring should not be found if it is surrounded by other characters.\n- The search should return the index of the first occurrence of the sub... |
[
{
"role": "user",
"content": "Create a program to find the maximum length common subsequence of two given strings.\nString1: \"abcdgf\" \nString2: \"abcdhfe\"\n\n**Note:** A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the ... |
[
{
"role": "user",
"content": "Write a function that takes two strings, \"ABC\" and \"XYZ\", as input and returns a list of all possible combinations of characters from both strings.\n\nConstraints:\n- The length of each input string will not exceed 10 characters.\n- The output list should not contain any du... |
[
{
"role": "user",
"content": "Write a Python script to identify all palindromes of length greater than or equal to 3 from a given input string. The script should return a list of all palindromes found.\n\ninputString = \"abacab\"\n\nExample:\nInput: \"abacab\"\nOutput: [\"aba\", \"aca\"]\n\nNote: The palind... |
[
{
"role": "user",
"content": "Construct a Python script to print the last occurrence of a specific character in a string.\nstr = \"Hello world!\"\ncharacter = 'l'"
},
{
"role": "system",
"content": "Here's a Python script that prints the last occurrence of a specific character in a given string:... |
[
{
"role": "user",
"content": "Input a two-dimensional array and calculate the sum of each row. However, some of the values in the array might be negative, so make sure to handle negative numbers correctly.\narr = [[1, -2, 3], [4, -5, 6], [-7, 8, -9]]"
},
{
"role": "system",
"content": "Here is o... |
[
{
"role": "user",
"content": "Create a function that returns the sum of all elements in a given array of numbers. However, if any element in the array is a negative number, raise an exception with a custom error message."
},
{
"role": "system",
"content": "Here is the Python code for the require... |
[
{
"role": "user",
"content": "Use Python to sort a given list of strings in descending order.\nmyList = [\"bananas\", \"oranges\", \"apples\", \"peaches\"]"
},
{
"role": "system",
"content": "You can use the `sorted()` function with the `reverse=True` parameter to sort the given list of strings ... |
[
{
"role": "user",
"content": "Create a Python class to store a customer's name, address, phone number, and email address. The email address should be validated to ensure it follows the standard format of \"username@domain.com\"."
},
{
"role": "system",
"content": "Here is an example of a Python ... |
[
{
"role": "user",
"content": "Increase the difficulty by requiring the solution to extract the top 10 rows from a matrix with a size of n x m, where n and m are large integers (e.g. n > 1000, m > 1000). Additionally, the solution should only use core Python functionality and not rely on external libraries l... |
[
{
"role": "user",
"content": "Suggest a way to complete the following Python program which takes two strings as input and prints out the longer string. The program should have a time complexity of O(1) and should not use any built-in functions or libraries that directly determine the length of the strings. ... |
[
{
"role": "user",
"content": "Create a function that takes two string arguments, where each string represents a large number with up to 10^6 digits. The function should add the two numbers together and return the result as a string.\n\nFor example:\nstring1 = \"12345678901234567890\"\nstring2 = \"9876543210... |
[
{
"role": "user",
"content": "Use NumPy to create a 3x3 array of random numbers from -1 to 1."
},
{
"role": "system",
"content": "To create a 3x3 array of random numbers from -1 to 1 using NumPy, you can use the `random` module from the NumPy library. Here's how you can do it:\n\n```python\nimpo... |
[
{
"role": "user",
"content": "Read the given JSON data and display the value of the \"Name\" field. The program should also validate if the value of the \"Version\" field is in the format of a semantic version (e.g., 1.0.0). If it is not in the correct format, display an error message."
},
{
"role":... |
[
{
"role": "user",
"content": "Construct a code to determine if two strings are equal, with a twist - the strings can be of different lengths.\nabc\nabcd"
},
{
"role": "system",
"content": "Here's a code snippet in Python that determines if two strings are equal, even if they have different lengt... |
[
{
"role": "user",
"content": "Write a function to compute the factorial of a number using recursion. Make sure to handle edge cases such as negative numbers and non-integer inputs.\n\n# Erroneous Code #\n```python\ndef factorial(n):\n if n == 0:\n return 1\n else:\n return n * factorial(... |
[
{
"role": "user",
"content": "Construct a program that can calculate the factorial of a number using a while loop. Additionally, the program should handle negative numbers and return an error message if the input is not a valid number."
},
{
"role": "system",
"content": "Here's a Python program ... |
[
{
"role": "user",
"content": "Create a program to find the longest substring with unique characters and return the length of the substring. If there are multiple substrings with the same longest length, return the first occurring substring.\n\nYou can assume that the input string only contains lowercase Eng... |
[
{
"role": "user",
"content": "Write a Python function called `calculate_sum` that takes a list of numbers as input and returns the sum of all the numbers in the list."
},
{
"role": "system",
"content": "Here is the Python function `calculate_sum` that takes a list of numbers as input and returns... |
[
{
"role": "user",
"content": "Implement an optimized version of insertion sort that can efficiently sort a large array of integers in ascending order. The input array can contain duplicate values and may have a length up to 10^6. The implementation should have a time complexity of O(n^2) and a space complex... |
[
{
"role": "user",
"content": "Construct a function to detect if a binary tree is balanced.\n\nA binary tree is balanced if the heights of the two subtrees of any node never differ by more than 1.\n\n## Input:\n- The root of a binary tree.\n\n## Output:\n- Return True if the binary tree is balanced, False ot... |
[
{
"role": "user",
"content": "Write a Python function that takes an array of strings as an argument and returns a boolean. The function should only return True if all the strings in the array contain at least one digit and one uppercase letter. Otherwise, the function should return False."
},
{
"rol... |
[
{
"role": "user",
"content": "Code a function to clamp a given number between a minimum value and maximum value. However, if the given number is negative, return the absolute value of the number before clamping it. Number: -5, Minimum: 0, Maximum: 10"
},
{
"role": "system",
"content": "Here's an... |
[
{
"role": "user",
"content": "Develop a program that prints out the output of the following expression, but you are not allowed to use any loops or list comprehensions. [2, 4, 6, 8]"
},
{
"role": "system",
"content": "To solve this problem without using loops or list comprehensions, we can make ... |
[
{
"role": "user",
"content": "Develop an algorithm in Python to determine whether two strings are anagrams, but without using the built-in Python functions or libraries for string manipulation and sorting."
},
{
"role": "system",
"content": "Here is an algorithm in Python to determine whether tw... |
[
{
"role": "user",
"content": "Suggest a solution to store years in ISO 8601 format in Python, but also include the functionality to convert the ISO 8601 format to a different date format such as 'mm-dd-yyyy'."
},
{
"role": "system",
"content": "To store years in ISO 8601 format in Python and con... |
[
{
"role": "user",
"content": "Create a function in Python which takes a string as an argument and returns the first character of the string in upper case. The function should also handle cases where the string may contain leading or trailing whitespace, and should remove any leading or trailing whitespace b... |
[
{
"role": "user",
"content": "Suggest a method in Python for sorting a list of strings on the basis of their length in descending order."
},
{
"role": "system",
"content": "One method to sort a list of strings based on their length in descending order is to use the `sorted()` function with a cus... |
[
{
"role": "user",
"content": "Build a program that prints out the length of a given list, but with the following additional requirements:\n\n1. The program should handle lists of any data type, not just integers or strings.\n2. The program should handle nested lists, i.e., lists that contain other lists as ... |
[
{
"role": "user",
"content": "Suggest an efficient algorithm for validating a password which should contain at least 1 uppercase character, 1 lowercase character, 1 digit, and 1 special character. Additionally, the password must be between 8 and 16 characters in length, and cannot contain any spaces."
},
... |
[
{
"role": "user",
"content": "Write a class in Python to represent a division with two integers and the following operations: addition, subtraction, multiplication, division, exponentiation, and modulo. Additionally, implement a method to calculate the factorial of a number."
},
{
"role": "system",
... |
[
{
"role": "user",
"content": "Write a Python function called `is_prime` that takes an integer as input and returns a boolean value indicating whether the input is a prime number or not. Additionally, provide a piece of erroneous code that falsely claims to correctly detect prime numbers and explain why it i... |
[
{
"role": "user",
"content": "Construct a for loop that prints out all prime numbers between 500 and 1000, and also counts the total number of prime numbers found."
},
{
"role": "system",
"content": "Here's an example of a for loop that prints out all prime numbers between 500 and 1000, and also... |
[
{
"role": "user",
"content": "Create a linked list from the given array of numbers.\n[2, 4, 5, 6, 7, 8, 9]\n\n# Erroneous Code #\n```python\ndef create_linked_list(numbers):\n head = None\n for num in numbers:\n node = ListNode(num)\n if not head:\n head = node\n else:\... |
[
{
"role": "user",
"content": "Construct an if-else statement that checks if the given day is a holiday. The day variable can be a string representing the day of the week (e.g., \"Sunday\", \"Monday\", etc.) or an integer representing the day of the month (e.g., 1 for January 1st, 2 for January 2nd, etc.). H... |
[
{
"role": "user",
"content": "Create a program that finds the sum of all numbers divisible by 4 between 150 and 300, where the sum should only include numbers that are also divisible by 5."
},
{
"role": "system",
"content": "Here's a Python program that finds the sum of all numbers divisible by ... |
[
{
"role": "user",
"content": "You are given two matrices, M1 and M2. Write a python code to multiply them. The number of columns in M1 should be equal to the number of rows in M2. The resulting matrix should have the same number of rows as M1 and the same number of columns as M2. Additionally, the input mat... |
[
{
"role": "user",
"content": "You are given two arrays, A and B. Write a program to determine if B is a subset of A. A subset is defined as a set where all the elements of B are also present in A, and A may have additional elements.\n\nA = [1, 2, 3, 4, 5]\nB = [2, 3, 5]\n\nWrite a program that checks if all... |
[
{
"role": "user",
"content": "Generate a code to form a Pascal Triangle with the given input. The input will be a positive integer, n, where n represents the number of rows in the Pascal Triangle.\n\nA Pascal Triangle is a triangular array of binomial coefficients. Each number in the triangle is the sum of ... |
[
{
"role": "user",
"content": "Retrieve the data in the given URL and calculate the average word length of the text content."
},
{
"role": "system",
"content": "To retrieve the data from a given URL and calculate the average word length of the text content, you can use the following Python code:\... |
[
{
"role": "user",
"content": "Change the given singly linked list into an array while also ensuring that the array is sorted in ascending order. Linked list: 1->3->5->7->9"
},
{
"role": "system",
"content": "To convert the given singly linked list into a sorted array in ascending order, follow t... |
[
{
"role": "user",
"content": "Write a code that swaps the two numbers using a temporary variable and cannot use any arithmetic or assignment operators. a = 10, b = 20"
},
{
"role": "system",
"content": "To swap the values of two variables without using arithmetic or assignment operators, you can... |
[
{
"role": "user",
"content": "Write a function that takes three integer parameters and finds the maximum of the three numbers using the ternary operator. Additionally, the function should also find the minimum of the three numbers using the ternary operator and return both the maximum and minimum values as ... |
[
{
"role": "user",
"content": "Fix the code so that the loop terminates after 10 iterations. However, you are not allowed to use any comparison operators (such as \"<\", \">\", \"<=\", \">=\") inside the loop condition."
},
{
"role": "system",
"content": "Here is an example of how you can fix the... |
[
{
"role": "user",
"content": "Write a python code to find the k-th smallest element in two sorted arrays.\nA = [1,4,6,7]B = [3,5,8,9]\nk = 6"
},
{
"role": "system",
"content": "One way to find the k-th smallest element in two sorted arrays is by using the merge process of merge sort.\n\nHere is ... |
[
{
"role": "user",
"content": "Detect if the given URL contains a query string parameter named \"food\" with the value \"burger\".\nurl = https://www.example.com/?food=burger"
},
{
"role": "system",
"content": "One possible way to detect if the given URL contains a query string parameter named \"... |
[
{
"role": "user",
"content": "Unwrap the function parameter with default argument and ensure that arg1 is a positive integer. If arg1 is not a positive integer, raise a ValueError with the message \"arg1 must be a positive integer\". The function should still have a default argument for arg2 with the value ... |
[
{
"role": "user",
"content": "Given a string s and an integer k, write a code to find the kth most frequent word with a length of at least 5 characters in the string.\nString s: \"hello world hello\"\nInteger k: 2"
},
{
"role": "system",
"content": "Here is one possible implementation in Python:... |
[
{
"role": "user",
"content": "Create a function that takes in a list of integers and returns a new list that includes only the prime numbers from the original list."
},
{
"role": "system",
"content": "Here is a possible implementation of the function:\n\n```python\ndef get_prime_numbers(numbers)... |
[
{
"role": "user",
"content": "Output the last two words in the following string. The string will always be at least three words long and will not contain any punctuation marks."
},
{
"role": "system",
"content": "To extract the last two words in the string, we can use string manipulation. Here's... |
[
{
"role": "user",
"content": "Create a program to convert a given time in GMT form to local time, considering daylight saving time (DST).\n\n# Requirements:\n1. The program should take the GMT time as input and return the corresponding local time, accounting for DST if applicable.\n2. The program should han... |
[
{
"role": "user",
"content": "Write a Python algorithm to find the most common value in an array. The array will always contain at least 5 elements and the maximum size of the array is 100. The elements in the array are integers between -1000 and 1000. The algorithm should have a time complexity of O(n). Re... |
[
{
"role": "user",
"content": "Develop a function to evaluate the following expression.\n3 + 2 * 4 - 5 / 2 % 3 ^ 2"
},
{
"role": "system",
"content": "To evaluate the given expression, we can break it down into smaller components and use the order of operations (PEMDAS) to solve it step by step.\... |
[
{
"role": "user",
"content": "Fill in the blanks to calculate the standard deviation of an array using the formula. Make sure to handle edge cases and provide appropriate error handling."
},
{
"role": "system",
"content": "To calculate the standard deviation of an array using the formula, you ca... |
[
{
"role": "user",
"content": "Create a new list where the elements are the sum of the square of each even number in the given list. The given list may contain positive and negative integers. If the given list does not contain any even numbers, the new list should be empty. If the given list contains any non... |
[
{
"role": "user",
"content": "Write a function that takes in two parameters: an array of integers and a target sum. The function should return a new array with each element from the original array multiplied by the target sum. \n\nFor example, if the input array is [1, 2, 3, 4] and the target sum is 10, the... |
[
{
"role": "user",
"content": "Code a solution in Python to replace all the occurrences of a specific word in a string, but only if the word is surrounded by spaces.\nsentence = \"I like apples and applesauce\"\nword = \"apples\"\nreplacement = \"bananas\""
},
{
"role": "system",
"content": "Here... |
[
{
"role": "user",
"content": "Write a function that takes a list of integers as input and returns a list of unique prime numbers present in the input list, sorted in ascending order. The function should have a time complexity of O(n√m), where n is the length of the input list and m is the maximum value in t... |
[
{
"role": "user",
"content": "Use the given JSON data to create a function that returns the number of males in the dataset. However, the function should ignore any individuals whose age is less than 20 or greater than 40."
},
{
"role": "system",
"content": "Here's a possible solution in Python:\... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.