qid
stringlengths
1
3
title
stringlengths
13
51
language
stringclasses
1 value
text
stringlengths
65
1.09k
signature_with_docstring
stringlengths
113
1.24k
signature
stringlengths
17
123
arguments
list
source
stringlengths
38
1.51k
question_info
dict
305
TP3/graphs.GraphIsomorphism
C++
Verifies that the inputs satisfy the problem: You are given two graphs which are permutations of one another and the goal is to find the permutation. Each graph is specified by vector of edges where each edge is a pair of integer vertex numbers.
/** * Verifies that the inputs satisfy the problem: * You are given two graphs which are permutations of one another and the goal is to find the permutation. * Each graph is specified by vector of edges where each edge is a pair of integer vertex numbers. */ bool sat(vector<int> bi, vector<vector<int>> g1, vector<v...
bool sat(vector<int> bi, vector<vector<int>> g1, vector<vector<int>> g2) {
[ "bi", "g1", "g2" ]
def sat(bi: List[int], g1, g2): return len(bi) == len(set(bi)) and {(i, j) for (i, j) in g1} == {(bi[i], bi[j]) for (i, j) in g2}
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"bi\": [0, 2, 3, 4, 1, 5], \"g1\": [[0, 1], [1, 2], [2, 3], [3, 4], [2, 5]], \"g2\": [[0, 4], [1, 5], [4, 1], [1, 2], [2, 3]]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"bi\": [5, 6, 2, 7, 4, 1, 0, 3], \"g1\": [[0, 1], [0, 7], [1, 1], [2, 0], [2, 3]...
306
TP3/graphs.ShortIntegerPath
C++
Verifies that the inputs satisfy the problem: Find vector of nine integers, starting with 0 and ending with 128, such that each integer either differs from the previous one by one or is thrice the previous one.
/** * Verifies that the inputs satisfy the problem: * Find vector of nine integers, starting with 0 and ending with 128, such that each integer either differs from * the previous one by one or is thrice the previous one. */ bool sat(vector<int> li) {
bool sat(vector<int> li) {
[ "li" ]
def sat(li: List[int]): return all((j in {i - 1, i + 1, 3 * i} for (i, j) in zip([0] + li, li + [128]))) and len(li) == 9
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [1, 3, 4, 12, 13, 14, 42, 126, 127]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"li\": []}}]", "extension": "cpp", "entry_fn_name": "sat", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\...
307
TP3/ICPC.BiPermutations
C++
Verifies that the inputs satisfy the problem: There are two rows of objects. Given the length-n integer vectors of prices and heights of objects in each row, find a permutation of both rows so that the permuted prices are non-decreasing in each row and so that the first row is taller than the second row.
/** * Verifies that the inputs satisfy the problem: * There are two rows of objects. Given the length-n integer vectors of prices and heights of objects in each * row, find a permutation of both rows so that the permuted prices are non-decreasing in each row and * so that the first row is taller than the second row...
bool sat(vector<vector<int>> perms, vector<int> prices0, vector<int> prices1, vector<int> heights0, vector<int> heights1) {
[ "perms", "prices0", "prices1", "heights0", "heights1" ]
def sat(perms: List[List[int]], prices0, prices1, heights0, heights1): n = len(prices0) (perm0, perm1) = perms if not sorted(perm0) == sorted(perm1) == list(range(n)): return False for i in range(n - 1): if not prices0[perm0[i]] <= prices0[perm0[i + 1]]: return False ...
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"perms\": [[6, 7, 4, 3, 0, 1, 5, 2], [6, 7, 4, 3, 0, 1, 5, 2]], \"prices0\": [7, 7, 9, 5, 3, 7, 1, 2], \"prices1\": [5, 5, 5, 4, 2, 5, 1, 1], \"heights0\": [2, 4, 9, 3, 8, 5, 5, 4], \"heights1\": [1, 3, 8, 1, 5, 4, 4, 2]}}, {\"idx\": 1, \"outputs\": true,...
308
TP3/ICPC.OptimalBridges
C++
Verifies that the inputs satisfy the problem: You are to choose locations for bridge bases from among a given set of mountain peaks located at `xs, ys`, where `xs` and `ys` are vectors of n integers of the same length. Your answer should be a sorted list of indices starting at 0 and ending at n-1. The goal is to minimi...
/** * Verifies that the inputs satisfy the problem: * You are to choose locations for bridge bases from among a given set of mountain peaks located at * `xs, ys`, where `xs` and `ys` are vectors of n integers of the same length. Your answer should be a sorted * list of indices starting at 0 and ending at n-1. The g...
bool sat(vector<int> indices, int h, int alpha, int beta, vector<int> xs, vector<int> ys, long long thresh) {
[ "indices", "h", "alpha", "beta", "xs", "ys", "thresh" ]
def sat(indices: List[int], h, alpha, beta, xs, ys, thresh): if not sorted({0, len(xs) - 1, *indices}) == indices: return False cost = alpha * (h - ys[0]) for (i, j) in zip(indices, indices[1:]): (a, b, r) = (xs[i], xs[j], (xs[j] - xs[i]) / 2) if not max(ys[i], ys[j]) + r <= h: ...
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"indices\": [0, 2, 6, 7, 8, 10], \"h\": 60, \"alpha\": 18, \"beta\": 2, \"xs\": [0, 10, 20, 30, 50, 80, 100, 120, 160, 190, 200], \"ys\": [0, 30, 10, 30, 50, 40, 10, 20, 20, 55, 10], \"thresh\": 26020}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"indi...
309
TP3/ICPC.CheckersPosition
C++
Verifies that the inputs satisfy the problem: You are given a partial transcript a checkers game. Find an initial position such that the transcript would be a legal set of moves. The board positions are [x, y] pairs with 0 <= x, y < 8 and x + y even. There are two players which we call -1 and 1 for convenience, and pla...
/** * Verifies that the inputs satisfy the problem: * You are given a partial transcript a checkers game. Find an initial position such that the transcript * would be a legal set of moves. The board positions are [x, y] pairs with 0 <= x, y < 8 and x + y even. * There are two players which we call -1 and 1 for conv...
bool sat(vector<vector<int>> position, vector<vector<vector<int>>> transcript) {
[ "position", "transcript" ]
def sat(position: List[List[int]], transcript): board = {(x, y): 0 for x in range(8) for y in range(8) if (x + y) % 2 == 0} for (x, y, p) in position: if not (-2 <= p <= 2 and board[x, y] == 0): return False board[x, y] = p def has_a_jump(x, y): p = board[x, y] d...
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"position\": [[0, 0, 0], [0, 2, 0], [0, 4, 0], [0, 6, 0], [1, 1, 0], [1, 3, 0], [1, 5, 0], [1, 7, 0], [2, 0, 0], [2, 2, 0], [2, 4, 0], [2, 6, 0], [3, 1, 0], [3, 3, 1], [3, 5, 0], [3, 7, 0], [4, 0, 0], [4, 2, 0], [4, 4, -1], [4, 6, -1], [5, 1, 0], [5, 3, -...
310
TP3/ICPC.MatchingMarkers
C++
Verifies that the inputs satisfy the problem: The input is a string of start and end markers "aaBAcGeg" where upper-case characters indicate start markers and lower-case characters indicate ending markers. The string indicates a ring (joined at the ends) and the goal is to find a location to split the ring so that ther...
/** * Verifies that the inputs satisfy the problem: * The input is a string of start and end markers "aaBAcGeg" where upper-case characters indicate start markers * and lower-case characters indicate ending markers. The string indicates a ring (joined at the ends) and the goal is * to find a location to split the r...
bool sat(int cut_position, string ring, int lower) {
[ "cut_position", "ring", "lower" ]
def sat(cut_position: int, ring, lower): line = ring[cut_position:] + ring[:cut_position] matches = {c: 0 for c in line.lower()} for c in line: if c.islower(): matches[c] -= 1 if matches[c] > 0 else len(line) else: matches[c.lower()] += 1 return sum((i == 0 for i ...
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"cut_position\": 4, \"ring\": \"yRrsmOkLCHSDJywpVDEDsjgCwSUmtvHMefxxPFdmBIpM\", \"lower\": 5}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"cut_position\": 0, \"ring\": \"MvI\", \"lower\": 0}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"cut_positio...
311
TP3/IMO.ExponentialCoinMoves
C++
Verifies that the inputs satisfy the problem: There are five boxes each having one coin initially. Two types of moves are allowed: * (advance) remove `k > 0` coins from box `i` and add `2k` coins to box `i + 1` * (swap) remove a coin from box `i` and swap the contents of boxes `i+1` and `i+2` Given `0 <= n <= 16385`, f...
/** * Verifies that the inputs satisfy the problem: * There are five boxes each having one coin initially. Two types of moves are allowed: * * (advance) remove `k > 0` coins from box `i` and add `2k` coins to box `i + 1` * * (swap) remove a coin from box `i` and swap the contents of boxes `i+1` and `i+2` * Given `...
bool sat(vector<vector<int>> states, int n) {
[ "states", "n" ]
def sat(states: List[List[int]], n): if not (states[0] == [1] * 5 and all((len(li) == 5 for li in states)) and all((i >= 0 for li in states for i in li))): return False for (prev, cur) in zip(states, states[1:]): for i in range(5): if cur[i] != prev[i]: break ...
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"states\": [[1, 1, 1, 1, 1], [0, 3, 1, 1, 1], [0, 2, 3, 1, 1], [0, 2, 2, 3, 1], [0, 2, 2, 0, 7], [0, 2, 1, 7, 0], [0, 2, 1, 0, 14], [0, 2, 0, 14, 0], [0, 1, 14, 0, 0], [0, 1, 13, 2, 0], [0, 1, 13, 0, 4], [0, 1, 12, 4, 0], [0, 1, 12, 0, 8], [0, 1, 11, 8, 0...
312
TP3/IMO.NoRelativePrimes
C++
Verifies that the inputs satisfy the problem: Let P(n) = n^2 + n + 1. Given b>=6 and m>=1, find m non-negative integers for which the set {P(a+1), P(a+2), ..., P(a+b)} has the property that there is no element that is relatively prime to every other element. Sample input: b = 6 m = 2 Sample output: [195, 196]
/** * Verifies that the inputs satisfy the problem: * Let P(n) = n^2 + n + 1. * Given b>=6 and m>=1, find m non-negative integers for which the set {P(a+1), P(a+2), ..., P(a+b)} has * the property that there is no element that is relatively prime to every other element. * Sample input: * b = 6 * m = 2 * Sample ...
bool sat(vector<int> nums, int b, int m) {
[ "nums", "b", "m" ]
def sat(nums: List[int], b, m): if not (len(nums) == len(set(nums)) == m and min(nums) >= 0): return False def gcd(i, j): (r, s) = (max(i, j), min(i, j)) while s >= 1: (r, s) = (s, r % s) return r for a in nums: nums = [(a + i + 1) ** 2 + (a + i + 1) + 1 ...
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"nums\": [195, 594, 993, 1392, 1791, 2190], \"b\": 7, \"m\": 6}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"nums\": [195, 594, 993, 1392, 1791, 2190, 2589, 2988, 3387, 3786, 4185, 4584, 4983, 5382, 5781, 6180, 6579, 6978, 7377, 7776, 8175, 8574, 8973...
313
TP3/IMO.PickNearNeighbors
C++
Verifies that the inputs satisfy the problem: Given a permutation of the integers up to n(n+1) as vector, choose 2n numbers to keep (in the same order) so that the remaining vector of numbers satisfies: * its largest number is next to its second largest number * its third largest number is next to its fourth largest nu...
/** * Verifies that the inputs satisfy the problem: * Given a permutation of the integers up to n(n+1) as vector, choose 2n numbers to keep (in the same order) * so that the remaining vector of numbers satisfies: * * its largest number is next to its second largest number * * its third largest number is next to it...
bool sat(vector<bool> keep, vector<int> heights) {
[ "keep", "heights" ]
def sat(keep: List[bool], heights): n = int(len(heights) ** 0.5) if not sorted(heights) == list(range(n * n + n)): return False kept = [i for (i, k) in zip(heights, keep) if k] if not len(kept) == 2 * n: return False pi = sorted(range(2 * n), key=lambda i: kept[i]) return all((ab...
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"keep\": [true, false, true, false, false, true, true, false, false, true, false, true, true, false, true, false, false, false, false, false], \"heights\": [10, 2, 14, 1, 8, 19, 16, 6, 12, 3, 17, 0, 9, 18, 5, 7, 11, 13, 15, 4]}}, {\"idx\": 1, \"outputs\":...
314
TP3/IMO.FindProductiveList
C++
Verifies that the inputs satisfy the problem: Given n, find n integers such that li[i] * li[i+1] + 1 == li[i+2], for i = 0, 1, ..., n-1 where indices >= n "wrap around". Note: only n multiples of 3 are given since this is only possible for n that are multiples of 3 (as proven in the IMO problem). Sample input: 6 Sample...
/** * Verifies that the inputs satisfy the problem: * Given n, find n integers such that li[i] * li[i+1] + 1 == li[i+2], for i = 0, 1, ..., n-1 * where indices >= n "wrap around". Note: only n multiples of 3 are given since this is only possible for n * that are multiples of 3 (as proven in the IMO problem). * Sam...
bool sat(vector<int> li, int n) {
[ "li", "n" ]
def sat(li: List[int], n): if not n % 3 == 0: return False return len(li) == n and all((li[(i + 2) % n] == 1 + li[(i + 1) % n] * li[i] for i in range(n)))
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [-1, -1, 2, -1, -1, 2, -1, -1, 2, -1, -1, 2, -1, -1, 2, -1, -1, 2], \"n\": 18}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"li\": [-1, -1, 2], \"n\": 3}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"li\": [-1, -1, 2, -1, -1, 2], \"n\": 6}}, ...
315
TP3/IMO.HalfTag
C++
Verifies that the inputs satisfy the problem: The input tags is vector of 4n integer tags each in range(n) with each tag occurring 4 times. The goal is to find a subset (list) li of half the indices such that: * The sum of the indices equals the sum of the sum of the missing indices. * The tags of the chosen indices co...
/** * Verifies that the inputs satisfy the problem: * The input tags is vector of 4n integer tags each in range(n) with each tag occurring 4 times. * The goal is to find a subset (list) li of half the indices such that: * * The sum of the indices equals the sum of the sum of the missing indices. * * The tags of th...
bool sat(vector<int> li, vector<int> tags) {
[ "li", "tags" ]
def sat(li: List[int], tags): n = max(tags) + 1 if not sorted(tags) == sorted(list(range(n)) * 4): return False if not (len(li) == len(set(li)) and min(li) >= 0): return False return sum(li) * 2 == sum(range(4 * n)) and sorted([tags[i] for i in li]) == [i // 2 for i in range(2 * n)]
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [8, 7, 2, 13, 12, 3, 14, 1], \"tags\": [3, 0, 3, 2, 0, 1, 0, 3, 1, 1, 2, 2, 0, 2, 1, 3]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"li\": [11, 4, 8, 7, 3, 12, 14, 1], \"tags\": [2, 3, 1, 0, 3, 3, 0, 2, 1, 3, 1, 0, 1, 2, 2, 0]}}, {\"idx\": 2, ...
316
TP3/lattices.LearnParity
C++
Verifies that the inputs satisfy the problem: Parity learning: Given binary vectors in a subspace, find the secret set S of indices such that: $\\sum_{i \in S} x_i = 1 (mod 2)$
/** * Verifies that the inputs satisfy the problem: * Parity learning: Given binary vectors in a subspace, find the secret set S of indices such that: * $\\\\sum_{i \\in S} x_i = 1 (mod 2)$ */ bool sat(vector<int> inds, vector<long long> vecs) {
bool sat(vector<int> inds, vector<long long> vecs) {
[ "inds", "vecs" ]
def sat(inds: List[int], vecs): return all((sum((v >> i & 1 for i in inds)) % 2 == 1 for v in vecs))
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"inds\": [0, 2, 5, 6, 7, 8], \"vecs\": [169, 203, 409, 50, 37, 479, 370, 133, 53, 159, 161, 367, 474, 107, 82, 447, 385]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"inds\": [0, 1, 3, 5, 7, 9, 11, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 35, 39, 4...
317
TP3/lattices.LearnParityWithNoise
C++
Verifies that the inputs satisfy the problem: Learning parity with noise: Given binary vectors, find the secret set $S$ of indices such that, for at least 3\/4 of the vectors, $$sum_{i \in S} x_i = 1 (mod 2)$$
/** * Verifies that the inputs satisfy the problem: * Learning parity with noise: Given binary vectors, find the secret set $S$ of indices such that, for at least * 3\\/4 of the vectors, $$sum_{i \\in S} x_i = 1 (mod 2)$$ */ bool sat(vector<int> inds, vector<int> vecs) {
bool sat(vector<int> inds, vector<int> vecs) {
[ "inds", "vecs" ]
def sat(inds: List[int], vecs): return sum((sum((v >> i & 1 for i in inds)) % 2 for v in vecs)) >= len(vecs) * 3 / 4
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"inds\": [2, 4, 5], \"vecs\": [26, 5, 32, 3, 15, 18, 31, 13, 24, 25, 34, 5, 15, 24, 16, 13, 0, 27, 37]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"inds\": [2, 4, 6, 9], \"vecs\": [576, 823, 480, 899, 652, 1017, 830, 125, 627, 889, 312, 663, 232, 856...
318
TP3/number_theory.GCD
C++
Verifies that the inputs satisfy the problem: Find a large common divisor of two integers.
/** * Verifies that the inputs satisfy the problem: * Find a large common divisor of two integers. */ bool sat(long long n, long long a, long long b, long long lower_bound) {
bool sat(long long n, long long a, long long b, long long lower_bound) {
[ "n", "a", "b", "lower_bound" ]
def sat(n: int, a, b, lower_bound): return a % n == 0 and b % n == 0 and (n >= lower_bound)
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 7741, \"a\": 15482, \"b\": 23223, \"lower_bound\": 5}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 9, \"a\": 9, \"b\": 9, \"lower_bound\": 6}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": 46522, \"a\": 232610, \"b\": 3131721474, \"l...
319
TP3/number_theory.GCD_multi
C++
Verifies that the inputs satisfy the problem: Find a large common divisor of the vector of integers.
/** * Verifies that the inputs satisfy the problem: * Find a large common divisor of the vector of integers. */ bool sat(int n, vector<long long> nums, int lower_bound) {
bool sat(int n, vector<long long> nums, int lower_bound) {
[ "n", "nums", "lower_bound" ]
def sat(n: int, nums, lower_bound): return all((i % n == 0 for i in nums)) and n >= lower_bound
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 7741, \"nums\": [77410, 23223, 54187], \"lower_bound\": 2}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 1, \"nums\": [14, 551755893, 902110495], \"lower_bound\": 1}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": 295717, \"nums\": [28...
320
TP3/number_theory.LCM
C++
Verifies that the inputs satisfy the problem: Find a small common multiple of two integers.
/** * Verifies that the inputs satisfy the problem: * Find a small common multiple of two integers. */ bool sat(long long n, long long a, long long b, long long upper_bound) {
bool sat(long long n, long long a, long long b, long long upper_bound) {
[ "n", "a", "b", "upper_bound" ]
def sat(n: int, a, b, upper_bound): return n % a == 0 and n % b == 0 and (0 < n <= upper_bound)
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 135, \"a\": 15, \"b\": 27, \"upper_bound\": 150}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 41234205765, \"a\": 41234205765, \"b\": 597597185, \"upper_bound\": 73349253728}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": 29053127312...
321
TP3/number_theory.LCM_multi
C++
Verifies that the inputs satisfy the problem: Find a small common multiple of vector of integers.
/** * Verifies that the inputs satisfy the problem: * Find a small common multiple of vector of integers. */ bool sat(long long n, vector<int> nums, long long upper_bound) {
bool sat(long long n, vector<int> nums, long long upper_bound) {
[ "n", "nums", "upper_bound" ]
def sat(n: int, nums, upper_bound): return all((n % i == 0 for i in nums)) and 0 < n <= upper_bound
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 4590, \"nums\": [15, 27, 102], \"upper_bound\": 5000}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 765022320, \"nums\": [2760, 1104, 16008, 44712, 32568], \"upper_bound\": 1287804786}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": 96...
322
TP3/number_theory.SmallExponentBigSolution
C++
Verifies that the inputs satisfy the problem: Solve for n: b^n = target (mod n)
/** * Verifies that the inputs satisfy the problem: * Solve for n: b^n = target (mod n) */ bool sat(int n, int b, int target) {
bool sat(int n, int b, int target) {
[ "n", "b", "target" ]
def sat(n: int, b, target): return b ** n % n == target
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 19147, \"b\": 2, \"target\": 5}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 67, \"b\": 69, \"target\": 2}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"n\": 67, \"b\": 69, \"target\": 5}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {...
323
TP3/number_theory.ThreeCubes
C++
Verifies that the inputs satisfy the problem: Given n, find integers a, b, c such that a^3 + b^3 + c^3 = n.
/** * Verifies that the inputs satisfy the problem: * Given n, find integers a, b, c such that a^3 + b^3 + c^3 = n. */ bool sat(vector<int> nums, int target) {
bool sat(vector<int> nums, int target) {
[ "nums", "target" ]
def sat(nums: List[int], target): if not target % 9 not in [4, 5]: return False return len(nums) == 3 and sum([i ** 3 for i in nums]) == target
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"nums\": [18, 4, -17], \"target\": 983}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"nums\": [], \"target\": 983}}]", "extension": "cpp", "entry_fn_name": "sat", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#incl...
324
TP3/number_theory.FourSquares
C++
Verifies that the inputs satisfy the problem: Find four integers whose squares sum to n
/** * Verifies that the inputs satisfy the problem: * Find four integers whose squares sum to n */ bool sat(vector<int> nums, int n) {
bool sat(vector<int> nums, int n) {
[ "nums", "n" ]
def sat(nums: List[int], n): return len(nums) <= 4 and sum((i ** 2 for i in nums)) == n
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"nums\": [80, 77, 4, 0], \"n\": 12345}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"nums\": [1, 0, 0, 0], \"n\": 1}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"nums\": [0, 0, 0, 0], \"n\": 0}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"nums...
325
TP3/number_theory.Factoring
C++
Verifies that the inputs satisfy the problem: Find a non-trivial factor of integer n
/** * Verifies that the inputs satisfy the problem: * Find a non-trivial factor of integer n */ bool sat(int i, int n) {
bool sat(int i, int n) {
[ "i", "n" ]
def sat(i: int, n): return 1 < i < n and n % i == 0
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"i\": 14543, \"n\": 241864633}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"i\": 2, \"n\": 16}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"i\": 3, \"n\": 3363}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"i\": 3, \"n\": 241864633}}, {\"idx\"...
326
TP3/number_theory.DiscreteLog
C++
Verifies that the inputs satisfy the problem: Find n such that g^n is congruent to t mod n
/** * Verifies that the inputs satisfy the problem: * Find n such that g^n is congruent to t mod n */ bool sat(int n, int g, int p, int t) {
bool sat(int n, int g, int p, int t) {
[ "n", "g", "p", "t" ]
def sat(n: int, g, p, t): return pow(g, n, p) == t
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 66957, \"g\": 44337, \"p\": 69337, \"t\": 38187}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 0, \"g\": 13, \"p\": 21, \"t\": 1}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"n\": 66957, \"g\": 13, \"p\": 21, \"t\": 38187}}, {\"idx\": 3...
327
TP3/number_theory.Znam
C++
Verifies that the inputs satisfy the problem: Find k positive integers such that each integer divides (the product of the rest plus 1).
/** * Verifies that the inputs satisfy the problem: * Find k positive integers such that each integer divides (the product of the rest plus 1). */ bool sat(vector<long long> li, int k) {
bool sat(vector<long long> li, int k) {
[ "li", "k" ]
def sat(li: List[int], k): def prod(nums): ans = 1 for i in nums: ans *= i return ans return min(li) > 1 and len(li) == k and all(((1 + prod(li[:i] + li[i + 1:])) % li[i] == 0 for i in range(k)))
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [2, 3, 7, 43, 1807], \"k\": 5}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"li\": [2, 3, 7, 43, 1807, 3263443], \"k\": 6}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"li\": [2, 3, 7, 43, 1807, 3263443, 10650056950807], \"k\": 7}}, {\"idx\":...
328
TP3/number_theory.CollatzDelay
C++
Verifies that the inputs satisfy the problem: Consider the following process. Start with an integer `n` and repeatedly applying the operation: * if n is even, divide n by 2, * if n is odd, multiply n by 3 and add 1 Find `0 < n < upper` so that it takes exactly `t` steps to reach 1.
/** * Verifies that the inputs satisfy the problem: * Consider the following process. Start with an integer `n` and repeatedly applying the operation: * * if n is even, divide n by 2, * * if n is odd, multiply n by 3 and add 1 * Find `0 < n < upper` so that it takes exactly `t` steps to reach 1. */ bool sat(int n...
bool sat(int n, int t, int upper) {
[ "n", "t", "upper" ]
def sat(n: int, t, upper): m = n for i in range(t): if n <= 1: return False n = 3 * n + 1 if n % 2 else n // 2 return n == 1 and m <= 2 ** upper
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 57048, \"t\": 197, \"upper\": 20}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"n\": 10, \"t\": 3, \"upper\": 4}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"n\": -1, \"t\": 10, \"upper\": 10}}]", "extension": "cpp", "entry_fn_name": "s...
329
TP3/number_theory.Lehmer
C++
Verifies that the inputs satisfy the problem: Find n such that 2^n mod n = 3
/** * Verifies that the inputs satisfy the problem: * Find n such that 2^n mod n = 3 */ bool sat(long long n) {
bool sat(long long n) {
[ "n" ]
def sat(n: int): return pow(2, n, n) == 3
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 4700063497}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"n\": 3}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"n\": 8}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"n\": 1}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"n\": 4}}]", ...
330
TP3/probability.BirthdayParadox
C++
Verifies that the inputs satisfy the problem: Find n such that the probability of two people having the same birthday in a group of n is near 1\/2.
/** * Verifies that the inputs satisfy the problem: * Find n such that the probability of two people having the same birthday in a group of n is near 1\\/2. */ bool sat(int n, int year_len) {
bool sat(int n, int year_len) {
[ "n", "year_len" ]
def sat(n: int, year_len): prob = 1.0 for i in range(n): prob *= (year_len - i) / year_len return (prob - 0.5) ** 2 <= 1 / year_len
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 23, \"year_len\": 365}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 289, \"year_len\": 60182}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": 2, \"year_len\": 2}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"n\": 2, \"year_len\": 3...
331
TP3/probability.BallotProblem
C++
Verifies that the inputs satisfy the problem: Suppose vector of m 1's and n -1's are permuted at random. What is the probability that all of the cumulative sums are positive? The goal is to find counts = [m, n] that make the probability of the ballot problem close to target_prob.
/** * Verifies that the inputs satisfy the problem: * Suppose vector of m 1's and n -1's are permuted at random. * What is the probability that all of the cumulative sums are positive? * The goal is to find counts = [m, n] that make the probability of the ballot problem close to target_prob. */ bool sat(vector<int...
bool sat(vector<int> counts, double target_prob) {
[ "counts", "target_prob" ]
def sat(counts: List[int], target_prob): (m, n) = counts probs = [1.0] + [0.0] * n for i in range(2, m + 1): old_probs = probs probs = [1.0] + [0.0] * n for j in range(1, min(n + 1, i)): probs[j] = j / (i + j) * probs[j - 1] + i / (i + j) * old_probs[j] return abs(pro...
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"counts\": [3, 1], \"target_prob\": 0.5}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"counts\": [79, 55], \"target_prob\": 0.1791044776119403}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"counts\": [33, 31], \"target_prob\": 0.03125}}, {\"idx\": 3...
332
TP3/probability.BinomialProbabilities
C++
Verifies that the inputs satisfy the problem: Find counts = [a, b] so that the probability of a H's and b T's among a + b coin flips is ~ target_prob.
/** * Verifies that the inputs satisfy the problem: * Find counts = [a, b] so that the probability of a H's and b T's among a + b coin flips is ~ target_prob. */ bool sat(vector<int> counts, double p, double target_prob) {
bool sat(vector<int> counts, double p, double target_prob) {
[ "counts", "p", "target_prob" ]
def sat(counts: List[int], p, target_prob): from itertools import product (a, b) = counts n = a + b prob = p ** a * (1 - p) ** b tot = sum([prob for sample in product([0, 1], repeat=n) if sum(sample) == a]) return abs(tot - target_prob) < 1e-06
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"counts\": [0, 4], \"p\": 0.5, \"target_prob\": 0.0625}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"counts\": [2, 1], \"p\": 0.7588822808660473, \"target_prob\": 0.41658075878732215}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"counts\": [1, 5], ...
333
TP3/probability.ExponentialProbability
C++
Verifies that the inputs satisfy the problem: Find p_stop so that the probability of stopping in steps or fewer time steps is the given target_prob if you stop each step with probability p_stop
/** * Verifies that the inputs satisfy the problem: * Find p_stop so that the probability of stopping in steps or fewer time steps is the given target_prob if you * stop each step with probability p_stop */ bool sat(double p_stop, int steps, double target_prob) {
bool sat(double p_stop, int steps, double target_prob) {
[ "p_stop", "steps", "target_prob" ]
def sat(p_stop: float, steps, target_prob): prob = sum((p_stop * (1 - p_stop) ** t for t in range(steps))) return abs(prob - target_prob) < 1e-06
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"p_stop\": 0.12944943670387588, \"steps\": 5, \"target_prob\": 0.5}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"p_stop\": 0.09801027331497669, \"steps\": 3, \"target_prob\": 0.2661542669448821}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"p_stop\...
334
TP3/trivial_inverse.BackWorlds
C++
Verifies that the inputs satisfy the problem: Find a string that when reversed and concatenated onto 'world' gives 'Hello world'.
/** * Verifies that the inputs satisfy the problem: * Find a string that when reversed and concatenated onto 'world' gives 'Hello world'. */ bool sat(string s) {
bool sat(string s) {
[ "s" ]
def sat(s: str): return s[::-1] + 'world' == 'Hello world'
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \" olleH\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"s\": \"\"}}]", "extension": "cpp", "entry_fn_name": "sat", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include...
335
TP3/trivial_inverse.StrAdd
C++
Verifies that the inputs satisfy the problem: Solve simple string addition problem.
/** * Verifies that the inputs satisfy the problem: * Solve simple string addition problem. */ bool sat(string st, string a, string b) {
bool sat(string st, string a, string b) {
[ "st", "a", "b" ]
def sat(st: str, a, b): return st + a == b
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"st\": \"Hello \", \"a\": \"world\", \"b\": \"Hello world\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"st\": \"cerofilimyba\", \"a\": \"zine\", \"b\": \"cerofilimybazine\"}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"st\": \"xak\", \"a\": \"id...
336
TP3/trivial_inverse.StrSetLen
C++
Verifies that the inputs satisfy the problem: Find a string with dups duplicate chars
/** * Verifies that the inputs satisfy the problem: * Find a string with dups duplicate chars */ bool sat(string s, int dups) {
bool sat(string s, int dups) {
[ "s", "dups" ]
def sat(s: str, dups): return len(set(s)) == len(s) - dups
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
337
TP3/trivial_inverse.StrMul
C++
Verifies that the inputs satisfy the problem: Find a string which when repeated n times gives target
/** * Verifies that the inputs satisfy the problem: * Find a string which when repeated n times gives target */ bool sat(string s, string target, int n) {
bool sat(string s, string target, int n) {
[ "s", "target", "n" ]
def sat(s: str, target, n): return s * n == target
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"foofoo\", \"target\": \"foofoofoofoo\", \"n\": 2}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"s\": \"biquacagegichisyk\", \"target\": \"biquacagegichisykbiquacagegichisykbiquacagegichisyk\", \"n\": 3}}, {\"idx\": 2, \"outputs\": true, \"input...
338
TP3/trivial_inverse.StrMul2
C++
Verifies that the inputs satisfy the problem: Find n such that s repeated n times gives target
/** * Verifies that the inputs satisfy the problem: * Find n such that s repeated n times gives target */ bool sat(int n, string target, string s) {
bool sat(int n, string target, string s) {
[ "n", "target", "s" ]
def sat(n: int, target, s): return s * n == target
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 2, \"target\": \"foofoofoofoo\", \"s\": \"foofoo\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 0, \"target\": \"\", \"s\": \"jan\"}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": 7, \"target\": \"koquuwibehyckoquuwibehyckoquuwibehy...
339
TP3/trivial_inverse.StrLen
C++
Verifies that the inputs satisfy the problem: Find a string of length n
/** * Verifies that the inputs satisfy the problem: * Find a string of length n */ bool sat(string s, int n) {
bool sat(string s, int n) {
[ "s", "n" ]
def sat(s: str, n): return len(s) == n
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
340
TP3/trivial_inverse.StrAt
C++
Verifies that the inputs satisfy the problem: Find the index of target in string s
/** * Verifies that the inputs satisfy the problem: * Find the index of target in string s */ bool sat(int i, string s, string target) {
bool sat(int i, string s, string target) {
[ "i", "s", "target" ]
def sat(i: int, s, target): return s[i] == target
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"i\": 1, \"s\": \"cat\", \"target\": \"a\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"i\": 2, \"s\": \"quadyquady\", \"target\": \"a\"}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"i\": 2, \"s\": \"quixatextofazejate\", \"target\": \"i\"}}, {\"...
341
TP3/trivial_inverse.StrNegAt
C++
Verifies that the inputs satisfy the problem: Find the index of target in s using a negative index.
/** * Verifies that the inputs satisfy the problem: * Find the index of target in s using a negative index. */ bool sat(int i, string s, char target) {
bool sat(int i, string s, char target) {
[ "i", "s", "target" ]
def sat(i: int, s, target): return s[i] == target and i < 0
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"i\": -2, \"s\": \"cat\", \"target\": \"a\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"i\": -2, \"s\": \"ch\", \"target\": \"c\"}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"i\": -17, \"s\": \"nydivimocuvacetext\", \"target\": \"y\"}}, {\"idx\...
342
TP3/trivial_inverse.StrSlice
C++
Verifies that the inputs satisfy the problem: Find the three slice indices that give the specific target in string s
/** * Verifies that the inputs satisfy the problem: * Find the three slice indices that give the specific target in string s */ bool sat(vector<int> inds, string s, string target) {
bool sat(vector<int> inds, string s, string target) {
[ "inds", "s", "target" ]
def sat(inds: List[int], s, target): (i, j, k) = inds return s[i:j:k] == target
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"inds\": [-1, -12, -6], \"s\": \"hello world\", \"target\": \"do\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"inds\": [-23, -23, -23], \"s\": \"ninykofiwimninykofiwim\", \"target\": \"\"}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"inds\": [-1...
343
TP3/trivial_inverse.StrIndex
C++
Verifies that the inputs satisfy the problem: Find a string whose *first* index in big_str is index
/** * Verifies that the inputs satisfy the problem: * Find a string whose *first* index in big_str is index */ bool sat(string s, string big_str, int index) {
bool sat(string s, string big_str, int index) {
[ "s", "big_str", "index" ]
def sat(s: str, big_str, index): return big_str.index(s) == index
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"obar\", \"big_str\": \"foobar\", \"index\": 2}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"s\": \"xtuj\", \"big_str\": \"fukulagatextuj\", \"index\": 10}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"s\": \"nopyrewithocukopojot\", \"big_st...
344
TP3/trivial_inverse.StrIndex2
C++
Verifies that the inputs satisfy the problem: Find a string whose *first* index of sub_str is index
/** * Verifies that the inputs satisfy the problem: * Find a string whose *first* index of sub_str is index */ bool sat(string big_str, string sub_str, int index) {
bool sat(string big_str, string sub_str, int index) {
[ "big_str", "sub_str", "index" ]
def sat(big_str: str, sub_str, index): return big_str.index(sub_str) == index
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"big_str\": \"AAfoobar\", \"sub_str\": \"foobar\", \"index\": 2}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"big_str\": \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAquadox\", \"sub_str\": \"quadox\", \"index\": 75}}, {...
345
TP3/trivial_inverse.StrIn
C++
Verifies that the inputs satisfy the problem: Find a string of length length that is in both strings a and b
/** * Verifies that the inputs satisfy the problem: * Find a string of length length that is in both strings a and b */ bool sat(string s, string a, string b, int length_arg3) {
bool sat(string s, string a, string b, int length_arg3) {
[ "s", "a", "b", "length_arg3" ]
def sat(s: str, a, b, length_arg3): return len(s) == length_arg3 and s in a and (s in b)
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"ello\", \"a\": \"hello\", \"b\": \"yellow\", \"length_arg3\": 4}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"s\": \"wejegutheme\", \"a\": \"vuzogaguzechicowejeguthemeralic\", \"b\": \"kybyjifidoquifwejeguthemelihitextodeju\", \"length_arg3\":...
346
TP3/trivial_inverse.StrIn2
C++
Verifies that the inputs satisfy the problem: Find vector of >= count distinct strings that are all contained in s
/** * Verifies that the inputs satisfy the problem: * Find vector of >= count distinct strings that are all contained in s */ bool sat(vector<string> substrings, string s, int count) {
bool sat(vector<string> substrings, string s, int count) {
[ "substrings", "s", "count" ]
def sat(substrings: List[str], s, count): return len(substrings) == len(set(substrings)) >= count and all((sub in s for sub in substrings))
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"substrings\": [\"\", \"e\", \"el\", \"ell\", \"ello\", \"h\", \"he\", \"hel\", \"hell\", \"hello\", \"l\", \"ll\", \"llo\", \"lo\", \"o\"], \"s\": \"hello\", \"count\": 15}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"substrings\": [\"\", \"a\", \"ag...
347
TP3/trivial_inverse.StrCount
C++
Verifies that the inputs satisfy the problem: Find a string with a certain number of copies of a given substring and of a given length
/** * Verifies that the inputs satisfy the problem: * Find a string with a certain number of copies of a given substring and of a given length */ bool sat(string string_arg0, string substring, int count, int length_arg3) {
bool sat(string string_arg0, string substring, int count, int length_arg3) {
[ "string_arg0", "substring", "count", "length_arg3" ]
def sat(string_arg0: str, substring, count, length_arg3): return string_arg0.count(substring) == count and len(string_arg0) == length_arg3
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"string_arg0\": \"aaaaaaaaaa^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\", \"substring\": \"a\", \"count\": 10, \"length_arg3\": 100}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"string_arg0\": \"kykykyky...
348
TP3/trivial_inverse.StrSplit
C++
Verifies that the inputs satisfy the problem: Find a string of a given length with a certain split
/** * Verifies that the inputs satisfy the problem: * Find a string of a given length with a certain split */ bool sat(string x, vector<string> parts, int length_arg2) {
bool sat(string x, vector<string> parts, int length_arg2) {
[ "x", "parts", "length_arg2" ]
def sat(x: str, parts, length_arg2): return len(x) == length_arg2 and x.split() == parts
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": \"I love dumplings ! \", \"parts\": [\"I\", \"love\", \"dumplings\", \"!\"], \"length_arg2\": 100}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": \"thala chaliri...
349
TP3/trivial_inverse.StrSplitter
C++
Verifies that the inputs satisfy the problem: Find a separator that when used to split a given string gives a certain result
/** * Verifies that the inputs satisfy the problem: * Find a separator that when used to split a given string gives a certain result */ bool sat(string x, vector<string> parts, string string_arg2) {
bool sat(string x, vector<string> parts, string string_arg2) {
[ "x", "parts", "string_arg2" ]
def sat(x: str, parts, string_arg2): return string_arg2.split(x) == parts
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": \"_\", \"parts\": [\"I\", \"love\", \"dumplings\", \"!\", \"\"], \"string_arg2\": \"I_love_dumplings_!_\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": \"textihocavikirofegyf\", \"parts\": [\"kowot\", \"quimimy\"], \"string_arg2\": \"kowott...
350
TP3/trivial_inverse.StrJoiner
C++
Verifies that the inputs satisfy the problem: Find a separator that when used to join a given string gives a certain result. This is related to the previous problem but there are some edge cases that differ.
/** * Verifies that the inputs satisfy the problem: * Find a separator that when used to join a given string gives a certain result. * This is related to the previous problem but there are some edge cases that differ. */ bool sat(string x, vector<string> parts, string string_arg2) {
bool sat(string x, vector<string> parts, string string_arg2) {
[ "x", "parts", "string_arg2" ]
def sat(x: str, parts, string_arg2): return x.join(parts) == string_arg2
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": \"!!\", \"parts\": [\"I!!\", \"!love\", \"dumplings\", \"!\", \"\"], \"string_arg2\": \"I!!!!!love!!dumplings!!!!!\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": \"\", \"parts\": [\"tatext\"], \"string_arg2\": \"tatext\"}}, {\"idx\": 2, \"...
351
TP3/trivial_inverse.StrParts
C++
Verifies that the inputs satisfy the problem: Find parts that when joined give a specific string.
/** * Verifies that the inputs satisfy the problem: * Find parts that when joined give a specific string. */ bool sat(vector<string> parts, string sep, string string_arg2) {
bool sat(vector<string> parts, string sep, string string_arg2) {
[ "parts", "sep", "string_arg2" ]
def sat(parts: List[str], sep, string_arg2): return sep.join(parts) == string_arg2 and all((sep not in p for p in parts))
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"parts\": [\"I\", \"\", \"!love\", \"dumplings\", \"\", \"!\"], \"sep\": \"!!\", \"string_arg2\": \"I!!!!!love!!dumplings!!!!!\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"parts\": [\"watalachyquu\", \"ba\"], \"sep\": \"jachasurobithu\", \"string_a...
352
TP3/trivial_inverse.ListSetLen
C++
Verifies that the inputs satisfy the problem: Find vector with a certain number of duplicate items
/** * Verifies that the inputs satisfy the problem: * Find vector with a certain number of duplicate items */ bool sat(vector<int> li, int dups) {
bool sat(vector<int> li, int dups) {
[ "li", "dups" ]
def sat(li: List[int], dups): return len(set(li)) == len(li) - dups
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"dups\": 50}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"li\": [1, 1, 1, 1, 1, 1, 1, 1,...
353
TP3/trivial_inverse.ListMul
C++
Verifies that the inputs satisfy the problem: Find vector that when multiplied n times gives the target list
/** * Verifies that the inputs satisfy the problem: * Find vector that when multiplied n times gives the target list */ bool sat(vector<int> li, vector<int> target, int n) {
bool sat(vector<int> li, vector<int> target, int n) {
[ "li", "target", "n" ]
def sat(li: List[int], target, n): return li * n == target
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [17, 9, -1], \"target\": [17, 9, -1, 17, 9, -1], \"n\": 2}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"li\": [-69358], \"target\": [-69358, -69358, -69358, -69358, -69358, -69358, -69358], \"n\": 7}}, {\"idx\": 2, \"outputs\": true, \"inputs\"...
354
TP3/trivial_inverse.ListLen
C++
Verifies that the inputs satisfy the problem: Find vector of a given length n
/** * Verifies that the inputs satisfy the problem: * Find vector of a given length n */ bool sat(vector<int> li, int n) {
bool sat(vector<int> li, int n) {
[ "li", "n" ]
def sat(li: List[int], n): return len(li) == n
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
355
TP3/trivial_inverse.ListAt
C++
Verifies that the inputs satisfy the problem: Find the index of an item in vector. Any such index is fine.
/** * Verifies that the inputs satisfy the problem: * Find the index of an item in vector. Any such index is fine. */ bool sat(int i, vector<int> li, int target) {
bool sat(int i, vector<int> li, int target) {
[ "i", "li", "target" ]
def sat(i: int, li, target): return li[i] == target
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"i\": 3, \"li\": [17, 31, 91, 18, 42, 1, 9], \"target\": 18}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"i\": 2, \"li\": [-62, -29, 73, -21, -45, -20, -74, -69, 30, -25, 16, 82, -31, 93, -20, 75, 68, 86], \"target\": 73}}, {\"idx\": 2, \"outputs\": t...
356
TP3/trivial_inverse.ListNegAt
C++
Verifies that the inputs satisfy the problem: Find the index of an item in vector using negative indexing.
/** * Verifies that the inputs satisfy the problem: * Find the index of an item in vector using negative indexing. */ bool sat(int i, vector<int> li, int target) {
bool sat(int i, vector<int> li, int target) {
[ "i", "li", "target" ]
def sat(i: int, li, target): return li[i] == target and i < 0
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"i\": -5, \"li\": [17, 31, 91, 18, 42, 1, 9], \"target\": 91}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"i\": -3, \"li\": [78, 91, -67, -5, 30, -42, 68, 32, 96, -55, -39, -46, 90], \"target\": -39}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"i\...
357
TP3/trivial_inverse.ListSlice
C++
Verifies that the inputs satisfy the problem: Find three slice indices to achieve a given vector slice
/** * Verifies that the inputs satisfy the problem: * Find three slice indices to achieve a given vector slice */ bool sat(vector<int> inds, vector<int> li, vector<int> target) {
bool sat(vector<int> inds, vector<int> li, vector<int> target) {
[ "inds", "li", "target" ]
def sat(inds: List[int], li, target): (i, j, k) = inds return li[i:j:k] == target
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"inds\": [-2, -7, -2], \"li\": [42, 18, 21, 103, -2, 11], \"target\": [-2, 21, 42]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"inds\": [-3, -12, -12], \"li\": [-11, 92, 42, 18, -83, 55, 13, 14, -67, -58, -41], \"target\": [-67]}}, {\"idx\": 2, \"out...
358
TP3/trivial_inverse.ListIndex
C++
Verifies that the inputs satisfy the problem: Find the item whose first index in li is index
/** * Verifies that the inputs satisfy the problem: * Find the item whose first index in li is index */ bool sat(int item, vector<int> li, int index) {
bool sat(int item, vector<int> li, int index) {
[ "item", "li", "index" ]
def sat(item: int, li, index): return li.index(item) == index
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"item\": 11, \"li\": [17, 2, 3, 9, 11, 11], \"index\": 4}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"item\": 93, \"li\": [93, -13], \"index\": 0}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"item\": 79, \"li\": [45, -26, 79, 42, -79, 49, 4, -75]...
359
TP3/trivial_inverse.ListIn
C++
Verifies that the inputs satisfy the problem: Find an item that is in both vectors a and b
/** * Verifies that the inputs satisfy the problem: * Find an item that is in both vectors a and b */ bool sat(string s, vector<string> a, vector<string> b) {
bool sat(string s, vector<string> a, vector<string> b) {
[ "s", "a", "b" ]
def sat(s: str, a, b): return s in a and s in b
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"dot\", \"a\": [\"cat\", \"dot\", \"bird\"], \"b\": [\"tree\", \"fly\", \"dot\"]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"s\": \"chywadetextekesyjup\", \"a\": [\"xetex\", \"jomuboxuc\", \"nyfiranuri\", \"curu\", \"jehykexethinun\", \"bumek...
360
TP3/trivial_inverse.IntNeg
C++
Verifies that the inputs satisfy the problem: Solve a unary negation problem
/** * Verifies that the inputs satisfy the problem: * Solve a unary negation problem */ bool sat(long long x, long long a) {
bool sat(long long x, long long a) {
[ "x", "a" ]
def sat(x: int, a): return -x == a
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": -93252338, \"a\": 93252338}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": 7788910835979672, \"a\": -7788910835979672}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"x\": -6734672221833987, \"a\": 6734672221833987}}, {\"idx\": 3, \"outputs\...
361
TP3/trivial_inverse.IntSum
C++
Verifies that the inputs satisfy the problem: Solve a sum problem
/** * Verifies that the inputs satisfy the problem: * Solve a sum problem */ bool sat(long long x, long long a, long long b) {
bool sat(long long x, long long a, long long b) {
[ "x", "a", "b" ]
def sat(x: int, a, b): return a + x == b
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": 71279291, \"a\": 1073258, \"b\": 72352549}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": -6163252192617378, \"a\": 7176599374880969, \"b\": 1013347182263591}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"x\": 14149563984814697, \"a\": -64...
362
TP3/trivial_inverse.IntSub
C++
Verifies that the inputs satisfy the problem: Solve a subtraction problem
/** * Verifies that the inputs satisfy the problem: * Solve a subtraction problem */ bool sat(long long x, long long a, long long b) {
bool sat(long long x, long long a, long long b) {
[ "x", "a", "b" ]
def sat(x: int, a, b): return x - a == b
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": 14545928, \"a\": -382, \"b\": 14546310}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": 510114708600341, \"a\": 4461955033869751, \"b\": -3951840325269410}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"x\": 9395109756216391, \"a\": 96882031...
363
TP3/trivial_inverse.IntSub2
C++
Verifies that the inputs satisfy the problem: Solve a subtraction problem
/** * Verifies that the inputs satisfy the problem: * Solve a subtraction problem */ bool sat(long long x, long long a, long long b) {
bool sat(long long x, long long a, long long b) {
[ "x", "a", "b" ]
def sat(x: int, a, b): return a - x == b
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": 8758670, \"a\": 8665464, \"b\": -93206}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": 641324100487641, \"a\": 1954051265970332, \"b\": 1312727165482691}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"x\": -5813905657100663, \"a\": -1159353...
364
TP3/trivial_inverse.IntMul
C++
Verifies that the inputs satisfy the problem: Solve a multiplication problem
/** * Verifies that the inputs satisfy the problem: * Solve a multiplication problem */ bool sat(int n, int a, int b) {
bool sat(int n, int a, int b) {
[ "n", "a", "b" ]
def sat(n: int, a, b): return b * n + a % b == a
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 2860, \"a\": 14302, \"b\": 5}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 10256, \"a\": -646156, \"b\": -63}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": 2704, \"a\": 159568, \"b\": 59}}, {\"idx\": 3, \"outputs\": true, \"inputs\"...
365
TP3/trivial_inverse.IntDiv
C++
Verifies that the inputs satisfy the problem: Solve a division problem
/** * Verifies that the inputs satisfy the problem: * Solve a division problem */ bool sat(long long n, int a, long long b) {
bool sat(long long n, int a, long long b) {
[ "n", "a", "b" ]
def sat(n: int, a, b): return b // n == a
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 7821154, \"a\": 3, \"b\": 23463462}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": -1459758477, \"a\": -1, \"b\": 1459758477}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": 1364647958, \"a\": -7, \"b\": -9552535703}}, {\"idx\": 3, \"ou...
366
TP3/trivial_inverse.IntDiv2
C++
Verifies that the inputs satisfy the problem: Find n that when divided by b is a
/** * Verifies that the inputs satisfy the problem: * Find n that when divided by b is a */ bool sat(long long n, int a, int b) {
bool sat(long long n, int a, int b) {
[ "n", "a", "b" ]
def sat(n: int, a, b): return n // b == a
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 3453463630, \"a\": 345346363, \"b\": 10}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 4015467889978780, \"a\": -78874540, \"b\": -50909557}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": -2850226860454515, \"a\": 30623115, \"b\": -93...
367
TP3/trivial_inverse.IntSquareRoot
C++
Verifies that the inputs satisfy the problem: Compute an integer that when squared equals perfect-square a.
/** * Verifies that the inputs satisfy the problem: * Compute an integer that when squared equals perfect-square a. */ bool sat(long long x, long long a) {
bool sat(long long x, long long a) {
[ "x", "a" ]
def sat(x: int, a): return x ** 2 == a
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": 101001, \"a\": 10201202001}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": 1617822806, \"a\": 2617350631613713636}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"x\": 317337692, \"a\": 100703210763886864}}, {\"idx\": 3, \"outputs\": true, \...
368
TP3/trivial_inverse.IntNegSquareRoot
C++
Verifies that the inputs satisfy the problem: Find a negative integer that when squared equals perfect-square a.
/** * Verifies that the inputs satisfy the problem: * Find a negative integer that when squared equals perfect-square a. */ bool sat(long long n, long long a) {
bool sat(long long n, long long a) {
[ "n", "a" ]
def sat(n: int, a): return a == n * n and n < 0
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": -100001, \"a\": 10000200001}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": -1074115377, \"a\": 1153723843107852129}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": -1392979698, \"a\": 1940392439040171204}}, {\"idx\": 3, \"outputs\": tr...
369
TP3/trivial_inverse.FloatSquareRoot
C++
Verifies that the inputs satisfy the problem: Find a number that when squared is close to a.
/** * Verifies that the inputs satisfy the problem: * Find a number that when squared is close to a. */ bool sat(double x, long long a) {
bool sat(double x, long long a) {
[ "x", "a" ]
def sat(x: float, a): return abs(x ** 2 - a) < 10 ** (-3)
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": 31.937438845342623, \"a\": 1020}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": 78570.2316147789, \"a\": 6173281296}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"x\": 89373.50110631227, \"a\": 7987622700}}, {\"idx\": 3, \"outputs\": true,...
370
TP3/trivial_inverse.FloatNegSquareRoot
C++
Verifies that the inputs satisfy the problem: Find a negative number that when squared is close to a.
/** * Verifies that the inputs satisfy the problem: * Find a negative number that when squared is close to a. */ bool sat(double x, long long a) {
bool sat(double x, long long a) {
[ "x", "a" ]
def sat(x: float, a): return abs(x ** 2 - a) < 10 ** (-3) and x < 0
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": -31.937438845342623, \"a\": 1020}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": -51781.03416309875, \"a\": 2681275499}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"x\": -36928.488257712364, \"a\": 1363713245}}, {\"idx\": 3, \"outputs\": ...
371
TP3/tutorial.Tutorial1
C++
Verifies that the inputs satisfy the problem: Find a string that when concatenated onto 'Hello ' gives 'Hello world'.
/** * Verifies that the inputs satisfy the problem: * Find a string that when concatenated onto 'Hello ' gives 'Hello world'. */ bool sat(string s) {
bool sat(string s) {
[ "s" ]
def sat(s: str): return 'Hello ' + s == 'Hello world'
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"world\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"s\": \"\"}}]", "extension": "cpp", "entry_fn_name": "sat", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include ...
372
TP3/tutorial.Tutorial2
C++
Verifies that the inputs satisfy the problem: Find a string that when reversed and concatenated onto 'Hello ' gives 'Hello world'.
/** * Verifies that the inputs satisfy the problem: * Find a string that when reversed and concatenated onto 'Hello ' gives 'Hello world'. */ bool sat(string s) {
bool sat(string s) {
[ "s" ]
def sat(s: str): return 'Hello ' + s[::-1] == 'Hello world'
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"dlrow\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"s\": \"\"}}]", "extension": "cpp", "entry_fn_name": "sat", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include ...
373
TP3/tutorial.Tutorial3
C++
Verifies that the inputs satisfy the problem: Find vector of two integers whose sum is 3.
/** * Verifies that the inputs satisfy the problem: * Find vector of two integers whose sum is 3. */ bool sat(vector<int> x) {
bool sat(vector<int> x) {
[ "x" ]
def sat(x: List[int]): return len(x) == 2 and sum(x) == 3
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": [1, 2]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"x\": []}}]", "extension": "cpp", "entry_fn_name": "sat", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>...
374
TP3/tutorial.Tutorial5
C++
Verifies that the inputs satisfy the problem: Find an integer whose perfect square begins with 123456789 in its decimal representation.
/** * Verifies that the inputs satisfy the problem: * Find an integer whose perfect square begins with 123456789 in its decimal representation. */ bool sat(int n) {
bool sat(int n) {
[ "n" ]
def sat(n: int): return str(n * n).startswith('123456789')
{ "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 351364183}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"n\": 8}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"n\": 0}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"n\": 4}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"n\": 1}}]", ...