messages listlengths 2 2 |
|---|
[
{
"role": "user",
"content": "Write a function that takes an array of integers and returns an array of the same size with each element equal to the sum of all the elements in the original array except itself.\n\nErroneous code reference:\n```\ndef calculate_sum(array):\n total_sum = 0\n for num in arr... |
[
{
"role": "user",
"content": "Write a function that takes in a string and returns the number of vowels (a, e, i, o, u) present in the string."
},
{
"role": "system",
"content": "Here is a Python function that takes in a string and returns the number of vowels present in the string:\n\n```python\... |
[
{
"role": "user",
"content": "Show an example of using the Python module, os, to create a directory and then delete it."
},
{
"role": "system",
"content": "Sure! Here's an example that uses the `os` module in Python to create a directory and then delete it:\n\n```python\nimport os\n\n# Directory... |
[
{
"role": "user",
"content": "Given a sorted array of size n, create a program to return the kth smallest element. Your program should have a time complexity of O(log n) and should not use any additional space."
},
{
"role": "system",
"content": "One way to solve this problem with a time complex... |
[
{
"role": "user",
"content": "Make the following Python function for generating powerset without using recursion."
},
{
"role": "system",
"content": "Here is a Python function for generating the powerset of a given set without using recursion:\n\n```python\ndef powerset(s):\n n = len(s)\n ... |
[
{
"role": "user",
"content": "Given a list of numbers, write a function that returns the index of the second minimum element.\n\nExample:\n\nInput: [22, 11, 13, 66]\nOutput: 2\n\nNote: In the example above, the second minimum element is 13, and its index is 2."
},
{
"role": "system",
"content": ... |
[
{
"role": "user",
"content": "Find the element in a list that occurs most frequently. The list may contain negative numbers and the length of the list should be at least 10."
},
{
"role": "system",
"content": "To find the element in a list that occurs most frequently, you can use the Counter cla... |
[
{
"role": "user",
"content": "Construct a program to shuffle the content of a list using the Fisher-Yates algorithm."
},
{
"role": "system",
"content": "Sure! Here's a Python program that uses the Fisher-Yates algorithm to shuffle the contents of a list:\n\n```python\nimport random\n\ndef fisher... |
[
{
"role": "user",
"content": "Read an array of n numbers and output the smallest one.\nExample:\nInput: [7, 4, 2, 9, 5]\nOutput: 2"
},
{
"role": "system",
"content": "Here is one possible solution in Python:\n\n```python\ndef find_smallest(numbers):\n smallest = numbers[0] # Assume the first... |
[
{
"role": "user",
"content": "Write a function to perform vector addition for two 1D arrays. The function should also handle cases where the lengths of the two arrays are not equal.\n\n[3, 4], [5, 6]\n\nExample input: \n[3, 4, 5], [5, 6]\nExpected output: [8, 10, 5]\n\nExample input: \n[1, 2, 3], [4, 5, 6, ... |
[
{
"role": "user",
"content": "Create a 3x4 NumPy array of random integers from 0 to 5, where each row should have at least one unique value."
},
{
"role": "system",
"content": "To create a 3x4 NumPy array with random integers from 0 to 5, where each row should have at least one unique value, you... |
[
{
"role": "user",
"content": "Develop a function to replace all consecutive whitespaces in a given string with a single space. However, the function should also ignore any whitespaces at the beginning or end of the string."
},
{
"role": "system",
"content": "Here's a Python function that replace... |
[
{
"role": "user",
"content": "Generate a code to extract the key-value pairs from a JSON string, where the JSON string may contain nested objects and arrays. Additionally, handle cases where the JSON string is malformed or contains invalid characters."
},
{
"role": "system",
"content": "To extra... |
[
{
"role": "user",
"content": "Create a function to determine if a given String contains a valid US phone number, with the additional constraint that the phone number must be in the format \"(XXX) XXX-XXXX\" and the first digit of the area code cannot be 0 or 1."
},
{
"role": "system",
"content":... |
[
{
"role": "user",
"content": "Create a function to perform recursive binary search in a sorted array. Your function should handle arrays of any size and should return the index of the target element if found, or -1 if the target is not present. Additionally, your function should have a time complexity of O(... |
[
{
"role": "user",
"content": "Create a function that takes in a string as input and returns an array containing all the unique characters in the string in Python. The returned array should be sorted in ascending order and should not contain any duplicate characters."
},
{
"role": "system",
"cont... |
[
{
"role": "user",
"content": "Given an XML document with nested nodes, parse the document and store the node names, attributes, and values in a list of dictionaries. Additionally, the attributes should be sorted in ascending order."
},
{
"role": "system",
"content": "Here's an example implementa... |
[
{
"role": "user",
"content": "Given a list of strings and a single character, write a Python function to return the count of strings containing that character. Each string in the list should be considered case-insensitive. The function should ignore any strings that contain special characters or numbers. If... |
[
{
"role": "user",
"content": "Generate a random string with the specified length n, where n is a positive integer less than or equal to 100."
},
{
"role": "system",
"content": "Here is an example code in Python that generates a random string with the specified length:\n\n```python\nimport random... |
[
{
"role": "user",
"content": "Generate a function in Python that takes a number and a list as input and finds the number of occurrences of the number in the list. The function should handle cases where the number is a float, and return an error message if the number is not a valid float. Additionally, the f... |
[
{
"role": "user",
"content": "Construct a Python class to model a circle. Include methods to calculate the circumference and area of the circle. Also, add a method to check if a given point is inside the circle."
},
{
"role": "system",
"content": "Here is a Python class that models a circle and ... |
[
{
"role": "user",
"content": "Create a for loop that counts up to the given number and prints out each number. \nNumber: 10"
},
{
"role": "system",
"content": "Here is the code for the requested for loop in Python:\n\n```python\nnumber = 10\nfor i in range(1, number + 1):\n print(i)\n```\n\nT... |
[
{
"role": "user",
"content": "Initialize a new array to 0 of size 10. The array must now be implemented using a linked list data structure instead of a regular array."
},
{
"role": "system",
"content": "To implement an array of size 10 using a linked list data structure, you can create a class f... |
[
{
"role": "user",
"content": "Write a code to parse a URL and return the domain name. You need to handle various scenarios such as different protocols (e.g. HTTP, HTTPS), different subdomains, and query parameters.\n\nFor example:\n- Input: \"https://example.com/page?param1=value1¶m2=value2\"\n- Output:... |
[
{
"role": "user",
"content": "Sort the array in descending order using a bubble sort algorithm. \n\nInitialize a variable called \"swapped\" to true. This variable will be used to determine if any swaps were made during a pass of the array. \nWhile \"swapped\" is true, do the following:\n- Set \"swapped\" t... |
[
{
"role": "user",
"content": "Create a program which takes an array of integers and an integer as input, and returns the index of the integer in the array. However, the program should now have a time complexity requirement of O(n^2), where n is the length of the array."
},
{
"role": "system",
"c... |
[
{
"role": "user",
"content": "Construct a loop in Python that iterates through each row of a dataframe and performs the following operations for each row:\n1. Print the index of the current row.\n2. Print the values of all columns in the current row.\n3. Calculate the sum of all numerical values in the curr... |
[
{
"role": "user",
"content": "Create a function that takes a list of integers and returns a new list containing only the odd numbers from the original list."
},
{
"role": "system",
"content": "Here is the implementation of the function:\n\n```python\ndef get_odd_numbers(lst):\n return [num fo... |
[
{
"role": "user",
"content": "Create a function that takes in a list of strings and sorts it by the reverse order of its length. The function should also remove any duplicate strings from the list before sorting. The resulting sorted list should then be converted to all uppercase letters. Finally, the funct... |
[
{
"role": "user",
"content": "Write a Python program to print the Odd numbers from 1 to 50, but only if the number is divisible by 3 and greater than 10."
},
{
"role": "system",
"content": "Here's a Python program that prints the odd numbers from 1 to 50, but only if the number is divisible by 3... |
[
{
"role": "user",
"content": "Write a Python program to output an array with dimensions [N, M] filled with random numbers between 0 and 1. Additionally, find the sum of all the numbers in the array.\n\nN = 5\nM = 4"
},
{
"role": "system",
"content": "Here is a Python program that generates an ar... |
[
{
"role": "user",
"content": "Find the position of a string within another string, taking into consideration both case sensitivity and partial matches.\n\nhaystack = \"This is a Sample string with the word 'sample' in it. Sample\"\nneedle = \"sample\"\n\n# Expected Output #\nThe position of the first occurr... |
[
{
"role": "user",
"content": "Write code to delete an element of a linked list given its value. If the value occurs multiple times in the list, delete all occurrences.\nLinked List: 8->3->65->7->3->9->3\nValue: 3"
},
{
"role": "system",
"content": "Here is an example code in Python that deletes ... |
[
{
"role": "user",
"content": "Create a code to rotate an array to the right by k steps, where k is a positive integer.\narr = [1,2,3,4,5,6,7,8,9,10], k = 5"
},
{
"role": "system",
"content": "Here is the code to rotate an array to the right by k steps:\n\n```python\ndef rotate_array(arr, k):\n ... |
[
{
"role": "user",
"content": "Given a number n, count the total number of digit only divisors of n that are also prime numbers. \nn = 100\n\n#Explanation#\nIn the given test, we are counting the total number of digit only divisors of 100. The digit only divisors of 100 are 1, 2, 4, and 5. However, only 2 an... |
[
{
"role": "user",
"content": "Implement a function in Python to convert a given sentence into title case, ensuring that all articles, prepositions, and coordinating conjunctions are lowercase unless they are the first or last word of the sentence. The function should also handle contractions and hyphenated ... |
[
{
"role": "user",
"content": "Construct a for loop in Python for summing up the elements of a given list, where the list can contain both positive and negative integers.\nList of integers: [-1, 2, -3, 4, -5]"
},
{
"role": "system",
"content": "Here is the code for the for loop to sum up the elem... |
[
{
"role": "user",
"content": "Create a Python program to check if all items in a list are unique, without using any built-in functions or data structures.\nlist_items = [1,2,3,2,3]"
},
{
"role": "system",
"content": "Here's a Python program that checks if all items in a list are unique without u... |
[
{
"role": "user",
"content": "How to extract all unique numbers from a given string in Python, while ignoring any duplicate numbers?\n\n#Explanation#\nIn the original test, the task was to extract numbers from a string, which is relatively straightforward. In the rewritten test, the additional requirement o... |
[
{
"role": "user",
"content": "Sort an array of integers in ascending order by implementing a Bubble Sort algorithm. However, you must modify the bubble sort algorithm so that it sorts the array in descending order instead of ascending order. \n\nunsorted_list = [8, 5, 3, 1, 9, 6, 0, 7, 4, 2, 5]"
},
{
... |
[
{
"role": "user",
"content": "Write a function that takes in an array of integers and returns a string with each number in reverse order, separated by a comma.\n[1,2,3,4,5]\n\n#Erroneous Code Example#\nHere is a piece of erroneous code that reverses the elements of the array in place instead of creating a n... |
[
{
"role": "user",
"content": "Create an algorithm that takes in an array of strings and returns a new array containing only the strings that start with the letter \"a\". If there are no strings starting with \"a\", return an empty array.\n\nProvide a piece of erroneous code as a reference to increase misdir... |
[
{
"role": "user",
"content": "Produce a program that takes in two strings and check if they are anagrams. An anagram is a word or phrase formed by rearranging the letters of another word or phrase. Implement the following two functions:\n\n1. `sort_string(string: str) -> str`: This function takes in a strin... |
[
{
"role": "user",
"content": "Develop a program that takes in two arrays of integers and returns the index of the first occurrence of the smallest common element in both arrays. If there is no common element, return -1.\n\nExample:\nInput:\nArray 1: [1, 5, 2, 9, 10]\nArray 2: [4, 6, 3, 1, 7, 8]\n\nOutput:\n... |
[
{
"role": "user",
"content": "Print the following string with all asterisks in lower case and output it. \nHowever, you are not allowed to use any built-in string manipulation functions or regular expressions."
},
{
"role": "system",
"content": "To print the string with all asterisks in lowercas... |
[
{
"role": "user",
"content": "Create a function to calculate the following expression and output the result.\n(2^2 + 4 - 3*6) / (7 - 3) * (8 / 2)"
},
{
"role": "system",
"content": "Here is a Python function to calculate the expression and output the result:\n\n```python\ndef calculate_expressio... |
[
{
"role": "user",
"content": "Given a matrix of integers, output a vector that contains the sum of each row in the matrix."
},
{
"role": "system",
"content": "To solve this problem, we can iterate over each row in the matrix and calculate the sum of that row. We then add the sum to a new vector.... |
[
{
"role": "user",
"content": "Write a Python script to find the area of a triangle with sides 18, 24, and 30. However, the input sides are given as strings instead of integers, and the code should convert the string inputs to integers before calculating the area."
},
{
"role": "system",
"content... |
[
{
"role": "user",
"content": "You are given two lists. Output a third list which contains only the elements common to both lists. The input lists may contain duplicate elements.\n\nlist1 = [1, 2, 2, 3, 4, 5]\nlist2 = [3, 4, 4, 5, 6, 7]"
},
{
"role": "system",
"content": "Here is one way to solve... |
[
{
"role": "user",
"content": "Create a class in python with 4 functions. Each function should take in a specific data type as an argument and return a specific data type as the result. The function names should also follow a specific naming convention."
},
{
"role": "system",
"content": "Here is... |
[
{
"role": "user",
"content": "Create a Python function that takes two arguments: a list of integers and an integer. The function should add the given integer to each element of the list and return the new list. The function should have a time complexity of O(n), where n is the length of the list."
},
{
... |
[
{
"role": "user",
"content": "Create a Python function 'findPattern' with two parameters which takes two strings and returns 1 if the second string is a subsequence of the first string, otherwise 0.\n\nAdditional Requirements:\n- The function should have a time complexity of O(n) where n is the length of th... |
[
{
"role": "user",
"content": "Explain the functionality and usage of the len() and index() methods in Python. Provide examples to illustrate their differences and similarities."
},
{
"role": "system",
"content": "The len() and index() methods are built-in functions in Python that provide differe... |
[
{
"role": "user",
"content": "Write a function that takes an array of numbers and prints out all the pairs of numbers whose sum is equal to a given number. The function should also handle duplicate pairs, where the order of the numbers in the pair does not matter. The output should be sorted in ascending or... |
[
{
"role": "user",
"content": "Construct a matrix of shape 1000 x 1000."
},
{
"role": "system",
"content": "To construct a matrix of shape 1000 x 1000, we need to create a 2-dimensional array with 1000 rows and 1000 columns. Here's an example using Python:\n\n```python\n# Create a matrix with 100... |
[
{
"role": "user",
"content": "Print the element with the second greatest value from an array named 'numbers' without using any built-in sorting functions or methods. The array 'numbers' will always contain at least 2 unique integers."
},
{
"role": "system",
"content": "Here is one way to find th... |
[
{
"role": "user",
"content": "Implement a function to implement Bubble Sort with a time complexity of O(n^2).\n\n#Erroneous Code Example#\n```python\ndef bubble_sort(arr):\n for i in range(len(arr)-1):\n for j in range(len(arr)-i-2):\n if arr[j] > arr[j+1]:\n arr[j], arr[... |
[
{
"role": "user",
"content": "Given two lists of integers, create a new list that contains the difference between the two lists, but with the following conditions:\n1. The difference should only be calculated for elements that are common to both lists.\n2. The difference should be calculated by subtracting ... |
[
{
"role": "user",
"content": "Determine whether two given arrays are equal or not, but this time you cannot use any built-in comparison functions.\narr1 = [1, 2, 3]\narr2 = [1, 2, 4]"
},
{
"role": "system",
"content": "To determine whether two given arrays are equal or not without using any buil... |
[
{
"role": "user",
"content": "Create a class that implements a set data structure with the following additional requirements:\n- The set should only allow elements of integer data type.\n- The set should have a maximum capacity of 100 elements.\n- The set should provide a method to calculate the sum of all ... |
[
{
"role": "user",
"content": "You need to find all the words in a given sentence sorted by their length in descending order. Additionally, you need to return the count of unique words in the sentence. The sentence may contain punctuation marks and special characters, and words are case-insensitive. The outp... |
[
{
"role": "user",
"content": "You need to build a function that takes a binary tree as input and returns a list containing the data stored at each level. The function should have a time complexity of O(n), where n is the number of nodes in the tree.\n\nExample:\n\nInput:\n 1\n / \\\n 2 3\n / \\ ... |
[
{
"role": "user",
"content": "Convert this octal number to a binary number, ensuring that your solution is implemented using recursion.\nOctal number: 77"
},
{
"role": "system",
"content": "To convert an octal number to a binary number recursively, we need to divide the octal number by 2 and kee... |
[
{
"role": "user",
"content": "Rewrite the code to implement a recursive function that calculates the factorial of a given number. The function should have the following signature:\n\n```python\ndef factorial(n: int) -> int:\n```\n\nThe function should return the factorial of `n`, where `n` is a non-negative... |
[
{
"role": "user",
"content": "Write a function in Python to convert a 2D array into a single column array, but also ensure that the function handles the case when the input array contains nested arrays with varying lengths. The function should flatten the 2D array while maintaining the order of the elements... |
[
{
"role": "user",
"content": "Write a function that takes in two colors represented in the hexadecimal triplet system and returns a combination of the two colors."
},
{
"role": "system",
"content": "Here is a Python function that takes in two colors represented in the hexadecimal triplet system ... |
[
{
"role": "user",
"content": "Parse the following XML data to get a list of country names along with their ranks, years, GDP per capita, and neighboring countries.\n\n<data>\n <country name=\"Ghana\">\n <rank>99</rank>\n <year>2012</year>\n <gdppc>2616.7</gdppc>\n <neighbor name=\"Togo\" direct... |
[
{
"role": "user",
"content": "Create a program that draws an inverted triangle with stars (*) with a given height."
},
{
"role": "system",
"content": "Sure! Here's a Python program that draws an inverted triangle with stars (*) based on a given height:\n\n```python\ndef draw_inverted_triangle(he... |
[
{
"role": "user",
"content": "Complete the program by filling in the missing code to call the appropriate function\n\n```python\ndef search(items, item): \n for ____ in ____: \n if ____ == ____:\n found = ____ \n if ____: \n return found \n else: \n r... |
[
{
"role": "user",
"content": "Create an array of 10 Boolean values and set it to \"False\". Additionally, create a function that takes in the array as a parameter and randomly sets one of the Boolean values to \"True\" each time it is called."
},
{
"role": "system",
"content": "Here is a Python ... |
[
{
"role": "user",
"content": "Create a program that prints all unique permutations of the given string, without using any built-in functions or libraries for permutation generation."
},
{
"role": "system",
"content": "Here's a program in Python that prints all unique permutations of a given stri... |
[
{
"role": "user",
"content": "Given two lists of integers, find all unique pairings where the sum of the pair equals to a given number. The pairs should be ordered in ascending order and should not contain duplicate elements. Each element in the pair can only be used once. The lists may contain duplicate el... |
[
{
"role": "user",
"content": "Create a function that prints the string passed to it as an argument, but the string must be reversed before printing."
},
{
"role": "system",
"content": "Here's a function that takes a string as an argument, reverses it, and then prints the reversed string:\n\n```p... |
[
{
"role": "user",
"content": "Writing a function to calculate the area of a triangle where the three sides are given. Additionally, you need to check if the given sides form a valid triangle.\n\nside1 = 5, side2 = 6, side3 = 7\n\nSteps:\n1. Check if the given sides form a valid triangle. A valid triangle sh... |
[
{
"role": "user",
"content": "Convert the given function into a recursive version. Your solution should handle the case where n is a negative number and return an appropriate error message."
},
{
"role": "system",
"content": "Here is a recursive version of the given function that handles the cas... |
[
{
"role": "user",
"content": "Make the following piece of code functional for priority queues, ensuring that the implementation is based on a max heap and that the priority queue supports the following operations: insert(value), deleteMax(), and getMax(). The implementation should also have a time complexit... |
[
{
"role": "user",
"content": "Design a function to clean binary data (strings) by keeping only printable characters. Additionally, convert any lowercase letters to uppercase.\nbinary_data = b'h\\x9Fl\\x04o'"
},
{
"role": "system",
"content": "To clean binary data by keeping only printable charac... |
[
{
"role": "user",
"content": "Resolve the issue in the code causing a \"TypeError\" to be thrown\nnames = [\"John\", \"James\", 10]\n\nfor name in names:\n if isinstance(name, str):\n print(name)\n else:\n raise ValueError(\"Invalid name type: \" + str(type(name)))"
},
{
"role": "system",
... |
[
{
"role": "user",
"content": "Convert pyramid of numbers to a single number.\n9\n 2 3\n 9 3 5\n1 8 6 8\n\n#Erroneous Code#\nThe code below is meant to solve the problem, but it contains an error. Identify and fix the error to obtain the correct solution.\n\n```python\ndef convert_pyramid(pyr... |
[
{
"role": "user",
"content": "For the given Python dictionary, list all its keys and values in the following format. However, for nested dictionaries, only display the keys and values if the key starts with the letter 'a'."
},
{
"role": "system",
"content": "To complete this task, you can use a ... |
[
{
"role": "user",
"content": "Create a dictionary in Python and store the names of four countries and the cities within them. Implement a function that takes a country name as input and returns the number of cities in that country. The function should have a time complexity of O(1)."
},
{
"role": "s... |
[
{
"role": "user",
"content": "Write a function to sort the elements of a list based on their frequency. The output list should contain the elements in descending order of frequency. If multiple elements have the same frequency, they should be sorted in ascending order. The function should have a time comple... |
[
{
"role": "user",
"content": "Write a Python function that takes in a string, a substring, and a replacement string as inputs. The function should search for all occurrences of the substring in the string and replace them with the replacement string. The function should be case-sensitive and should return t... |
[
{
"role": "user",
"content": "Using the 'arrays' library in Python, generate a random array of 100 numbers and find the average of all the numbers in the array."
},
{
"role": "system",
"content": "Here's an example code that uses the `random` module to generate a random array of 100 numbers and ... |
[
{
"role": "user",
"content": "Create a program for sorting a given array in O(n) time complexity. The array consists of positive integers.\n\nAdditionally, the program should sort the array in descending order instead of ascending order.\n\nFurthermore, the program should be implemented using a recursive ap... |
[
{
"role": "user",
"content": "What is the most efficient way to iterate through a list of dictionaries in Python, without using any built-in functions or methods like `for` loops, list comprehensions, or `map()`?"
},
{
"role": "system",
"content": "One possible approach to iterate through a list... |
[
{
"role": "user",
"content": "Given a list of dictionaries, each containing information about a person, write a function that converts the list to a JSON string representation.\n\nThe function should have the following signature:\n```\ndef convert_to_json(list_of_dictionaries: List[Dict[str, Union[str, int]... |
[
{
"role": "user",
"content": "Compose a Python script to convert a string to an all-uppercase string, while excluding any vowels in the string.\nString: 'Experiment'"
},
{
"role": "system",
"content": "Here's a Python script that converts a string to an all-uppercase string, excluding any vowels... |
[
{
"role": "user",
"content": "Write a program that takes an array of integers as input and prints all the unique elements in the array, sorted in ascending order. The program should have a time complexity of O(nlogn), where n is the size of the input array."
},
{
"role": "system",
"content": "He... |
[
{
"role": "user",
"content": "Write a RegEx to extract text inside HTML paragraph tags\n<p>This is a test</p>"
},
{
"role": "system",
"content": "To extract the text inside HTML paragraph tags, you can use the following regular expression:\n\n```regex\n<\\s*p\\s*>(.*?)<\\/\\s*p\\s*>\n```\n\nExpl... |
[
{
"role": "user",
"content": "What do the following two lines of code do? Write a function called \"string_operations\" that takes in two parameters: a string called \"string\" and a boolean called \"capitalize\". The function should replace all occurrences of the word 'old' with the word 'new' in the input... |
[
{
"role": "user",
"content": "Write code to check if a given string contains only alpha-numeric characters and has a minimum length of 5 characters."
},
{
"role": "system",
"content": "Here is a code snippet in Python to check if a given string contains only alphanumeric characters and has a min... |
[
{
"role": "user",
"content": "Implement the Levenshtein distance algorithm in Python, but with the additional constraint that you are not allowed to use any built-in string manipulation functions or libraries."
},
{
"role": "system",
"content": "Here's an implementation of the Levenshtein distan... |
[
{
"role": "user",
"content": "Replace the character on odd index positions with '#' in a string that may contain uppercase letters, lowercase letters, spaces, and special characters. The string should not exceed 100 characters in length. Return the modified string."
},
{
"role": "system",
"conte... |
[
{
"role": "user",
"content": "Using the given code snippet, reverse the words of the string and ensure that all vowels within each word are capitalized.\nstring = \"this is a string\""
},
{
"role": "system",
"content": "```python\ndef reverse_string(string):\n words = string.split()\n reve... |
[
{
"role": "user",
"content": "Given an array containing words and a string, find the shortest word in the array that is a substring of the string. The array may contain duplicates. The string may contain special characters and spaces.\n\nwords = [\"apple\", \"banana\", \"cat\", \"dog\", \"banana\", \"apple\... |
[
{
"role": "user",
"content": "Use set operations to obtain the intersection of two given sets. The program should also remove any duplicates from the resulting intersection set and sort the elements in descending order.\nSetA = {1, 2, 3, 4}\nSetB = {2, 4, 6, 8}"
},
{
"role": "system",
"content":... |
[
{
"role": "user",
"content": "Create a function that prints the multiplication table for a provided integer x = 8.\n\nIn the original test, the task was simply to create a function that prints the multiplication table for a given integer. To increase the difficulty, we can add more reasoning steps and make ... |
[
{
"role": "user",
"content": "Write a program that takes a 2D array of integers as input and prints the sum of the elements in each row."
},
{
"role": "system",
"content": "Here is a Python program that takes a 2D array of integers as input and prints the sum of the elements in each row:\n\n```p... |
[
{
"role": "user",
"content": "Implement a function that takes in a string as input and checks whether it is a valid CSS selector. A valid CSS selector follows the CSS selector syntax rules and can be used to select HTML elements in a webpage.\n\nExample input: \"#id .class > p\"\nExample output: True"
},
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.