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 has_consecutive_sequence(nums): if len(nums) < 3: return False for i in range(len(nums) - 2): if nums[i+1] == nums[i] + 1 and nums[i+2] == nums[i+1] + 1: return True return False
simplelr_Prefill
[ { "content": "Question:\nWrite a function to detect if a given list of integers contains a sequence of three consecutive numbers in ascending order. If such a sequence exists, return true; otherwise, return false. The function should also handle edge cases where the list is empty or has less than three elements...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5500, "level": 1, "question": "Write a function to detect if a given list of integers contains a sequence of three consecutive numbers in ascending order. If such a sequence exists, return true; otherwise, return false. The function should also handle edge cases where the list is em...
from collections import Counter def word_frequencies(text: str) -> dict: words = text.split() return Counter(words)
simplelr_Algorithm
[ { "content": "Question:\n### Word Frequency Counter\n\n#### Problem Description:\nWrite a function that takes a string of text and returns a dictionary representing the frequency of each unique word in the text.\n\n#### Function Signature:\n```python\ndef word_frequencies(text: str) -> dict:\n pass\n```\n\n#...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5501, "level": 1, "question": "### Word Frequency Counter\n\n#### Problem Description:\nWrite a function that takes a string of text and returns a dictionary representing the frequency of each unique word in the text.\n\n#### Function Signature:\n```python\ndef word_frequencies(text...
def set_intersection(set_a, set_b): result = set() for element in set_a: if element in set_b: result.add(element) return result
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to find the intersection of two sets without using the built-in `intersection` method or the `&` operator.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5502, "level": 1, "question": "Write a python function to find the intersection of two sets without using the built-in `intersection` method or the `&` operator.", "split": "train" }
from collections import defaultdict def count_pairs(nums, target): counts = defaultdict(int) result = 0 for num in nums: complement = target - num result += counts.get(complement, 0) counts[num] += 1 return result # Example usage: # print(num_pairs([1, 2, 3, 4, 3], 6)) # Outpu...
simplelr_Apps
[ { "content": "Question:\nGiven an integer array \"nums\" and an integer \"target\", return the number of pairs (i, j) where nums[i] + nums[j] equals the target and i < j.\n\nExample 1:\n\nInput: nums = [1, 2, 3, 4, 3], target = 6\nOutput: 2\nExplanation: The pairs that sum up to target are (2, 4) and (3, 3).\n\...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5503, "level": 1, "question": "Given an integer array \"nums\" and an integer \"target\", return the number of pairs (i, j) where nums[i] + nums[j] equals the target and i < j.\n\nExample 1:\n\nInput: nums = [1, 2, 3, 4, 3], target = 6\nOutput: 2\nExplanation: The pairs that sum up ...
def min_window_substring(s, required): if not required: return "" required_set = set(required) s_chars = set(s) # Check if all required characters are present in the string if not required_set.issubset(s_chars): return "" from collections import defaultdict cha...
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that, given a string and a set of characters, returns the shortest substring that contains all the characters in the set. If no such substring exists, the function should return an empty string.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5504, "level": 1, "question": "Write a Python function that, given a string and a set of characters, returns the shortest substring that contains all the characters in the set. If no such substring exists, the function should return an empty string.", "split": "train" }
from typing import Tuple def robot_moves(commands: str) -> Tuple[int, int]: up = down = left = right = 0 for command in commands: if command == 'U': up += 1 elif command == 'D': down += 1 elif command == 'L': left += 1 elif command == 'R': ...
simplelr_Algorithm
[ { "content": "Question:\n### Question:\n\nYou are tasked with writing a function `robot_moves` that determines the final position of a robot on a 2D plane after a series of movements. The robot starts at the origin point `(0, 0)` and can move up, down, left, or right controlled by a sequence of commands.\n\n**F...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5505, "level": 1, "question": "### Question:\n\nYou are tasked with writing a function `robot_moves` that determines the final position of a robot on a 2D plane after a series of movements. The robot starts at the origin point `(0, 0)` and can move up, down, left, or right controlle...
def transform_array(nums): result = [] for num in nums: if num % 2 == 0: result.append(num ** 2) else: result.append(num ** 3) return result
simplelr_Filter
[ { "content": "Question:\nGiven the array `nums = [3, 5, 7, 9, 11, 13, 15]`, write a Python function that returns a new array where each element is the square of the original element if the element is even, and the cube if the element is odd. If the array is empty, the function should return an empty array.\nAns...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5506, "level": 1, "question": "Given the array `nums = [3, 5, 7, 9, 11, 13, 15]`, write a Python function that returns a new array where each element is the square of the original element if the element is even, and the cube if the element is odd. If the array is empty, the function...
import math from collections import Counter def unique_permutations(s): if not s: return 1 n = len(s) counts = Counter(s) total = math.factorial(n) for char, count in counts.items(): total //= math.factorial(count) return total
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to find the number of unique permutations of a given string. The permutations should be considered unique based on their character order.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5507, "level": 1, "question": "Write a python function to find the number of unique permutations of a given string. The permutations should be considered unique based on their character order.", "split": "train" }
import seaborn as sns import matplotlib.pyplot as plt def create_styled_plots(df, styles): # Create a 2x2 grid of bar plots with different styles fig, axes = plt.subplots(2, 2, figsize=(12, 10)) for i, style in enumerate(styles): with sns.axes_style(style): plt.subplot(2, 2, i + 1)...
simplelr_Docs
[ { "content": "Question:\n### Seaborn Coding Assessment Question\n\n#### Objective\nAssess the ability to apply seaborn's styling capabilities in the context of creating and customizing complex plots.\n\n#### Problem Statement\n\nYou are given a dataset represented as a DataFrame, and you need to create several ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5508, "level": 1, "question": "### Seaborn Coding Assessment Question\n\n#### Objective\nAssess the ability to apply seaborn's styling capabilities in the context of creating and customizing complex plots.\n\n#### Problem Statement\n\nYou are given a dataset represented as a DataFra...
import itertools def get_permutations(words, length): return list(itertools.permutations(words, length)) words = ['cat', 'dog', 'sun', 'hat'] length = 3 print(get_permutations(words, length))
simplelr_Filter
[ { "content": "Question:\nI have a large list of words and I want to generate all permutations of a certain length. \n\nGiven that I have a list of words:\n\n```\nwords = ['cat', 'dog', 'sun', 'hat']\n```\n\nAnd a length of 3, I want to output all possible permutations of 3 words:\n\n```python\n[('cat', 'dog', '...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5509, "level": 1, "question": "I have a large list of words and I want to generate all permutations of a certain length. \n\nGiven that I have a list of words:\n\n```\nwords = ['cat', 'dog', 'sun', 'hat']\n```\n\nAnd a length of 3, I want to output all possible permutations of 3 wor...
def tuples_to_dict(tuple_list): result = {} for key, value in tuple_list: if key in result: if isinstance(result[key], list): result[key].append(value) else: result[key] = [result[key], value] else: result[key] = value retur...
simplelr_Filter
[ { "content": "Question:\nCan you help me write a function in Python to convert a list of tuples into a dictionary? Each tuple in the list has two elements: a key and a value. If there are duplicate keys, the value should be stored in a list. For example, given the list of tuples `[('a', 1), ('b', 2), ('a', 3)]`...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5510, "level": 1, "question": "Can you help me write a function in Python to convert a list of tuples into a dictionary? Each tuple in the list has two elements: a key and a value. If there are duplicate keys, the value should be stored in a list. For example, given the list of tupl...
def merge_sorted_arrays(array1: list, array2: list) -> list: i = j = 0 merged = [] # Merge the two sorted arrays using two-pointer technique while i < len(array1) and j < len(array2): if array1[i] < array2[j]: merged.append(array1[i]) i += 1 else: ...
simplelr_Package
[ { "content": "Question:\nYou need to write a Python function named `merge_sorted_arrays` that merges two already sorted arrays into one sorted array in ascending order. The function will take two parameters: `array1`, a list of integers, and `array2`, another list of integers. The function should return a singl...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5511, "level": 1, "question": "You need to write a Python function named `merge_sorted_arrays` that merges two already sorted arrays into one sorted array in ascending order. The function will take two parameters: `array1`, a list of integers, and `array2`, another list of integers....
from collections import Counter import heapq def reorganize_string(s): counter = Counter(s) max_freq = max(counter.values()) if counter else 0 n = len(s) # Check if it's impossible to rearrange if max_freq > (n + 1) // 2: return "" # Create a max heap using negative values ...
simplelr_Taco
[ { "content": "Question:\nYou are given a string consisting of lowercase English letters. The goal is to reorder the string in such a way that no two adjacent characters are the same. If it is not possible to do so, return an empty string.\n\n-----Input-----\n- The input consists of a single string s, where 1 ≤ ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5512, "level": 1, "question": "You are given a string consisting of lowercase English letters. The goal is to reorder the string in such a way that no two adjacent characters are the same. If it is not possible to do so, return an empty string.\n\n-----Input-----\n- The input consis...
def two_sum(nums, target): num_to_index = {} for i, num in enumerate(nums): complement = target - num if complement in num_to_index: return (num_to_index[complement], i) num_to_index[num] = i
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that takes a list of numbers and a target sum. The function should return a tuple containing the indices of the two numbers such that they add up to the target sum. Assume that each input would have exactly one solution, and you may not use the same element twice...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5513, "level": 1, "question": "Write a Python function that takes a list of numbers and a target sum. The function should return a tuple containing the indices of the two numbers such that they add up to the target sum. Assume that each input would have exactly one solution, and you...
from collections import deque from typing import List def shortest_path(grid: List[List[int]]) -> int: rows = len(grid) if rows == 0: return -1 cols = len(grid[0]) if rows == 1 and cols == 1: return 0 visited = [[False for _ in range(cols)] for _ in range(rows)] queue = deq...
simplelr_Algorithm
[ { "content": "Question:\n### Problem Statement:\nYou are developing a navigation system that finds the shortest path in a grid-based city map with obstacles. Given a grid where each cell represents a city block, write a function that calculates the length of the shortest path from the top-left corner to the bot...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5514, "level": 1, "question": "### Problem Statement:\nYou are developing a navigation system that finds the shortest path in a grid-based city map with obstacles. Given a grid where each cell represents a city block, write a function that calculates the length of the shortest path ...
def inplace_switch_pairs(stack): for i in range(0, len(stack) - 1, 2): stack[i], stack[i + 1] = stack[i + 1], stack[i]
simplelr_Data_Structure
[ { "content": "Question:\n## Coding Assessment Question\n\n**Objective**: Write a function to switch successive pairs of elements in a stack starting from the bottom, without using any additional data structures such as arrays, stacks, or queues.\n\n### Function Signature\n```python\ndef inplace_switch_pairs(sta...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5515, "level": 1, "question": "## Coding Assessment Question\n\n**Objective**: Write a function to switch successive pairs of elements in a stack starting from the bottom, without using any additional data structures such as arrays, stacks, or queues.\n\n### Function Signature\n```p...
from collections import Counter import heapq def rearrange_string(s): count = Counter(s) heap = [] for char, freq in count.items(): heapq.heappush(heap, (-freq, char)) result = [] while heap: current = heapq.heappop(heap) if result and result[-1] == current[1]: ...
simplelr_Codeforces
[ { "content": "Question:\nGiven a string s consisting of lowercase English letters, you are required to rearrange the characters of the string such that no two adjacent characters are the same. If it is not possible to rearrange the characters in such a way, return an empty string. \n\n**Input:** \nA single str...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5516, "level": 1, "question": "Given a string s consisting of lowercase English letters, you are required to rearrange the characters of the string such that no two adjacent characters are the same. If it is not possible to rearrange the characters in such a way, return an empty str...
def generate_pascal(n): result = [] for i in range(n): row = [1] for k in range(1, i + 1): next_val = row[k - 1] * (i - k + 1) // k row.append(next_val) result.append(row) return result
simplelr_Taco
[ { "content": "Question:\nAlex is a puzzle enthusiast and loves working on patterns. He recently came across the concept of Pascal's Triangle and was fascinated by it. He decided to generate Pascal's Triangle up to a given number of rows, but he needs your help to implement it.\n\n## Task\n\nWrite a function tha...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5517, "level": 1, "question": "Alex is a puzzle enthusiast and loves working on patterns. He recently came across the concept of Pascal's Triangle and was fascinated by it. He decided to generate Pascal's Triangle up to a given number of rows, but he needs your help to implement it....
def rotate_image(matrix): n = len(matrix) # Transpose the matrix for i in range(n): for j in range(i + 1, n): matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j] # Reverse each row for row in matrix: row.reverse()
simplelr_Algorithm
[ { "content": "Question:\n**Question:**\nYou are given an n x n 2D matrix representing an image, where each element of the matrix represents a pixel's color value. Your task is to rotate the image 90 degrees clockwise in-place, which means you have to modify the input 2D matrix directly without using an addition...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5518, "level": 1, "question": "**Question:**\nYou are given an n x n 2D matrix representing an image, where each element of the matrix represents a pixel's color value. Your task is to rotate the image 90 degrees clockwise in-place, which means you have to modify the input 2D matrix...
def has_zero_sum_subarray(arr): seen = {0} current_sum = 0 for num in arr: current_sum += num if current_sum in seen: return True seen.add(current_sum) return False
simplelr_Evol
[ { "content": "Question:\nDesign a function in Python that takes an integer array as input and determines if a continuous subarray sums to zero. You are required to return a Boolean value: `True` if there is a continuous subarray that sums to zero, otherwise `False`. Ensure that your function has an optimal time...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5519, "level": 1, "question": "Design a function in Python that takes an integer array as input and determines if a continuous subarray sums to zero. You are required to return a Boolean value: `True` if there is a continuous subarray that sums to zero, otherwise `False`. Ensure tha...
import re from collections import Counter def most_frequent_words(k: int, text: str) -> list[str]: # Convert the text to lowercase text_lower = text.lower() # Extract words using regex, considering only alphabetic characters words = re.findall(r'[a-z]+', text_lower) # Count the frequency ...
simplelr_Taco
[ { "content": "Question:\n## Problem\n\nYou are working on a text processing tool that helps to identify the most frequently used words in a given piece of text. To refine this tool, you need to implement a function that returns a list of the k most frequently occurring words in a given string. If two or more wo...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5520, "level": 1, "question": "## Problem\n\nYou are working on a text processing tool that helps to identify the most frequently used words in a given piece of text. To refine this tool, you need to implement a function that returns a list of the k most frequently occurring words i...
def count_even_sum_subarrays(nums): prefix_sum = 0 result = 0 even_count = 1 # starts with 0 odd_count = 0 for num in nums: prefix_sum += num if prefix_sum % 2 == 0: result += even_count even_count += 1 else: result += odd_count ...
simplelr_Leetcode
[ { "content": "Question:\nGiven an integer array `nums` of length `n`, return _the **number of subarrays** that have an **even** sum_. A **subarray** is a contiguous (non-empty) sequence of elements within an array.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5521, "level": 1, "question": "Given an integer array `nums` of length `n`, return _the **number of subarrays** that have an **even** sum_. A **subarray** is a contiguous (non-empty) sequence of elements within an array.", "split": "train" }
def get_max_occurrence(lst): if not lst: return None counts = {} first_occurrence = {} for index, num in enumerate(lst): if num not in counts: counts[num] = 1 first_occurrence[num] = index else: counts[num] += 1 max_count = m...
simplelr_Filter
[ { "content": "Question:\nDesign a Python function `get_max_occurrence` that processes a list of unsorted integers and returns the integer that appears most frequently in the list. If multiple integers have the same highest frequency, return the one that appears first in the list. Optimize the solution for bette...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5522, "level": 1, "question": "Design a Python function `get_max_occurrence` that processes a list of unsorted integers and returns the integer that appears most frequently in the list. If multiple integers have the same highest frequency, return the one that appears first in the li...
def move_zeroes(arr): pos = 0 for i in range(len(arr)): if arr[i] != 0: arr[pos], arr[i] = arr[i], arr[pos] pos += 1 return arr
simplelr_Prefill
[ { "content": "Question:\nWrite a function to move all the zeroes in an integer array to the end while maintaining the order of the other elements. Try to do this in-place with a time complexity of O(n) and a space complexity of O(1).\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5523, "level": 1, "question": "Write a function to move all the zeroes in an integer array to the end while maintaining the order of the other elements. Try to do this in-place with a time complexity of O(n) and a space complexity of O(1).", "split": "train" }
def next_higher_number(num: int) -> int: digits = list(map(int, str(num))) n = len(digits) if n == 1: return -1 # Step 1: Find the pivot i = n - 2 while i >= 0 and digits[i] >= digits[i + 1]: i -= 1 if i == -1: return -1 # No such number possible ...
simplelr_Data_Structure
[ { "content": "Question:\n**Scenario**:\nYou are designing a feature for a new numeric puzzle game. One level requires players to generate the next higher number using the same digits of a given number. This helps players learn about permutations and number rearrangements. You want to implement a function to fin...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5524, "level": 1, "question": "**Scenario**:\nYou are designing a feature for a new numeric puzzle game. One level requires players to generate the next higher number using the same digits of a given number. This helps players learn about permutations and number rearrangements. You ...
def is_anagram(s, t): return sorted(s) == sorted(t)
simplelr_Filter
[ { "content": "Question:\nAn 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. Given two strings, write a function to determine if they are anagrams of each other.\n\n### Example 1:\nInput: `s = \"listen\", t = \"si...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5525, "level": 1, "question": "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. Given two strings, write a function to determine if they are anagrams of each other.\n\n### Example 1...
def smallest_string(s): return ''.join(sorted(s))
simplelr_Filter
[ { "content": "Question:\nYou are given a string of lowercase English letters. You can perform the following operation:\nChoose any two adjacent characters in the string and swap them.\n\nYou can perform this operation any number of times.\n\nThe goal is to find the lexicographically smallest string that can be ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5526, "level": 1, "question": "You are given a string of lowercase English letters. You can perform the following operation:\nChoose any two adjacent characters in the string and swap them.\n\nYou can perform this operation any number of times.\n\nThe goal is to find the lexicograph...
def has_unique_characters(s): return len(set(s)) == len(s)
simplelr_Prefill
[ { "content": "Question:\nCreate a function that checks if a string contains only unique characters. The function should return `true` if all characters in the string are unique, and `false` otherwise. Consider both lowercase and uppercase letters as distinct characters.\nAnswer:\nLet's think step by step.\n", ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5527, "level": 1, "question": "Create a function that checks if a string contains only unique characters. The function should return `true` if all characters in the string are unique, and `false` otherwise. Consider both lowercase and uppercase letters as distinct characters.", "s...
def max_product_of_pairs(nums): if len(nums) < 2: return None nums_sorted = sorted(nums) product1 = nums_sorted[-1] * nums_sorted[-2] product2 = nums_sorted[0] * nums_sorted[1] return max(product1, product2)
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to find the maximum product of numbers from a given list, but considering each pair of numbers in the list. The function should return the maximum product of any two distinct numbers in the list.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5528, "level": 1, "question": "Write a python function to find the maximum product of numbers from a given list, but considering each pair of numbers in the list. The function should return the maximum product of any two distinct numbers in the list.", "split": "train" }
import csv import sys def filter_csv(input_file, output_file, column_name, min_value, max_value): with open(input_file, 'r') as infile, open(output_file, 'w', newline='') as outfile: reader = csv.reader(infile) writer = csv.writer(outfile) # Read the header row header = nex...
simplelr_Filter
[ { "content": "Question:\nI need to create a Python script that takes a CSV file as input and outputs another CSV file with only the rows where a specific column's values are within a given range. In the input CSV, the first row is a header row and should be included in the output CSV. How can I achieve this?\nA...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5529, "level": 1, "question": "I need to create a Python script that takes a CSV file as input and outputs another CSV file with only the rows where a specific column's values are within a given range. In the input CSV, the first row is a header row and should be included in the out...
def gcd(a, b): a = abs(a) b = abs(b) if b == 0: return a else: return gcd(b, a % b)
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes two parameters, `int a` and `int b`, and returns the greatest common divisor (GCD) of `a` and `b`. Use the Euclidean algorithm.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5530, "level": 1, "question": "Create a function that takes two parameters, `int a` and `int b`, and returns the greatest common divisor (GCD) of `a` and `b`. Use the Euclidean algorithm.", "split": "train" }
import re def check_regret(text): regret_keywords = ["regret", "wish", "disappointed", "should", "could", "would", "mistake", "if only", "had", "error"] # Process the text into clean tokens text_lower = text.lower() tokens = [] for t in text_lower.split(): # Remove leading and trailing...
simplelr_Filter
[ { "content": "Question:\n### Overview\nthis task is about natural language processing. The objective is to find phrases and keywords that indicate whether a certain piece of text is expressing sentiment of regret or not. \n\nTo achieve the this the following phrases and keywords are given:\n1. regret\n2. wish\n...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5531, "level": 1, "question": "### Overview\nthis task is about natural language processing. The objective is to find phrases and keywords that indicate whether a certain piece of text is expressing sentiment of regret or not. \n\nTo achieve the this the following phrases and keywor...
def format_number(n): s = str(n) reversed_str = s[::-1] chunks = [reversed_str[i:i+3] for i in range(0, len(reversed_str), 3)] joined = ','.join(chunks) return joined[::-1]
simplelr_Taco
[ { "content": "Question:\nWrite a function that takes an integer as input and returns a string representation of the number with commas as thousands separators.\n\nFor example:\n```\n1000 -> \"1,000\"\n123456789 -> \"123,456,789\"\n12 -> \"12\"\n```\n\nNote:\n\n* Do not use any built-in format functions to solve...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5532, "level": 1, "question": "Write a function that takes an integer as input and returns a string representation of the number with commas as thousands separators.\n\nFor example:\n```\n1000 -> \"1,000\"\n123456789 -> \"123,456,789\"\n12 -> \"12\"\n```\n\nNote:\n\n* Do not use any...
def generate_squares_dict(N): return {i: i ** 2 for i in range(1, N + 1)}
simplelr_Filter
[ { "content": "Question:\nGenerate a code snippet to create a dictionary with keys as the first N natural numbers and values as their squares.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5533, "level": 1, "question": "Generate a code snippet to create a dictionary with keys as the first N natural numbers and values as their squares.", "split": "train" }
def find_second_highest(nums): unique_nums = list(set(nums)) unique_nums.sort() if len(unique_nums) < 2: return None return unique_nums[-2]
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to find the second highest number in a list of integers without duplicates.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5534, "level": 1, "question": "Write a python function to find the second highest number in a list of integers without duplicates.", "split": "train" }
def has_duplicates(seq): """Return True if the sequence has duplicates, False otherwise""" seen = set() for item in seq: if item in seen: return True seen.add(item) return False
simplelr_Filter
[ { "content": "Question:\ndef has_duplicates(seq):\n \"\"\"Return True if the sequence has duplicates, False otherwise\"\"\"\n seen = set()\n for item in seq:\n if item in seen:\n return True\n seen.add(item)\n return False\nAnswer:\nLet's think step by step.\n", "role": ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5535, "level": 1, "question": "def has_duplicates(seq):\n \"\"\"Return True if the sequence has duplicates, False otherwise\"\"\"\n seen = set()\n for item in seq:\n if item in seen:\n return True\n seen.add(item)\n return False", "split": "tra...
def find_pair_with_sum(numbers, target): seen = set() for num in numbers: complement = target - num if complement in seen: return (complement, num) seen.add(num) return None
simplelr_Filter
[ { "content": "Question:\nGiven a list of integers and a target value, write a Python program to find a pair of integers from the list that adds up to the target value. The program should return the pair as a tuple. If no such pair exists, the program should return None.\nAnswer:\nLet's think step by step.\n", ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5536, "level": 1, "question": "Given a list of integers and a target value, write a Python program to find a pair of integers from the list that adds up to the target value. The program should return the pair as a tuple. If no such pair exists, the program should return None.", "s...
def caesar_cipher(s, shift): effective_shift = shift % 26 result = [] for char in s: if char.islower(): offset = ord('a') elif char.isupper(): offset = ord('A') else: result.append(char) continue original_position = ord...
simplelr_Taco
[ { "content": "Question:\nYour task is to implement a function that takes a string and returns an encrypted version of that string using a basic Caesar Cipher algorithm. Here’s how the Caesar Cipher works:\n\n- Each letter in the plaintext is shifted a certain number of places down the alphabet.\n- For example, ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5537, "level": 1, "question": "Your task is to implement a function that takes a string and returns an encrypted version of that string using a basic Caesar Cipher algorithm. Here’s how the Caesar Cipher works:\n\n- Each letter in the plaintext is shifted a certain number of places ...
from collections import Counter def modal_average(lst): if not lst: return None counts = Counter(lst) max_count = max(counts.values()) modes = [num for num, count in counts.items() if count == max_count] return sum(modes) / len(modes)
simplelr_Filter
[ { "content": "Question:\nModify a given code that computes the modal average of a list of integers. The modal average is defined as the mode (the most frequent element) of the list, if more than one element occurs most frequently, all of these potential modes should be averaged.\nAnswer:\nLet's think step by st...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5538, "level": 1, "question": "Modify a given code that computes the modal average of a list of integers. The modal average is defined as the mode (the most frequent element) of the list, if more than one element occurs most frequently, all of these potential modes should be average...
def generate_primes(limit): if limit < 2: return [] sieve = [True] * (limit + 1) sieve[0], sieve[1] = False, False for num in range(2, int(limit ** 0.5) + 1): if sieve[num]: sieve[num*num : limit+1 : num] = [False] * len(sieve[num*num : limit+1 : num]) primes = [i for i, ...
simplelr_Filter
[ { "content": "Question:\nI've recently started learning Python. One problem I'm trying to solve is generating prime numbers using a Python function. Can you provide me with a simple function to generate prime numbers up to a specified limit?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5539, "level": 1, "question": "I've recently started learning Python. One problem I'm trying to solve is generating prime numbers using a Python function. Can you provide me with a simple function to generate prime numbers up to a specified limit?", "split": "train" }
def min_operations_to_sort(nums): count = 0 n = len(nums) for i in range(n): for j in range(i + 1, n): if nums[i] > nums[j]: count += 1 return count
simplelr_Leetcode
[ { "content": "Question:\nYou are given an integer array `nums`. You are allowed to perform one type of operation: \n\n**Type-1: Select any two adjacent elements in the array and swap them.**\n\nReturn _the **minimum** number of **type-1** operations you need to perform_ to sort the array in non-decreasing order...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5540, "level": 1, "question": "You are given an integer array `nums`. You are allowed to perform one type of operation: \n\n**Type-1: Select any two adjacent elements in the array and swap them.**\n\nReturn _the **minimum** number of **type-1** operations you need to perform_ to sor...
def findPairWithSum(arr, target): seen = set() for num in arr: complement = target - num if complement in seen: return (complement, num) seen.add(num) return None
simplelr_Codeforces
[ { "content": "Question:\nYou are given an array of integers and a target sum. Your task is to determine if there are two distinct elements in the array that add up to the target sum.\n\nWrite a function `findPairWithSum` that takes the following parameters:\n- `arr`: a list of integers\n- `target`: an integer r...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5541, "level": 1, "question": "You are given an array of integers and a target sum. Your task is to determine if there are two distinct elements in the array that add up to the target sum.\n\nWrite a function `findPairWithSum` that takes the following parameters:\n- `arr`: a list of...
def length_of_longest_substring(s: str) -> int: char_map = {} left = 0 max_len = 0 for right in range(len(s)): char = s[right] if char in char_map and char_map[char] >= left: left = char_map[char] + 1 char_map[char] = right current_length = right - left + 1 ...
simplelr_Taco
[ { "content": "Question:\nWrite a function that takes a string as input and returns the length of the longest substring with no repeating characters. Ensure your function handles edge cases such as empty strings or strings with all identical characters. \n\nExample:\n\n- The longest substring without repeating c...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5542, "level": 1, "question": "Write a function that takes a string as input and returns the length of the longest substring with no repeating characters. Ensure your function handles edge cases such as empty strings or strings with all identical characters. \n\nExample:\n\n- The lo...
def find_first_pair(nums, target): seen = set() for num in nums: complement = target - num if complement in seen: return (complement, num) seen.add(num) return None
simplelr_Filter
[ { "content": "Question:\nHere is the problem statement:\n\nWe have a list of integers. The task is to find the first pair of elements in the list that add up to a given sum. The elements in each pair should be distinct, i.e., they should not be the same element. Also, the pair should be the first pair that meet...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5543, "level": 1, "question": "Here is the problem statement:\n\nWe have a list of integers. The task is to find the first pair of elements in the list that add up to a given sum. The elements in each pair should be distinct, i.e., they should not be the same element. Also, the pair...
def generate_pascals_triangle(n): if n == 0: return [] triangle = [] triangle.append([1]) for i in range(1, n): current_row = [1] for j in range(1, i): current_row.append(triangle[i-1][j-1] + triangle[i-1][j]) current_row.append(1) triangle.append(curr...
simplelr_Prefill
[ { "content": "Question:\nCreate a function that generates a Pascal's Triangle up to the given number of rows. The function should return the Pascal's Triangle as a list of lists, where each inner list represents a row in Pascal's Triangle.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5544, "level": 1, "question": "Create a function that generates a Pascal's Triangle up to the given number of rows. The function should return the Pascal's Triangle as a list of lists, where each inner list represents a row in Pascal's Triangle.", "split": "train" }
def calculate_monthly_expenditure(transactions: list, month: str, year: int) -> dict: result = {} for transaction in transactions: date_str = transaction['date'] parts = date_str.split('-') trans_year = parts[0] trans_month = parts[1] if int(trans_year) == year and trans_...
simplelr_Evol
[ { "content": "Question:\nYou are provided with a list of transactions where each transaction is represented as a dictionary with the keys: \"date\", \"amount\", \"type\", and \"category\". Write a function that calculates the total expenditure for each category in a given month and returns the result as a dicti...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5545, "level": 1, "question": "You are provided with a list of transactions where each transaction is represented as a dictionary with the keys: \"date\", \"amount\", \"type\", and \"category\". Write a function that calculates the total expenditure for each category in a given mont...
def levenshtein_distance(s1, s2): m = len(s1) n = len(s2) # Create a matrix of (m+1) x (n+1) with initial values dp = [[0] * (n + 1) for _ in range(m + 1)] # Initialize the first row and column for i in range(m + 1): dp[i][0] = i for j in range(n + 1): dp[0][j] = j ...
simplelr_Filter
[ { "content": "Question:\nCan you provide a Python function that calculates the Levenshtein distance between two strings? The Levenshtein distance is a metric for measuring the difference between two sequences.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5546, "level": 1, "question": "Can you provide a Python function that calculates the Levenshtein distance between two strings? The Levenshtein distance is a metric for measuring the difference between two sequences.", "split": "train" }
def merge_unique_lists(a, b): return list(set(a + b))
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that takes two lists as input and returns a new list containing all items from both input lists, without duplicates.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5547, "level": 1, "question": "Write a Python function that takes two lists as input and returns a new list containing all items from both input lists, without duplicates.", "split": "train" }
def gcd(a, b): """ Compute the greatest common divisor of two non-negative integers using the Euclidean algorithm. Args: a (int): The first non-negative integer. b (int): The second non-negative integer. Returns: int: The greatest common divisor of a and b. """ while b ...
simplelr_Filter
[ { "content": "Question:\nCan you design a Python function that solves a basic math problem, like finding the greatest common divisor (GCD) of two numbers using the Euclidean algorithm? Also, explain the function and the algorithm briefly.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5548, "level": 1, "question": "Can you design a Python function that solves a basic math problem, like finding the greatest common divisor (GCD) of two numbers using the Euclidean algorithm? Also, explain the function and the algorithm briefly.", "split": "train" }
def is_sensor_data_stable(data): """ Evaluate if all sensor data values are identical. Args: data (list): A list of numerical values. Returns: bool: True if all values are the same or the list is empty, False otherwise. Example: >>> is_sensor_data_stable([5, 5, 5]) ...
simplelr_Filter
[ { "content": "Question:\nDesign a Python function named `is_sensor_data_stable` that evaluates the stability of sensor readings. The function should take a flat list of numerical sensor data as input and return `True` if all values in the list are identical (implying the sensor readings are stable), and `False`...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5549, "level": 1, "question": "Design a Python function named `is_sensor_data_stable` that evaluates the stability of sensor readings. The function should take a flat list of numerical sensor data as input and return `True` if all values in the list are identical (implying the senso...
def longest_common_prefix(str1, str2): length = 0 min_length = min(len(str1), len(str2)) for i in range(min_length): if str1[i] == str2[i]: length += 1 else: break return length
simplelr_Filter
[ { "content": "Question:\nI want to create a function that calculates the length of the longest common prefix between two strings. What's a good way to do this?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5550, "level": 1, "question": "I want to create a function that calculates the length of the longest common prefix between two strings. What's a good way to do this?", "split": "train" }
import math def triangle_area(a, b, c): """ Calculate the area of a triangle given the lengths of its three sides using Heron's formula. Args: a (float): Length of the first side. b (float): Length of the second side. c (float): Length of the third side. Returns: float...
simplelr_Filter
[ { "content": "Question:\nHow can I create a function in Python that calculates the area of a triangle given the lengths of its three sides?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5551, "level": 1, "question": "How can I create a function in Python that calculates the area of a triangle given the lengths of its three sides?", "split": "train" }
def effective_cameras(corridor_length, cameras, intruders): effective = [] for i in range(len(cameras)): position, r = cameras[i] start = position - r end = position + r for intruder in intruders: if start <= intruder <= end: effective.append(i) ...
simplelr_Apps
[ { "content": "Question:\n## Task\nA sleepy security guard is responsible for monitoring a corridor with several surveillance cameras positioned at various points. Unfortunately, his nap schedule aligns perfectly with his patrol times, so he needs to rely on these cameras to alert him when someone unauthorized p...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5552, "level": 1, "question": "## Task\nA sleepy security guard is responsible for monitoring a corridor with several surveillance cameras positioned at various points. Unfortunately, his nap schedule aligns perfectly with his patrol times, so he needs to rely on these cameras to al...
def max_subarray_sum(arr): if not arr: return 0 current_max = global_max = arr[0] for num in arr[1:]: current_max = max(num, current_max + num) if current_max > global_max: global_max = current_max return global_max
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to find the maximum sum of a subarray within a given array. This function should take an array `arr` as a parameter and return the maximum sum. You should use Kadane's algorithm to solve this problem. Provide a detailed explanation and code with comments.\nAnswer...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5553, "level": 1, "question": "Write a python function to find the maximum sum of a subarray within a given array. This function should take an array `arr` as a parameter and return the maximum sum. You should use Kadane's algorithm to solve this problem. Provide a detailed explanat...
def is_parentheses_matched(s): stack = [] for char in s: if char == '(': stack.append(char) elif char == ')': if not stack: return False stack.pop() return len(stack) == 0
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that checks if a given string of parentheses is correctly matched. A string of parentheses is considered correctly matched if every opening parenthesis '(' has a corresponding closing parenthesis ')'. The function should return `True` if the string is correctly m...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5554, "level": 1, "question": "Write a Python function that checks if a given string of parentheses is correctly matched. A string of parentheses is considered correctly matched if every opening parenthesis '(' has a corresponding closing parenthesis ')'. The function should return ...
def remove_all_occurrences(lst, value): return [x for x in lst if x != value]
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to remove all occurrences of a given value from a list of integers.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5555, "level": 1, "question": "Write a python function to remove all occurrences of a given value from a list of integers.", "split": "train" }
from collections import deque def shortest_path(grid): """ Finds the shortest path from the top-left to the bottom-right corner of the grid using BFS. Parameters: grid (List[List[str]]): A 2D list where each element is either '.' (open space) or '#' (wall). Returns: int: The length of the sho...
simplelr_Algorithm
[ { "content": "Question:\n### Coding Assessment Question\n\n#### Problem Statement\n\nYou are given a 2D grid representing a labyrinth where each cell may either be a wall ('#') or an open space ('.'). Your task is to find the shortest path from the top-left corner (0, 0) to the bottom-right corner (n-1, m-1), w...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5556, "level": 1, "question": "### Coding Assessment Question\n\n#### Problem Statement\n\nYou are given a 2D grid representing a labyrinth where each cell may either be a wall ('#') or an open space ('.'). Your task is to find the shortest path from the top-left corner (0, 0) to th...
def length_of_longest_substring(s): last_occurrence = {} max_length = 0 left = 0 for right in range(len(s)): char = s[right] if char in last_occurrence and last_occurrence[char] >= left: left = last_occurrence[char] + 1 last_occurrence[char] = right current_le...
simplelr_Leetcode
[ { "content": "Question:\nGiven a string `str`, return the length of the longest substring without repeating characters. The substring must be contiguous and consist of distinct characters.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5557, "level": 1, "question": "Given a string `str`, return the length of the longest substring without repeating characters. The substring must be contiguous and consist of distinct characters.", "split": "train" }
import heapq def dijkstra_shortest_path(n, edges, src): adj = [[] for _ in range(n)] for edge in edges: u, v, w = edge adj[u].append((v, w)) dist = [float('inf')] * n dist[src] = 0 heap = [] heapq.heappush(heap, (0, src)) while heap: current_dist, u = heapq...
simplelr_Data_Structure
[ { "content": "Question:\nYou are asked to implement a modified version of Dijkstra's algorithm for a given directed graph. The graph is represented with a list of edges, where each edge is a triplet (source, destination, weight). Your task is to find the shortest path from a given source vertex to all other ver...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5558, "level": 1, "question": "You are asked to implement a modified version of Dijkstra's algorithm for a given directed graph. The graph is represented with a list of edges, where each edge is a triplet (source, destination, weight). Your task is to find the shortest path from a g...
from typing import List def custom_insertion_sort(arr: List[int], threshold: int) -> List[int]: if len(arr) > threshold: return arr else: arr_copy = arr.copy() for i in range(1, len(arr_copy)): key = arr_copy[i] j = i - 1 while j >= 0 and key < arr_co...
simplelr_Data_Structure
[ { "content": "Question:\n### Context:\nThe Insertion Sort algorithm is a simple and intuitive way of sorting a small array of numbers efficiently. However, it may not always be the best choice for larger datasets due to its quadratic time complexity. Understanding and implementing this algorithm will help in fo...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5559, "level": 1, "question": "### Context:\nThe Insertion Sort algorithm is a simple and intuitive way of sorting a small array of numbers efficiently. However, it may not always be the best choice for larger datasets due to its quadratic time complexity. Understanding and implemen...
def maxValueInArray(n: int, queries: list[tuple[int, int, int]]) -> int: # Initialize the difference array with n+2 elements to handle 1-based indexing and end+1 cases diff = [0] * (n + 2) for start, end, inc in queries: diff[start] += inc if end + 1 <= n: diff[end + 1] -= i...
simplelr_Algorithm
[ { "content": "Question:\n### Intermediate Problem: Array Manipulation with Prefix Sum\n\n#### Scenario\nYou are given a task to optimize a set of range update operations on an array. The challenge is to efficiently perform a sequence of range increment operations and finally return the maximum value in the arra...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5560, "level": 1, "question": "### Intermediate Problem: Array Manipulation with Prefix Sum\n\n#### Scenario\nYou are given a task to optimize a set of range update operations on an array. The challenge is to efficiently perform a sequence of range increment operations and finally r...
def is_one_edit_away(s: str, t: str) -> bool: """ Determines if two strings are exactly one edit distance apart. """ if abs(len(s) - len(t)) > 1: return False if len(s) == len(t): differences = 0 for i in range(len(s)): if s[i] != t[i]: differences...
simplelr_Data_Structure
[ { "content": "Question:\n### Strings One Edit Distance Apart\n\nYour task is to implement a function to determine if two strings are exactly one edit distance apart. An edit is defined as:\n1. Inserting a single character into either string.\n2. Deleting a single character from either string.\n3. Replacing a si...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5561, "level": 1, "question": "### Strings One Edit Distance Apart\n\nYour task is to implement a function to determine if two strings are exactly one edit distance apart. An edit is defined as:\n1. Inserting a single character into either string.\n2. Deleting a single character fro...
def decrypt_caesar_cipher(s): result = '' for c in s: if c.isupper(): shifted = (ord(c) - ord('A') - 3) % 26 result += chr(shifted + ord('A')) elif c.islower(): shifted = (ord(c) - ord('a') - 3) % 26 result += chr(shifted + ord('a')) else: ...
simplelr_Filter
[ { "content": "Question:\nWrite a Python code to decrypt a Caesar cipher. The function takes a string as an input and returns a decrypted string. The Caesar cipher is a type of substitution cipher where each letter in the plaintext is 'shifted' a certain number of places down the alphabet. For decryption, we wil...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5562, "level": 1, "question": "Write a Python code to decrypt a Caesar cipher. The function takes a string as an input and returns a decrypted string. The Caesar cipher is a type of substitution cipher where each letter in the plaintext is 'shifted' a certain number of places down t...
def roman_to_integer(s: str) -> int: roman_dict = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} total = 0 for i in range(len(s)): current = roman_dict[s[i]] if i < len(s) - 1: next_val = roman_dict[s[i+1]] if current < next_val: tot...
simplelr_Algorithm
[ { "content": "Question:\n### Roman Numeral to Integer Conversion\n\nYou are tasked with implementing a function to convert a Roman numeral string into its corresponding integer value. The function should handle a single string input representing the Roman numeral and return the integer value.\n\n#### Function S...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5563, "level": 1, "question": "### Roman Numeral to Integer Conversion\n\nYou are tasked with implementing a function to convert a Roman numeral string into its corresponding integer value. The function should handle a single string input representing the Roman numeral and return th...
def find_nth_digit(n: int) -> int: digits = 1 count = 9 start = 1 while n > digits * count: n -= digits * count digits += 1 count *= 10 start *= 10 num = start + (n - 1) // digits digit_index = (n - 1) % digits return int(str(num)[digit_index])
simplelr_Data_Structure
[ { "content": "Question:\n### Question: Find the nth Digit in Suffix of Integers\n\n#### Problem Statement\n\nYou are given an infinite sequence of integers starting from 1 and concatenating them: \"123456789101112...\". Write a function `find_nth_digit(n: int) -> int` that returns the nth digit of this sequence...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5564, "level": 1, "question": "### Question: Find the nth Digit in Suffix of Integers\n\n#### Problem Statement\n\nYou are given an infinite sequence of integers starting from 1 and concatenating them: \"123456789101112...\". Write a function `find_nth_digit(n: int) -> int` that ret...
def trap_rain_water(height): if not height: return 0 n = len(height) left_max = [0] * n right_max = [0] * n current_max = 0 for i in range(n): left_max[i] = current_max if height[i] > current_max: current_max = height[i] current_max = 0 ...
simplelr_Taco
[ { "content": "Question:\nGiven a list of non-negative integers representing the amount of rainwater trapped at each bar of a histogram where the width of each bar is 1, return the total amount of rainwater trapped.\n\nExample 1:\nInput: [0,1,0,2,1,0,1,3,2,1,2,1]\nOutput: 6\nExplanation: The structure of the his...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5565, "level": 1, "question": "Given a list of non-negative integers representing the amount of rainwater trapped at each bar of a histogram where the width of each bar is 1, return the total amount of rainwater trapped.\n\nExample 1:\nInput: [0,1,0,2,1,0,1,3,2,1,2,1]\nOutput: 6\nEx...
def merge_lists(list1, list2): merged_list = [] seen = set() for element in list1: if element not in seen: merged_list.append(element) seen.add(element) for element in list2: if element not in seen: merged_list.append(element) seen.add(elem...
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to merge two lists into one list, preserving the order of elements from both original lists. The function should not contain any duplicate elements, ensuring that each element appears only once in the new list.\nAnswer:\nLet's think step by step.\n", "role": ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5566, "level": 1, "question": "Write a python function to merge two lists into one list, preserving the order of elements from both original lists. The function should not contain any duplicate elements, ensuring that each element appears only once in the new list.", "split": "tra...
from datetime import datetime def calculate_elapsed_days(date1, date2): """ Calculate the number of days between two dates in 'dd-mm-yyyy' format. Args: date1 (str): The first date string. date2 (str): The second date string. Returns: int: The absolute number of days b...
simplelr_Filter
[ { "content": "Question:\nYou have been tasked with finding the elapsed time between two dates in the \"dd-mm-yyyy\" format. Write a code to solve this problem and explain the end result.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5567, "level": 1, "question": "You have been tasked with finding the elapsed time between two dates in the \"dd-mm-yyyy\" format. Write a code to solve this problem and explain the end result.", "split": "train" }
def trap(heights): if not heights or len(heights) < 3: return 0 n = len(heights) left_max = [0] * n right_max = [0] * n # Compute left_max array current_max = 0 for i in range(n): if i == 0: left_max[i] = 0 else: current_max = max(cur...
simplelr_Leetcode
[ { "content": "Question:\nYou are given an array of integers `heights` representing the heights of buildings in a row. Rainwater is trapped in valleys between the buildings. The width of each building and each unit of space between buildings is `1`. Compute and return _the total amount of rainwater that would be...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5568, "level": 1, "question": "You are given an array of integers `heights` representing the heights of buildings in a row. Rainwater is trapped in valleys between the buildings. The width of each building and each unit of space between buildings is `1`. Compute and return _the tota...
def find_max_length_subarray(arr: list) -> int: max_length = 0 current_balance = 0 balance_map = {0: -1} for i, num in enumerate(arr): if num == 0: current_balance += 1 else: current_balance -= 1 if current_balance in balance_map: length = i - ...
simplelr_Evol
[ { "content": "Question:\nGiven an array of integers, write a Python function that finds and returns the length of the longest contiguous subarray with an equal number of 0s and 1s. \n\nFor example, given the input array [0, 1, 0, 0, 1, 1, 0], the function should return 6, since the longest subarray with equal n...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5569, "level": 1, "question": "Given an array of integers, write a Python function that finds and returns the length of the longest contiguous subarray with an equal number of 0s and 1s. \n\nFor example, given the input array [0, 1, 0, 0, 1, 1, 0], the function should return 6, sinc...
import math def is_perfect_square(n): if n < 0: return -1 s = math.isqrt(n) return s if s * s == n else -1
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes an integer as input and checks if it is a perfect square. If it is, return the square root of the number as an integer. If it is not, return -1.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5570, "level": 1, "question": "Create a function that takes an integer as input and checks if it is a perfect square. If it is, return the square root of the number as an integer. If it is not, return -1.", "split": "train" }
def city_to_uppercase(city_name): return city_name.upper()
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that takes a string representing the name of a city, converts it to uppercase, and returns it. The function should be able to handle various city names, including those with special characters and spaces.\nAnswer:\nLet's think step by step.\n", "role": "user"...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5571, "level": 1, "question": "Write a Python function that takes a string representing the name of a city, converts it to uppercase, and returns it. The function should be able to handle various city names, including those with special characters and spaces.", "split": "train" }
def recursive_sum(n: int) -> int: """ Calculate the sum of all positive integers up to and including n using recursion. Input Parameter: n (int): The upper limit integer up to which the sum is to be calculated. Returns: int: The sum of all integers from 1 to n. Rai...
simplelr_Algorithm
[ { "content": "Question:\n### Recursive Sum Calculation\n\n#### Background:\nRecursion is a programming technique where a function calls itself in order to solve a problem. Recursive methods can simplify the code required to solve complex problems that have self-similar sub-problems.\n\n#### Task:\nYou are requi...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5572, "level": 1, "question": "### Recursive Sum Calculation\n\n#### Background:\nRecursion is a programming technique where a function calls itself in order to solve a problem. Recursive methods can simplify the code required to solve complex problems that have self-similar sub-pro...
import math def sigmoid_activation(x: float) -> float: # Check if x is a valid number if not isinstance(x, (int, float)): raise ValueError("Input must be a number") # Check if x is NaN if isinstance(x, float) and x != x: raise ValueError("Input must be a number") exponent = -x e...
simplelr_Algorithm
[ { "content": "Question:\n### Coding Assessment Question\n\n#### Scenario\nYou are building a simple neural network library, and one of the fundamental components required is a function that computes the sigmoid activation. The sigmoid function is widely used in neural networks to introduce non-linearity into th...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5573, "level": 1, "question": "### Coding Assessment Question\n\n#### Scenario\nYou are building a simple neural network library, and one of the fundamental components required is a function that computes the sigmoid activation. The sigmoid function is widely used in neural networks...
def is_interleave(s1: str, s2: str, s3: str) -> bool: m = len(s1) n = len(s2) l3 = len(s3) if m + n != l3: return False dp = [[False] * (n + 1) for _ in range(m + 1)] dp[0][0] = True for i in range(m + 1): for j in range(n + 1): if i == 0 and j == 0...
simplelr_Algorithm
[ { "content": "Question:\n### Coding Challenge: Interleaving Strings\n\n#### Problem Statement\nGiven three strings `s1`, `s2`, and `s3`, determine if `s3` is formed by an interleaving of `s1` and `s2`. An interleaving of `s1` and `s2` is a string constructed from all the characters of `s1` and `s2` such that th...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5574, "level": 1, "question": "### Coding Challenge: Interleaving Strings\n\n#### Problem Statement\nGiven three strings `s1`, `s2`, and `s3`, determine if `s3` is formed by an interleaving of `s1` and `s2`. An interleaving of `s1` and `s2` is a string constructed from all the chara...
def length_of_longest_substring(s: str) -> int: last_seen = {} max_length = 0 start = 0 for i in range(len(s)): char = s[i] if char in last_seen and last_seen[char] >= start: start = last_seen[char] + 1 last_seen[char] = i current_length = i - start + 1 ...
simplelr_Filter
[ { "content": "Question:\nGiven a string, find the length of the longest substring without repeating characters.\n\nExample 1:\nInput: \"abcabcbb\"\nOutput: 3\nExplanation: The answer is \"abc\", with the length of 3.\n\nExample 2:\nInput: \"bbbbb\"\nOutput: 1\nExplanation: The answer is \"b\", with the length o...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5575, "level": 1, "question": "Given a string, find the length of the longest substring without repeating characters.\n\nExample 1:\nInput: \"abcabcbb\"\nOutput: 3\nExplanation: The answer is \"abc\", with the length of 3.\n\nExample 2:\nInput: \"bbbbb\"\nOutput: 1\nExplanation: The...
from typing import List, Tuple def maxNonOverlappingActivities(activities: List[Tuple[int, int]]) -> int: # Sort the activities by their end times activities.sort(key=lambda x: x[1]) count = 0 last_end = -1 for activity in activities: start, end = activity if start >= last_end: ...
simplelr_Codeforces
[ { "content": "Question:\nYou are given a list of activities, each represented by a pair of integers `[start, end]`. Each activity starts at `start` and ends at `end`. You want to select the maximum number of non-overlapping activities that you can attend.\n\nNote that if `start` is equal to `end`, it means the ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5576, "level": 1, "question": "You are given a list of activities, each represented by a pair of integers `[start, end]`. Each activity starts at `start` and ends at `end`. You want to select the maximum number of non-overlapping activities that you can attend.\n\nNote that if `star...
def trap(height): if not height: return 0 n = len(height) if n < 3: return 0 # Not enough bars to trap water left_max = [0] * n right_max = [0] * n # Compute left_max for i in range(1, n): left_max[i] = max(left_max[i-1], height[i-1]) # Compute rig...
simplelr_Leetcode
[ { "content": "Question:\nYou are given a list of non-negative integers representing the heights of columns of water in a histogram where the width of each column is 1. Compute how much water can be trapped after raining. The list will have at least one column. Return the total amount of trapped water.\nAnswer:\...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5577, "level": 1, "question": "You are given a list of non-negative integers representing the heights of columns of water in a histogram where the width of each column is 1. Compute how much water can be trapped after raining. The list will have at least one column. Return the total...
def longest_balanced_substring(s): sum_indices = {0: -1} current_sum = 0 max_length = 0 for i, char in enumerate(s): if char == 'a': current_sum += 1 else: current_sum -= 1 if current_sum in sum_indices: length = i - sum_indices[current_sum] ...
simplelr_Leetcode
[ { "content": "Question:\nYou are given a string `s` consisting solely of the characters `'a'` and `'b'`. A substring of `s` is called a **balanced substring** if it contains an equal number of `'a'` and `'b'`. Your task is to return _the length of the **longest balanced substring** in_ `s`_. If there is no such...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5578, "level": 1, "question": "You are given a string `s` consisting solely of the characters `'a'` and `'b'`. A substring of `s` is called a **balanced substring** if it contains an equal number of `'a'` and `'b'`. Your task is to return _the length of the **longest balanced substr...
def remove_duplicates(lst): seen = set() result = [] for num in lst: if num not in seen: seen.add(num) result.append(num) return result
simplelr_Apps
[ { "content": "Question:\nComplete the function that takes a list of integers and returns a new list with duplicates removed while preserving the order of the first occurrence of each element.\n\n## Example\n\nGiven `lst = [4, 5, 4, 1, 2, 3, 5, 2, 3]` the function should return `[4, 5, 1, 2, 3]`, as these are th...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5579, "level": 1, "question": "Complete the function that takes a list of integers and returns a new list with duplicates removed while preserving the order of the first occurrence of each element.\n\n## Example\n\nGiven `lst = [4, 5, 4, 1, 2, 3, 5, 2, 3]` the function should return...
from typing import List def ternary_search(left: int, right: int, key: int, arr: List[int]) -> int: while left <= right: mid1 = left + (right - left) // 3 mid2 = right - (right - left) // 3 if mid1 == mid2: if arr[mid1] == key: return mid1 else: ...
simplelr_Data_Structure
[ { "content": "Question:\n### Question\nYou are given a sorted array of integers and an integer key. Implement the ternary search algorithm in Python to find the index of the key. If the key is not present in the array, return -1. Ensure that your implementation handles edge cases and perform the search in O(log...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5580, "level": 1, "question": "### Question\nYou are given a sorted array of integers and an integer key. Implement the ternary search algorithm in Python to find the index of the key. If the key is not present in the array, return -1. Ensure that your implementation handles edge ca...
def twoSum(nums, target): num_map = {} for i, num in enumerate(nums): complement = target - num if complement in num_map: return [num_map[complement], i] num_map[num] = i return None
simplelr_Leetcode
[ { "content": "Question:\nGiven an integer array `nums` and an integer `target`, return _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. Implement the function `twoSum` that finds th...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5581, "level": 1, "question": "Given an integer array `nums` and an integer `target`, return _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. Implement ...
def length_of_longest_unique_subsequence(arr): return len(set(arr))
simplelr_Leetcode
[ { "content": "Question:\nYou are given an integer array `arr` consisting of `n` integers. A subsequence of `arr` is obtained by deleting some (possibly none) elements from `arr` without changing the order of the remaining elements. Find the length of the longest subsequence that consists of only unique elements...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5582, "level": 1, "question": "You are given an integer array `arr` consisting of `n` integers. A subsequence of `arr` is obtained by deleting some (possibly none) elements from `arr` without changing the order of the remaining elements. Find the length of the longest subsequence th...
def is_permutation(s1, s2): return len(s1) == len(s2) and sorted(s1) == sorted(s2)
simplelr_Filter
[ { "content": "Question:\nProvided two strings, determine whether one is a permutation of the others. For example, **'abc'** and **'bca'** are permutations of each other, but **'abc'** and **'def'** are not. Write a Python function `is_permutation` that takes two strings as input and returns `True` if one string...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5583, "level": 1, "question": "Provided two strings, determine whether one is a permutation of the others. For example, **'abc'** and **'bca'** are permutations of each other, but **'abc'** and **'def'** are not. Write a Python function `is_permutation` that takes two strings as inp...
def move_player(position, command, rooms): command_to_delta = { 'north': (0, 1), 'south': (0, -1), 'east': (1, 0), 'west': (-1, 0) } if command not in command_to_delta: return position delta = command_to_delta[command] new_x = position[0] + delta[0] ...
simplelr_Package
[ { "content": "Question:\nYou are building a simple text-based adventure game where the player navigates through different rooms. Each room is connected to other rooms in four possible directions: north, south, east, and west. Your task is to implement a function that takes the current position of the player and...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5584, "level": 1, "question": "You are building a simple text-based adventure game where the player navigates through different rooms. Each room is connected to other rooms in four possible directions: north, south, east, and west. Your task is to implement a function that takes the...
def max_area(height): left = 0 right = len(height) - 1 max_water = 0 while left < right: current_area = min(height[left], height[right]) * (right - left) if current_area > max_water: max_water = current_area if height[left] < height[right]: left += 1 ...
simplelr_Leetcode
[ { "content": "Question:\nYou are given an array of integers `height` representing the height of trees in a forest. Your task is to calculate the maximum volume of water that can be trapped after it rains. The width of each tree is 1 unit. You need to find the two trees such that the container forms with the mos...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5585, "level": 1, "question": "You are given an array of integers `height` representing the height of trees in a forest. Your task is to calculate the maximum volume of water that can be trapped after it rains. The width of each tree is 1 unit. You need to find the two trees such th...
def sum_of_absolute_values(numbers): return sum(abs(x) for x in numbers)
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to find the sum of the absolute values of a list of numbers.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5586, "level": 1, "question": "Write a python function to find the sum of the absolute values of a list of numbers.", "split": "train" }
def f(x: float, y: float) -> float: sum = x + y return sum
simplelr_Filter
[ { "content": "Question:\nI wrote a function that adds two numbers. It has two inputs and one output. The inputs are \"x\" and \"y\" and the output is \"sum\". \n\nHere is my function: \n``` \nf(x, y) {\n sum = x + y\n return sum\n}\n```\nIs there a way to indicate what type of data \"x\" and \"y\" should be a...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5587, "level": 1, "question": "I wrote a function that adds two numbers. It has two inputs and one output. The inputs are \"x\" and \"y\" and the output is \"sum\". \n\nHere is my function: \n``` \nf(x, y) {\n sum = x + y\n return sum\n}\n```\nIs there a way to indicate what type ...
def multiply(x, y): if x == 0 or y == 0: return 0 if y < 0: return -multiply(x, -y) return x + multiply(x, y - 1)
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that multiplies two numbers but using only addition.\n\n Example:\n\n\n ```python\n multiply(3, 4) == 12\n multiply(5, -2) == -10\n ```\n\n Constraints:\n\nYou cannot use the asterisk operator () for multiplication.\n\n\nHere's my solution:\n\n```python\ndef mult...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5588, "level": 1, "question": "Write a Python function that multiplies two numbers but using only addition.\n\n Example:\n\n\n ```python\n multiply(3, 4) == 12\n multiply(5, -2) == -10\n ```\n\n Constraints:\n\nYou cannot use the asterisk operator () for multiplication.\n\n\nHere's ...
import re def count_unique_words(text): text_lower = text.lower() words = re.findall(r"[a-z']+", text_lower) unique_words = set() for word in words: stripped_word = word.strip("'") if any(c.isalpha() for c in stripped_word): unique_words.add(stripped_word) return len(uni...
simplelr_Filter
[ { "content": "Question:\nI have a programming project that involves analyzing text data. I need to create a function that can accurately count the number of unique words in a given text, ignoring case sensitivity and punctuation. Can you help me design this function in Python?\nAnswer:\nLet's think step by step...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5589, "level": 1, "question": "I have a programming project that involves analyzing text data. I need to create a function that can accurately count the number of unique words in a given text, ignoring case sensitivity and punctuation. Can you help me design this function in Python?...
def countPairsWithSum(arr, n, target): freq = {} for num in arr: if num in freq: freq[num] += 1 else: freq[num] = 1 processed = set() count = 0 for num in sorted(freq.keys()): if num in processed: continue complement = target - nu...
simplelr_Taco
[ { "content": "Question:\nGiven an array of integers and a target sum, your task is to determine the number of unique pairs in the array that add up to the target sum. A pair (a, b) and (b, a) are considered the same, and the array may contain negative numbers.\n\nExample 1:\nInput: \nn = 5\nA[] = {1, 5, 7, -1, ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5590, "level": 1, "question": "Given an array of integers and a target sum, your task is to determine the number of unique pairs in the array that add up to the target sum. A pair (a, b) and (b, a) are considered the same, and the array may contain negative numbers.\n\nExample 1:\nI...
def can_transform(s: str, t: str) -> bool: i = j = 0 while i < len(s) and j < len(t): if s[i] == t[j]: j += 1 i += 1 return j == len(t)
simplelr_Leetcode
[ { "content": "Question:\nYou are given two strings `s` and `t` of lengths `m` and `n` respectively. Your task is to determine if `s` can be transformed into `t` by deleting some (possibly zero) characters from `s` without changing the order of the remaining characters. Return `true` if it is possible, otherwise...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5591, "level": 1, "question": "You are given two strings `s` and `t` of lengths `m` and `n` respectively. Your task is to determine if `s` can be transformed into `t` by deleting some (possibly zero) characters from `s` without changing the order of the remaining characters. Return ...
from typing import List def shallowest_path(matrix: List[List[int]]) -> int: if not matrix: return 0 n = len(matrix) m = len(matrix[0]) if n > 0 else 0 if m == 0: return 0 # Initialize DP table dp = [[0 for _ in range(m)] for _ in range(n)] dp[0][0] = matrix[0][0] f...
simplelr_Taco
[ { "content": "Question:\nYou are participating in a treasure hunt game, and you are given a map represented by a 2D matrix. Each cell of the matrix contains an integer that represents the depth at that point. Your goal is to find the shallowest path from the top-left corner to the bottom-right corner.\n\nThe pa...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5592, "level": 1, "question": "You are participating in a treasure hunt game, and you are given a map represented by a 2D matrix. Each cell of the matrix contains an integer that represents the depth at that point. Your goal is to find the shallowest path from the top-left corner to...
def find_most_frequent_character(s: str) -> str: if not s: return "" freq = {} for char in s: if char.isalpha(): lower_char = char.lower() freq[lower_char] = freq.get(lower_char, 0) + 1 if not freq: return "" max_freq = max(freq.values()...
simplelr_Evol
[ { "content": "Question:\nImplement a function `find_most_frequent_character(s: str) -> str` that takes a string `s` as input and returns the most frequent alphabetical character in the string. The function should ignore character case (i.e., treat 'A' and 'a' as the same character) and if there are multiple cha...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5593, "level": 1, "question": "Implement a function `find_most_frequent_character(s: str) -> str` that takes a string `s` as input and returns the most frequent alphabetical character in the string. The function should ignore character case (i.e., treat 'A' and 'a' as the same chara...
def remove_vowels(s): vowels = {'a', 'e', 'i', 'o', 'u'} result = [] for char in s: if char.lower() not in vowels: result.append(char) return ''.join(result)
simplelr_Taco
[ { "content": "Question:\nWrite a function that takes a string and returns the same string but with all the vowels removed. For the purpose of this problem, 'a', 'e', 'i', 'o', and 'u' (both uppercase and lowercase) are considered vowels. The input is a non-empty string containing only alphabetical characters an...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5594, "level": 1, "question": "Write a function that takes a string and returns the same string but with all the vowels removed. For the purpose of this problem, 'a', 'e', 'i', 'o', and 'u' (both uppercase and lowercase) are considered vowels. The input is a non-empty string contain...
from typing import List, Tuple def find_pairs_with_sum(arr: List[int], target: int) -> List[Tuple[int, int]]: seen_pairs = set() for i in range(len(arr)): for j in range(i + 1, len(arr)): if arr[i] + arr[j] == target: a, b = sorted((arr[i], arr[j])) seen_pair...
simplelr_Evol
[ { "content": "Question:\nGiven an array of integers and a target sum, implement a function in Python that returns all unique pairs of numbers from the array that add up to the target sum. Note that a pair must consist of two distinct elements and the same pair must not be repeated (i.e., (a, b) and (b, a) are c...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5595, "level": 1, "question": "Given an array of integers and a target sum, implement a function in Python that returns all unique pairs of numbers from the array that add up to the target sum. Note that a pair must consist of two distinct elements and the same pair must not be repe...
import re def count_words(document): # Define the punctuation to replace punctuation = '.,:;!?()[]{}-' # Create translation table: each punctuation to space trans_table = str.maketrans({c: ' ' for c in punctuation}) # Lowercase the document document = document.lower() # Replace punctuation ...
simplelr_Taco
[ { "content": "Question:\nYou have been hired to design a simple text editor. One of the features of this text editor is to count the frequency of each word in a given document and output the word counts in descending order. Specifically, if two words have the same frequency, they should be sorted in ascending l...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5596, "level": 1, "question": "You have been hired to design a simple text editor. One of the features of this text editor is to count the frequency of each word in a given document and output the word counts in descending order. Specifically, if two words have the same frequency, t...
def reconstructQueue(heights, inFront): people = list(zip(heights, inFront)) people.sort(key=lambda x: (-x[0], x[1])) result = [] for h, f in people: result.insert(f, [h, f]) return result
simplelr_Leetcode
[ { "content": "Question:\nYou are given an array of integers `heights` representing the height of each person in a queue. You are also given an array of integers `inFront`, where `inFront[i]` is the number of people in front of the `i`th person who have a height greater than or equal to `heights[i]`. Write an al...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5597, "level": 1, "question": "You are given an array of integers `heights` representing the height of each person in a queue. You are also given an array of integers `inFront`, where `inFront[i]` is the number of people in front of the `i`th person who have a height greater than or...
def reverse_sentence(sentence): return ' '.join(sentence.split()[::-1])
simplelr_Apps
[ { "content": "Question:\nTask:\nWrite a function that takes a sentence as input and returns the sentence in reverse word order, while maintaining the words themselves in their original order.\n\nRules:\n1. You should split the sentence into words based on spaces.\n2. Reverse the order of the words.\n3. Join the...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5598, "level": 1, "question": "Task:\nWrite a function that takes a sentence as input and returns the sentence in reverse word order, while maintaining the words themselves in their original order.\n\nRules:\n1. You should split the sentence into words based on spaces.\n2. Reverse t...
def partial_insertion_sort(sequence: list, start_index: int) -> list: result = list(sequence) for i in range(start_index, len(result)): key = result[i] j = i - 1 while j >= start_index and result[j] > key: result[j + 1] = result[j] j -= 1 result[j + 1] = k...
simplelr_Algorithm
[ { "content": "Question:\n### Programming Assessment Question\n\n#### Context\nSorting algorithms are fundamental in computer science. While many sophisticated sorting algorithms exist, insertion sort provides an excellent opportunity to understand basic concepts and get acquainted with algorithmic problem-solvi...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 5599, "level": 1, "question": "### Programming Assessment Question\n\n#### Context\nSorting algorithms are fundamental in computer science. While many sophisticated sorting algorithms exist, insertion sort provides an excellent opportunity to understand basic concepts and get acquai...