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 fibonacci(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n-1) + fibonacci(n-2) | simplelr_Prefill | [
{
"content": "Question:\nCreate a function that takes in a number n and returns the nth Fibonacci number. The Fibonacci sequence is defined as follows: F(0) = 0, F(1) = 1, and F(n) = F(n-1) + F(n-2) for n > 1. Implement this function using recursion.\nAnswer:\nLet's think step by step.\n",
"role": "user"
... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6100,
"level": 1,
"question": "Create a function that takes in a number n and returns the nth Fibonacci number. The Fibonacci sequence is defined as follows: F(0) = 0, F(1) = 1, and F(n) = F(n-1) + F(n-2) for n > 1. Implement this function using recursion.",
"split": "train"
} |
from collections import Counter
def can_permute_palindrome(text):
"""
Given a string, this function checks if it is a permutation of a palindrome.
A string is a permutation of a palindrome if it can be rearranged into a
palindrome, which reads the same forward and backward.
"""
if not text:
... | simplelr_Filter | [
{
"content": "Question:\nThis week's challenge on my coding platform requires me to write a function that correctly identifies whether a given string is a permutation of a palindrome.\n\nI am getting stuck on how to approach the character frequency count.\n\n```python\ndef can_permute_palindrome(text):\n \"\... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6101,
"level": 1,
"question": "This week's challenge on my coding platform requires me to write a function that correctly identifies whether a given string is a permutation of a palindrome.\n\nI am getting stuck on how to approach the character frequency count.\n\n```python\ndef can... |
def count_occurrences(lst, element):
return lst.count(element) | simplelr_Prefill | [
{
"content": "Question:\nWrite a function to count the number of occurrences of a given element in a list (array) in Python.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6102,
"level": 1,
"question": "Write a function to count the number of occurrences of a given element in a list (array) in Python.",
"split": "train"
} |
import heapq
def shortest_path(graph, start_node, end_node):
if start_node not in graph or end_node not in graph:
return -1
if start_node == end_node:
return 0
distances = {node: float('infinity') for node in graph}
distances[start_node] = 0
heap = []
heapq.heappush(heap, (... | simplelr_Evol | [
{
"content": "Question:\nConsider a scenario where you have a large dataset representing a series of connected nodes, forming a weighted graph. Write a function in Python that accepts an adjacency list representing this graph and returns the length of the shortest path between two given nodes. The function shou... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6103,
"level": 1,
"question": "Consider a scenario where you have a large dataset representing a series of connected nodes, forming a weighted graph. Write a function in Python that accepts an adjacency list representing this graph and returns the length of the shortest path between... |
def anagram_words(word1: str, word2: str) -> bool:
if len(word1) != len(word2):
return False
return sorted(word1) == sorted(word2) | simplelr_Apps | [
{
"content": "Question:\nA word is said to be an \"anagram word\" if it can be formed by rearranging the letters of another word while using all the original letters exactly once. For example:\n\n- \"binary\" can be rearranged to form \"brainy\".\n- \"listen\" can be rearranged to form \"silent\".\n- \"hello\" ... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6104,
"level": 1,
"question": "A word is said to be an \"anagram word\" if it can be formed by rearranging the letters of another word while using all the original letters exactly once. For example:\n\n- \"binary\" can be rearranged to form \"brainy\".\n- \"listen\" can be rearrange... |
def find_unique_elements(arr):
seen = set()
unique_elements = []
for element in arr:
if element not in seen:
seen.add(element)
unique_elements.append(element)
return unique_elements | simplelr_Filter | [
{
"content": "Question:\nHere's a problem I have been trying to work on for a while and I've made good progress but I still can't get the answer:\n\nI've been tasked with writing a function that determines the unique values in a given array. The array can contain any type of object. This function should return ... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6105,
"level": 1,
"question": "Here's a problem I have been trying to work on for a while and I've made good progress but I still can't get the answer:\n\nI've been tasked with writing a function that determines the unique values in a given array. The array can contain any type of o... |
def sort_dicts_by_key(lst, key):
return sorted(lst, key=lambda x: x[key], reverse=True) | simplelr_Prefill | [
{
"content": "Question:\nWrite a python function to sort a list of dictionaries based on a specific key's value in descending order. For example, if the list of dictionaries is [{'name': 'John', 'age': 30}, {'name': 'Alice', 'age': 25}, {'name': 'Bob', 'age': 35}], and the sorting key is 'age', the function sho... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6106,
"level": 1,
"question": "Write a python function to sort a list of dictionaries based on a specific key's value in descending order. For example, if the list of dictionaries is [{'name': 'John', 'age': 30}, {'name': 'Alice', 'age': 25}, {'name': 'Bob', 'age': 35}], and the sor... |
def remove_duplicates_and_sort(input_list):
unique = list(set(input_list))
unique.sort()
return unique | simplelr_Prefill | [
{
"content": "Question:\nWrite a function to remove duplicates from a list of integers and return a new list containing the unique elements in sorted order. For example, if the input list is `[4, 1, 2, 4, 3, 2, 1]`, the function should return `[1, 2, 3, 4]`.\nAnswer:\nLet's think step by step.\n",
"role": "... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6107,
"level": 1,
"question": "Write a function to remove duplicates from a list of integers and return a new list containing the unique elements in sorted order. For example, if the input list is `[4, 1, 2, 4, 3, 2, 1]`, the function should return `[1, 2, 3, 4]`.",
"split": "trai... |
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]
return [prefix[i] * suffix[i] ... | simplelr_Evol | [
{
"content": "Question:\nWrite a function that takes a list of non-negative integers and returns a list where each integer is replaced by the product of all other integers in the original list, without using division. \n\nExample:\nInput: [1, 2, 3, 4]\nOutput: [24, 12, 8, 6]\nAnswer:\nLet's think step by step.\... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6108,
"level": 1,
"question": "Write a function that takes a list of non-negative integers and returns a list where each integer is replaced by the product of all other integers in the original list, without using division. \n\nExample:\nInput: [1, 2, 3, 4]\nOutput: [24, 12, 8, 6]",... |
def islandPerimeter(grid):
perimeter = 0
rows = len(grid)
if rows == 0:
return 0
cols = len(grid[0])
for i in range(rows):
for j in range(cols):
if grid[i][j] == 1:
perimeter += 4
# Check up
if i > 0 and grid[i-1][j] == 1:
... | simplelr_Taco | [
{
"content": "Question:\nAn island is represented by a 2D grid where '1' represents land and '0' represents water. An island is formed by connecting adjacent lands horizontally or vertically. Given a 2D grid containing only '0's and '1's, your task is to determine the perimeter of the island. The island does no... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6109,
"level": 1,
"question": "An island is represented by a 2D grid where '1' represents land and '0' represents water. An island is formed by connecting adjacent lands horizontally or vertically. Given a 2D grid containing only '0's and '1's, your task is to determine the perimete... |
def filter_and_truncate_strings(strings):
result = []
for s in strings:
length = len(s)
if length == 2:
result.append(s)
elif length > 2:
if length % 2 != 0:
result.append(s[:2])
return result | simplelr_Filter | [
{
"content": "Question:\nWrite a Python function that takes a list of strings as input and returns a new list that contains all strings from the input list that have exactly two characters. If a string has more than two characters, the function should check if the string length is an even number. If it is, cont... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6110,
"level": 1,
"question": "Write a Python function that takes a list of strings as input and returns a new list that contains all strings from the input list that have exactly two characters. If a string has more than two characters, the function should check if the string lengt... |
def largest_rectangle_area(heights):
n = len(heights)
max_area = 0
stack = []
for i in range(n):
while stack and heights[i] < heights[stack[-1]]:
j = stack.pop()
prev = stack[-1] if stack else -1
width = i - prev - 1
area = heights[j] * width
... | simplelr_Filter | [
{
"content": "Question:\nHere's the problem:\n\nYou are given an array of integers representing the height of bars in a histogram. The width of each bar is 1. Find the largest rectangular area that can be formed within the histogram.\n\n**Example:**\n\n```\nInput: [2,1,5,6,2,3]\nOutput: 10\n```\n\n**Explanation... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6111,
"level": 1,
"question": "Here's the problem:\n\nYou are given an array of integers representing the height of bars in a histogram. The width of each bar is 1. Find the largest rectangular area that can be formed within the histogram.\n\n**Example:**\n\n```\nInput: [2,1,5,6,2,3... |
def decodeString(s, shift):
result = []
for c in s:
if c == ' ':
result.append(c)
elif c.isalpha():
if c.isupper():
base = ord('A')
else:
base = ord('a')
offset = ord(c) - base
new_offset = (offset - shif... | simplelr_Taco | [
{
"content": "Question:\nYou are given an encoded string where each alphabetic character is shifted by a certain number of places. For example, shifting 'A' by 3 places results in 'D', shifting 'Z' by 1 place results in 'A'. Spaces in the string are not shifted. You need to decode the string with the given shif... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6112,
"level": 1,
"question": "You are given an encoded string where each alphabetic character is shifted by a certain number of places. For example, shifting 'A' by 3 places results in 'D', shifting 'Z' by 1 place results in 'A'. Spaces in the string are not shifted. You need to de... |
from http import HTTPStatus
def http_status_details(status_codes):
result = {}
for code in status_codes:
status = HTTPStatus(code)
result[code] = {
"phrase": status.phrase,
"description": status.description
}
return result
# Example usage:
status_codes = [20... | simplelr_Docs | [
{
"content": "Question:\n#### Objective:\nImplement a function that takes a list of HTTP status codes and returns a dictionary where the keys are the status codes, and the values are dictionaries containing the phrase and description for each status code.\n\n### Detailed Requirements:\n1. **Function Name**: `ht... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6113,
"level": 1,
"question": "#### Objective:\nImplement a function that takes a list of HTTP status codes and returns a dictionary where the keys are the status codes, and the values are dictionaries containing the phrase and description for each status code.\n\n### Detailed Requi... |
def multiply_matrix_by_scalar(A, c):
return [[c * elem for elem in row] for row in A] | simplelr_Prefill | [
{
"content": "Question:\nWrite a function to multiply a matrix by a scalar. The function should take as inputs an m x n matrix A and a scalar value c. The function should return the resulting m x n matrix where each element of the matrix has been multiplied by the scalar c.\nAnswer:\nLet's think step by step.\n... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6114,
"level": 1,
"question": "Write a function to multiply a matrix by a scalar. The function should take as inputs an m x n matrix A and a scalar value c. The function should return the resulting m x n matrix where each element of the matrix has been multiplied by the scalar c.",
... |
def countRectangles(m, n):
horizontal = (m + 1) * m // 2
vertical = (n + 1) * n // 2
return horizontal * vertical | simplelr_Leetcode | [
{
"content": "Question:\nGiven a 2-dimensional grid of size `m x n` where each cell represents a potential building lot, calculate the number of unique rectangular buildings that can be formed within the grid.\n\nA rectangular building is defined by selecting two distinct sets of horizontal and vertical grid li... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6115,
"level": 1,
"question": "Given a 2-dimensional grid of size `m x n` where each cell represents a potential building lot, calculate the number of unique rectangular buildings that can be formed within the grid.\n\nA rectangular building is defined by selecting two distinct sets... |
def sum_of_odd_numbers(arr):
total = 0
for number in arr:
if number % 2 != 0:
total += number
return total | simplelr_Filter | [
{
"content": "Question:\nIn a programming interview, I was asked to write a function that calculates the sum of odd numbers in a given array. How can I approach this problem?\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6116,
"level": 1,
"question": "In a programming interview, I was asked to write a function that calculates the sum of odd numbers in a given array. How can I approach this problem?",
"split": "train"
} |
def three_sum(nums, target):
nums.sort()
n = len(nums)
if n < 3:
return False
for i in range(n - 2):
left = i + 1
right = n - 1
while left < right:
current_sum = nums[i] + nums[left] + nums[right]
if current_sum == target:
return Tr... | simplelr_Evol | [
{
"content": "Question:\nWrite a program that takes a list of integers and a target sum as inputs. Your task is to determine if there are any three distinct elements in the list that add up to the target sum. If such elements exist, return `True`; otherwise, return `False`.\n\nExample input:\nList = [1, 4, 45, ... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6117,
"level": 1,
"question": "Write a program that takes a list of integers and a target sum as inputs. Your task is to determine if there are any three distinct elements in the list that add up to the target sum. If such elements exist, return `True`; otherwise, return `False`.\n\... |
def delete_all_instances(lst, value):
return [x for x in lst if x != value] | simplelr_Prefill | [
{
"content": "Question:\nWrite a python function to delete all instances of a specified value from a list.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6118,
"level": 1,
"question": "Write a python function to delete all instances of a specified value from a list.",
"split": "train"
} |
def to_binary(nums):
return [bin(num)[2:] for num in nums] | simplelr_Apps | [
{
"content": "Question:\nIn this task, you are required to implement a function that receives a list of integers and returns a list of strings representing the binary representation of each integer. The input list will only contain non-negative integers.\n\nFor example, the number `5` in binary is `101`, the nu... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6119,
"level": 1,
"question": "In this task, you are required to implement a function that receives a list of integers and returns a list of strings representing the binary representation of each integer. The input list will only contain non-negative integers.\n\nFor example, the nu... |
import re
def mask_digits(s):
return re.sub(r'\d', '#', s) | simplelr_Filter | [
{
"content": "Question:\nDesign a Python function to mask numerical data in a given string. The function should take a single string as input and return a new string where all digits are masked with a `#` character. For example, the input `\"My phone number is 123-456-7890, but don't call after 9 PM.\"` should ... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6120,
"level": 1,
"question": "Design a Python function to mask numerical data in a given string. The function should take a single string as input and return a new string where all digits are masked with a `#` character. For example, the input `\"My phone number is 123-456-7890, bu... |
def is_palindrome(s):
# Clean the string by removing non-alphanumeric characters and converting to lowercase
cleaned = ''.join([c for c in s if c.isalnum()]).lower()
# Check if the cleaned string is equal to its reverse
return cleaned == cleaned[::-1] | simplelr_Filter | [
{
"content": "Question:\nCan you write a script that checks if a string is a palindrome in Python? It should return `True` if the string is a palindrome (reads the same backwards as forwards), and `False` otherwise. Make sure to handle cases where the string might contain spaces or punctuation. For example, \"A... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6121,
"level": 1,
"question": "Can you write a script that checks if a string is a palindrome in Python? It should return `True` if the string is a palindrome (reads the same backwards as forwards), and `False` otherwise. Make sure to handle cases where the string might contain spac... |
from typing import List
def trap_water(heights: List[int]) -> int:
if not heights or len(heights) < 3:
return 0
left = 0
right = len(heights) - 1
left_max = right_max = 0
result = 0
while left <= right:
if left_max <= right_max:
if heights[left] >= left_max:
... | simplelr_Codeforces | [
{
"content": "Question:\nGiven a list of `n` integers, where each integer represents the height of a terrain at that position, you are tasked with determining the maximum amount of water that can be trapped after raining. \n\nThe list of integers represents the elevation map where the width of each bar is 1 uni... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6122,
"level": 1,
"question": "Given a list of `n` integers, where each integer represents the height of a terrain at that position, you are tasked with determining the maximum amount of water that can be trapped after raining. \n\nThe list of integers represents the elevation map w... |
def add_min_chars_to_make_palindrome(s):
n = len(s)
for l in range(n, 0, -1):
suffix = s[n - l:]
if suffix == suffix[::-1]:
prefix = s[:n - l]
return s + prefix[::-1]
return s | simplelr_Prefill | [
{
"content": "Question:\nWrite a function to convert a string to a palindrome by appending the minimum number of characters to the end. To achieve this, the function should find the longest palindromic suffix of the input string and append the reverse of the prefix before the suffix to the end of the string. Fo... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6123,
"level": 1,
"question": "Write a function to convert a string to a palindrome by appending the minimum number of characters to the end. To achieve this, the function should find the longest palindromic suffix of the input string and append the reverse of the prefix before the ... |
def search(arr, target, index):
# Search from the given index to the end of the array
for i in range(index, len(arr)):
if arr[i] == target:
return i
# If not found, search from the beginning to just before the index
for i in range(0, index):
if arr[i] == target:
r... | simplelr_Filter | [
{
"content": "Question:\nI have a circular array of 5 elements and I need to find the index of a specific number. The array looks like this:\n```\n[10, 12, 13, 15, 18]\n```\nHowever, I need to handle wrap-around cases where the target will be after the first element in the array when searching from the last ele... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6124,
"level": 1,
"question": "I have a circular array of 5 elements and I need to find the index of a specific number. The array looks like this:\n```\n[10, 12, 13, 15, 18]\n```\nHowever, I need to handle wrap-around cases where the target will be after the first element in the arr... |
from collections import deque
def has_path_bfs(grid, start, end):
if not grid:
return False
m = len(grid)
n = len(grid[0]) if m > 0 else 0
start_r, start_c = start
end_r, end_c = end
# Check if start or end is a wall
if grid[start_r][start_c] == '#' or grid[end_r][end_c] =... | simplelr_Leetcode | [
{
"content": "Question:\nYou are given a 2D grid of size `m x n` representing a labyrinth, where each cell is either a wall (`'#'`) or a free space (`'.'`). You are also given two integers `start` and `end`, representing the coordinates of the starting and ending points in the grid. Determine if there exists a ... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6125,
"level": 1,
"question": "You are given a 2D grid of size `m x n` representing a labyrinth, where each cell is either a wall (`'#'`) or a free space (`'.'`). You are also given two integers `start` and `end`, representing the coordinates of the starting and ending points in the... |
def find_target_indices(arr, target):
result = []
for index, value in enumerate(arr):
if value == target:
result.append(index)
return result | simplelr_Prefill | [
{
"content": "Question:\nCreate a function that accepts two parameters, an integer array and a target integer. The function should return a list of indices where the target integer is found in the array. If the target is not found, return an empty list.\nAnswer:\nLet's think step by step.\n",
"role": "user"... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6126,
"level": 1,
"question": "Create a function that accepts two parameters, an integer array and a target integer. The function should return a list of indices where the target integer is found in the array. If the target is not found, return an empty list.",
"split": "train"
} |
def count_occurrences(nested_list, value):
count = 0
for element in nested_list:
if element == value:
count += 1
if isinstance(element, list):
count += count_occurrences(element, value)
return count | simplelr_Prefill | [
{
"content": "Question:\nWrite a python function to find the number of occurrences of a given value in a nested list using recursion.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6127,
"level": 1,
"question": "Write a python function to find the number of occurrences of a given value in a nested list using recursion.",
"split": "train"
} |
def find_middle_element(lst):
middle_index = len(lst) // 2
return lst[middle_index]
numbers = [1, 2, 3, 4, 5, 6]
print(find_middle_element(numbers)) | simplelr_Filter | [
{
"content": "Question:\ndef find_middle_element(lst):\n middle_index = len(lst) // 2\n return lst[middle_index]\n\nnumbers = [1, 2, 3, 4, 5, 6]\nprint(find_middle_element(numbers))\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6128,
"level": 1,
"question": "def find_middle_element(lst):\n middle_index = len(lst) // 2\n return lst[middle_index]\n\nnumbers = [1, 2, 3, 4, 5, 6]\nprint(find_middle_element(numbers))",
"split": "train"
} |
from typing import List
def max_product_of_three(nums: List[int]) -> int:
nums_sorted = sorted(nums)
n = len(nums_sorted)
product1 = nums_sorted[-1] * nums_sorted[-2] * nums_sorted[-3]
product2 = nums_sorted[0] * nums_sorted[1] * nums_sorted[-1]
return max(product1, product2) | simplelr_Evol | [
{
"content": "Question:\nCreate a function in Python that takes a list of integers and returns the maximum product of any three distinct numbers from the list. Your function should consider large numerical values and handle both positive and negative numbers. \n\nTo ensure the solution is efficient, aim for an ... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6129,
"level": 1,
"question": "Create a function in Python that takes a list of integers and returns the maximum product of any three distinct numbers from the list. Your function should consider large numerical values and handle both positive and negative numbers. \n\nTo ensure the... |
def is_palindrome(s: str) -> bool:
cleaned = [c.lower() for c in s if c.isalnum()]
cleaned_str = ''.join(cleaned)
left = 0
right = len(cleaned_str) - 1
while left < right:
if cleaned_str[left] != cleaned_str[right]:
return False
left += 1
right -= 1
return Tru... | simplelr_Algorithm | [
{
"content": "Question:\n**Question: Efficient Palindrome Checking**\n\n**Context:**\nBob is developing a text processing tool that needs to efficiently identify palindromes within strings. A palindrome is a string that reads the same forward and backward. Given the need to handle large strings and numerous que... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6130,
"level": 1,
"question": "**Question: Efficient Palindrome Checking**\n\n**Context:**\nBob is developing a text processing tool that needs to efficiently identify palindromes within strings. A palindrome is a string that reads the same forward and backward. Given the need to ha... |
def process_stack_operations(s):
tokens = s.split()
stack = []
i = 0
while i < len(tokens):
if tokens[i] == 'push':
x = int(tokens[i + 1])
stack.append(x)
i += 2
elif tokens[i] == 'pop':
if not stack:
return []
s... | simplelr_Apps | [
{
"content": "Question:\nDesign a function that takes as input a string representing the operations of a stack (push and pop) and the values being pushed onto the stack. The task is to determine if the sequence of operations is valid and then return the elements remaining in the stack after performing all opera... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6131,
"level": 1,
"question": "Design a function that takes as input a string representing the operations of a stack (push and pop) and the values being pushed onto the stack. The task is to determine if the sequence of operations is valid and then return the elements remaining in t... |
def generate_even_squares():
return [num ** 2 for num in range(0, 11, 2)] | simplelr_Prefill | [
{
"content": "Question:\nWrite a python function to generate a list using list comprehension. The list should contain the squares of all even numbers from 0 to 10.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6132,
"level": 1,
"question": "Write a python function to generate a list using list comprehension. The list should contain the squares of all even numbers from 0 to 10.",
"split": "train"
} |
def isToeplitzMatrix(matrix):
m = len(matrix)
if m == 0:
return True # Assuming empty matrix is considered Toeplitz, though constraints say m >=1
n = len(matrix[0])
if m == 1 or n == 1:
return True
for i in range(m - 1):
for j in range(n - 1):
if matrix[i][j] != ... | simplelr_Apps | [
{
"content": "Question:\nImplement a function to solve the \"Toeplitz Matrix\" problem. A matrix is called Toeplitz if every diagonal from top-left to bottom-right has the same element. More precisely, if a matrix `matrix` is Toeplitz, then `matrix[i][j] == matrix[i+1][j+1]` for all `i` and `j` such that `i + 1... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6133,
"level": 1,
"question": "Implement a function to solve the \"Toeplitz Matrix\" problem. A matrix is called Toeplitz if every diagonal from top-left to bottom-right has the same element. More precisely, if a matrix `matrix` is Toeplitz, then `matrix[i][j] == matrix[i+1][j+1]` f... |
from PIL import Image
def convert_image_format(input_path, output_path, output_format=None, quality=75):
"""
Convert an image from one format to another.
Args:
input_path (str): Path to the input image file.
output_path (str): Path to the output image file.
output_format (str, opti... | simplelr_Filter | [
{
"content": "Question:\nPlease provide a Python code to demonstrate how to convert an image from one format to another using the `PIL` library (Pillow).\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6134,
"level": 1,
"question": "Please provide a Python code to demonstrate how to convert an image from one format to another using the `PIL` library (Pillow).",
"split": "train"
} |
def reverse_string(s):
# Process the string to check for palindrome (ignore case and non-alphanumeric)
processed = ''.join([c.lower() for c in s if c.isalnum()])
# Check if the processed string is a palindrome
if processed == processed[::-1]:
return s.upper()
else:
return s[::-1].low... | simplelr_Filter | [
{
"content": "Question:\nWrite a Python function to reverse a string, but with a twist: if the string is a palindrome (reads the same backward as forward), the function should return the original string in uppercase. If not, return the reversed string in lowercase. Additionally, the function should ignore case ... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6135,
"level": 1,
"question": "Write a Python function to reverse a string, but with a twist: if the string is a palindrome (reads the same backward as forward), the function should return the original string in uppercase. If not, return the reversed string in lowercase. Additionall... |
def removeDuplicateLetters(s):
last_occurrence = {char: idx for idx, char in enumerate(s)}
stack = []
used = set()
for idx, char in enumerate(s):
if char in used:
continue
# Remove characters from the stack that are larger than current and can be removed
while st... | simplelr_Taco | [
{
"content": "Question:\nGiven a string composed of lowercase alphabets, you need to remove duplicate letters so that every letter appears once and only once. You must make sure the resultant string is the smallest in lexicographical order among all possible results.\n\nExample 1:\nInput: \"bcabc\"\nOutput: \"a... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6136,
"level": 1,
"question": "Given a string composed of lowercase alphabets, you need to remove duplicate letters so that every letter appears once and only once. You must make sure the resultant string is the smallest in lexicographical order among all possible results.\n\nExampl... |
def generate_customized_plots():
import seaborn as sns
import matplotlib.pyplot as plt
# Bar Plot with Whitegrid Style
sns.set_style("whitegrid")
plt.figure()
sns.barplot(x=["Category A", "Category B", "Category C"], y=[10, 20, 15])
plt.xlabel("Categories")
plt.ylabel("Values")
plt.... | simplelr_Docs | [
{
"content": "Question:\nUsing Seaborn, styles can significantly enhance the readability and aesthetics of your plots. Your task is to create a function that generates two different types of plots with customized styles and saves them to disk.\n\n### Function Signature\n```python\ndef generate_customized_plots(... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6137,
"level": 1,
"question": "Using Seaborn, styles can significantly enhance the readability and aesthetics of your plots. Your task is to create a function that generates two different types of plots with customized styles and saves them to disk.\n\n### Function Signature\n```pyt... |
def binary_search(arr, target):
low = 0
high = len(arr) - 1
while low <= high:
mid = (low + high) // 2
if arr[mid] == target:
return mid
elif arr[mid] > target:
high = mid - 1
else:
low = mid + 1
return -1 | simplelr_Filter | [
{
"content": "Question:\nGiven a sorted list of integers, how can I find the index of a specific target value using a binary search algorithm in Python? If the target is not found, what should the function return?\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6138,
"level": 1,
"question": "Given a sorted list of integers, how can I find the index of a specific target value using a binary search algorithm in Python? If the target is not found, what should the function return?",
"split": "train"
} |
def normalize_path(path: str) -> str:
"""
This function normalizes a Unix-style file path by resolving '.' and '..' components.
The function processes the path to handle the current directory (.) and parent directory (..) references.
It returns the absolute equivalent path, ensuring it starts with ... | simplelr_Algorithm | [
{
"content": "Question:\n### File System Path Manipulator\n\n#### Background\nIn many programming scenarios, manipulating file paths is a common operation. This could involve normalizing, joining, or extracting parts of paths for various purposes. Working with file paths can be tricky due to the different conve... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6139,
"level": 1,
"question": "### File System Path Manipulator\n\n#### Background\nIn many programming scenarios, manipulating file paths is a common operation. This could involve normalizing, joining, or extracting parts of paths for various purposes. Working with file paths can b... |
def left_rotate_array(arr: list, d: int) -> list:
n = len(arr)
d = d % n
return arr[d:] + arr[:d] | simplelr_Algorithm | [
{
"content": "Question:\n### Array Rotation\n\nYou are given an array and a number `d`. Your task is to rotate the array to the left by `d` positions.\n\n#### Function Signature\n```python\ndef left_rotate_array(arr: list, d: int) -> list:\n \"\"\"\n Args:\n - arr (list): A list of integers.\n - d (... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6140,
"level": 1,
"question": "### Array Rotation\n\nYou are given an array and a number `d`. Your task is to rotate the array to the left by `d` positions.\n\n#### Function Signature\n```python\ndef left_rotate_array(arr: list, d: int) -> list:\n \"\"\"\n Args:\n - arr (li... |
def concatenate_strings(strings):
return ",".join(strings) | simplelr_Apps | [
{
"content": "Question:\nWrite a function that accepts a list of strings and returns a single string that contains all the original strings concatenated together, separated by commas. If the input list is empty, return an empty string.\n\nFor example:\n```\ninput = [\"apple\", \"banana\", \"cherry\"]\n--> \"app... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6141,
"level": 1,
"question": "Write a function that accepts a list of strings and returns a single string that contains all the original strings concatenated together, separated by commas. If the input list is empty, return an empty string.\n\nFor example:\n```\ninput = [\"apple\",... |
def rotate_image(image):
# Transpose the image and convert tuples to lists
transposed = [list(row) for row in zip(*image)]
# Reverse each row to complete the rotation
rotated = [row[::-1] for row in transposed]
return rotated | simplelr_Algorithm | [
{
"content": "Question:\n### Question: Image Rotate Function\n\n#### Context\nIn computer graphics and image processing, rotating an image by 90 degrees is a common operation. This can be done in an efficient manner by transforming the pixel positions.\n\n#### Task \nYou are given a function `rotate_image(image... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6142,
"level": 1,
"question": "### Question: Image Rotate Function\n\n#### Context\nIn computer graphics and image processing, rotating an image by 90 degrees is a common operation. This can be done in an efficient manner by transforming the pixel positions.\n\n#### Task \nYou are g... |
from collections import Counter
def count_pairs_with_sum(arr, target_sum):
counts = Counter(arr)
s = set(arr)
count = 0
for x in s:
y = target_sum - x
if y in s:
if x <= y:
if x == y:
# Check if there are at least two occurrences
... | simplelr_Code_Contests | [
{
"content": "Question:\nAn alien spaceship has landed on Earth, and the aliens are fascinated by human mathematics. They have decided to test the humans' understanding of array manipulations. The aliens have provided an array of integers and a target sum. Your task is to find the number of distinct pairs in th... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6143,
"level": 1,
"question": "An alien spaceship has landed on Earth, and the aliens are fascinated by human mathematics. They have decided to test the humans' understanding of array manipulations. The aliens have provided an array of integers and a target sum. Your task is to find... |
from typing import List
def can_reach_end(arr: List[int]) -> bool:
max_reachable = 0
n = len(arr)
for i in range(n):
if i > max_reachable:
return False
max_reachable = max(max_reachable, i + arr[i])
return max_reachable >= n - 1 | simplelr_Algorithm | [
{
"content": "Question:\n### Problem Statement\n\nWrite a function named `can_reach_end` that determines whether it's possible to reach the last position in an array of non-negative integers, where each element represents the maximum number of steps you can move forward from that position.\n\n### Detailed Requi... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6144,
"level": 1,
"question": "### Problem Statement\n\nWrite a function named `can_reach_end` that determines whether it's possible to reach the last position in an array of non-negative integers, where each element represents the maximum number of steps you can move forward from t... |
def rectangle_area(dimensions):
length, width = dimensions
return length * width | simplelr_Filter | [
{
"content": "Question:\nHere is a simple challenge:\n\nWrite a simple Python function to calculate the area of a rectangle given its length and width as a tuple.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6145,
"level": 1,
"question": "Here is a simple challenge:\n\nWrite a simple Python function to calculate the area of a rectangle given its length and width as a tuple.",
"split": "train"
} |
def find_lowest_cost_path(graph, start, end):
"""
Find the path with the lowest total cost between two nodes in a weighted graph.
Parameters:
graph: dict
A dictionary representation of a weighted graph where keys are nodes and values are lists of tuples (neighbor, cost).
start: str
... | simplelr_Data_Structure | [
{
"content": "Question:\n### Pathfinding with Weighted Graphs\n\n#### Scenario:\nYou are working on a navigation system that needs to compute the optimal route between locations on a weighted graph. Each location is a node, and each route between locations has a specific travel cost. The goal is to find not onl... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6146,
"level": 1,
"question": "### Pathfinding with Weighted Graphs\n\n#### Scenario:\nYou are working on a navigation system that needs to compute the optimal route between locations on a weighted graph. Each location is a node, and each route between locations has a specific trave... |
def optimal_knapsack_value(capacity, items):
n = len(items)
# Create a DP table with (n+1) rows and (capacity+1) columns
dp = [[0] * (capacity + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
value, weight = items[i-1]
for w in range(1, capacity + 1):
if weight > w:... | simplelr_Data_Structure | [
{
"content": "Question:\n### 0/1 Knapsack Problem\n\nYou are required to solve the classic 0/1 Knapsack problem using dynamic programming. You are given the capacity of the knapsack and a list of items, each represented by its value and weight. The goal is to determine the maximum value that can be carried in t... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6147,
"level": 1,
"question": "### 0/1 Knapsack Problem\n\nYou are required to solve the classic 0/1 Knapsack problem using dynamic programming. You are given the capacity of the knapsack and a list of items, each represented by its value and weight. The goal is to determine the max... |
def factorial(n):
if n < 0:
raise ValueError("n must be a non-negative integer")
result = 1
for i in range(1, n + 1):
result *= i
return result | simplelr_Prefill | [
{
"content": "Question:\nWrite a python function to calculate the factorial of a given non-negative integer `n`. If `n`, is negative, the function should raise a `ValueError`.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6148,
"level": 1,
"question": "Write a python function to calculate the factorial of a given non-negative integer `n`. If `n`, is negative, the function should raise a `ValueError`.",
"split": "train"
} |
import errno
import os
def handle_error_codes(error_codes: list[int]) -> list[str]:
results = []
for code in error_codes:
if code in errno.errorcode:
symbolic_name = errno.errorcode[code]
description = os.strerror(code)
try:
if code == errno.EPERM:
... | simplelr_Docs | [
{
"content": "Question:\n### Error Code Translation and Exception Handling\n\nYou are tasked with developing a diagnostic tool in Python that will help users understand specific system-related errors encountered during various operations. This tool should take a list of error codes and output their correspondin... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6149,
"level": 1,
"question": "### Error Code Translation and Exception Handling\n\nYou are tasked with developing a diagnostic tool in Python that will help users understand specific system-related errors encountered during various operations. This tool should take a list of error ... |
def extract_emails(users):
# Initialize an empty set to store unique emails
unique_emails = set()
# Iterate through each user in the list
for user in users:
# Add the email to the set
unique_emails.add(user['email'])
# Convert the set to a sorted list
sorted_emails = so... | simplelr_Filter | [
{
"content": "Question:\nWrite a Python code that extracts the email of the users from the given list of dictionaries. The dictionary consists of the key-value pairs of the user's name, age, and email. The function should return a list of emails, but there shouldn't be any duplicates, meaning if an email alread... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6150,
"level": 1,
"question": "Write a Python code that extracts the email of the users from the given list of dictionaries. The dictionary consists of the key-value pairs of the user's name, age, and email. The function should return a list of emails, but there shouldn't be any dup... |
def find_max_elements_and_sort(tuples_list):
# Extract the maximum element from each tuple
maxima = [max(t) for t in tuples_list]
# Implement bubble sort in descending order
n = len(maxima)
for i in range(n):
swapped = False
for j in range(n - i - 1):
if maxima[j] < ... | simplelr_Filter | [
{
"content": "Question:\nWrite a function that takes a list of tuples as input, finds the maximum element in each tuple, and returns a new list with these maximum elements, but arranged in decreasing order. To make the task more challenging, you should complete this task without using any built-in sorting funct... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6151,
"level": 1,
"question": "Write a function that takes a list of tuples as input, finds the maximum element in each tuple, and returns a new list with these maximum elements, but arranged in decreasing order. To make the task more challenging, you should complete this task witho... |
def coinChange(coins, amount):
if amount == 0:
return 0
dp = [float('inf')] * (amount + 1)
dp[0] = 0 # Base case: 0 coins needed to make 0 amount
for coin in coins:
for j in range(coin, amount + 1):
dp[j] = min(dp[j], dp[j - coin] + 1)
return dp[amount] if dp[amount] !... | simplelr_Leetcode | [
{
"content": "Question:\nGiven a list of `n` integers representing coin denominations and an integer amount representing a total sum of money, design an algorithm to determine the minimum number of coins needed to make up that amount. If it is not possible to make up the amount with the given denominations, ret... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6152,
"level": 1,
"question": "Given a list of `n` integers representing coin denominations and an integer amount representing a total sum of money, design an algorithm to determine the minimum number of coins needed to make up that amount. If it is not possible to make up the amoun... |
def create_conversation(listA, listB):
conversation = []
for i in range(len(listA)):
conversation.append(listA[i])
conversation.append(listB[i % len(listB)])
return conversation
# Example usage:
listA = ['msg1', 'msg2', 'msg3', 'msg4']
listB = ['response1', 'response2']
print(create_convers... | simplelr_Filter | [
{
"content": "Question:\nI have two lists of different lengths that contain dialogue from different characters. I want to create a conversation between two characters, taking one message from the first character, then one from the second character, etc. \n\nHere is an example of my lists:\n\nList A: ['msg1', 'm... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6153,
"level": 1,
"question": "I have two lists of different lengths that contain dialogue from different characters. I want to create a conversation between two characters, taking one message from the first character, then one from the second character, etc. \n\nHere is an example ... |
def can_split_array(nums):
n = len(nums)
if n < 2:
return False
total = sum(nums)
if total % 2 != 0:
return False
target = total // 2
current_sum = 0
for i in range(n - 1): # Ensure there's at least one element in the second subarray
current_sum += nums[i]
if... | simplelr_Leetcode | [
{
"content": "Question:\nYou are given an integer array `nums` and you need to determine if it can be split into two contiguous subarrays such that the sum of the elements in the first subarray is equal to the sum of the elements in the second subarray. Return _true if such a split is possible, and false otherw... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6154,
"level": 1,
"question": "You are given an integer array `nums` and you need to determine if it can be split into two contiguous subarrays such that the sum of the elements in the first subarray is equal to the sum of the elements in the second subarray. Return _true if such a ... |
from typing import List
def filter_even_squares(numbers: List[int]) -> List[int]:
even_squares = []
for num in numbers:
if num % 2 == 0:
even_squares.append(num ** 2)
even_squares.sort(reverse=True)
return even_squares | simplelr_Algorithm | [
{
"content": "Question:\n### Problem Statement\nWrite a function `filter_even_squares` that takes a list of integers and returns a new list containing the squares of the even numbers from the original list, sorted in descending order.\n\n### Function Signature\n```python\ndef filter_even_squares(numbers: List[i... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6155,
"level": 1,
"question": "### Problem Statement\nWrite a function `filter_even_squares` that takes a list of integers and returns a new list containing the squares of the even numbers from the original list, sorted in descending order.\n\n### Function Signature\n```python\ndef ... |
def find_maximum_sum(numbers):
if not numbers:
return 0 # or raise ValueError("List is empty") if needed
current_max = max_so_far = numbers[0]
for num in numbers[1:]:
current_max = max(num, current_max + num)
max_so_far = max(max_so_far, current_max)
return max_so_far | simplelr_Filter | [
{
"content": "Question:\nThis code defines a function called `find_maximum_sum` that takes a list of numbers as its argument and returns the maximum sum of any contiguous sublist within the list.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6156,
"level": 1,
"question": "This code defines a function called `find_maximum_sum` that takes a list of numbers as its argument and returns the maximum sum of any contiguous sublist within the list.",
"split": "train"
} |
def calculate_average(numbers):
if not numbers:
return None
for num in numbers:
if type(num) not in (int, float):
return None
return sum(numbers) / len(numbers) | simplelr_Filter | [
{
"content": "Question:\nWrite a Python function to calculate the average of a list of numbers. The function should handle both empty lists and lists with non-numeric values gracefully, returning `None` in such cases.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6157,
"level": 1,
"question": "Write a Python function to calculate the average of a list of numbers. The function should handle both empty lists and lists with non-numeric values gracefully, returning `None` in such cases.",
"split": "train"
} |
from collections import deque
def shortest_path(graph, s, t):
if s not in graph or t not in graph:
return None # Destination or source not present in the graph
if s == t:
return [s]
visited = set()
queue = deque([s])
visited.add(s)
parent = {}
found = False
wh... | simplelr_Filter | [
{
"content": "Question:\nGiven a directed graph G = (V, E), a source vertex s and a destination vertex t, the problem is to find the path from s to t that is the shortest with respect to the number of edges. The graph is represented by an adjacency list representation.\n\nWhat is the proper way to implement the... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6158,
"level": 1,
"question": "Given a directed graph G = (V, E), a source vertex s and a destination vertex t, the problem is to find the path from s to t that is the shortest with respect to the number of edges. The graph is represented by an adjacency list representation.\n\nWhat... |
def two_product(arr, target):
if target == 0:
return False
seen = set()
for num in arr:
complement = target / num
if complement in seen:
return True
seen.add(num)
return False | simplelr_Leetcode | [
{
"content": "Question:\nYou are given an array of **n** positive integers `arr` and an integer `target`. Your task is to determine if there are exactly two different elements of the array whose product is equal to `target`. Return `True` if such elements exist, otherwise return `False`. Note that the elements ... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6159,
"level": 1,
"question": "You are given an array of **n** positive integers `arr` and an integer `target`. Your task is to determine if there are exactly two different elements of the array whose product is equal to `target`. Return `True` if such elements exist, otherwise retu... |
def calculate_total_cost(subtotal, tax_rate):
tax = subtotal * tax_rate
total = subtotal + tax
return round(total, 2) | simplelr_Prefill | [
{
"content": "Question:\nWrite a function to calculate the total cost of an order, including tax.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6160,
"level": 1,
"question": "Write a function to calculate the total cost of an order, including tax.",
"split": "train"
} |
from typing import List
def extract_unique_words(text: str) -> List[str]:
words = []
for token in text.split():
cleaned_word = ''.join([c for c in token if c.isalpha()])
if cleaned_word:
words.append(cleaned_word.lower())
unique_words = set(words)
return sorted(unique_words)... | simplelr_Algorithm | [
{
"content": "Question:\n### Coding Assessment Question\n\n#### Scenario:\nYou are working on a text processing application that needs to summarize texts by extracting unique words and sorting them alphabetically. To achieve this, your task is to create a function that takes a string of text and returns a sorte... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6161,
"level": 1,
"question": "### Coding Assessment Question\n\n#### Scenario:\nYou are working on a text processing application that needs to summarize texts by extracting unique words and sorting them alphabetically. To achieve this, your task is to create a function that takes a... |
def generate_issue_key(project_key, issue_number, padding_size):
padded_number = str(issue_number).zfill(padding_size)
return f"{project_key}-{padded_number}" | simplelr_Filter | [
{
"content": "Question:\nWrite a Python function to implement Atlassian-style issue generation key. The key should take three parameters: the project key (string), the unique number of the issue (integer), and the padding size (integer) for the leading zeros in the issue number.\nAnswer:\nLet's think step by st... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6162,
"level": 1,
"question": "Write a Python function to implement Atlassian-style issue generation key. The key should take three parameters: the project key (string), the unique number of the issue (integer), and the padding size (integer) for the leading zeros in the issue numbe... |
def unique_integers(lst):
seen = set()
unique_list = []
for num in lst:
if num not in seen:
unique_list.append(num)
seen.add(num)
return unique_list | simplelr_Prefill | [
{
"content": "Question:\nCreate a function that takes a list of integers and returns a new list containing only the unique integers from the original list, in the same order they appeared.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6163,
"level": 1,
"question": "Create a function that takes a list of integers and returns a new list containing only the unique integers from the original list, in the same order they appeared.",
"split": "train"
} |
def transform_iterable(x, f):
return map(f, x) | simplelr_Prefill | [
{
"content": "Question:\nCreate a function that takes two parameters: an iterable `x` and a function `f`. It should return a new iterable where the elements of `x` are transformed using the function `f`.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6164,
"level": 1,
"question": "Create a function that takes two parameters: an iterable `x` and a function `f`. It should return a new iterable where the elements of `x` are transformed using the function `f`.",
"split": "train"
} |
from typing import List
def spiral_traversal(matrix: List[List[int]]) -> List[int]:
result = []
if not matrix:
return result
top = 0
bottom = len(matrix) - 1
left = 0
right = len(matrix[0]) - 1
while top <= bottom and left <= right:
# Traverse from left to right on... | simplelr_Data_Structure | [
{
"content": "Question:\n### Scenario\nYou are given a 2D matrix representing a minefield. To defuse the minefield without setting off any mines, a robot has to traverse the field in a specific pattern - a clockwise spiral starting from the top-left corner. Write a function `spiral_traversal` that takes a 2D ma... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6165,
"level": 1,
"question": "### Scenario\nYou are given a 2D matrix representing a minefield. To defuse the minefield without setting off any mines, a robot has to traverse the field in a specific pattern - a clockwise spiral starting from the top-left corner. Write a function `s... |
def unique_odd_occurrences(arr):
freq = {}
for num in arr:
if num in freq:
freq[num] += 1
else:
freq[num] = 1
result = []
for key in freq:
if freq[key] % 2 != 0:
result.append(key)
return result | simplelr_Evol | [
{
"content": "Question:\nConsider an array of integers. The task is to generate a new array that contains only the unique integers that appear an odd number of times in the original array. Ensure that the order of the elements in the new array follows their first appearance in the original array.\nAnswer:\nLet'... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6166,
"level": 1,
"question": "Consider an array of integers. The task is to generate a new array that contains only the unique integers that appear an odd number of times in the original array. Ensure that the order of the elements in the new array follows their first appearance in... |
def find_divisible_by_3_or_5(n):
return [num for num in range(2, n + 1) if num % 3 == 0 or num % 5 == 0] | simplelr_Prefill | [
{
"content": "Question:\nWrite a python function to find all numbers in the range from 2 to the given parameter n, that are divisible by either 3 or 5.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6167,
"level": 1,
"question": "Write a python function to find all numbers in the range from 2 to the given parameter n, that are divisible by either 3 or 5.",
"split": "train"
} |
def evaluate(s):
# Tokenize the string into numbers and operators, ignoring spaces
s = s.strip()
tokens = []
current_num = ''
for c in s:
if c.isdigit():
current_num += c
else:
if c in '+-*/ ':
if current_num:
tokens.append(... | simplelr_Taco | [
{
"content": "Question:\n## Evaluating Expression\n\nGiven a mathematical expression string input that consists of non-negative integers and the operators `+`, `-`, `*`, and `/` (no parenthesis), evaluate the expression and return the result as an integer.\n\n---\n\n## Input\n\n* A string `s` representing the m... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6168,
"level": 1,
"question": "## Evaluating Expression\n\nGiven a mathematical expression string input that consists of non-negative integers and the operators `+`, `-`, `*`, and `/` (no parenthesis), evaluate the expression and return the result as an integer.\n\n---\n\n## Input\n... |
def minCompletionTime(tasks: list[int]) -> int:
total = sum(tasks)
if total == 0:
return 0
target = total // 2
possible_sums = {0}
for task in tasks:
new_sums = set()
for s in possible_sums:
new_sum = s + task
if new_sum <= target:
new_... | simplelr_Leetcode | [
{
"content": "Question:\nYou are given an array of integers `tasks` where `tasks[i]` represents the time it takes to complete the `i-th` task. There are **two workers** who will work on completing these tasks. Each worker can only work on one task at a time. The goal is to divide the tasks between the two worke... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6169,
"level": 1,
"question": "You are given an array of integers `tasks` where `tasks[i]` represents the time it takes to complete the `i-th` task. There are **two workers** who will work on completing these tasks. Each worker can only work on one task at a time. The goal is to div... |
def recursive_sum(lst):
if not lst:
return 0
else:
return lst[0] + recursive_sum(lst[1:]) | simplelr_Prefill | [
{
"content": "Question:\nWrite a python function to implement the recursive sum of a list of numbers.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6170,
"level": 1,
"question": "Write a python function to implement the recursive sum of a list of numbers.",
"split": "train"
} |
def count_words(s: str) -> int:
if not isinstance(s, str):
raise TypeError("Input must be a string")
return len(s.split()) | simplelr_Algorithm | [
{
"content": "Question:\n### Question\n\n#### Scenario:\nYou are developing a utility tool that analyzes the content of text files. One of the features needed is to identify and count the number of words in a given string. A \"word\" is defined as a sequence of characters separated by whitespace characters such... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6171,
"level": 1,
"question": "### Question\n\n#### Scenario:\nYou are developing a utility tool that analyzes the content of text files. One of the features needed is to identify and count the number of words in a given string. A \"word\" is defined as a sequence of characters sepa... |
from collections import Counter
def is_anagram_of_palindrome(s):
# Filter to include only lowercase alphabetical characters
filtered = [c for c in s if c.islower() and c.isalpha()]
# Count the frequency of each character
freq = Counter(filtered)
# Count how many characters have an odd number of occ... | simplelr_Filter | [
{
"content": "Question:\nWrite a function called \"is_anagram_of_palindrome\" that takes a string as input and returns True if the input string can be rearranged to form a palindrome, and False otherwise. Note that only lowercase alphabetical characters are considered for the palindrome formation.\nAnswer:\nLet... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6172,
"level": 1,
"question": "Write a function called \"is_anagram_of_palindrome\" that takes a string as input and returns True if the input string can be rearranged to form a palindrome, and False otherwise. Note that only lowercase alphabetical characters are considered for the ... |
def reverse_list_in_place(lst):
n = len(lst)
for i in range(n // 2):
lst[i], lst[n - 1 - i] = lst[n - 1 - i], lst[i]
return lst | simplelr_Prefill | [
{
"content": "Question:\nWrite a python function to reverse the elements of a list in place without using any extra space, and with a time complexity of O(n).\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6173,
"level": 1,
"question": "Write a python function to reverse the elements of a list in place without using any extra space, and with a time complexity of O(n).",
"split": "train"
} |
import string
def count_distinct_words(s):
tokens = s.split()
unique_words = set()
for token in tokens:
stripped = token.strip(string.punctuation)
if stripped:
unique_words.add(stripped)
return len(unique_words) | simplelr_Filter | [
{
"content": "Question:\nCode a method in Python that determines the number of distinct words in a given string. You may assume that the string only contains lowercase letters, spaces, and punctuation marks such as commas and periods.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6174,
"level": 1,
"question": "Code a method in Python that determines the number of distinct words in a given string. You may assume that the string only contains lowercase letters, spaces, and punctuation marks such as commas and periods.",
"split": "train"
} |
from collections import Counter
def count_strings(strings):
return Counter(strings) | simplelr_Evol | [
{
"content": "Question:\nWrite a function that takes a list of strings as input and returns a dictionary where the keys are the unique strings from the list and the values are the number of times each string appears in the list. Ensure your function efficiently handles lists with a large number of strings and a... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6175,
"level": 1,
"question": "Write a function that takes a list of strings as input and returns a dictionary where the keys are the unique strings from the list and the values are the number of times each string appears in the list. Ensure your function efficiently handles lists w... |
def longest_substring_with_constraints(s: str, k: int) -> int:
if k == 0:
return 0
if not s:
return 0
distinct_chars = len(set(s))
if distinct_chars <= k:
return len(s)
char_count = {}
max_length = 0
current_distinct = 0
left = 0
for right in ra... | simplelr_Algorithm | [
{
"content": "Question:\n## Coding Question: Longest Substring with Constraints\n\n### Context:\nAnalyzing substrings within a string while adhering to specific constraints is a fundamental problem in string processing. Such applications are often encountered in tasks involving text manipulation, data compressi... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6176,
"level": 1,
"question": "## Coding Question: Longest Substring with Constraints\n\n### Context:\nAnalyzing substrings within a string while adhering to specific constraints is a fundamental problem in string processing. Such applications are often encountered in tasks involvin... |
def max_subarray_sum(nums):
if not nums:
return 0 # Assuming the function should return 0 for empty input, though the problem implies nums is non-empty
current_max = max_so_far = nums[0]
for num in nums[1:]:
current_max = max(num, current_max + num)
max_so_far = max(max_so_far,... | simplelr_Leetcode | [
{
"content": "Question:\nGiven an integer array `nums`, find the **subarray** with the largest sum and return its sum. A subarray is a contiguous non-empty sequence of elements within an array. Implement an algorithm that runs in `O(n)` time complexity.\nAnswer:\nLet's think step by step.\n",
"role": "user"... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6177,
"level": 1,
"question": "Given an integer array `nums`, find the **subarray** with the largest sum and return its sum. A subarray is a contiguous non-empty sequence of elements within an array. Implement an algorithm that runs in `O(n)` time complexity.",
"split": "train"
} |
def is_valid_sequence(numbers: list) -> bool:
# Check if the input is a list
if not isinstance(numbers, list):
raise ValueError("Input must be a list of integers")
# Check if all elements are integers
for num in numbers:
if type(num) is not int:
raise ValueError("Input m... | simplelr_Algorithm | [
{
"content": "Question:\n### Coding Question\n\n#### Problem Statement\nYou are given a list of integers `numbers`. Your task is to write a Python function called `is_valid_sequence` that determines whether the given list can be considered a \"valid sequence.\" A list is deemed a \"valid sequence\" if each elem... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6178,
"level": 1,
"question": "### Coding Question\n\n#### Problem Statement\nYou are given a list of integers `numbers`. Your task is to write a Python function called `is_valid_sequence` that determines whether the given list can be considered a \"valid sequence.\" A list is deeme... |
def rotate_matrix(matrix):
n = len(matrix)
rotated = []
for j in range(n):
new_row = [matrix[i][j] for i in range(n)]
new_row.reverse()
rotated.append(new_row)
return rotated | simplelr_Apps | [
{
"content": "Question:\nWrite a function `rotate_matrix(matrix)` that takes a 2D list `matrix` as input and returns the matrix rotated 90 degrees clockwise. The function should handle any NxN matrix.\n\nFor example, given the following matrix:\n```python\n[\n [1, 2, 3],\n [4, 5, 6],\n [7, 8, 9]\n]\n``... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6179,
"level": 1,
"question": "Write a function `rotate_matrix(matrix)` that takes a 2D list `matrix` as input and returns the matrix rotated 90 degrees clockwise. The function should handle any NxN matrix.\n\nFor example, given the following matrix:\n```python\n[\n [1, 2, 3],\n ... |
def remove_duplicates_and_sort(lst):
unique_set = set(lst)
sorted_list = sorted(unique_set)
return sorted_list | simplelr_Prefill | [
{
"content": "Question:\nCreate a function that takes a list of numbers and returns the list with all duplicates removed and elements sorted in ascending order.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6180,
"level": 1,
"question": "Create a function that takes a list of numbers and returns the list with all duplicates removed and elements sorted in ascending order.",
"split": "train"
} |
def max_profit(prices):
if not prices or len(prices) < 2:
return 0
min_price = prices[0]
max_profit = 0
for price in prices[1:]:
if price < min_price:
min_price = price
current_profit = price - min_price
if current_profit > max_profit:
max_profit =... | simplelr_Prefill | [
{
"content": "Question:\nWrite a python function to find the maximum profit that can be made from buying and selling stocks on different days. The function should take a list of integers representing the stock prices on consecutive days and return the maximum profit that can be achieved. Assume you can only com... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6181,
"level": 1,
"question": "Write a python function to find the maximum profit that can be made from buying and selling stocks on different days. The function should take a list of integers representing the stock prices on consecutive days and return the maximum profit that can b... |
def canAttendMeetings(intervals):
if not intervals:
return True
intervals.sort()
last_end = intervals[0][1]
for i in range(1, len(intervals)):
if intervals[i][0] < last_end:
return False
last_end = intervals[i][1]
return True
| simplelr_Taco | [
{
"content": "Question:\nGiven n pairs of integers where each pair represents a start and end time of a meeting, determine if a person can attend all meetings. If a person can attend all meetings, return True, otherwise, return False.\n\nExample 1:\nInput: intervals = [[0, 30], [5, 10], [15, 20]]\nOutput: False... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6182,
"level": 1,
"question": "Given n pairs of integers where each pair represents a start and end time of a meeting, determine if a person can attend all meetings. If a person can attend all meetings, return True, otherwise, return False.\n\nExample 1:\nInput: intervals = [[0, 30]... |
import hashlib
def sha256_hash(s):
if not s:
return None
return hashlib.sha256(s.encode('utf-8')).hexdigest() | simplelr_Filter | [
{
"content": "Question:\nWrite a Python function that takes a string as input and returns the SHA-256 hash of the string. If the input string is empty, the function should return `None`. Use the `hashlib` library to generate the hash. Make sure to import the necessary library at the beginning of the code snippe... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6183,
"level": 1,
"question": "Write a Python function that takes a string as input and returns the SHA-256 hash of the string. If the input string is empty, the function should return `None`. Use the `hashlib` library to generate the hash. Make sure to import the necessary library ... |
def decimal_to_binary(n: int) -> str:
return bin(n)[2:] | simplelr_Algorithm | [
{
"content": "Question:\n### Decimal to Binary Conversion\n\nWrite a function that converts a given non-negative integer to its binary representation in the form of a string.\n\nThe function should be able to handle integers ranging from 0 to 1000, inclusive. The binary representation should exclude any leading... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6184,
"level": 1,
"question": "### Decimal to Binary Conversion\n\nWrite a function that converts a given non-negative integer to its binary representation in the form of a string.\n\nThe function should be able to handle integers ranging from 0 to 1000, inclusive. The binary repres... |
def sum_of_list(numbers):
total = 0
for number in numbers:
total += number
return total | simplelr_Prefill | [
{
"content": "Question:\nCreate a function that calculates the sum of all the numbers in a list. How would you handle the case if the list is empty and what should the return type be?\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6185,
"level": 1,
"question": "Create a function that calculates the sum of all the numbers in a list. How would you handle the case if the list is empty and what should the return type be?",
"split": "train"
} |
def closest_multiple_of_6(n):
r = n % 6
if r == 0:
return n
elif r <= 3:
return n - r
else:
return n + (6 - r) | simplelr_Prefill | [
{
"content": "Question:\nWrite a function to find the multiple of 6 closest to a given integer. If the number is exactly divisible by 6, return the number itself.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6186,
"level": 1,
"question": "Write a function to find the multiple of 6 closest to a given integer. If the number is exactly divisible by 6, return the number itself.",
"split": "train"
} |
def extract_and_sum_digits(s):
sum_total = 0
temp = ''
for char in s:
if char.isdigit():
temp += char
else:
if temp:
sum_total += int(temp)
temp = ''
if temp:
sum_total += int(temp)
return sum_total | simplelr_Leetcode | [
{
"content": "Question:\nYou are given a string `s` representing a string containing segments of alphabetic characters and digits. The task is to extract the integer values embedded within the string and return the sum of all these integer values. If the string does not contain any digits, return `0`. Each segm... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6187,
"level": 1,
"question": "You are given a string `s` representing a string containing segments of alphabetic characters and digits. The task is to extract the integer values embedded within the string and return the sum of all these integer values. If the string does not contai... |
def calculate_factorial_quadratic_time(n):
result = 1
for i in range(1, n + 1):
product = 1
for j in range(1, i + 1):
product *= j
result = product
return result | simplelr_Filter | [
{
"content": "Question:\nCreate a Python function named \"calculate_factorial_quadratic_time\" that takes a positive integer as input and returns the factorial of the number using a quadratic time complexity algorithm.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6188,
"level": 1,
"question": "Create a Python function named \"calculate_factorial_quadratic_time\" that takes a positive integer as input and returns the factorial of the number using a quadratic time complexity algorithm.",
"split": "train"
} |
def multiply_large_numbers(num1: str, num2: str) -> str:
if num1 == "0" or num2 == "0":
return "0"
m = len(num1)
n = len(num2)
product = [0] * (m + n)
for j in range(n):
digit2 = int(num2[-1 - j])
for i in range(m):
digit1 = int(num1[-1 - i])
... | simplelr_Data_Structure | [
{
"content": "Question:\nYou are given two non-negative integers `num1` and `num2` represented as strings. Your task is to write a function `multiply_large_numbers(num1: str, num2: str) -> str` that returns the product of these two numbers as a string.\n\n#### Requirements:\n1. You **must not** use any built-in... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6189,
"level": 1,
"question": "You are given two non-negative integers `num1` and `num2` represented as strings. Your task is to write a function `multiply_large_numbers(num1: str, num2: str) -> str` that returns the product of these two numbers as a string.\n\n#### Requirements:\n1... |
import itertools
def generate_combinations(lst):
result = []
for r in range(0, len(lst) + 1):
if r == 0:
result.append(())
else:
for combo in itertools.combinations(lst, r):
result.append(combo)
return result | simplelr_Filter | [
{
"content": "Question:\nCan you provide a Python function that generates all combinations of a given list of numbers? The function should handle combinations of all possible lengths, from 0 to the length of the list.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6190,
"level": 1,
"question": "Can you provide a Python function that generates all combinations of a given list of numbers? The function should handle combinations of all possible lengths, from 0 to the length of the list.",
"split": "train"
} |
from typing import List
def find_element_in_rotated_array(arr: List[int], target: int) -> int:
low = 0
high = len(arr) - 1
while low <= high:
mid = (low + high) // 2
if arr[mid] == target:
return mid
# Determine if the left half is sorted
if arr[low] <= arr[mi... | simplelr_Data_Structure | [
{
"content": "Question:\n### Question: Modified Binary Search in Rotated Sorted Array\n\n#### Scenario\nYou are given an array of integers sorted in ascending order is rotated at some pivot unknown to you beforehand and a target integer to search for in the array.\n\n#### Task\nWrite a function `find_element_in... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6191,
"level": 1,
"question": "### Question: Modified Binary Search in Rotated Sorted Array\n\n#### Scenario\nYou are given an array of integers sorted in ascending order is rotated at some pivot unknown to you beforehand and a target integer to search for in the array.\n\n#### Task... |
import csv
def memory_efficient_csv_parser(file_path: str, column_name: str) -> float:
with open(file_path, 'r') as csvfile:
reader = csv.reader(csvfile)
headers = next(reader, None)
if headers is None:
return 0.0
try:
col_index = headers.index(column_name)
... | simplelr_Algorithm | [
{
"content": "Question:\n### Memory Efficient CSV Parser\n\nYou are required to implement a memory efficient CSV parser that can handle large CSV files without loading the entire file into memory. Your task is to read a CSV file and compute the average value of a specified column while ensuring memory usage is ... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6192,
"level": 1,
"question": "### Memory Efficient CSV Parser\n\nYou are required to implement a memory efficient CSV parser that can handle large CSV files without loading the entire file into memory. Your task is to read a CSV file and compute the average value of a specified col... |
def first_n_even_numbers(n):
return [2 * i for i in range(n)] | simplelr_Prefill | [
{
"content": "Question:\nCreate a function that returns a list of the first 'n' even numbers starting from 0.\nAnswer:\nLet's think step by step.\n",
"role": "user"
}
] | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6193,
"level": 1,
"question": "Create a function that returns a list of the first 'n' even numbers starting from 0.",
"split": "train"
} |
def is_strong_password(password):
if len(password) < 8:
return False
has_lower = any(c.islower() for c in password)
has_upper = any(c.isupper() for c in password)
has_digit = any(c.isdigit() for c in password)
special_chars = {'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', ... | simplelr_Taco | [
{
"content": "Question:\n*Let's test your ability to identify valid passwords. You are to create a function that checks if a given password is strong based on certain criteria.*\n\nYou will create a method `is_strong_password(password)` that verifies the strength of a password based on the following rules:\n\n-... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6194,
"level": 1,
"question": "*Let's test your ability to identify valid passwords. You are to create a function that checks if a given password is strong based on certain criteria.*\n\nYou will create a method `is_strong_password(password)` that verifies the strength of a password... |
def largestRectangleArea(heights: list[int]) -> int:
stack = []
max_area = 0
n = len(heights)
for i in range(n):
while stack and heights[i] < heights[stack[-1]]:
h = stack.pop()
prev = stack[-1] if stack else -1
width = i - prev - 1
area = hei... | simplelr_Taco | [
{
"content": "Question:\nYou are given a list of non-negative integers representing the heights of bars in a histogram. Write a function that computes the largest rectangle area that can be formed within the bounds of the histogram. Each bar has a width of 1.\n\nFor example, given the histogram [2, 1, 5, 6, 2, ... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6195,
"level": 1,
"question": "You are given a list of non-negative integers representing the heights of bars in a histogram. Write a function that computes the largest rectangle area that can be formed within the bounds of the histogram. Each bar has a width of 1.\n\nFor example, g... |
def next_higher_permutation(nums):
nums = list(nums)
n = len(nums)
pivot = -1
# Step 1: Find the pivot
for i in range(n - 2, -1, -1):
if nums[i] < nums[i + 1]:
pivot = i
break
# Step 2: Handle the case where the entire list is non-increasing
if pivot... | simplelr_Package | [
{
"content": "Question:\nIn this problem, you will implement a function `next_higher_permutation` that finds the next lexicographical permutation of a given list of numbers. This permutation should be the immediate successor of the current sequence in the set of permutations sorted in lexicographical order. If ... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6196,
"level": 1,
"question": "In this problem, you will implement a function `next_higher_permutation` that finds the next lexicographical permutation of a given list of numbers. This permutation should be the immediate successor of the current sequence in the set of permutations s... |
from collections import deque
from typing import List, Tuple
def can_route_packet(edges: List[Tuple[int, int, int]], start: int, end: int, packet_size: int) -> bool:
if start == end:
return True
# Build the adjacency list with edges that can handle the packet size
adj = {}
for u, v, b in e... | simplelr_Algorithm | [
{
"content": "Question:\n### Network Packet Routing\n\n#### Problem Description\nYou are tasked with designing a function to simulate packet routing in a simple network. The network is represented by a list of edges where each edge connects two nodes and has a specific data transfer limit (bandwidth). Your goal... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6197,
"level": 1,
"question": "### Network Packet Routing\n\n#### Problem Description\nYou are tasked with designing a function to simulate packet routing in a simple network. The network is represented by a list of edges where each edge connects two nodes and has a specific data tr... |
import json
import csv
def json_to_csv(json_path, csv_path):
try:
# Open and read the JSON file
with open(json_path, 'r') as json_file:
data = json.load(json_file)
# Open the CSV file for writing
with open(csv_path, 'w', newline='') as csv_file:
writ... | simplelr_Filter | [
{
"content": "Question:\nWrite a Python function that reads a JSON file, extracts specific information, and writes the extracted data into a CSV file. The JSON file contains a list of dictionaries, where each dictionary represents a person's information with keys such as \"name\", \"age\", and \"email\". The fu... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6198,
"level": 1,
"question": "Write a Python function that reads a JSON file, extracts specific information, and writes the extracted data into a CSV file. The JSON file contains a list of dictionaries, where each dictionary represents a person's information with keys such as \"nam... |
def min_operations(X, Y):
m = len(X)
n = len(Y)
# Create a DP table with (m+1) rows and (n+1) columns
dp = [[0] * (n + 1) for _ in range(m + 1)]
# Initialize the first row and first column
for i in range(m + 1):
dp[i][0] = i
for j in range(n + 1):
dp[0][j] = j
#... | simplelr_Apps | [
{
"content": "Question:\nCreate a function that calculates the minimum number of operations required to convert a given string 'X' to another string 'Y'. An operation is defined as either an insertion, deletion, or substitution of a single character. Both strings are case-sensitive and consist only of uppercase... | code | {
"ground_truth": "pass",
"style": "exec"
} | {
"answer": "pass",
"index": 6199,
"level": 1,
"question": "Create a function that calculates the minimum number of operations required to convert a given string 'X' to another string 'Y'. An operation is defined as either an insertion, deletion, or substitution of a single character. Both strings are case-sens... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.