Skip to content
🤔prompts chat🧠
🔍
question:def nth_prime_square(N): Returns the N'th prime square. A prime square is defined as the square of a prime number. >>> nth_prime_square(1) 4 >>> nth_prime_square(2) 9 >>> nth_prime_square(3) 25 >>> nth_prime_square(4) 49 >>> nth_prime_square(5) 121 >>> nth_prime_square(6) 169 >>> nth_prime_square(7) 289 >>> nth_prime_square(8) 361 >>> nth_prime_square(9) 529 >>> nth_prime_square(10) 841

answer:def nth_prime_square(N): Returns the N'th prime square. A prime square is defined as the square of a prime number. def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True primes = [] i = 2 while len(primes) < N: if is_prime(i): primes.append(i) i += 1 return primes[N - 1] ** 2

question:def categorize_runner_finish_time(finish_time: int) -> str: Returns the category of the runner based on their finish time in minutes. :param finish_time: int. The finish time in minutes. :return: str. The category of the runner. Categories: - If the finish time is less than 180 minutes: "Elite Runner" - If the finish time is between 180 (inclusive) and 240 minutes: "Competitive Runner" - If the finish time is between 240 (inclusive) and 300 minutes: "Average Runner" - If the finish time is greater than or equal to 300 minutes: "Casual Runner" >>> categorize_runner_finish_time(179) 'Elite Runner' >>> categorize_runner_finish_time(180) 'Competitive Runner' >>> categorize_runner_finish_time(240) 'Average Runner' >>> categorize_runner_finish_time(300) 'Casual Runner'

answer:def categorize_runner_finish_time(finish_time): Returns the category of the runner based on their finish time in minutes. :param finish_time: int. The finish time in minutes. :return: str. The category of the runner. if finish_time < 180: return "Elite Runner" elif 180 <= finish_time < 240: return "Competitive Runner" elif 240 <= finish_time < 300: return "Average Runner" else: return "Casual Runner"

question:def max_profit(prices): Calculate the maximum profit that can be achieved from a single transaction. If no profit is possible, returns 0. >>> max_profit([7, 1, 5, 3, 6, 4]) == 5 >>> max_profit([7, 6, 4, 3, 1]) == 0 >>> max_profit([2, 4, 1, 7, 5, 8, 3]) == 7

answer:def max_profit(prices): Returns the maximum profit that can be achieved from a single transaction. If no profit is possible, returns 0. n = len(prices) if n < 2: return 0 min_price = float('inf') max_profit = 0 for price in prices: if price < min_price: min_price = price elif price - min_price > max_profit: max_profit = price - min_price return max_profit

question:import re def count_unique_words(text: str) -> int: Given a large text document, the function counts the total number of unique words in it. For the purpose of this task, a word is defined as any sequence of characters separated by spaces. Words are case-insensitive, meaning that "Hello", "hello", and "HELLO" are considered the same word. >>> count_unique_words("Hello world! Hello again, world.") 3 >>> count_unique_words("This is a Test. This test is simple.") 5

answer:import re def count_unique_words(text): Returns the number of unique words in the given text. Words are case insensitive and any sequence of characters separated by spaces is considered a word. # Convert text to lowercase text = text.lower() # Use regular expression to find all words words = re.findall(r'bw+b', text) # Use a set to store unique words unique_words = set(words) # Return the number of unique words return len(unique_words)

Released under the chat License.

has loaded