target
stringlengths
29
3.65k
data_source
stringclasses
12 values
prompt
listlengths
1
1
ability
stringclasses
1 value
reward_model
dict
extra_info
dict
def text_before_marker(s, marker): if marker in s: index = s.index(marker) return s[:index] else: return s
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes a string, and a marker character. Your function should return all of the text before the marker appears. If the marker does not appear, it should return the entire string. Use Python.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7300, "level": 1, "question": "Create a function that takes a string, and a marker character. Your function should return all of the text before the marker appears. If the marker does not appear, it should return the entire string. Use Python.", "split": "train" }
def format_license_key(key: str, k: int) -> str: # Remove all dashes and convert to uppercase cleaned = ''.join([c.upper() for c in key if c != '-']) if not cleaned: return '' n = len(cleaned) r = n % k groups = [] if r != 0 and n > r: groups.append(cleaned[0:r]) ...
simplelr_Data_Structure
[ { "content": "Question:\n**Problem Statement:**\n\nDesign a function `format_license_key` to format a given alphanumeric key string by inserting dashes at every `k` interval.\n\n**Input**:\n- A string `key` consisting of alphanumeric characters and dashes (`-`).\n- An integer `k` representing the interval for g...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7301, "level": 1, "question": "**Problem Statement:**\n\nDesign a function `format_license_key` to format a given alphanumeric key string by inserting dashes at every `k` interval.\n\n**Input**:\n- A string `key` consisting of alphanumeric characters and dashes (`-`).\n- An integer ...
def replace_long_strings(lst, n): return ["REPLACED" if len(s) > n else s for s in lst]
simplelr_Filter
[ { "content": "Question:\nGiven a list of strings \"lst\" and an integer \"n\", write a Python program to replace all strings in \"lst\" that have length greater than \"n\" with \"REPLACED\".\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7302, "level": 1, "question": "Given a list of strings \"lst\" and an integer \"n\", write a Python program to replace all strings in \"lst\" that have length greater than \"n\" with \"REPLACED\".", "split": "train" }
def schedule_tasks(tasks: list[tuple[str, int, int]]) -> list[str]: # Create a list of tuples with (-priority, index, name) sorted_tasks = [] for index, task in enumerate(tasks): name = task[0] priority = task[1] sorted_tasks.append( (-priority, index, name) ) # Sort the list of ...
simplelr_Algorithm
[ { "content": "Question:\n### Problem Statement\n\nImplement a function that simulates a simple task scheduler. The scheduler should execute tasks based on their priority levels and execution times. Tasks with higher priority should be executed first. If two tasks have the same priority, the one that comes first...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7303, "level": 1, "question": "### Problem Statement\n\nImplement a function that simulates a simple task scheduler. The scheduler should execute tasks based on their priority levels and execution times. Tasks with higher priority should be executed first. If two tasks have the same...
def can_partition(nums): total = sum(nums) if total % 2 != 0: return False target = total // 2 dp = [False] * (target + 1) dp[0] = True # Base case: empty subset for num in nums: # Iterate backwards to avoid using the same number multiple times in the same subset fo...
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to determine if a given array can be partitioned into two subsets such that the sum of elements in both subsets is equal. This is known as the \"Partition Equal Subset Sum\" problem.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7304, "level": 1, "question": "Write a python function to determine if a given array can be partitioned into two subsets such that the sum of elements in both subsets is equal. This is known as the \"Partition Equal Subset Sum\" problem.", "split": "train" }
def smallest_integer_with_sum(n): if n == 0: return "0" k = (n + 8) // 9 d1 = n - 9 * (k - 1) return str(d1) + '9' * (k - 1)
simplelr_Leetcode
[ { "content": "Question:\nGiven a positive integer `n`, write a function to find the smallest integer `x` such that the sum of the digits in `x` equals `n`, and `x` is greater than or equal to `n`. Return `x` as a string. For instance, for `n = 5`, the result would be `\"5\"`, and for `n = 19`, the result would ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7305, "level": 1, "question": "Given a positive integer `n`, write a function to find the smallest integer `x` such that the sum of the digits in `x` equals `n`, and `x` is greater than or equal to `n`. Return `x` as a string. For instance, for `n = 5`, the result would be `\"5\"`, ...
def longest_unique_substring(s): last_seen = {} # Dictionary to track the last index of each character max_length = 0 # Maximum length of unique substring found start = 0 # Starting index of the longest substring left = 0 # Left pointer of the sliding window for right in range...
simplelr_Apps
[ { "content": "Question:\nGiven a string `s`, write a function that returns the longest substring of `s` that contains only unique characters. If there are multiple substrings with the same maximum length, return the one that appears first. \n\n### Example\n- For the string `\"abcabcbb\"`, the longest substring ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7306, "level": 1, "question": "Given a string `s`, write a function that returns the longest substring of `s` that contains only unique characters. If there are multiple substrings with the same maximum length, return the one that appears first. \n\n### Example\n- For the string `\"...
import heapq def minPathCost(grid): if not grid or not grid[0]: return 0 rows = len(grid) cols = len(grid[0]) INF = float('inf') distances = [[INF for _ in range(cols)] for _ in range(rows)] distances[0][0] = grid[0][0] heap = [] heapq.heappush(heap, (grid[0][0], 0, 0)) dire...
simplelr_Leetcode
[ { "content": "Question:\nYou are given a grid representing a city, where each cell in the grid contains a non-negative integer indicating the cost to pass through that cell. You are to find a path from the top-left corner of the grid to the bottom-right corner such that the total cost is minimized. You can move...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7307, "level": 1, "question": "You are given a grid representing a city, where each cell in the grid contains a non-negative integer indicating the cost to pass through that cell. You are to find a path from the top-left corner of the grid to the bottom-right corner such that the to...
def two_sum(arr, target): seen = {} for index, num in enumerate(arr): complement = target - num if complement in seen: return [seen[complement], index] seen[num] = index return []
simplelr_Leetcode
[ { "content": "Question:\nYou are given a list of `n` integers `arr` and an integer `target`. Implement a function that returns the indices of the two numbers such that they add up to `target`. You may assume that each input would have exactly one solution, and you may not use the same element twice. The solutio...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7308, "level": 1, "question": "You are given a list of `n` integers `arr` and an integer `target`. Implement a function that returns the indices of the two numbers such that they add up to `target`. You may assume that each input would have exactly one solution, and you may not use ...
def find_longest_substring(s1: str, s2: str) -> str: # Handle edge cases where either string is empty if not s1 or not s2: return "" m = len(s1) n = len(s2) # Create a DP table with (m+1) rows and (n+1) columns dp = [[0] * (n + 1) for _ in range(m + 1)] max_len = 0 end_...
simplelr_Package
[ { "content": "Question:\nDesign a function `find_longest_substring` that takes two strings as input and returns the longest common substring shared between them.\n\n**Function Signature:**\n```python\ndef find_longest_substring(s1: str, s2: str) -> str:\n```\n\n**Parameters:**\n- `s1` (str): The first input str...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7309, "level": 1, "question": "Design a function `find_longest_substring` that takes two strings as input and returns the longest common substring shared between them.\n\n**Function Signature:**\n```python\ndef find_longest_substring(s1: str, s2: str) -> str:\n```\n\n**Parameters:**...
def reverse_words(string): reversed_words = [''.join(reversed(word)) for word in string.split()] return ' '.join(reversed_words)
simplelr_Filter
[ { "content": "Question:\ndef reverse_words(string):\n words = string.split()\n reversed_words = []\n for word in words:\n reversed_word = ''.join(reversed(word))\n reversed_words.append(reversed_word)\n reversed_string = ' '.join(reversed_words)\n return reversed_string\nAnswer:\nLe...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7310, "level": 1, "question": "def reverse_words(string):\n words = string.split()\n reversed_words = []\n for word in words:\n reversed_word = ''.join(reversed(word))\n reversed_words.append(reversed_word)\n reversed_string = ' '.join(reversed_words)\n ...
def find_anagrams(word, word_list): target = ''.join(sorted(word.lower())) anagrams = [] for w in word_list: if ''.join(sorted(w.lower())) == target: anagrams.append(w) return anagrams
simplelr_Filter
[ { "content": "Question:\nCan you provide a Python code that can find all the anagrams of a given word in a list of words? For example, if the word is \"listen\" and the list of words is [\"enlist\", \"google\", \"inlets\", \"banana\"], the output should be [\"enlist\", \"inlets\"].\nAnswer:\nLet's think step by...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7311, "level": 1, "question": "Can you provide a Python code that can find all the anagrams of a given word in a list of words? For example, if the word is \"listen\" and the list of words is [\"enlist\", \"google\", \"inlets\", \"banana\"], the output should be [\"enlist\", \"inlet...
numbers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20] def reverse_array(arr): arr_copy = arr.copy() start = 0 end = len(arr_copy) - 1 while start < end: arr_copy[start], arr_copy[end] = arr_copy[end], arr_copy[start] start += 1 end -= 1 return arr_copy # Example usage: reversed_nu...
simplelr_Filter
[ { "content": "Question:\nMake an array in Python with the following elements in this order: 2, 4, 6, 8, 10, 12, 14, 16, 18, and 20. Then, write a function to reverse this array and return the reversed array without using any built-in reverse functions or methods. Ensure the time complexity of your solution is O...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7312, "level": 1, "question": "Make an array in Python with the following elements in this order: 2, 4, 6, 8, 10, 12, 14, 16, 18, and 20. Then, write a function to reverse this array and return the reversed array without using any built-in reverse functions or methods. Ensure the ti...
def longest_unique_substring(text): if not text: return "" left = 0 max_length = 0 start = 0 char_index = {} for right in range(len(text)): char = text[right] if char in char_index and char_index[char] >= left: left = char_index[char] + 1 char_index[ch...
simplelr_Leetcode
[ { "content": "Question:\nWrite a function that takes a string `text` as input and returns the longest substring without repeating characters. If there are multiple substrings with the same maximum length, return the first one.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7313, "level": 1, "question": "Write a function that takes a string `text` as input and returns the longest substring without repeating characters. If there are multiple substrings with the same maximum length, return the first one.", "split": "train" }
from collections import Counter def canFormPalindrome(s): counts = Counter(s) odd_count = sum(1 for v in counts.values() if v % 2 != 0) if len(s) % 2 == 0: return odd_count == 0 else: return odd_count == 1
simplelr_Leetcode
[ { "content": "Question:\nGiven a string consisting of only lowercase English letters, you need to determine if it can be rearranged to form a palindrome. A palindrome is a word that reads the same backward as forward. For example, \"racecar\" and \"level\" are palindromes. Implement a function `canFormPalindrom...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7314, "level": 1, "question": "Given a string consisting of only lowercase English letters, you need to determine if it can be rearranged to form a palindrome. A palindrome is a word that reads the same backward as forward. For example, \"racecar\" and \"level\" are palindromes. Imp...
def word_frequencies(words): word_counts = {} for word in words: word_counts[word] = word_counts.get(word, 0) + 1 return word_counts
simplelr_Filter
[ { "content": "Question:\nCreate a Python function that takes a list of words and returns a dictionary that tabulates the frequency of each word's appearance in the list.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7315, "level": 1, "question": "Create a Python function that takes a list of words and returns a dictionary that tabulates the frequency of each word's appearance in the list.", "split": "train" }
def prefix_sum_2d(matrix): if not matrix or not matrix[0]: return [] rows = len(matrix) cols = len(matrix[0]) # Initialize the prefix sum matrix with an extra row and column of zeros prefix = [[0] * (cols + 1) for _ in range(rows + 1)] for i in range(1, rows + 1): ...
simplelr_Prefill
[ { "content": "Question:\nWrite a function to implement a prefix sum of a 2D array. The prefix sum of a 2D array is calculated as the sum of all elements up to the current row and column in the 2D array. You are required to achieve this efficiently.\nAnswer:\nLet's think step by step.\n", "role": "user" } ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7316, "level": 1, "question": "Write a function to implement a prefix sum of a 2D array. The prefix sum of a 2D array is calculated as the sum of all elements up to the current row and column in the 2D array. You are required to achieve this efficiently.", "split": "train" }
def is_disjoint_sequence(arr): n = len(arr) if n <= 1: return True # Check for duplicate elements if len(set(arr)) != n: return False # Check consecutive elements for i in range(n - 1): if abs(arr[i] - arr[i + 1]) <= 1: return False return True
simplelr_Leetcode
[ { "content": "Question:\nGiven an integer array `arr`, write a function to determine if it is a **disjoint** sequence. A sequence is considered **disjoint** if no element in the sequence repeats and the absolute difference between every pair of consecutive elements is greater than 1. Return `true` if the array ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7317, "level": 1, "question": "Given an integer array `arr`, write a function to determine if it is a **disjoint** sequence. A sequence is considered **disjoint** if no element in the sequence repeats and the absolute difference between every pair of consecutive elements is greater ...
from typing import List def count_people_who_can_see(heights: List[int]) -> int: if not heights: return 0 count = 1 max_h = heights[0] for h in heights[1:]: if h > max_h: count += 1 max_h = h return count
simplelr_Code_Contests
[ { "content": "Question:\nYou are given an array of integers that represent the heights of people standing in a row. Each person wants to see a parade happening in front of them. However, if a person is shorter than any person in front of them, their view will be blocked.\n\nWrite a function `count_people_who_ca...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7318, "level": 1, "question": "You are given an array of integers that represent the heights of people standing in a row. Each person wants to see a parade happening in front of them. However, if a person is shorter than any person in front of them, their view will be blocked.\n\nWr...
import re from collections import defaultdict def count_word_occurrences(filename): word_counts = defaultdict(int) word_pattern = re.compile(r"[a-z']+") with open(filename, 'r') as file: for line in file: line_lower = line.lower() words = word_pattern.findall(line_lower...
simplelr_Prefill
[ { "content": "Question:\nCreate a function that reads a file and counts the occurrences of each word in the file. The function should ignore case sensitivity and punctuation. Then, return a dictionary with words as keys and their counts as values. Assume the file is large and text processing efficiency is cruci...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7319, "level": 1, "question": "Create a function that reads a file and counts the occurrences of each word in the file. The function should ignore case sensitivity and punctuation. Then, return a dictionary with words as keys and their counts as values. Assume the file is large and ...
def find_peak(lst): if not lst: return -1 n = len(lst) if n == 1: return 0 for i in range(n): if i == 0: if lst[i] > lst[i+1]: return i elif i == n-1: if lst[i] > lst[i-1]: return i else: if lst[i...
simplelr_Evol
[ { "content": "Question:\nWrite a function that receives a list of integers and returns the index of the first peak element. A peak element is an element that is greater than its neighbors. If the input list is empty or no peak exists, return -1. A peak at the first or last position is acceptable.\n\nExample inp...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7320, "level": 1, "question": "Write a function that receives a list of integers and returns the index of the first peak element. A peak element is an element that is greater than its neighbors. If the input list is empty or no peak exists, return -1. A peak at the first or last pos...
import numpy as np def standardize_and_fill_missing(X): # Create a copy of the input array to avoid modifying the original X_filled = X.copy() # Iterate over each column to fill missing values with the column's mean for i in range(X_filled.shape[1]): col = X_filled[:, i] col_mean =...
simplelr_Package
[ { "content": "Question:\nCreate a function that standardizes a given 2D numpy array using Z-score normalization and fills any missing values (NaNs) with the mean of the respective column before standardization. The function should take as input a 2D numpy array and return the standardized array. If there are no...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7321, "level": 1, "question": "Create a function that standardizes a given 2D numpy array using Z-score normalization and fills any missing values (NaNs) with the mean of the respective column before standardization. The function should take as input a 2D numpy array and return the ...
def count_balanced_substrings(s: str) -> int: count = 0 balance = 0 start = 0 for i in range(len(s)): if s[i] == 'R': balance += 1 else: balance -= 1 if balance == 0: count += 1 start = i + 1 balance = 0 return count
simplelr_Apps
[ { "content": "Question:\nWrite a function `count_balanced_substrings(s: str) -> int` that takes a string s consisting only of characters 'L' and 'R'. The function should return the number of balanced substrings. A balanced substring is one that contains an equal number of 'L' and 'R' characters, and all the bal...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7322, "level": 1, "question": "Write a function `count_balanced_substrings(s: str) -> int` that takes a string s consisting only of characters 'L' and 'R'. The function should return the number of balanced substrings. A balanced substring is one that contains an equal number of 'L' ...
import numpy as np def rotate_matrix_90_clockwise(matrix: np.ndarray) -> np.ndarray: return np.rot90(matrix, k=-1)
simplelr_Package
[ { "content": "Question:\nYour task is to write a function that rotates a matrix by 90 degrees clockwise. This exercise will help you understand matrix manipulation using the `numpy` library.\n\n**Function Signature**:\n```python\ndef rotate_matrix_90_clockwise(matrix: np.ndarray) -> np.ndarray:\n```\n\n**Parame...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7323, "level": 1, "question": "Your task is to write a function that rotates a matrix by 90 degrees clockwise. This exercise will help you understand matrix manipulation using the `numpy` library.\n\n**Function Signature**:\n```python\ndef rotate_matrix_90_clockwise(matrix: np.ndarr...
def compress_string(s): if not s: return s compressed = [] current = s[0] count = 1 for c in s[1:]: if c == current: count += 1 else: compressed.append(current + str(count)) current = c count = 1 compressed.append(current + ...
simplelr_Code_Contests
[ { "content": "Question:\nA software company wants to implement a feature that compresses strings using the Run-Length Encoding (RLE) algorithm. The RLE algorithm works by replacing sequences of the same character with a single character followed by the number of consecutive occurrences. For example, the string ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7324, "level": 1, "question": "A software company wants to implement a feature that compresses strings using the Run-Length Encoding (RLE) algorithm. The RLE algorithm works by replacing sequences of the same character with a single character followed by the number of consecutive oc...
from typing import List def max_non_adjacent_sum(distances: List[int]) -> int: if not distances: return 0 n = len(distances) if n == 1: return distances[0] prev_prev = 0 # Represents max sum up to i-2 prev = distances[0] # Represents max sum up to i-1 for i in range(...
simplelr_Algorithm
[ { "content": "Question:\n### Problem Statement\n\nYou are the lead developer at a logistics company that manages a large fleet of delivery trucks. To improve delivery efficiency, you need to analyze the travel patterns of these trucks. Each travel pattern is represented as a list of integers, with each integer ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7325, "level": 1, "question": "### Problem Statement\n\nYou are the lead developer at a logistics company that manages a large fleet of delivery trucks. To improve delivery efficiency, you need to analyze the travel patterns of these trucks. Each travel pattern is represented as a l...
from typing import List def custom_counting_sort(arr: List[int]) -> List[int]: if not arr: return [] min_val = min(arr) max_val = max(arr) range_size = max_val - min_val + 1 count_arr = [0] * range_size for num in arr: index = num - min_val count_arr[index] += ...
simplelr_Data_Structure
[ { "content": "Question:\n### Problem: Custom Counting Sort Implementation\n\nYou are tasked with implementing a custom variation of the Counting Sort algorithm that can handle both positive and negative integers. Based on the framework provided in the analysis, your goal is to complete a function `custom_counti...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7326, "level": 1, "question": "### Problem: Custom Counting Sort Implementation\n\nYou are tasked with implementing a custom variation of the Counting Sort algorithm that can handle both positive and negative integers. Based on the framework provided in the analysis, your goal is to...
from typing import Tuple def find_longest_unique_substring(s: str) -> Tuple[int, str]: left = 0 max_len = 0 start = 0 end = 0 char_index = {} for right in range(len(s)): char = s[right] if char in char_index and char_index[char] >= left: left = char_index[char] + 1 ...
simplelr_Taco
[ { "content": "Question:\nYou are given a string consisting of only lowercase alphabets. Your task is to find the longest substring that consists of only distinct characters and print its length. If there are multiple substrings with the maximum length, print any one of them.\n\nImplement a function `find_longes...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7327, "level": 1, "question": "You are given a string consisting of only lowercase alphabets. Your task is to find the longest substring that consists of only distinct characters and print its length. If there are multiple substrings with the maximum length, print any one of them.\n...
def max_product_subarray(nums): if not nums: return 0 n = len(nums) if n == 1: return nums[0] currentMax = nums[0] currentMin = nums[0] maxSoFar = currentMax for i in range(1, n): num = nums[i] # Calculate potential new max and min tempMax = ...
simplelr_Prefill
[ { "content": "Question:\nCreate a function that accepts an array of integers and returns the maximum product of a sub-array. The sub-array must contain at least one element. If the input array contains only one element, return that element. If the input array is empty, return 0.\nAnswer:\nLet's think step by st...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7328, "level": 1, "question": "Create a function that accepts an array of integers and returns the maximum product of a sub-array. The sub-array must contain at least one element. If the input array contains only one element, return that element. If the input array is empty, return ...
from collections import deque def find_shortest_path(network, start, end, allow_indirect): if start not in network: return [] if start == end: return [start] visited = set() queue = deque() queue.append((start, [start], 0)) while queue: node, path, depth = queu...
simplelr_Algorithm
[ { "content": "Question:\n### Background\nYou are developing a software that analyzes social network connections. In this network, users are represented as nodes, and friendships are represented as edges between the nodes. You need to determine the shortest path between two users, allowing the user to specify wh...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7329, "level": 1, "question": "### Background\nYou are developing a software that analyzes social network connections. In this network, users are represented as nodes, and friendships are represented as edges between the nodes. You need to determine the shortest path between two use...
import seaborn as sns import numpy as np import matplotlib.pyplot as plt def custom_cubehelix_palette(n_colors: int = 6, start: float = 0, rot: float = 0.4, gamma: float = 1.0, hue: float = 0.8, dark: float = 0, light: float = 1, reverse: bool = False, as_cma...
simplelr_Docs
[ { "content": "Question:\n### Question: Customizing Seaborn's `cubehelix_palette`\n\n#### Objective:\nWrite a Python function that generates a seaborn `cubehelix` palette based on a variety of parameters, and then apply this palette to a simple plot using seaborn.\n\n#### Function Signature:\n```python\ndef cust...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7330, "level": 1, "question": "### Question: Customizing Seaborn's `cubehelix_palette`\n\n#### Objective:\nWrite a Python function that generates a seaborn `cubehelix` palette based on a variety of parameters, and then apply this palette to a simple plot using seaborn.\n\n#### Funct...
def count_unique_elements(data: list) -> list: counts = {} result_order = [] for element in data: if element not in counts: counts[element] = 1 result_order.append(element) else: counts[element] += 1 return [(elem, counts[elem]) for elem in result_orde...
simplelr_Algorithm
[ { "content": "Question:\n### Unique Elements Counter\n\n**Objective**: Implement a function to count unique elements in a list while preserving the original order of appearance and displaying elements' counts.\n\n**Scenario**: In a data normalization process, it's necessary to count the occurrences of each uniq...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7331, "level": 1, "question": "### Unique Elements Counter\n\n**Objective**: Implement a function to count unique elements in a list while preserving the original order of appearance and displaying elements' counts.\n\n**Scenario**: In a data normalization process, it's necessary to...
def two_sum(nums, target): seen = {} for i, num in enumerate(nums): complement = target - num if complement in seen: return [seen[complement], i] seen[num] = i return []
simplelr_Evol
[ { "content": "Question:\nWrite a function that takes an integer array and an integer target, and returns the indices of the two numbers in the array such that they add up to the target. If no such two numbers exist, return an empty list. Consider the array to have exactly one solution and do not use the same el...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7332, "level": 1, "question": "Write a function that takes an integer array and an integer target, and returns the indices of the two numbers in the array such that they add up to the target. If no such two numbers exist, return an empty list. Consider the array to have exactly one ...
def canBeHighest(nums, extraPoints): res = [] n = len(nums) for i in range(n): new_score = nums[i] + extraPoints others = nums[:i] + nums[i+1:] if not others: others_max = -float('inf') else: others_max = max(others) res.append(new_score >= oth...
simplelr_Taco
[ { "content": "Question:\nWrite a function that takes an integer array `nums`, representing the current scores of various players in a game, and an integer `extraPoints`, denoting the extra points a player can gain. Return a list of booleans where each boolean indicates whether, after adding the `extraPoints` to...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7333, "level": 1, "question": "Write a function that takes an integer array `nums`, representing the current scores of various players in a game, and an integer `extraPoints`, denoting the extra points a player can gain. Return a list of booleans where each boolean indicates whether...
def is_panagram(sentence: str, alphabet: str) -> bool: alphabet_set = set(alphabet.lower()) sentence_set = set(sentence.lower()) return alphabet_set.issubset(sentence_set)
simplelr_Data_Structure
[ { "content": "Question:\nPanagram Checker for Custom Alphabets\n\n#### Context:\nYou are assigned to develop a feature in a multilingual natural language processing (NLP) tool. The tool needs to check whether a given sentence is a panagram for a dynamically defined set of alphabets. This is important for analyz...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7334, "level": 1, "question": "Panagram Checker for Custom Alphabets\n\n#### Context:\nYou are assigned to develop a feature in a multilingual natural language processing (NLP) tool. The tool needs to check whether a given sentence is a panagram for a dynamically defined set of alph...
import pickle import json import hashlib import os def secure_file_transform(input_filepath: str, output_filepath: str) -> None: try: # Check if input file exists if not os.path.isfile(input_filepath): raise FileNotFoundError(f"Input file {input_filepath} not found.") # Read an...
simplelr_Docs
[ { "content": "Question:\n**Coding Assessment Question: Security-Aware Function Implementation**\n\n### Objective\nYou are required to implement a function that reads data from a file, processes it, and then securely outputs the transformed data in a new file. This task will assess your understanding of handling...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7335, "level": 1, "question": "**Coding Assessment Question: Security-Aware Function Implementation**\n\n### Objective\nYou are required to implement a function that reads data from a file, processes it, and then securely outputs the transformed data in a new file. This task will as...
def convert_value(value): """Convert a string value to an appropriate type (int, float, bool, or string)""" if value is None: return "None" if value == 'true': return True if value == 'false': return False # Try converting to integer first try: return int(value) ...
simplelr_Filter
[ { "content": "Question:\nI'm building a simple script that converts well-structured XML to JSON. I want to define two functions: `parse_xml_to_json` and `convert_value`. The `parse_xml_to_json` function should take an XML element as input and return a JSON-compatible dictionary representation. The `convert_valu...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7336, "level": 1, "question": "I'm building a simple script that converts well-structured XML to JSON. I want to define two functions: `parse_xml_to_json` and `convert_value`. The `parse_xml_to_json` function should take an XML element as input and return a JSON-compatible dictionar...
def trap_rain_water(heights: list) -> int: if not heights or len(heights) < 3: return 0 n = len(heights) left_max = [0] * n for i in range(1, n): left_max[i] = max(left_max[i-1], heights[i-1]) right_max = [0] * n for i in range(n-2, -1, -1): right_max[i] = max(right_max[i...
simplelr_Algorithm
[ { "content": "Question:\n### Coding Question\n\nWrite a function that can solve the \"Trapped Rain Water\" problem. The function should determine the amount of rainwater that can be trapped between the bars in a given list of non-negative integers, where each integer represents the height of a bar.\n\n### Funct...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7337, "level": 1, "question": "### Coding Question\n\nWrite a function that can solve the \"Trapped Rain Water\" problem. The function should determine the amount of rainwater that can be trapped between the bars in a given list of non-negative integers, where each integer represent...
def max_product_of_two(arr): if len(arr) < 2: return None arr_sorted = sorted(arr) candidate1 = arr_sorted[-1] * arr_sorted[-2] candidate2 = arr_sorted[0] * arr_sorted[1] return max(candidate1, candidate2)
simplelr_Apps
[ { "content": "Question:\nYou need to write a function that takes an array of integers and returns the maximum product of any two distinct numbers from the array.\n\nFor example, for the array `[3, 5, -2, 8, 11]` the function should return `88`, because the maximum product is from the pair `(8, 11)`.\n\nFor the ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7338, "level": 1, "question": "You need to write a function that takes an array of integers and returns the maximum product of any two distinct numbers from the array.\n\nFor example, for the array `[3, 5, -2, 8, 11]` the function should return `88`, because the maximum product is f...
def product_except_self(nums): n = len(nums) if n == 0: return [] prefix = [1] * n for i in range(1, n): prefix[i] = prefix[i-1] * nums[i-1] suffix = [1] * n for i in range(n-2, -1, -1): suffix[i] = suffix[i+1] * nums[i+1] result = [prefix[i] * suffix[i...
simplelr_Filter
[ { "content": "Question:\nWrite a program that takes an array of integers and returns an array of the same size where each element is the product of all the elements in the input array except for the one at the current index. Do not use division in your solution.\nAnswer:\nLet's think step by step.\n", "role...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7339, "level": 1, "question": "Write a program that takes an array of integers and returns an array of the same size where each element is the product of all the elements in the input array except for the one at the current index. Do not use division in your solution.", "split": "...
import pwd def get_users_with_shell(shell): users = {} for user in pwd.getpwall(): if user.pw_shell == shell: users[user.pw_name] = user.pw_dir if not users: raise ValueError("No users found with the specified shell.") return users
simplelr_Docs
[ { "content": "Question:\n### Unix User Account and Password Database Analysis\n\n#### Objective:\nYou are required to write a Python function that utilizes the `pwd` module to analyze Unix user account data and output specific information based on given criteria.\n\n#### Function Specification:\n\n- **Function ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7340, "level": 1, "question": "### Unix User Account and Password Database Analysis\n\n#### Objective:\nYou are required to write a Python function that utilizes the `pwd` module to analyze Unix user account data and output specific information based on given criteria.\n\n#### Funct...
def square_values_in_pairs(pairs): return [(key, [num ** 2 for num in nums]) for key, nums in pairs]
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that takes a list of pairs (tuples) and returns a new list of pairs. In the input list, for every pair, the first element is a string representing a key, and the second element is a list of integers. The function should square each integer in the list and return ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7341, "level": 1, "question": "Write a Python function that takes a list of pairs (tuples) and returns a new list of pairs. In the input list, for every pair, the first element is a string representing a key, and the second element is a list of integers. The function should square e...
def binary_search(arr, target): low = 0 high = len(arr) - 1 while low <= high: mid = (low + high) // 2 if arr[mid] == target: return True elif arr[mid] > target: high = mid - 1 else: low = mid + 1 return False
simplelr_Prefill
[ { "content": "Question:\nWrite a function to perform a binary search on a sorted array to find if a given target value exists in the array.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7342, "level": 1, "question": "Write a function to perform a binary search on a sorted array to find if a given target value exists in the array.", "split": "train" }
import os import datetime from datetime import datetime as dt def search_file(directory, filename, start_date, end_date): """ Searches for a specific file by name and creation date within a directory and its subdirectories. Args: directory (str): Path to the directory to search in. filenam...
simplelr_Filter
[ { "content": "Question:\nCan you write a short Python script that can search for a specific file in a given directory and all its subdirectories, using file name and creation date as search parameters? It should accept the directory path, the file name, and a date range as input.\nAnswer:\nLet's think step by s...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7343, "level": 1, "question": "Can you write a short Python script that can search for a specific file in a given directory and all its subdirectories, using file name and creation date as search parameters? It should accept the directory path, the file name, and a date range as inp...
def minDistance(str1, str2): m = len(str1) n = len(str2) # Create a DP table with (m+1) rows and (n+1) columns dp = [[0] * (n + 1) for _ in range(m + 1)] # Initialize the base cases for i in range(m + 1): dp[i][0] = i # Deleting all characters from str1[0..i-1] for j in ra...
simplelr_Filter
[ { "content": "Question:\nThe goal is to find the minimum number of moves to convert a given string to another string.\n\nFor example:\n\n**Input:**\n\n```\nstr1 = \"horse\"\nstr2 = \"ros\"\n```\n\n**Output:**\n\n```\n3\n```\n\n**Explanation:**\n\n1. Delete 'h' from \"horse\" -> \"orse\"\n2. Delete 'e' from \"or...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7344, "level": 1, "question": "The goal is to find the minimum number of moves to convert a given string to another string.\n\nFor example:\n\n**Input:**\n\n```\nstr1 = \"horse\"\nstr2 = \"ros\"\n```\n\n**Output:**\n\n```\n3\n```\n\n**Explanation:**\n\n1. Delete 'h' from \"horse\" -...
from typing import List def count_exact_matches(secret: str, guesses: List[str]) -> List[int]: results = [] for guess in guesses: count = sum(s == g for s, g in zip(secret, guess)) results.append(count) return results
simplelr_Code_Contests
[ { "content": "Question:\nAlice loves organizing contests for her friends. This time, she came up with a number guessing game. She writes down a secret number and asks her friends to guess it. To make the game fair and interesting, she gives some hints. After each friend's guess, she tells them how many digits i...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7345, "level": 1, "question": "Alice loves organizing contests for her friends. This time, she came up with a number guessing game. She writes down a secret number and asks her friends to guess it. To make the game fair and interesting, she gives some hints. After each friend's gues...
def binary_search(lst, value): low = 0 high = len(lst) - 1 while low <= high: mid = (low + high) // 2 if lst[mid] == value: return mid elif lst[mid] > value: high = mid - 1 else: low = mid + 1 return -1
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that takes a list and a value, and returns the index of the value in the list if it exists, otherwise returns -1. This function should implement a binary search algorithm for this purpose.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7346, "level": 1, "question": "Write a Python function that takes a list and a value, and returns the index of the value in the list if it exists, otherwise returns -1. This function should implement a binary search algorithm for this purpose.", "split": "train" }
def maxReward(grid): m = len(grid) if m == 0: return 0 n = len(grid[0]) dp = [[0 for _ in range(n)] for _ in range(m)] dp[0][0] = grid[0][0] # Fill the first row for j in range(1, n): dp[0][j] = dp[0][j-1] + grid[0][j] # Fill the first column for i in range(...
simplelr_Taco
[ { "content": "Question:\nFox AI is playing a simple grid-based game and wants to find the optimal path to collect rewards. The grid is an m x n matrix where each cell contains a reward value. Fox AI can only move right or down from the top-left corner to the bottom-right corner of the grid. Fox AI wants to coll...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7347, "level": 1, "question": "Fox AI is playing a simple grid-based game and wants to find the optimal path to collect rewards. The grid is an m x n matrix where each cell contains a reward value. Fox AI can only move right or down from the top-left corner to the bottom-right corne...
def count_occurrences(arr): if not arr: return {} count_dict = {} current_num = arr[0] current_count = 1 for num in arr[1:]: if num == current_num: current_count += 1 else: count_dict[current_num] = current_count current_num = num ...
simplelr_Filter
[ { "content": "Question:\nHere's the exercise: we have a given sorted array of integers and we need to count the occurrences of each distinct integer using a single pass through the array. \n\nI am thinking of creating a dictionary where the keys will be distinct integers and the values will be their correspondi...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7348, "level": 1, "question": "Here's the exercise: we have a given sorted array of integers and we need to count the occurrences of each distinct integer using a single pass through the array. \n\nI am thinking of creating a dictionary where the keys will be distinct integers and t...
def format_number(number): return "{:,}".format(number)
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to format a large number into a comma-separated string.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7349, "level": 1, "question": "Write a python function to format a large number into a comma-separated string.", "split": "train" }
def is_sorted_and_single_duplicate(arr): if not arr: return True # An empty array is considered sorted. freq = {} for i in range(len(arr)): current = arr[i] # Check if the array is non-decreasing if i > 0 and current < arr[i-1]: return False # Check ...
simplelr_Prefill
[ { "content": "Question:\nWrite a function to determine if an array is sorted in non-decreasing order and contains at most one duplicate of any element.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7350, "level": 1, "question": "Write a function to determine if an array is sorted in non-decreasing order and contains at most one duplicate of any element.", "split": "train" }
def remove_duplicates(nums): if not nums: return 0 write_pointer = 0 for i in range(1, len(nums)): if nums[i] != nums[write_pointer]: write_pointer += 1 nums[write_pointer] = nums[i] return write_pointer + 1
simplelr_Prefill
[ { "content": "Question:\nWrite a function to remove duplicates from a sorted array in place and return the new length of the array. Do not allocate extra space for another array; you must do this by modifying the input array in place with O(1) extra memory.\nAnswer:\nLet's think step by step.\n", "role": "u...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7351, "level": 1, "question": "Write a function to remove duplicates from a sorted array in place and return the new length of the array. Do not allocate extra space for another array; you must do this by modifying the input array in place with O(1) extra memory.", "split": "train...
def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: a, b = 0, 1 for i in range(2, n + 1): c = a + b a = b b = c return b
simplelr_Prefill
[ { "content": "Question:\nWrite a function to generate the nth Fibonacci number. The Fibonacci sequence is defined as follows: the first number in the sequence is 0, the second number is 1, and each subsequent number is the sum of the previous two. For example, the first six numbers in the Fibonacci sequence are...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7352, "level": 1, "question": "Write a function to generate the nth Fibonacci number. The Fibonacci sequence is defined as follows: the first number in the sequence is 0, the second number is 1, and each subsequent number is the sum of the previous two. For example, the first six nu...
import pandas as pd import numpy as np def preprocess_stock_data( data: pd.DataFrame, n_steps: int, feature_range: tuple[float, float] = (0, 1) ) -> tuple[np.ndarray, np.ndarray]: # Handle missing values using forward fill for all columns except 'Date' data.iloc[:, 1:] = data.iloc[:, 1:].ffill() ...
simplelr_Algorithm
[ { "content": "Question:\n### Data Preprocessing for Stock Price Prediction\n\n#### Description\nYou are building a machine learning model to predict stock prices, and you need to preprocess the data for training. The preprocessing steps involve handling missing values, scaling features, and generating sequences...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7353, "level": 1, "question": "### Data Preprocessing for Stock Price Prediction\n\n#### Description\nYou are building a machine learning model to predict stock prices, and you need to preprocess the data for training. The preprocessing steps involve handling missing values, scaling...
def factorial(n): if n == 0: return 1 else: result = 1 for i in range(1, n + 1): result *= i return result # Example usage: print(factorial(5)) # Outputs: 120 print(factorial(0)) # Outputs: 1
simplelr_Filter
[ { "content": "Question:\nCan you help me write a simple function in Python to calculate the factorial of a number? I'm a beginner in programming and would appreciate a clear explanation.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7354, "level": 1, "question": "Can you help me write a simple function in Python to calculate the factorial of a number? I'm a beginner in programming and would appreciate a clear explanation.", "split": "train" }
def group_anagrams(strs): groups = {} for s in strs: key = ''.join(sorted(s)) if key in groups: groups[key].append(s) else: groups[key] = [s] return list(groups.values())
simplelr_Leetcode
[ { "content": "Question:\nGiven a list of strings `strs`, group the anagrams together and return the result in a list of lists. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Each element in the list of string...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7355, "level": 1, "question": "Given a list of strings `strs`, group the anagrams together and return the result in a list of lists. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once....
import torch def tensor_view_operations(A: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]: # Step 1: Create tensor view B of shape (6, 4, 5) B = A.view(6, 4, 5) # Step 2: Modify the first element of B and get the modified element from A B[0, 0, 0] = 3.14 modifie...
simplelr_Docs
[ { "content": "Question:\n### PyTorch Coding Assessment Question\n\n#### Objective:\nTo assess students' comprehension of tensor views in PyTorch, including creating views, modifying views, and ensuring contiguity.\n\n#### Problem Statement:\nYou are provided with a 4-dimensional tensor `A` of shape (2, 3, 4, 5)...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7356, "level": 1, "question": "### PyTorch Coding Assessment Question\n\n#### Objective:\nTo assess students' comprehension of tensor views in PyTorch, including creating views, modifying views, and ensuring contiguity.\n\n#### Problem Statement:\nYou are provided with a 4-dimension...
def int_to_roman(num): roman_numerals = [ (1000, 'M'), (900, 'CM'), (500, 'D'), (400, 'CD'), (100, 'C'), (90, 'XC'), (50, 'L'), (40, 'XL'), (10, 'X'), (9, 'IX'), (5, 'V'), (4, 'IV'), (1, 'I') ] result = '...
simplelr_Taco
[ { "content": "Question:\nWrite a function that takes an integer as input and returns a string representing the number in Roman numeral form. The input will be an integer between 1 and 3999.\n\nExamples:\n\n```python\nint_to_roman(1) # returns \"I\"\nint_to_roman(1990) # returns \"MCMXC\"\nint_to_roman(3999) ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7357, "level": 1, "question": "Write a function that takes an integer as input and returns a string representing the number in Roman numeral form. The input will be an integer between 1 and 3999.\n\nExamples:\n\n```python\nint_to_roman(1) # returns \"I\"\nint_to_roman(1990) # ret...
def find_subsequence_index(input_str, search_str): if len(search_str) == 0: return 0 if len(input_str) < len(search_str): return -1 len_sub = len(search_str) len_s = len(input_str) for i in range(len_s - len_sub + 1): current_pos = i found = True for char in s...
simplelr_Filter
[ { "content": "Question:\nYou are given a string input_str. You need to find if a given substring, search_str, \nis a subsequence of the input string. If it finds the subsequence return the starting index of the \nfirst instance of the subsequence, otherwise return -1.\n\n\nExample:\n\ninput_str = “abcde”\nsearc...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7358, "level": 1, "question": "You are given a string input_str. You need to find if a given substring, search_str, \nis a subsequence of the input string. If it finds the subsequence return the starting index of the \nfirst instance of the subsequence, otherwise return -1.\n\n\nExa...
def max_tasks_assigned(tasks, workers): tasks.sort() workers.sort() i = j = count = 0 while i < len(tasks) and j < len(workers): if workers[j] >= tasks[i]: count += 1 i += 1 j += 1 else: j += 1 return count # Example usage: # print(max...
simplelr_Taco
[ { "content": "Question:\nYou are given two integer arrays. The first array represents the number of tasks to be completed, where each task i has a duration ti. The second array represents workers available, where each worker j can handle a maximum duration dj. If dj >= ti, the task i can be assigned to the work...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7359, "level": 1, "question": "You are given two integer arrays. The first array represents the number of tasks to be completed, where each task i has a duration ti. The second array represents workers available, where each worker j can handle a maximum duration dj. If dj >= ti, the...
def countSubstrings(S): count = 0 n = len(S) for i in range(n): for j in range(i, n): if S[i] == S[j]: count += 1 return count
simplelr_Taco
[ { "content": "Question:\nGiven a string S consisting of lowercase alphabets, the task is to find the count of substrings that start and end with the same character.\n\nExample 1:\nInput: S = \"abcab\"\nOutput: 7\nExplanation: The substrings are:\na, b, c, a, b, aa, bb.\nHere, 7 substrings start and end with the...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7360, "level": 1, "question": "Given a string S consisting of lowercase alphabets, the task is to find the count of substrings that start and end with the same character.\n\nExample 1:\nInput: S = \"abcab\"\nOutput: 7\nExplanation: The substrings are:\na, b, c, a, b, aa, bb.\nHere, ...
def smallest_substring_with_all_chars(s: str) -> str: required = len(set(s)) if required == 0: return "" counts = {} current_unique = 0 min_length = float('inf') result = "" left = 0 for right in range(len(s)): c = s[right] counts[c] = counts.get(c, 0) +...
simplelr_Algorithm
[ { "content": "Question:\n### Problem Statement\nYou are tasked with implementing a function to find the smallest substring in a given string `s` that contains all the distinct characters in `s`. The function should be efficient with respect to both time and space complexity.\n\n### Objective\nWrite a function `...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7361, "level": 1, "question": "### Problem Statement\nYou are tasked with implementing a function to find the smallest substring in a given string `s` that contains all the distinct characters in `s`. The function should be efficient with respect to both time and space complexity.\n...
def non_repeated_elements(lst): counts = {} for item in lst: counts[item] = counts.get(item, 0) + 1 result = [] for item in lst: if counts[item] == 1: result.append(item) return result
simplelr_Prefill
[ { "content": "Question:\nCreate a function that returns a list of non-repeated elements in the given list.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7362, "level": 1, "question": "Create a function that returns a list of non-repeated elements in the given list.", "split": "train" }
from typing import List, Tuple def find_pair_with_sum(nums: List[int], k: int) -> Tuple[int, int]: seen = {} for i, num in enumerate(nums): complement = k - num if complement in seen: return (seen[complement], i) seen[num] = i return ()
simplelr_Codeforces
[ { "content": "Question:\nYou are given an integer array nums of length n and an integer k. Write a function that finds out whether there exist two distinct indices i and j in the array such that nums[i] + nums[j] equals k. If such a pair exists, return the indices as a tuple (i, j). If there are multiple valid ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7363, "level": 1, "question": "You are given an integer array nums of length n and an integer k. Write a function that finds out whether there exist two distinct indices i and j in the array such that nums[i] + nums[j] equals k. If such a pair exists, return the indices as a tuple (...
def palindrome(s): """Return True if the string is a palindrome, False otherwise.""" return s == s[::-1]
simplelr_Filter
[ { "content": "Question:\ndef palindrome(s):\n \"\"\"Return True if the string is a palindrome, False otherwise.\"\"\"\n return s == s[::-1]\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7364, "level": 1, "question": "def palindrome(s):\n \"\"\"Return True if the string is a palindrome, False otherwise.\"\"\"\n return s == s[::-1]", "split": "train" }
from typing import List import math def normalize_vector(vector: List[float]) -> List[float]: """ Normalize a vector to unit length. Args: vector: A list of floats representing the vector to be normalized. Returns: A new list of floats representing the normalized vector. Raises: ...
simplelr_Algorithm
[ { "content": "Question:\n### Scenario\nIn computational geometry, the concept of vector normalization is frequently used. Normalizing a vector scales it to unit length while preserving its direction, which can be critical in graphics, physics simulations, and machine learning.\n\n### Problem\nCreate a function:...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7365, "level": 1, "question": "### Scenario\nIn computational geometry, the concept of vector normalization is frequently used. Normalizing a vector scales it to unit length while preserving its direction, which can be critical in graphics, physics simulations, and machine learning....
def maxFlowers(flowerBunches): total = 0 for bunch in flowerBunches: if bunch % 2 != 0: total += bunch return total
simplelr_Code_Contests
[ { "content": "Question:\nA florist sells flowers in bunches, where each bunch contains a random number of flowers. Given an array of integers where each integer represents the number of flowers in a bunch, calculate the maximum number of flowers the florist can sell without selling any bunch that contains an ev...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7366, "level": 1, "question": "A florist sells flowers in bunches, where each bunch contains a random number of flowers. Given an array of integers where each integer represents the number of flowers in a bunch, calculate the maximum number of flowers the florist can sell without se...
from collections import deque def fill_grid(grid, seed_row, seed_col): if not grid or not grid[0]: return grid rows = len(grid) cols = len(grid[0]) if seed_row < 0 or seed_row >= rows or seed_col < 0 or seed_col >= cols: return grid if grid[seed_row][seed_col] != 0: ...
simplelr_Filter
[ { "content": "Question:\nDesign an algorithm to fill grid cells using a color fill technique, starting from a given seed point. Assume all cells are initially uncolored. Cells can be filled only if they are adjacent (up, down, left, right) to an already filled cell. The grid is represented as a 2D list where 0 ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7367, "level": 1, "question": "Design an algorithm to fill grid cells using a color fill technique, starting from a given seed point. Assume all cells are initially uncolored. Cells can be filled only if they are adjacent (up, down, left, right) to an already filled cell. The grid i...
from typing import List def rotate_array(arr: List[int], d: int) -> List[int]: n = len(arr) if n == 0: return [] effective_d = d % n return arr[effective_d:] + arr[:effective_d]
simplelr_Algorithm
[ { "content": "Question:\n### Array Rotation\n\n#### Objective\nWrite a Python function that performs a left rotation on an array of integers and returns the rotated array.\n\n#### Problem Statement\nGiven an array of integers `arr` and a number `d`, implement a function `rotate_array(arr: List[int], d: int) -> ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7368, "level": 1, "question": "### Array Rotation\n\n#### Objective\nWrite a Python function that performs a left rotation on an array of integers and returns the rotated array.\n\n#### Problem Statement\nGiven an array of integers `arr` and a number `d`, implement a function `rotat...
def min_sensors(n: int, m: int, d: int) -> int: rows = (n + d) // (d + 1) cols = (m + d) // (d + 1) return rows * cols
simplelr_Codeforces
[ { "content": "Question:\nA company plans to deploy sensors across a city grid to monitor air quality. The grid is represented as an n x m matrix where each cell (i, j) represents a possible location for a sensor. The sensor can detect air quality in all 8 directions (up, down, left, right, and the 4 diagonals) ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7369, "level": 1, "question": "A company plans to deploy sensors across a city grid to monitor air quality. The grid is represented as an n x m matrix where each cell (i, j) represents a possible location for a sensor. The sensor can detect air quality in all 8 directions (up, down,...
def reduce_string_length(s): a = s.count('a') b = s.count('b') c = s.count('c') total = a + b + c max_count = max(a, b, c) sum_others = total - max_count if max_count > sum_others: return max_count - sum_others else: return total % 2
simplelr_Leetcode
[ { "content": "Question:\nGiven a string `s` containing only the characters `'a'`, `'b'`, and `'c'`, you can delete any two adjacent characters in the string that are different. For example, deleting `'ab'` or `'bc'` from the string will reduce its length by two. Your task is to return _the length of the shortes...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7370, "level": 1, "question": "Given a string `s` containing only the characters `'a'`, `'b'`, and `'c'`, you can delete any two adjacent characters in the string that are different. For example, deleting `'ab'` or `'bc'` from the string will reduce its length by two. Your task is t...
def get_page(data, page_number, page_size): # Check for invalid inputs if not data or page_number < 1 or page_size < 1: return [] # Calculate the starting index of the page start = (page_number - 1) * page_size # If start exceeds the length of data, return empty list if start >= len(data...
simplelr_Algorithm
[ { "content": "Question:\n### Problem Statement\n\nYou are in charge of developing a pagination feature for a large dataset. One aspect of this feature is extracting a specific page of data from a list of items, where each page contains a fixed number of items. Your task is to implement a Python function that re...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7371, "level": 1, "question": "### Problem Statement\n\nYou are in charge of developing a pagination feature for a large dataset. One aspect of this feature is extracting a specific page of data from a list of items, where each page contains a fixed number of items. Your task is to ...
def longest_substring_without_repeating_characters(s): char_index = {} left = 0 max_length = 0 for right in range(len(s)): char = s[right] if char in char_index and char_index[char] >= left: left = char_index[char] + 1 char_index[char] = right current_length =...
simplelr_Filter
[ { "content": "Question:\nObjective: Implement a Python function called `longest_substring_without_repeating_characters` that finds the length of the longest substring without repeating characters in a given string.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7372, "level": 1, "question": "Objective: Implement a Python function called `longest_substring_without_repeating_characters` that finds the length of the longest substring without repeating characters in a given string.", "split": "train" }
def has_consecutive_ones(s): return '11' in s
simplelr_Prefill
[ { "content": "Question:\nWrite a function to check if a binary string has at least one pair of consecutive ones. Given a binary string `s`, return `True` if there is at least one occurrence of two consecutive '1's, otherwise return `False`.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7373, "level": 1, "question": "Write a function to check if a binary string has at least one pair of consecutive ones. Given a binary string `s`, return `True` if there is at least one occurrence of two consecutive '1's, otherwise return `False`.", "split": "train" }
def insertion_sort(arr): for i in range(1, len(arr)): key = arr[i] j = i - 1 while j >= 0 and key < arr[j]: arr[j + 1] = arr[j] j -= 1 arr[j + 1] = key return arr
simplelr_Prefill
[ { "content": "Question:\nWrite a function to sort an array of numbers in ascending order using the insertion sort algorithm. Provide the implementation in Python.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7374, "level": 1, "question": "Write a function to sort an array of numbers in ascending order using the insertion sort algorithm. Provide the implementation in Python.", "split": "train" }
def count_consecutive_duplicates(lst): count = 0 for i in range(len(lst) - 1): if lst[i] == lst[i + 1]: count += 1 return count
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to find the number of consecutive duplicates in a list.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7375, "level": 1, "question": "Write a python function to find the number of consecutive duplicates in a list.", "split": "train" }
def count_string_frequencies(strings): frequency = {} for s in strings: processed = s.strip().lower() if processed in frequency: frequency[processed] += 1 else: frequency[processed] = 1 return frequency
simplelr_Package
[ { "content": "Question:\nWrite a function that takes a list of strings and returns a dictionary where the keys are the unique strings from the list and the values are the frequency of each string. The function should be case-insensitive and ignore leading and trailing whitespace. If the list is empty, return an...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7376, "level": 1, "question": "Write a function that takes a list of strings and returns a dictionary where the keys are the unique strings from the list and the values are the frequency of each string. The function should be case-insensitive and ignore leading and trailing whitespa...
def reverse_in_place(L): left = 0 right = len(L) - 1 while left < right: L[left], L[right] = L[right], L[left] left += 1 right -= 1 return L
simplelr_Filter
[ { "content": "Question:\nGiven a list L, implement a function to reverse L in place. The function should not use any additional data structures and should have a time complexity of O(n), where n is the length of the list. Additionally, the function should only use a constant amount of extra space, meaning that ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7377, "level": 1, "question": "Given a list L, implement a function to reverse L in place. The function should not use any additional data structures and should have a time complexity of O(n), where n is the length of the list. Additionally, the function should only use a constant a...
def my_function(n): for i in range(n, 0, -1): print(i)
simplelr_Filter
[ { "content": "Question:\nThis code produces the following output:\n\n```\n>>> my_function(10)\n\n10 \n9 \n8 \n7 \n6 \n5 \n4 \n3 \n2 \n1\n```\n\nWhat does the function `my_function` do?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7378, "level": 1, "question": "This code produces the following output:\n\n```\n>>> my_function(10)\n\n10 \n9 \n8 \n7 \n6 \n5 \n4 \n3 \n2 \n1\n```\n\nWhat does the function `my_function` do?", "split": "train" }
def longestUniqueSubstring(s): last_seen = {} max_len = 0 left = 0 for right in range(len(s)): char = s[right] if char in last_seen: left = max(left, last_seen[char] + 1) last_seen[char] = right current_len = right - left + 1 if current_len > max_len: ...
simplelr_Apps
[ { "content": "Question:\n## Task\n\n**_Given_** *a string* , **_find_** *the length of the longest substring without repeating characters*.\n____\n\n# Notes\n\n* **_String_** size is *at least 1*.\n\n* **_String_** may contain *lowercase letters, uppercase letters, digits, and symbols*.\n___\n\n# Input >> Outpu...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7379, "level": 1, "question": "## Task\n\n**_Given_** *a string* , **_find_** *the length of the longest substring without repeating characters*.\n____\n\n# Notes\n\n* **_String_** size is *at least 1*.\n\n* **_String_** may contain *lowercase letters, uppercase letters, digits, and...
def validate_serial_number(serial): if len(serial) != 10: return False has_upper = False has_lower = False has_digit = False has_special = False for c in serial: if c.isupper(): has_upper = True elif c.islower(): has_lower = True elif c.isd...
simplelr_Taco
[ { "content": "Question:\nYou are an employee at a factory that produces widgets. Each widget has a serial number that consists of a string of characters (alphanumeric). As part of the quality control process, you need to verify that all the serial numbers meet the following criteria:\n- The serial number must b...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7380, "level": 1, "question": "You are an employee at a factory that produces widgets. Each widget has a serial number that consists of a string of characters (alphanumeric). As part of the quality control process, you need to verify that all the serial numbers meet the following cr...
def reconstruct_string(s, indices): new_str = [''] * len(s) for i in range(len(s)): new_str[indices[i]] = s[i] return ''.join(new_str)
simplelr_Taco
[ { "content": "Question:\nYou are given a string `s` consisting of lowercase English letters, and an integer array `indices` of the same length. The array `indices` is a permutation of the indices `[0, 1, 2, ..., s.length - 1]`.\n\nYou need to function that reconstructs the string such that the character at the ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7381, "level": 1, "question": "You are given a string `s` consisting of lowercase English letters, and an integer array `indices` of the same length. The array `indices` is a permutation of the indices `[0, 1, 2, ..., s.length - 1]`.\n\nYou need to function that reconstructs the str...
import re from typing import List, Dict def parse_logs(logs: str) -> List[Dict[str, str]]: log_list = [] pattern = re.compile(r'^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\s+([A-Z]+)\s+(.*)$') for line in logs.split('\n'): if not line: continue match = pattern.match(line) if ...
simplelr_Docs
[ { "content": "Question:\n### Question: Dynamic Log File Parser\n\nYou are given a multi-line string representing log file entries for a server. Each log entry is on a new line and includes a timestamp, log level, and a message. Here is an example of the log file:\n\n```\n2023-10-10T13:55:30 ERROR An error occur...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7382, "level": 1, "question": "### Question: Dynamic Log File Parser\n\nYou are given a multi-line string representing log file entries for a server. Each log entry is on a new line and includes a timestamp, log level, and a message. Here is an example of the log file:\n\n```\n2023-...
def two_sum(nums, target): seen = {} for num in nums: complement = target - num if complement in seen: return (complement, num) seen[num] = True return ()
simplelr_Taco
[ { "content": "Question:\nDesign a function that takes a list of integers and an integer target, and returns a tuple of two integers from the list that sum up to the target. If such a pair does not exist, return an empty tuple.\n\nExample 1:\n\nInput: nums = [2, 7, 11, 15], target = 9\nOutput: (2, 7)\nExplanatio...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7383, "level": 1, "question": "Design a function that takes a list of integers and an integer target, and returns a tuple of two integers from the list that sum up to the target. If such a pair does not exist, return an empty tuple.\n\nExample 1:\n\nInput: nums = [2, 7, 11, 15], tar...
def sum_of_digits(s): total = 0 for char in s: total += int(char) return total
simplelr_Prefill
[ { "content": "Question:\nCreate a function that reads a string of digits and returns the sum of all the digits. For example, the string \"1234\" should return 10 because 1 + 2 + 3 + 4 = 10.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7384, "level": 1, "question": "Create a function that reads a string of digits and returns the sum of all the digits. For example, the string \"1234\" should return 10 because 1 + 2 + 3 + 4 = 10.", "split": "train" }
def find_duplicates(lst): counts = {} for num in lst: counts[num] = counts.get(num, 0) + 1 result = [] added = set() for num in lst: if counts[num] > 1 and num not in added: result.append(num) added.add(num) return result
simplelr_Code_Contests
[ { "content": "Question:\nWrite a function that takes a list of integers and returns a new list containing only elements that appear more than once in the original list, preserving the order of their first occurrence.\n\nConstraints\n\n* The length of the list is between 1 and 1000 inclusive.\n* Each element in ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7385, "level": 1, "question": "Write a function that takes a list of integers and returns a new list containing only elements that appear more than once in the original list, preserving the order of their first occurrence.\n\nConstraints\n\n* The length of the list is between 1 and ...
def filter_odd_numbers(numbers): return [num for num in numbers if num % 2 != 0]
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes a list of integers, filters out the even numbers, and returns a new list containing only odd numbers. Write the function in Python.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7386, "level": 1, "question": "Create a function that takes a list of integers, filters out the even numbers, and returns a new list containing only odd numbers. Write the function in Python.", "split": "train" }
from collections import Counter def count_player_names(players): return Counter(players)
simplelr_Filter
[ { "content": "Question:\nYou are given a list of strings, each representing a player's name. Your task is to write a Python function that takes this list as input and returns a dictionary where the keys are the player names and the values are the number of occurrences of each name in the list.\nAnswer:\nLet's t...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7387, "level": 1, "question": "You are given a list of strings, each representing a player's name. Your task is to write a Python function that takes this list as input and returns a dictionary where the keys are the player names and the values are the number of occurrences of each ...
def isSpecialPalindrome(s): n = len(s) if n % 2 != 0: return 0 for i in range(n // 2): if s[i] != s[n - 1 - i]: return 0 return 1
simplelr_Taco
[ { "content": "Question:\nGiven a string S containing lowercase English alphabets. Check if the string is a \"Special Palindrome\" or not. A string is considered a Special Palindrome if it reads the same backwards and forwards and has an even length.\n\nExample 1:\nInput:\nS = \"abba\"\nOutput:\n1\nExplanation:\...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7388, "level": 1, "question": "Given a string S containing lowercase English alphabets. Check if the string is a \"Special Palindrome\" or not. A string is considered a Special Palindrome if it reads the same backwards and forwards and has an even length.\n\nExample 1:\nInput:\nS = ...
def measure_string_safety(input_string: str) -> bool: if len(input_string) < 8: return False has_upper = any(c.isupper() for c in input_string) has_lower = any(c.islower() for c in input_string) has_digit = any(c.isdigit() for c in input_string) has_special = any(c in "!@#$%^&*()-_+=" for c...
simplelr_Package
[ { "content": "Question:\nWrite a function named `measure_string_safety` that determines if the given string is safe based on certain criteria. For a string to be considered \"safe\", it must meet the following conditions:\n1. The string must be at least 8 characters long.\n2. It must contain at least one upperc...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7389, "level": 1, "question": "Write a function named `measure_string_safety` that determines if the given string is safe based on certain criteria. For a string to be considered \"safe\", it must meet the following conditions:\n1. The string must be at least 8 characters long.\n2. ...
def common_elements(list1, list2): set1 = set(list1) set2 = set(list2) common = set1.intersection(set2) return list(common)
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes in two lists of integers and returns a new list containing the common elements between the two lists. The returned list should not contain duplicates.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7390, "level": 1, "question": "Create a function that takes in two lists of integers and returns a new list containing the common elements between the two lists. The returned list should not contain duplicates.", "split": "train" }
import torch def tensor_dimensions_info(x: torch.Tensor) -> dict: size = x.size() return { "num_dimensions": len(size), "sizes": list(size), "total_elements": x.numel() }
simplelr_Docs
[ { "content": "Question:\n**Objective**: Demonstrate your understanding of PyTorch's `torch.Size` class and its usage in handling tensor dimensions.\n\n**Question**:\nYou are given a tensor `x` of arbitrary dimensions. Write a function `tensor_dimensions_info` that takes this tensor as input and returns a dictio...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7391, "level": 1, "question": "**Objective**: Demonstrate your understanding of PyTorch's `torch.Size` class and its usage in handling tensor dimensions.\n\n**Question**:\nYou are given a tensor `x` of arbitrary dimensions. Write a function `tensor_dimensions_info` that takes this t...
def generate_square_sequence(size=1): if size < 1: size = 1 return [i ** 2 for i in range(size)]
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that generates a sequence of numbers, each being the square of its index, for a given list size. The function should return a list containing these squared numbers. Additionally, ensure that your function can handle a minimum list size requirement, defaulting to ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7392, "level": 1, "question": "Write a Python function that generates a sequence of numbers, each being the square of its index, for a given list size. The function should return a list containing these squared numbers. Additionally, ensure that your function can handle a minimum li...
import sys from typing import List, Tuple, Dict, Any def process_float_operations(strings: List[str]) -> Dict[str, Any]: converted = [] floats = [] for s in strings: try: f = float(s) except ValueError: continue s_float = str(f) converted.append((s, f...
simplelr_Docs
[ { "content": "Question:\n### Python Coding Assessment: Working with Floating Point Numbers\n\n**Objective:** This task is designed to assess your understanding of creating and manipulating floating point numbers in Python, as well as handling conversions and limits.\n\n**Task:**\n\nWrite a Python function `proc...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7393, "level": 1, "question": "### Python Coding Assessment: Working with Floating Point Numbers\n\n**Objective:** This task is designed to assess your understanding of creating and manipulating floating point numbers in Python, as well as handling conversions and limits.\n\n**Task:...
def decimal_to_hexadecimal(n): return "{:x}".format(n)
simplelr_Filter
[ { "content": "Question:\nImplement a function to convert a decimal number to its hexadecimal representation. The function should take an integer as an input and return a string representing the hexadecimal number. The hexadecimal should be in lowercase and should not include the '0x' prefix.\nAnswer:\nLet's thi...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7394, "level": 1, "question": "Implement a function to convert a decimal number to its hexadecimal representation. The function should take an integer as an input and return a string representing the hexadecimal number. The hexadecimal should be in lowercase and should not include t...
def strong_password(n, password): numbers = set('0123456789') lower = set('abcdefghijklmnopqrstuvwxyz') upper = set('ABCDEFGHIJKLMNOPQRSTUVWXYZ') special = set('!@#$%^&*()-+') has_num = False has_lower = False has_upper = False has_special = False for c in password: ...
simplelr_Data_Structure
[ { "content": "Question:\n### Scenario\nYou are implementing a feature for a new website's signup page that enforces strong password policies. To ensure the security of user accounts, you must validate passwords according to the given requirements. If a password does not meet these criteria, you must determine t...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7395, "level": 1, "question": "### Scenario\nYou are implementing a feature for a new website's signup page that enforces strong password policies. To ensure the security of user accounts, you must validate passwords according to the given requirements. If a password does not meet t...
def reorder_for_max_sum(arr): sorted_arr = sorted(arr) result = [] i, j = 0, len(sorted_arr) - 1 while i <= j: if i == j: result.append(sorted_arr[i]) else: result.append(sorted_arr[i]) result.append(sorted_arr[j]) i += 1 j -= 1 ret...
simplelr_Algorithm
[ { "content": "Question:\n### Coding Question: Reorder Array for Maximum Sum\n\nYou are given an array of integers `arr`. Your task is to write a function `reorder_for_max_sum` that reorders the elements of `arr` to maximize the sum of adjacent differences. The sum of adjacent differences is defined as the sum o...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7396, "level": 1, "question": "### Coding Question: Reorder Array for Maximum Sum\n\nYou are given an array of integers `arr`. Your task is to write a function `reorder_for_max_sum` that reorders the elements of `arr` to maximize the sum of adjacent differences. The sum of adjacent ...
def stoogesort(arr: list, l: int, h: int) -> None: if l >= h: return if arr[l] > arr[h]: arr[l], arr[h] = arr[h], arr[l] if l + 1 == h: return m = (h - l + 1) // 3 stoogesort(arr, l, h - m) stoogesort(arr, l + m, h) stoogesort(arr, l, h - m)
simplelr_Data_Structure
[ { "content": "Question:\n#### Scenario\nStooge Sorting Company specializes in an old-fashioned sorting algorithm—Stooge Sort. Despite its inefficiency, they need to demonstrate this sorting method in their data processing software to showcase algorithm performance differences.\n\n#### Problem Statement\nYou are...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7397, "level": 1, "question": "#### Scenario\nStooge Sorting Company specializes in an old-fashioned sorting algorithm—Stooge Sort. Despite its inefficiency, they need to demonstrate this sorting method in their data processing software to showcase algorithm performance differences....
def longest_common_subsequence(s1, s2): m = len(s1) n = len(s2) # Create a table to store lengths of longest common subsequence. dp = [[0] * (n + 1) for _ in range(m + 1)] # Fill the dp table for i in range(1, m + 1): for j in range(1, n + 1): if s1[i-1] == s2[j-1]: ...
simplelr_Filter
[ { "content": "Question:\nWrite a Python program to find the longest common subsequence between two strings.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7398, "level": 1, "question": "Write a Python program to find the longest common subsequence between two strings.", "split": "train" }
def transpose(matrix): return [list(row) for row in zip(*matrix)]
simplelr_Prefill
[ { "content": "Question:\nCreate a function that accepts a 2D list (matrix) as an input and returns the transpose of the matrix. The transpose of a matrix is obtained by swapping rows with columns.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 7399, "level": 1, "question": "Create a function that accepts a 2D list (matrix) as an input and returns the transpose of the matrix. The transpose of a matrix is obtained by swapping rows with columns.", "split": "train" }