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 |
|---|---|---|---|---|---|---|---|---|
0 | TP3/study.Study_1 | C++ | Verifies that the inputs satisfy the problem:
Find a string with 1000 'o's but no two adjacent 'o's. | /**
* Verifies that the inputs satisfy the problem:
* Find a string with 1000 'o's but no two adjacent 'o's.
*/
bool sat(string s) { | bool sat(string s) { | [
"s"
] | def sat(s: str):
return s.count('o') == 1000 and s.count('oo') == 0 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"hohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohoh... |
1 | TP3/study.Study_2 | C++ | Verifies that the inputs satisfy the problem:
Find a string with 1000 'o's, 100 pairs of adjacent 'o's and 801 copies of 'ho'. | /**
* Verifies that the inputs satisfy the problem:
* Find a string with 1000 'o's, 100 pairs of adjacent 'o's and 801 copies of 'ho'.
*/
bool sat(string s) { | bool sat(string s) { | [
"s"
] | def sat(s: str):
return s.count('o') == 1000 and s.count('oo') == 100 and (s.count('ho') == 801) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"hohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohoh... |
2 | TP3/study.Study_3 | C++ | Verifies that the inputs satisfy the problem:
Find a permutation of [0, 1, ..., 998] such that the ith element is *not* i, for all i=0, 1, ..., 998. | /**
* Verifies that the inputs satisfy the problem:
* Find a permutation of [0, 1, ..., 998] such that the ith element is *not* i, for all i=0, 1, ..., 998.
*/
bool sat(vector<int> li) { | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return sorted(li) == list(range(999)) and all((li[i] != i for i in range(len(li)))) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, ... |
3 | TP3/study.Study_4 | C++ | Verifies that the inputs satisfy the problem:
Find vector of length 10 where the fourth element occurs exactly twice. | /**
* Verifies that the inputs satisfy the problem:
* Find vector of length 10 where the fourth element occurs exactly twice.
*/
bool sat(vector<int> li) { | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return len(li) == 10 and li.count(li[3]) == 2 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]}}, {\"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>\n#inc... |
4 | TP3/study.Study_5 | C++ | Verifies that the inputs satisfy the problem:
Find vector integers such that the integer i occurs i times, for i = 0, 1, 2, ..., 9. | /**
* Verifies that the inputs satisfy the problem:
* Find vector integers such that the integer i occurs i times, for i = 0, 1, 2, ..., 9.
*/
bool sat(vector<int> li) { | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return all([li.count(i) == i for i in range(10)]) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"li\": []}}]",
"extension": "cpp",
"entry_fn_name": "sat",... |
5 | TP3/study.Study_6 | C++ | Verifies that the inputs satisfy the problem:
Find an integer greater than 10^10 which is 4 mod 123. | /**
* Verifies that the inputs satisfy the problem:
* Find an integer greater than 10^10 which is 4 mod 123.
*/
bool sat(long long i) { | bool sat(long long i) { | [
"i"
] | def sat(i: int):
return i % 123 == 4 and i > 10 ** 10 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"i\": 10000000126}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"i\": 4}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"i\": 3}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"i\": 1}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"i\": 0}}]",
... |
6 | TP3/study.Study_7 | C++ | Verifies that the inputs satisfy the problem:
Find a three-digit pattern that occurs more than 8 times in the decimal representation of 8^2888. | /**
* Verifies that the inputs satisfy the problem:
* Find a three-digit pattern that occurs more than 8 times in the decimal representation of 8^2888.
*/
bool sat(string s) { | bool sat(string s) { | [
"s"
] | def sat(s: str):
return str(8 ** 2888).count(s) > 8 and len(s) == 3 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"672\"}}, {\"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 <s... |
7 | TP3/study.Study_9 | C++ | Verifies that the inputs satisfy the problem:
Find a way to rearrange the letters in the pangram "The quick brown fox jumps over the lazy dog" to get
the pangram "The five boxing wizards jump quickly". The answer should be represented as vector of index
mappings. | /**
* Verifies that the inputs satisfy the problem:
* Find a way to rearrange the letters in the pangram "The quick brown fox jumps over the lazy dog" to get
* the pangram "The five boxing wizards jump quickly". The answer should be represented as vector of index
* mappings.
*/
bool sat(vector<int> li) { | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return ['The quick brown fox jumps over the lazy dog'[i] for i in li] == list('The five boxing wizards jump quickly') | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [0, 1, 2, 3, 16, 6, 27, 2, 3, 10, 12, 18, 6, 14, 42, 3, 13, 6, 37, 36, 11, 40, 24, 3, 20, 5, 22, 23, 3, 4, 5, 6, 7, 8, 35, 38]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"li\": []}}]",
"extension": "cpp",
"entry_fn_name": "sat",
"test_... |
8 | TP3/study.Study_10 | C++ | Verifies that the inputs satisfy the problem:
Find a palindrome of length greater than 11 in the decimal representation of 8^1818. | /**
* Verifies that the inputs satisfy the problem:
* Find a palindrome of length greater than 11 in the decimal representation of 8^1818.
*/
bool sat(string s) { | bool sat(string s) { | [
"s"
] | def sat(s: str):
return s in str(8 ** 1818) and s == s[::-1] and (len(s) > 11) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"8834117114388\"}}, {\"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#... |
9 | TP3/study.Study_11 | C++ | Verifies that the inputs satisfy the problem:
Find vector of strings whose length (viewed as a string) is equal to the lexicographically largest element
and is equal to the lexicographically smallest element. | /**
* Verifies that the inputs satisfy the problem:
* Find vector of strings whose length (viewed as a string) is equal to the lexicographically largest element
* and is equal to the lexicographically smallest element.
*/
bool sat(vector<string> ls) { | bool sat(vector<string> ls) { | [
"ls"
] | def sat(ls: List[str]):
return min(ls) == max(ls) == str(len(ls)) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ls\": [\"1\"]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"ls\": [\"t\"]}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"ls\": [\"()\"]}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"ls\": [\"F\"]}}, {\"idx\": 4, \"outputs\": false, \"inputs... |
10 | TP3/study.Study_12 | C++ | Verifies that the inputs satisfy the problem:
Find vector of 1,000 integers where every two adjacent integers sum to 9, and where the first
integer plus 4 is 9. | /**
* Verifies that the inputs satisfy the problem:
* Find vector of 1,000 integers where every two adjacent integers sum to 9, and where the first
* integer plus 4 is 9.
*/
bool sat(vector<int> li) { | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return all((i + j == 9 for (i, j) in zip([4] + li, li))) and len(li) == 1000 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5... |
11 | TP3/study.Study_13 | C++ | Verifies that the inputs satisfy the problem:
Find a real number which, when you subtract 3.1415, has a decimal representation starting with 123.456. | /**
* Verifies that the inputs satisfy the problem:
* Find a real number which, when you subtract 3.1415, has a decimal representation starting with 123.456.
*/
bool sat(float x) { | bool sat(float x) { | [
"x"
] | def sat(x: float):
return str(x - 3.1415).startswith('123.456') | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": 126.5975}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"x\": -8.8}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"x\": 98.0}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"x\": 8.6}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"x\": 0.... |
12 | TP3/study.Study_14 | C++ | Verifies that the inputs satisfy the problem:
Find vector of integers such that the sum of the first i integers is i, for i=0, 1, 2, ..., 19. | /**
* Verifies that the inputs satisfy the problem:
* Find vector of integers such that the sum of the first i integers is i, for i=0, 1, 2, ..., 19.
*/
bool sat(vector<int> li) { | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return all([sum(li[:i]) == i for i in range(20)]) | {
"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]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"li\": []}}]",
"extension": "cpp",
"entry_fn_name": "sat",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdl... |
13 | TP3/study.Study_15 | C++ | Verifies that the inputs satisfy the problem:
Find vector of integers such that the sum of the first i integers is 2^i -1, for i = 0, 1, 2, ..., 19. | /**
* Verifies that the inputs satisfy the problem:
* Find vector of integers such that the sum of the first i integers is 2^i -1, for i = 0, 1, 2, ..., 19.
*/
bool sat(vector<int> li) { | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return all((sum(li[:i]) == 2 ** i - 1 for i in range(20))) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"li\": []}}]",
"extension": "cpp",
"entry_fn_name": "sat",
"test_code": "#include <... |
14 | TP3/study.Study_16 | C++ | Verifies that the inputs satisfy the problem:
Find a real number such that when you add the length of its decimal representation to it, you get 4.5.
Your answer should be the string form of the number in its decimal representation. | /**
* Verifies that the inputs satisfy the problem:
* Find a real number such that when you add the length of its decimal representation to it, you get 4.5.
* Your answer should be the string form of the number in its decimal representation.
*/
bool sat(string s) { | bool sat(string s) { | [
"s"
] | def sat(s: str):
return float(s) + len(s) == 4.5 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"1.5\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"s\": \"1.23\"}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"s\": \"4.51\"}}]",
"extension": "cpp",
"entry_fn_name": "sat",
"test_code": "#include <algorithm>\n#include <assert.h>\... |
15 | TP3/study.Study_17 | C++ | Verifies that the inputs satisfy the problem:
Find a number whose decimal representation is *a longer string* when you add 1,000 to it than when you add 1,001. | /**
* Verifies that the inputs satisfy the problem:
* Find a number whose decimal representation is *a longer string* when you add 1,000 to it than when you add 1,001.
*/
bool sat(int i) { | bool sat(int i) { | [
"i"
] | def sat(i: int):
return len(str(i + 1000)) > len(str(i + 1001)) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"i\": -1001}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"i\": 0}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"i\": 1}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"i\": 8}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"i\": 4}}]",
"ext... |
16 | TP3/study.Study_18 | C++ | Verifies that the inputs satisfy the problem:
Find vector of strings that when you combine them in all pairwise combinations gives the six strings:
'berlin', 'berger', 'linber', 'linger', 'gerber', 'gerlin' | /**
* Verifies that the inputs satisfy the problem:
* Find vector of strings that when you combine them in all pairwise combinations gives the six strings:
* 'berlin', 'berger', 'linber', 'linger', 'gerber', 'gerlin'
*/
bool sat(vector<string> ls) { | bool sat(vector<string> ls) { | [
"ls"
] | def sat(ls: List[str]):
return [s + t for s in ls for t in ls if s != t] == 'berlin berger linber linger gerber gerlin'.split() | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ls\": [\"ber\", \"lin\", \"ger\"]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"ls\": []}}]",
"extension": "cpp",
"entry_fn_name": "sat",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#includ... |
17 | TP3/study.Study_19 | C++ | Verifies that the inputs satisfy the problem:
Find vector of integers whose pairwise sums make the set {0, 1, 2, 3, 4, 5, 6, 17, 18, 19, 20, 34}.
That is find L such that, { i + j | i, j in L } = {0, 1, 2, 3, 4, 5, 6, 17, 18, 19, 20, 34}. | /**
* Verifies that the inputs satisfy the problem:
* Find vector of integers whose pairwise sums make the set {0, 1, 2, 3, 4, 5, 6, 17, 18, 19, 20, 34}.
* That is find L such that, { i + j | i, j in L } = {0, 1, 2, 3, 4, 5, 6, 17, 18, 19, 20, 34}.
*/
bool sat(vector<int> li) { | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return {i + j for i in li for j in li} == {0, 1, 2, 3, 4, 5, 6, 17, 18, 19, 20, 34} | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [0, 1, 2, 3, 17]}}, {\"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>\n#include <map>\n#i... |
18 | TP3/study.Study_20 | C++ | Verifies that the inputs satisfy the problem:
Find vector of 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 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]))) | {
"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>\... |
19 | TP3/study.Study_21 | C++ | Verifies that the inputs satisfy the problem:
Find vector integers containing exactly three distinct values, such that no integer repeats
twice consecutively among the first eleven entries. (So the vector needs to have length greater than ten.) | /**
* Verifies that the inputs satisfy the problem:
* Find vector integers containing exactly three distinct values, such that no integer repeats
* twice consecutively among the first eleven entries. (So the vector needs to have length greater than ten.)
*/
bool sat(vector<int> li) { | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return all([li[i] != li[i + 1] for i in range(10)]) and len(set(li)) == 3 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"li\": [1, 2, 3, 1, 3, 3, 1, 2, 3, 1, 2, 3]}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"li\": [0, 1,... |
20 | TP3/study.Study_22 | C++ | Verifies that the inputs satisfy the problem:
Find a string s containing exactly five distinct characters which also contains as a substring every other
character of s (e.g., if the string s were 'parrotfish' every other character would be 'profs'). | /**
* Verifies that the inputs satisfy the problem:
* Find a string s containing exactly five distinct characters which also contains as a substring every other
* character of s (e.g., if the string s were 'parrotfish' every other character would be 'profs').
*/
bool sat(string s) { | bool sat(string s) { | [
"s"
] | def sat(s: str):
return s[::2] in s and len(set(s)) == 5 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"abacadaeaaaaaaaaaa\"}}, {\"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 <ma... |
21 | TP3/study.Study_23 | C++ | Verifies that the inputs satisfy the problem:
Find vector of characters which are aligned at the same indices of the three strings 'dee', 'doo', and 'dah!'. | /**
* Verifies that the inputs satisfy the problem:
* Find vector of characters which are aligned at the same indices of the three strings 'dee', 'doo', and 'dah!'.
*/
bool sat(vector<string> ls) { | bool sat(vector<string> ls) { | [
"ls"
] | def sat(ls: List[str]):
return tuple(ls) in zip('dee', 'doo', 'dah!') | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ls\": [\"d\", \"d\", \"d\"]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"ls\": []}}]",
"extension": "cpp",
"entry_fn_name": "sat",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map... |
22 | TP3/study.Study_24 | C++ | Verifies that the inputs satisfy the problem:
Find vector of integers with exactly three occurrences of seventeen and at least two occurrences of three. | /**
* Verifies that the inputs satisfy the problem:
* Find vector of integers with exactly three occurrences of seventeen and at least two occurrences of three.
*/
bool sat(vector<int> li) { | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return li.count(17) == 3 and li.count(3) >= 2 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [17, 17, 17, 3, 3]}}, {\"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>\n#include <map>\n... |
23 | TP3/study.Study_25 | C++ | Verifies that the inputs satisfy the problem:
Find a permutation of the string 'Permute me true' which is a palindrome. | /**
* Verifies that the inputs satisfy the problem:
* Find a permutation of the string 'Permute me true' which is a palindrome.
*/
bool sat(string s) { | bool sat(string s) { | [
"s"
] | def sat(s: str):
return sorted(s) == sorted('Permute me true') and s == s[::-1] | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \" eemrtuPutrmee \"}}, {\"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>\... |
24 | TP3/study.Study_26 | C++ | Verifies that the inputs satisfy the problem:
Divide the decimal representation of 8^88 up into strings of length eight. | /**
* Verifies that the inputs satisfy the problem:
* Divide the decimal representation of 8^88 up into strings of length eight.
*/
bool sat(vector<string> ls) { | bool sat(vector<string> ls) { | [
"ls"
] | def sat(ls: List[str]):
return ''.join(ls) == str(8 ** 88) and all((len(s) == 8 for s in ls)) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ls\": [\"29642774\", \"84475294\", \"60284341\", \"72162224\", \"10441043\", \"71160744\", \"03984394\", \"10114150\", \"60257611\", \"87823616\"]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"ls\": []}}]",
"extension": "cpp",
"entry_fn_name": "... |
25 | TP3/study.Study_27 | C++ | Verifies that the inputs satisfy the problem:
Consider a digraph where each node has exactly one outgoing edge. For each edge (u, v), call u the parent and
v the child. Then find such a digraph where the grandchildren of the first and second nodes differ but they
share the same great-grandchildren. Represented this dig... | /**
* Verifies that the inputs satisfy the problem:
* Consider a digraph where each node has exactly one outgoing edge. For each edge (u, v), call u the parent and
* v the child. Then find such a digraph where the grandchildren of the first and second nodes differ but they
* share the same great-grandchildren. Repr... | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return li[li[0]] != li[li[1]] and li[li[li[0]]] == li[li[li[1]]] | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [1, 2, 3, 3]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"li\": [1, 2, 3, 4]}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"li\": [1, 1, 1, 2]}}]",
"extension": "cpp",
"entry_fn_name": "sat",
"test_code": "#include <algorithm>\n#inc... |
26 | TP3/study.Study_28 | C++ | Verifies that the inputs satisfy the problem:
Find vector of one hundred integers between 0 and 999 which all differ by at least ten from one another. | /**
* Verifies that the inputs satisfy the problem:
* Find vector of one hundred integers between 0 and 999 which all differ by at least ten from one another.
*/
bool sat(vector<int> li) { | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return all((i in range(1000) and abs(i - j) >= 10 for i in li for j in li if i != j)) and len(set(li)) == 100 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510... |
27 | TP3/study.Study_29 | C++ | Verifies that the inputs satisfy the problem:
Find vector of more than 995 distinct integers between 0 and 999, inclusive, such that each pair of integers
have squares that differ by at least 10. | /**
* Verifies that the inputs satisfy the problem:
* Find vector of more than 995 distinct integers between 0 and 999, inclusive, such that each pair of integers
* have squares that differ by at least 10.
*/
bool sat(vector<int> l) { | bool sat(vector<int> l) { | [
"l"
] | def sat(l: List[int]):
return all((i in range(1000) and abs(i * i - j * j) >= 10 for i in l for j in l if i != j)) and len(set(l)) > 995 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"l\": [0, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67... |
28 | TP3/study.Study_30 | C++ | Verifies that the inputs satisfy the problem:
Define f(n) to be the residue of 123 times n mod 1000. Find vector of integers such that the first twenty one
are between 0 and 999, inclusive, and are strictly increasing in terms of f(n). | /**
* Verifies that the inputs satisfy the problem:
* Define f(n) to be the residue of 123 times n mod 1000. Find vector of integers such that the first twenty one
* are between 0 and 999, inclusive, and are strictly increasing in terms of f(n).
*/
bool sat(vector<int> li) { | bool sat(vector<int> li) { | [
"li"
] | def sat(li: List[int]):
return all([123 * li[i] % 1000 < 123 * li[i + 1] % 1000 and li[i] in range(1000) for i in range(20)]) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [0, 187, 374, 561, 748, 935, 122, 309, 496, 683, 870, 57, 244, 431, 618, 805, 992, 179, 366, 553, 740]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"li\": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]}}, {\"idx... |
29 | TP3/classic_puzzles.TowersOfHanoi | C++ | Verifies that the inputs satisfy the problem:
Eight disks of sizes 1-8 are stacked on three towers, with each tower having disks in order of largest to
smallest. Move [i, j] corresponds to taking the smallest disk off tower i and putting it on tower j, and it
is legal as long as the towers remain in sorted order. Find ... | /**
* Verifies that the inputs satisfy the problem:
* Eight disks of sizes 1-8 are stacked on three towers, with each tower having disks in order of largest to
* smallest. Move [i, j] corresponds to taking the smallest disk off tower i and putting it on tower j, and it
* is legal as long as the towers remain in sor... | bool sat(vector<vector<int>> moves) { | [
"moves"
] | def sat(moves: List[List[int]]):
rods = ([5, 4, 3, 2, 1], [], [])
for [i, j] in moves:
rods[j].append(rods[i].pop())
if not rods[j][-1] == min(rods[j]):
return False
return rods[0] == rods[1] == [] | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"moves\": [[0, 2], [0, 1], [2, 1], [0, 2], [1, 0], [1, 2], [0, 2], [0, 1], [2, 1], [2, 0], [1, 0], [2, 1], [0, 2], [0, 1], [2, 1], [0, 2], [1, 0], [1, 2], [0, 2], [1, 0], [2, 1], [2, 0], [1, 0], [1, 2], [0, 2], [0, 1], [2, 1], [0, 2], [1, 0], [1, 2], [0, ... |
31 | TP3/classic_puzzles.LongestMonotonicSubstring | C++ | Verifies that the inputs satisfy the problem:
Remove as few characters as possible from s so that the characters of the remaining string are alphebetical.
Here x is the vector of string indices that have not been deleted. | /**
* Verifies that the inputs satisfy the problem:
* Remove as few characters as possible from s so that the characters of the remaining string are alphebetical.
* Here x is the vector of string indices that have not been deleted.
*/
bool sat(vector<int> x, int length_arg1, string s) { | bool sat(vector<int> x, int length_arg1, string s) { | [
"x",
"length_arg1",
"s"
] | def sat(x: List[int], length_arg1, s):
return all((s[x[i]] <= s[x[i + 1]] and x[i + 1] > x[i] >= 0 for i in range(length_arg1 - 1))) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": [0, 3, 6, 11, 14, 15, 17, 21, 25, 30, 33, 34, 35], \"length_arg1\": 13, \"s\": \"Dynamic programming solves this puzzle!!!\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20... |
32 | TP3/classic_puzzles.LongestMonotonicSubstringTricky | C++ | Verifies that the inputs satisfy the problem:
Find the indices of the longest substring with characters in sorted order | /**
* Verifies that the inputs satisfy the problem:
* Find the indices of the longest substring with characters in sorted order
*/
bool sat(vector<int> x, int length_arg1, string s) { | bool sat(vector<int> x, int length_arg1, string s) { | [
"x",
"length_arg1",
"s"
] | def sat(x: List[int], length_arg1, s):
return all((s[x[i]] <= s[x[i + 1]] and x[i + 1] > x[i] for i in range(length_arg1 - 1))) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": [-56, -44, -37, -32, -24, -10, -3, -2, -1, 0, 3, 6, 11, 14, 15, 17, 21, 25, 30, 35, 36, 46, 49, 52, 56, 57], \"length_arg1\": 20, \"s\": \"Dynamic programming solves this classic job-interview puzzle!!!\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\... |
33 | TP3/classic_puzzles.Quine | C++ | Verifies that the inputs satisfy the problem:
Find a string that when evaluated as a C++ expression is that string itself. | /**
* Verifies that the inputs satisfy the problem:
* Find a string that when evaluated as a C++ expression is that string itself.
*/
bool sat(string quine) { | bool sat(string quine) { | [
"quine"
] | def sat(quine: str):
return eval(quine) == quine | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"quine\": \"(lambda x: f'({x})({chr(34)}{x}{chr(34)})')(\\\"lambda x: f'({x})({chr(34)}{x}{chr(34)})'\\\")\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"quine\": \"(lambda x: chr(34))\"}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"quine\": \"... |
34 | TP3/classic_puzzles.RevQuine | C++ | Verifies that the inputs satisfy the problem:
Find a string that, when reversed and evaluated gives you back that same string. | /**
* Verifies that the inputs satisfy the problem:
* Find a string that, when reversed and evaluated gives you back that same string.
*/
bool sat(string rev_quine) { | bool sat(string rev_quine) { | [
"rev_quine"
] | def sat(rev_quine: str):
return eval(rev_quine[::-1]) == rev_quine | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"rev_quine\": \"eniuq_ver\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"rev_quine\": \"'no'\"}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"rev_quine\": \"'yessir'\"}}]",
"extension": "cpp",
"entry_fn_name": "sat",
"test_code": "#include... |
35 | TP3/classic_puzzles.BooleanPythagoreanTriples | C++ | Verifies that the inputs satisfy the problem:
Color the first n integers with one of two colors so that there is no monochromatic Pythagorean triple.
A monochromatic Pythagorean triple is a triple of numbers i, j, k such that i^2 + j^2 = k^2 that
are all assigned the same color. The input, colors, is vector of 0\/1 col... | /**
* Verifies that the inputs satisfy the problem:
* Color the first n integers with one of two colors so that there is no monochromatic Pythagorean triple.
* A monochromatic Pythagorean triple is a triple of numbers i, j, k such that i^2 + j^2 = k^2 that
* are all assigned the same color. The input, colors, is ve... | bool sat(vector<int> colors, int n) { | [
"colors",
"n"
] | def sat(colors: List[int], n):
if not (set(colors) <= {0, 1} and len(colors) >= n):
return False
squares = {i ** 2: colors[i] for i in range(1, len(colors))}
return not any((c == d == squares.get(i + j) for (i, c) in squares.items() for (j, d) in squares.items())) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"colors\": [1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, ... |
36 | TP3/classic_puzzles.ClockAngle | C++ | Verifies that the inputs satisfy the problem:
Find clock hands = [hour, min] such that the angle is target_angle degrees. | /**
* Verifies that the inputs satisfy the problem:
* Find clock hands = [hour, min] such that the angle is target_angle degrees.
*/
bool sat(vector<int> hands, int target_angle) { | bool sat(vector<int> hands, int target_angle) { | [
"hands",
"target_angle"
] | def sat(hands: List[int], target_angle):
(h, m) = hands
if not (0 < h <= 12 and 0 <= m < 60):
return False
hour_angle = 30 * h + m / 2
minute_angle = 6 * m
return abs(hour_angle - minute_angle) in [target_angle, 360 - target_angle] | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"hands\": [4, 30], \"target_angle\": 45}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"hands\": [2, 18], \"target_angle\": 39}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"hands\": [4, 46], \"target_angle\": 133}}, {\"idx\": 3, \"outputs\": true, \... |
37 | TP3/classic_puzzles.MonkeyAndCoconuts | C++ | Verifies that the inputs satisfy the problem:
Find the number of coconuts to solve the following riddle:
There is a pile of coconuts, owned by five men. One man divides the pile into five equal piles, giving the
one left over coconut to a passing monkey, and takes away his own share. The second man then repeats the
pro... | /**
* Verifies that the inputs satisfy the problem:
* Find the number of coconuts to solve the following riddle:
* There is a pile of coconuts, owned by five men. One man divides the pile into five equal piles, giving the
* one left over coconut to a passing monkey, and takes away his own share. The second man then... | bool sat(int n) { | [
"n"
] | def sat(n: int):
for i in range(5):
if not n % 5 == 1:
return False
n -= 1 + (n - 1) // 5
return n > 0 and n % 5 == 1 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 15621}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"n\": 4}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"n\": 3}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"n\": 1}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"n\": 8}}]",
"ext... |
38 | TP3/classic_puzzles.No3Colinear | C++ | Verifies that the inputs satisfy the problem:
Find num_points points in an side x side grid such that no three points are collinear. | /**
* Verifies that the inputs satisfy the problem:
* Find num_points points in an side x side grid such that no three points are collinear.
*/
bool sat(vector<vector<int>> coords, int side, int num_points) { | bool sat(vector<vector<int>> coords, int side, int num_points) { | [
"coords",
"side",
"num_points"
] | def sat(coords: List[List[int]], side, num_points):
for i1 in range(len(coords)):
(x1, y1) = coords[i1]
if not (0 <= x1 < side and 0 <= y1 < side):
return False
for i2 in range(i1):
(x2, y2) = coords[i2]
for i3 in range(i2):
(x3, y3) = coor... | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"coords\": [[0, 4], [0, 5], [9, 4], [9, 5], [1, 2], [1, 7], [8, 2], [8, 7], [2, 1], [2, 8], [7, 1], [7, 8], [3, 3], [3, 6], [6, 3], [6, 6], [4, 0], [4, 9], [5, 0], [5, 9]], \"side\": 10, \"num_points\": 20}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\... |
39 | TP3/classic_puzzles.PostageStamp | C++ | Verifies that the inputs satisfy the problem:
Find a selection of at most max_stamps stamps whose total worth is the target value. | /**
* Verifies that the inputs satisfy the problem:
* Find a selection of at most max_stamps stamps whose total worth is the target value.
*/
bool sat(vector<int> stamps, int target, int max_stamps, vector<int> options) { | bool sat(vector<int> stamps, int target, int max_stamps, vector<int> options) { | [
"stamps",
"target",
"max_stamps",
"options"
] | def sat(stamps: List[int], target, max_stamps, options):
for s in stamps:
if not s in options:
return False
return len(stamps) <= max_stamps and sum(stamps) == target | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"stamps\": [32, 32, 8, 8], \"target\": 80, \"max_stamps\": 4, \"options\": [10, 32, 8]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"stamps\": [37, 39, 39, 39, 39, 39, 39], \"target\": 271, \"max_stamps\": 8, \"options\": [37, 37, 12, 87, 39]}}, {\"id... |
40 | TP3/classic_puzzles.Sudoku | C++ | Verifies that the inputs satisfy the problem:
Find the unique valid solution to the Sudoku puzzle | /**
* Verifies that the inputs satisfy the problem:
* Find the unique valid solution to the Sudoku puzzle
*/
bool sat(string x, string puz) { | bool sat(string x, string puz) { | [
"x",
"puz"
] | def sat(x: str, puz):
if not all((c == '_' or c == s for (c, s) in zip(puz, x))):
return False
full = set('123456789')
for i in range(9):
if not {x[i] for i in range(9 * i, 9 * i + 9)} == full:
return False
if not {x[i] for i in range(i, i + 81, 9)} == full:
r... | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": \"481793265975642138632158947356217894294385671817469523123876459568934712749521386\", \"puz\": \"____9_2___7__________1_8_4____2_78____4_____1____69____2_8___5__6__3_7___49______\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": \"8426915371... |
41 | TP3/classic_puzzles.SquaringTheSquare | C++ | Verifies that the inputs satisfy the problem:
Partition a square into smaller squares with unique side lengths. A perfect squared path has distinct sides.
xy_sides is Vector of (x, y, side) | /**
* Verifies that the inputs satisfy the problem:
* Partition a square into smaller squares with unique side lengths. A perfect squared path has distinct sides.
* xy_sides is Vector of (x, y, side)
*/
bool sat(vector<vector<int>> xy_sides) { | bool sat(vector<vector<int>> xy_sides) { | [
"xy_sides"
] | def sat(xy_sides: List[List[int]]):
n = max((x + side for (x, y, side) in xy_sides))
if not len({side for (x, y, side) in xy_sides}) == len(xy_sides) > 1:
return False
for (x, y, s) in xy_sides:
if not (0 <= y < y + s <= n and 0 <= x):
return False
for (x2, y2, s2) in xy_... | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"xy_sides\": [[0, 0, 50], [0, 50, 29], [0, 79, 33], [29, 50, 25], [29, 75, 4], [33, 75, 37], [50, 0, 35], [50, 35, 15], [54, 50, 9], [54, 59, 16], [63, 50, 2], [63, 52, 7], [65, 35, 17], [70, 52, 18], [70, 70, 42], [82, 35, 11], [82, 46, 6], [85, 0, 27], ... |
42 | TP3/classic_puzzles.NecklaceSplit | C++ | Verifies that the inputs satisfy the problem:
Find a split dividing the given red\/blue necklace in half at n so that each piece has an equal number of
reds and blues. | /**
* Verifies that the inputs satisfy the problem:
* Find a split dividing the given red\\/blue necklace in half at n so that each piece has an equal number of
* reds and blues.
*/
bool sat(int n, string lace) { | bool sat(int n, string lace) { | [
"n",
"lace"
] | def sat(n: int, lace):
sub = lace[n:n + len(lace) // 2]
return n >= 0 and lace.count('r') == 2 * sub.count('r') and (lace.count('b') == 2 * sub.count('b')) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 37, \"lace\": \"bbrbrbbbbbbrrrrrrrbrrrrbbbrbrrbbbrbrrrbrrbrrbrbbrrrrrbrbbbrrrbbbrbbrbbbrbrbb\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 0, \"lace\": \"rbbrrbbrbrbbbrrrbbrbrbrrbbrbbbbbbrrrrrrrrbrrrbbrbrrbbbrbbrrrbbrbbrrbrrbrbbrbbbbbbrbb... |
43 | TP3/classic_puzzles.PandigitalSquare | C++ | Verifies that the inputs satisfy the problem:
Find an integer whose square has all digits 0-9 once. | /**
* Verifies that the inputs satisfy the problem:
* Find an integer whose square has all digits 0-9 once.
*/
bool sat(int n) { | bool sat(int n) { | [
"n"
] | def sat(n: int):
s = str(n * n)
for i in '0123456789':
if not s.count(i) == 1:
return False
return True | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 32043}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"n\": 0}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"n\": 3}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"n\": 4}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"n\": 8}}]",
"ext... |
44 | TP3/classic_puzzles.AllPandigitalSquares | C++ | Verifies that the inputs satisfy the problem:
Find all 174 integers whose 10-digit square has all digits 0-9 just once. | /**
* Verifies that the inputs satisfy the problem:
* Find all 174 integers whose 10-digit square has all digits 0-9 just once.
*/
bool sat(vector<int> nums) { | bool sat(vector<int> nums) { | [
"nums"
] | def sat(nums: List[int]):
return [sorted([int(s) for s in str(n * n)]) for n in set(nums)] == [list(range(10))] * 174 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"nums\": [-99066, -98802, -98055, -97779, -96702, -95154, -94695, -92214, -91605, -91248, -90198, -90153, -90144, -89523, -89355, -89145, -89079, -88623, -87639, -86073, -85803, -85743, -85353, -84648, -83919, -81945, -81222, -80445, -80361, -78453, -7807... |
45 | TP3/classic_puzzles.CardGame24 | C++ | Verifies that the inputs satisfy the problem:
Find a formula with two 3's and two 7's and + - * \/ (and parentheses) that evaluates to 24. | /**
* Verifies that the inputs satisfy the problem:
* Find a formula with two 3's and two 7's and + - * \\/ (and parentheses) that evaluates to 24.
*/
bool sat(string expr, vector<int> nums) { | bool sat(string expr, vector<int> nums) { | [
"expr",
"nums"
] | def sat(expr: str, nums):
if not (len(nums) == 4 and 1 <= min(nums) and (max(nums) <= 13)):
return False
expr = expr.replace(' ', '')
digits = ''
for i in range(len(expr)):
if i == 0 or expr[i - 1] in '+*-/(':
if not expr[i] in '123456789(':
return False
... | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"expr\": \"((3)/(7)+3)*(7)\", \"nums\": [3, 7, 3, 7]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"expr\": \"1+13+3+7\", \"nums\": [1, 3, 7, 13]}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"expr\": \"(10)*(3)+1-(7)\", \"nums\": [10, 7, 3, 1]}}, {... |
46 | TP3/classic_puzzles.Easy63 | C++ | Verifies that the inputs satisfy the problem:
Find a formula using two 8s and two 1's and -+\*\/ that evaluates to 1. | /**
* Verifies that the inputs satisfy the problem:
* Find a formula using two 8s and two 1's and -+\\*\\/ that evaluates to 1.
*/
bool sat(string s) { | bool sat(string s) { | [
"s"
] | def sat(s: str):
return set(s) <= set('18-+*/') and s.count('8') == 2 and (s.count('1') == 1) and (eval(s) == 63) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"8*8-1\"}}, {\"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 ... |
47 | TP3/classic_puzzles.Harder63 | C++ | Verifies that the inputs satisfy the problem:
Find an expression using two 8s and two 1's and -+\*\/ that evaluates to 1. | /**
* Verifies that the inputs satisfy the problem:
* Find an expression using two 8s and two 1's and -+\\*\\/ that evaluates to 1.
*/
bool sat(string s) { | bool sat(string s) { | [
"s"
] | def sat(s: str):
return set(s) <= set('18-+*/') and s.count('8') == 3 and (s.count('1') == 1) and (eval(s) == 63) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"8*8-1**8\"}}, {\"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#inclu... |
48 | TP3/classic_puzzles.WaterPouring | C++ | Verifies that the inputs satisfy the problem:
Given an initial state of water quantities in jugs and jug capacities, find a sequence of moves (pouring
one jug into another until it is full or the first is empty) to reaches the given goal state.
moves is vector of [from, to] pairs | /**
* Verifies that the inputs satisfy the problem:
* Given an initial state of water quantities in jugs and jug capacities, find a sequence of moves (pouring
* one jug into another until it is full or the first is empty) to reaches the given goal state.
* moves is vector of [from, to] pairs
*/
bool sat(vector<vec... | bool sat(vector<vector<int>> moves, vector<int> capacities, vector<int> init, vector<int> goal) { | [
"moves",
"capacities",
"init",
"goal"
] | def sat(moves: List[List[int]], capacities, init, goal):
state = init.copy()
for [i, j] in moves:
if not min(i, j) >= 0:
return False
if not i != j:
return False
n = min(capacities[j], state[i] + state[j])
(state[i], state[j]) = (state[i] + state[j] - n, n... | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"moves\": [[0, 1], [1, 2], [2, 0], [1, 2], [0, 1], [1, 2], [2, 0]], \"capacities\": [8, 5, 3], \"init\": [8, 0, 0], \"goal\": [4, 4, 0]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"moves\": [[2, 1], [1, 0], [2, 1], [1, 0], [2, 1], [1, 0], [2, 1], [1,... |
49 | TP3/classic_puzzles.VerbalArithmetic | C++ | Verifies that the inputs satisfy the problem:
Find vector of integers corresponding to the given vector of strings substituting a different digit for each
character, so that the last string corresponds to the sum of the previous numbers. | /**
* Verifies that the inputs satisfy the problem:
* Find vector of integers corresponding to the given vector of strings substituting a different digit for each
* character, so that the last string corresponds to the sum of the previous numbers.
*/
bool sat(vector<int> li, vector<string> words) { | bool sat(vector<int> li, vector<string> words) { | [
"li",
"words"
] | def sat(li: List[int], words):
if not (len(li) == len(words) and all((i > 0 and len(str(i)) == len(w) for (i, w) in zip(li, words)))):
return False
if not len({c for w in words for c in w}) == len({(d, c) for (i, w) in zip(li, words) for (d, c) in zip(str(i), w)}):
return False
return sum(li... | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [9567, 1085, 10652], \"words\": [\"SEND\", \"MORE\", \"MONEY\"]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"li\": [29786, 850, 850, 31486], \"words\": [\"FORTY\", \"TEN\", \"TEN\", \"SIXTY\"]}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"... |
50 | TP3/classic_puzzles.SlidingPuzzle | C++ | Verifies that the inputs satisfy the problem:
In this puzzle, you are given a board like:
1 2 5
3 4 0
6 7 8
and your goal is to transform it to:
0 1 2
3 4 5
6 7 8
by a sequence of swaps with the 0 square (0 indicates blank). The starting configuration is given by a 2d list
of vectors and the answer is represented by ve... | /**
* Verifies that the inputs satisfy the problem:
* In this puzzle, you are given a board like:
* 1 2 5
* 3 4 0
* 6 7 8
* and your goal is to transform it to:
* 0 1 2
* 3 4 5
* 6 7 8
* by a sequence of swaps with the 0 square (0 indicates blank). The starting configuration is given by a 2d list
* of vector... | bool sat(vector<int> moves, vector<vector<int>> start) { | [
"moves",
"start"
] | def sat(moves: List[int], start):
locs = {i: [x, y] for (y, row) in enumerate(start) for (x, i) in enumerate(row)}
for i in moves:
if not abs(locs[0][0] - locs[i][0]) + abs(locs[0][1] - locs[i][1]) == 1:
return False
(locs[0], locs[i]) = (locs[i], locs[0])
return all((locs[i] == ... | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"moves\": [5, 1, 4, 12, 13, 14, 8, 10, 14, 13, 12, 8, 9, 5, 1], \"start\": [[5, 0, 2, 3], [1, 9, 6, 7], [4, 14, 8, 11], [12, 13, 10, 15]]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"moves\": [5, 2, 4, 7, 8, 5, 2, 1], \"start\": [[1, 5, 0], [3, 2, 8]... |
51 | TP3/human_eval.FindCloseElements | C++ | Verifies that the inputs satisfy the problem:
Given vector of numbers, find the two closest distinct numbers in the vector.
Sample Input:
[1.2, 5.23, 0.89, 21.0, 5.28, 1.2]
Sample Output:
[5.23, 5.28] | /**
* Verifies that the inputs satisfy the problem:
* Given vector of numbers, find the two closest distinct numbers in the vector.
* Sample Input:
* [1.2, 5.23, 0.89, 21.0, 5.28, 1.2]
* Sample Output:
* [5.23, 5.28]
*/
bool sat(vector<double> pair, vector<double> nums) { | bool sat(vector<double> pair, vector<double> nums) { | [
"pair",
"nums"
] | def sat(pair: List[float], nums):
(a, b) = pair
if not (a in nums and b in nums and (a != b)):
return False
return abs(a - b) == min((x - y for x in nums for y in nums if x > y)) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"pair\": [4.99, 5.0], \"nums\": [0.17, 21.3, 5.0, 9.0, 11.0, 4.99, 17.0, 17.0, 12.4, 6.8]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"pair\": [-6.773598672960938, -6.642297851887924], \"nums\": [-3.027185809375565, -6.642297851887924, -6.77359867296... |
52 | TP3/human_eval.SeparateParenGroups | C++ | Verifies that the inputs satisfy the problem:
Given a string consisting of whitespace and groups of matched parentheses, split it
into groups of perfectly matched parentheses without any whitespace.
Sample Input:
'( ()) ((()()())) (()) ()'
Sample Output:
['(())', '((()()()))', '(())', '()'] | /**
* Verifies that the inputs satisfy the problem:
* Given a string consisting of whitespace and groups of matched parentheses, split it
* into groups of perfectly matched parentheses without any whitespace.
* Sample Input:
* '( ()) ((()()())) (()) ()'
* Sample Output:
* ['(())', '((()()()))', '(())', '()']
*/... | bool sat(vector<string> ls, string combined) { | [
"ls",
"combined"
] | def sat(ls: List[str], combined):
for s in ls:
if not s.count('(') == s.count(')'):
return False
if not all((s[:i].count('(') > s[:i].count(')') for i in range(1, len(s)))):
return False
return ''.join(ls) == combined.replace(' ', '') | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ls\": [\"()\", \"(())\", \"((()()()))\", \"(())\"], \"combined\": \"() (()) ((() () ())) (() )\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"ls\": [\"()\", \"()\"], \"combined\": \"() () \"}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"ls\": [... |
53 | TP3/human_eval.Frac | C++ | Verifies that the inputs satisfy the problem:
Given a floating point number, find its fractional part.
Sample Input:
4.175
Sample Output:
0.175 | /**
* Verifies that the inputs satisfy the problem:
* Given a floating point number, find its fractional part.
* Sample Input:
* 4.175
* Sample Output:
* 0.175
*/
bool sat(double x, double v) { | bool sat(double x, double v) { | [
"x",
"v"
] | def sat(x: float, v):
return 0 <= x < 1 and (v - x).is_integer() | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": 0.1289199999999937, \"v\": 523.12892}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": 0.8607091710264854, \"v\": 93.86070917102649}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"x\": 0.22976286188466588, \"v\": -6.770237138115334}}, {\"idx\... |
54 | TP3/human_eval.FirstNegCumulative | C++ | Verifies that the inputs satisfy the problem:
Given vector of numbers which represent bank deposits and withdrawals, find the *first* negative balance.
Sample Input:
[[12, -5, 3, -99, 14, 88, -99], [-1, 2, 5]]
Sample Output:
[-89, -1] | /**
* Verifies that the inputs satisfy the problem:
* Given vector of numbers which represent bank deposits and withdrawals, find the *first* negative balance.
* Sample Input:
* [[12, -5, 3, -99, 14, 88, -99], [-1, 2, 5]]
* Sample Output:
* [-89, -1]
*/
bool sat(vector<long long> firsts, vector<vector<long long>... | bool sat(vector<long long> firsts, vector<vector<long long>> balances) { | [
"firsts",
"balances"
] | def sat(firsts: List[int], balances):
for (i, bals) in enumerate(balances):
total = 0
for b in bals:
total += b
if total < 0:
if not total == firsts[i]:
return False
break
return True | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"firsts\": [-1, -10, -101, -1], \"balances\": [[2, 7, -2, 4, 3, -15, 10, -45, 3], [3, 4, -17, -1], [100, -100, -101], [-1]]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"firsts\": [-1500518832, -922459571, -5581999780, -1496460602, -391376505, -102687... |
55 | TP3/human_eval.MinSquaredDeviation | C++ | Verifies that the inputs satisfy the problem:
Given vector of numbers, find x that minimizes mean squared deviation.
Sample Input:
[4, -5, 17, -9, 14, 108, -9]
Sample Output:
17.14285 | /**
* Verifies that the inputs satisfy the problem:
* Given vector of numbers, find x that minimizes mean squared deviation.
* Sample Input:
* [4, -5, 17, -9, 14, 108, -9]
* Sample Output:
* 17.14285
*/
bool sat(double x, vector<int> nums) { | bool sat(double x, vector<int> nums) { | [
"x",
"nums"
] | def sat(x: float, nums):
return sum(((n - x) ** 2 for n in nums)) * len(nums) <= sum(((m - n) ** 2 for m in nums for n in nums)) * 0.5 + 0.0001 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": 1.1111111111111112, \"nums\": [12, -2, 14, 3, -15, 10, -45, 3, 30]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": -12.75, \"nums\": [-47, -58, -46, -29, 48, -7, 85, -48]}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"x\": 8.6, \"nums\": [... |
56 | TP3/human_eval.Intersperse | C++ | Verifies that the inputs satisfy the problem:
Given vector of numbers and a number to inject, create vector containing that number in between each pair of
adjacent numbers.
Sample Input:
[8, 14, 21, 17, 9, -5], 3
Sample Output:
[8, 3, 14, 3, 21, 3, 17, 3, 9, 3, -5] | /**
* Verifies that the inputs satisfy the problem:
* Given vector of numbers and a number to inject, create vector containing that number in between each pair of
* adjacent numbers.
* Sample Input:
* [8, 14, 21, 17, 9, -5], 3
* Sample Output:
* [8, 3, 14, 3, 21, 3, 17, 3, 9, 3, -5]
*/
bool sat(vector<int> li, ... | bool sat(vector<int> li, vector<int> nums, int sep) { | [
"li",
"nums",
"sep"
] | def sat(li: List[int], nums, sep):
return li[::2] == nums and li[1::2] == [sep] * (len(nums) - 1) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [12, 4, 23, 4, -2, 4, 5, 4, 0], \"nums\": [12, 23, -2, 5, 0], \"sep\": 4}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"li\": [], \"nums\": [], \"sep\": 23}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"li\": [90, 14, 23, 14, 0, 14, 0, 14, 36... |
57 | TP3/human_eval.DeepestParens | C++ | Verifies that the inputs satisfy the problem:
Given a string consisting of groups of matched nested parentheses separated by parentheses,
compute the depth of each group.
Sample Input:
'(()) ((()()())) (()) ()'
Sample Output:
[2, 3, 2, 1] | /**
* Verifies that the inputs satisfy the problem:
* Given a string consisting of groups of matched nested parentheses separated by parentheses,
* compute the depth of each group.
* Sample Input:
* '(()) ((()()())) (()) ()'
* Sample Output:
* [2, 3, 2, 1]
*/
bool sat(vector<int> depths, string parens) { | bool sat(vector<int> depths, string parens) { | [
"depths",
"parens"
] | def sat(depths: List[int], parens):
groups = parens.split()
for (depth, group) in zip(depths, groups):
budget = depth
success = False
for c in group:
if c == '(':
budget -= 1
if budget == 0:
success = True
if... | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"depths\": [1, 2, 3, 8], \"parens\": \"() (()) ((()()())) (((((((())))))))\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"depths\": [], \"parens\": \"\"}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"depths\": [2, 7], \"parens\": \"(()) (((()(((()... |
58 | TP3/human_eval.FindContainers | C++ | Verifies that the inputs satisfy the problem:
Find the strings in vector containing a given substring
Sample Input:
['cat', 'dog', 'bear'], 'a'
Sample Output:
['cat', 'bear'] | /**
* Verifies that the inputs satisfy the problem:
* Find the strings in vector containing a given substring
* Sample Input:
* ['cat', 'dog', 'bear'], 'a'
* Sample Output:
* ['cat', 'bear']
*/
bool sat(vector<string> containers, vector<string> strings, string substring) { | bool sat(vector<string> containers, vector<string> strings, string substring) { | [
"containers",
"strings",
"substring"
] | def sat(containers: List[str], strings, substring):
i = 0
for s in strings:
if substring in s:
if not containers[i] == s:
return False
i += 1
return i == len(containers) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"containers\": [\"cat\", \"shatter\", \"at\"], \"strings\": [\"cat\", \"dog\", \"shatter\", \"bear\", \"at\", \"ta\"], \"substring\": \"at\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"containers\": [\"jsesnicy\"], \"strings\": [\"ty\", \"jy\", \"js... |
59 | TP3/human_eval.SumProduct | C++ | Verifies that the inputs satisfy the problem:
Find vector of numbers with a given sum and a given product.
Sample Input:
12, 32
Sample Output:
[2, 8, 2] | /**
* Verifies that the inputs satisfy the problem:
* Find vector of numbers with a given sum and a given product.
* Sample Input:
* 12, 32
* Sample Output:
* [2, 8, 2]
*/
bool sat(vector<int> nums, int tot, int prod) { | bool sat(vector<int> nums, int tot, int prod) { | [
"nums",
"tot",
"prod"
] | def sat(nums: List[int], tot, prod):
if not sum(nums) == tot:
return False
p = 1
for n in nums:
p *= n
return p == prod | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"nums\": [99, -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, -... |
60 | TP3/human_eval.RollingMax | C++ | Verifies that the inputs satisfy the problem:
Find vector whose ith element is the maximum of the first i elements of the input vector.
Sample Input:
[2, 8, 2]
Sample Output:
[2, 8, 8] | /**
* Verifies that the inputs satisfy the problem:
* Find vector whose ith element is the maximum of the first i elements of the input vector.
* Sample Input:
* [2, 8, 2]
* Sample Output:
* [2, 8, 8]
*/
bool sat(vector<int> maxes, vector<int> nums) { | bool sat(vector<int> maxes, vector<int> nums) { | [
"maxes",
"nums"
] | def sat(maxes: List[int], nums):
if not len(maxes) == len(nums):
return False
for i in range(len(nums)):
if i > 0:
if not maxes[i] == max(maxes[i - 1], nums[i]):
return False
elif not maxes[0] == nums[0]:
return False
return True | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"maxes\": [1, 4, 4, 4, 19], \"nums\": [1, 4, 3, -6, 19]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"maxes\": [-15, -6], \"nums\": [-15, -6]}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"maxes\": [], \"nums\": []}}, {\"idx\": 3, \"outputs\": true... |
61 | TP3/human_eval.PalindromeContaining | C++ | Verifies that the inputs satisfy the problem:
Find a palindrome of a given length containing a given string.
Sample Input:
"abba", 6
Sample Output:
"cabbac" | /**
* Verifies that the inputs satisfy the problem:
* Find a palindrome of a given length containing a given string.
* Sample Input:
* "abba", 6
* Sample Output:
* "cabbac"
*/
bool sat(string ans, string s, int length_arg2) { | bool sat(string ans, string s, int length_arg2) { | [
"ans",
"s",
"length_arg2"
] | def sat(ans: str, s, length_arg2):
return ans == ans[::-1] and len(ans) == length_arg2 and (s in ans) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ans\": \"so easyxxxxxxysae os\", \"s\": \"so easy\", \"length_arg2\": 20}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"ans\": \"aabbabbabbaa\", \"s\": \"aabbab\", \"length_arg2\": 12}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"ans\": \"bbbxxxxx... |
62 | TP3/human_eval.BinaryStrXOR | C++ | Verifies that the inputs satisfy the problem:
Find a the XOR of two given strings interpreted as binary numbers.
Sample Input:
"0001", "1011"
Sample Output:
"1010" | /**
* Verifies that the inputs satisfy the problem:
* Find a the XOR of two given strings interpreted as binary numbers.
* Sample Input:
* "0001", "1011"
* Sample Output:
* "1010"
*/
bool sat(string str_num, vector<string> nums) { | bool sat(string str_num, vector<string> nums) { | [
"str_num",
"nums"
] | def sat(str_num: str, nums):
(a, b) = nums
return int(str_num, 2) == int(a, 2) ^ int(b, 2) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"str_num\": \"110001001111\", \"nums\": [\"100011101100001\", \"100101100101110\"]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"str_num\": \"1110100011\", \"nums\": [\"1101101111\", \"11001100\"]}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"str_... |
63 | TP3/human_eval.LongestStr | C++ | Verifies that the inputs satisfy the problem:
Find the longest of vector of strings
Sample Input:
["cat", "dog", "sheep", "chimp"]
Sample Output:
"sheep" | /**
* Verifies that the inputs satisfy the problem:
* Find the longest of vector of strings
* Sample Input:
* ["cat", "dog", "sheep", "chimp"]
* Sample Output:
* "sheep"
*/
bool sat(string ans, vector<string> words) { | bool sat(string ans, vector<string> words) { | [
"ans",
"words"
] | def sat(ans: str, words):
return ans in words and all((len(ans) >= len(w) for w in words)) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ans\": \"pretty\", \"words\": [\"these\", \"are\", \"some\", \"pretty\", \"long\", \"words\"]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"ans\": \"zetenejubichicyj\", \"words\": [\"suquojurethy\", \"zetenejubichicyj\", \"dyzeroquyxipyfe\"]}}, {\"id... |
64 | TP3/human_eval.CertifiedGCD | C++ | Verifies that the inputs satisfy the problem:
Find the greatest common divisor of two integers m, n and a certificate a, b such that m*a + n*b = gcd
Sample Input:
20, 30
Sample Output:
10, -1, 1 | /**
* Verifies that the inputs satisfy the problem:
* Find the greatest common divisor of two integers m, n and a certificate a, b such that m*a + n*b = gcd
* Sample Input:
* 20, 30
* Sample Output:
* 10, -1, 1
*/
bool sat(vector<int> ans, long long m, long long n) { | bool sat(vector<int> ans, long long m, long long n) { | [
"ans",
"m",
"n"
] | def sat(ans: List[int], m, n):
(gcd, a, b) = ans
return m % gcd == n % gcd == 0 and a * m + b * n == gcd and (gcd > 0) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ans\": [35021, -1, 3], \"m\": 200004931, \"n\": 66679984}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"ans\": [2, -18930, 60347], \"m\": 2642408, \"n\": 828886}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"ans\": [846, -1716856, 3], \"m\": 184428... |
65 | TP3/human_eval.AllPrefixes | C++ | Verifies that the inputs satisfy the problem:
Find all prefixes of a given string
Sample Input:
"aabcd"
Sample Output:
["", "a", "aa", "aab", "aabc", "aabcd"] | /**
* Verifies that the inputs satisfy the problem:
* Find all prefixes of a given string
* Sample Input:
* "aabcd"
* Sample Output:
* ["", "a", "aa", "aab", "aabc", "aabcd"]
*/
bool sat(vector<string> prefixes, string s) { | bool sat(vector<string> prefixes, string s) { | [
"prefixes",
"s"
] | def sat(prefixes: List[str], s):
return all((s.startswith(p) for p in prefixes)) and len(set(prefixes)) > len(s) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"prefixes\": [\"\", \"d\", \"do\", \"don\", \"done\", \"dones\", \"donese\", \"donesez\", \"donesezi\", \"donesezic\", \"donesezich\", \"doneseziche\", \"donesezichet\", \"donesezicheth\", \"donesezichetho\", \"donesezichethof\", \"donesezichethofa\", \"d... |
66 | TP3/human_eval.SpaceyRange | C++ | Verifies that the inputs satisfy the problem:
Find a string consisting of the non-negative integers up to n inclusive
Sample Input:
4
Sample Output:
'0 1 2 3 4' | /**
* Verifies that the inputs satisfy the problem:
* Find a string consisting of the non-negative integers up to n inclusive
* Sample Input:
* 4
* Sample Output:
* '0 1 2 3 4'
*/
bool sat(string ans, int n) { | bool sat(string ans, int n) { | [
"ans",
"n"
] | def sat(ans: str, n):
return [int(i) for i in ans.split(' ')] == list(range(n + 1)) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ans\": \"0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\", \"n\": 15}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"ans\": \"0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 4... |
67 | TP3/human_eval.DistinctChars | C++ | Verifies that the inputs satisfy the problem:
Find the set of distinct characters in a string, ignoring case
Sample Input:
'HELlo', 4
Sample Output:
['h', 'e', 'l', 'o'] | /**
* Verifies that the inputs satisfy the problem:
* Find the set of distinct characters in a string, ignoring case
* Sample Input:
* 'HELlo', 4
* Sample Output:
* ['h', 'e', 'l', 'o']
*/
bool sat(vector<string> ans, string s, int n) { | bool sat(vector<string> ans, string s, int n) { | [
"ans",
"s",
"n"
] | def sat(ans: List[str], s, n):
if not all((ans.count(c.lower()) == 1 for c in s)):
return False
if not all((c == c.lower() for c in ans)):
return False
if not all((c in s.lower() for c in ans)):
return False
return True | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ans\": [\"d\", \"i\", \" \", \"o\", \"m\", \"q\", \"h\", \"e\", \"v\", \"c\", \"!\", \"s\", \"u\", \"f\", \"p\", \"j\", \"x\", \"w\", \"b\", \"g\", \"y\", \"r\", \"t\", \"n\", \"l\", \"a\", \"z\", \"k\"], \"s\": \"The quick brown fox jumps over the lazy ... |
68 | TP3/human_eval.ParseMusic | C++ | Verifies that the inputs satisfy the problem:
Parse a string of notes to beats, 'o'=4, 'o|'=2, '.|'=1
Example input:
'o o .| o|'
Example output:
[4, 4, 1, 2] | /**
* Verifies that the inputs satisfy the problem:
* Parse a string of notes to beats, 'o'=4, 'o|'=2, '.|'=1
* Example input:
* 'o o .| o|'
* Example output:
* [4, 4, 1, 2]
*/
bool sat(vector<int> beats, string score) { | bool sat(vector<int> beats, string score) { | [
"beats",
"score"
] | def sat(beats: List[int], score):
return ' '.join(({1: '.|', 2: 'o|', 4: 'o'}[b] for b in beats)) == score | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"beats\": [4, 4, 2, 2, 1, 1, 1, 2, 2, 4, 4, 2, 1], \"score\": \"o o o| o| .| .| .| o| o| o o o| .|\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"beats\": [1, 4, 1, 2, 2, 2, 2, 1, 4, 4], \"score\": \".| o .| o| o| o| o| .| o o\"}}, {\"idx\": 2, \"out... |
69 | TP3/human_eval.OverlappingCount | C++ | Verifies that the inputs satisfy the problem:
Find occurrences of a substring in a parent string *including overlaps*
Sample Input:
'helllo', 'll'
Sample Output:
[2, 3] | /**
* Verifies that the inputs satisfy the problem:
* Find occurrences of a substring in a parent string *including overlaps*
* Sample Input:
* 'helllo', 'll'
* Sample Output:
* [2, 3]
*/
bool sat(vector<int> ans, string s, string sub, int count) { | bool sat(vector<int> ans, string s, string sub, int count) { | [
"ans",
"s",
"sub",
"count"
] | def sat(ans: List[int], s, sub, count):
return all((sub == s[i:i + len(sub)] and i >= 0 for i in ans)) and len(set(ans)) >= count | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ans\": [1, 3, 17, 19, 21, 23, 25], \"s\": \"Bananannanaannanaanananananana\", \"sub\": \"anan\", \"count\": 7}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"ans\": [53], \"s\": \"halidykugadobezebothidububawuvejiquitextyrequamobythynethojahyquutatexto... |
70 | TP3/human_eval.SortNumbers | C++ | Verifies that the inputs satisfy the problem:
Sort numbers based on strings
Sample input
---
"six one four"
Sample output
---
"one four six" | /**
* Verifies that the inputs satisfy the problem:
* Sort numbers based on strings
* Sample input
* ---
* "six one four"
* Sample output
* ---
* "one four six"
*/
bool sat(string ans, string s) { | bool sat(string ans, string s) { | [
"ans",
"s"
] | def sat(ans: str, s):
nums = 'zero one two three four five six seven eight nine'.split()
return [nums.index(x) for x in ans.split(' ')] == sorted([nums.index(x) for x in s.split(' ')]) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ans\": \"one two three four six eight nine\", \"s\": \"six one four three two nine eight\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"ans\": \"zero two four six six eight nine nine\", \"s\": \"nine two four nine zero six six eight\"}}, {\"idx\": 2... |
71 | TP3/human_eval.FindClosePair | C++ | Verifies that the inputs satisfy the problem:
Given vector of numbers, find the indices of the closest pair.
Sample Input:
[1.2, 5.25, 0.89, 21.0, 5.23]
Sample Output:
[4, 1] | /**
* Verifies that the inputs satisfy the problem:
* Given vector of numbers, find the indices of the closest pair.
* Sample Input:
* [1.2, 5.25, 0.89, 21.0, 5.23]
* Sample Output:
* [4, 1]
*/
bool sat(vector<int> inds, vector<double> nums) { | bool sat(vector<int> inds, vector<double> nums) { | [
"inds",
"nums"
] | def sat(inds: List[int], nums):
(a, b) = inds
if not (a != b and a >= 0 and (b >= 0)):
return False
for i in range(len(nums)):
for j in range(i):
if not abs(nums[i] - nums[j]) >= abs(nums[b] - nums[a]):
return False
return True | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"inds\": [5, 2], \"nums\": [0.31, 21.3, 5.0, 9.0, 11.0, 5.01, 17.2]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"inds\": [4, 1], \"nums\": [-7.587461542549912, 0.7494004368541578, 2.0142388071411013, -1.552072793834526, 0.44845194836415025]}}, {\"idx... |
72 | TP3/human_eval.Rescale | C++ | Verifies that the inputs satisfy the problem:
Rescale and shift numbers so that they cover the range [0, 1]
Sample input
---
[18.5, 17.0, 18.0, 19.0, 18.0]
Sample output
---
[0.75, 0.0, 0.5, 1.0, 0.5] | /**
* Verifies that the inputs satisfy the problem:
* Rescale and shift numbers so that they cover the range [0, 1]
* Sample input
* ---
* [18.5, 17.0, 18.0, 19.0, 18.0]
* Sample output
* ---
* [0.75, 0.0, 0.5, 1.0, 0.5]
*/
bool sat(vector<double> ans, vector<double> nums) { | bool sat(vector<double> ans, vector<double> nums) { | [
"ans",
"nums"
] | def sat(ans: List[float], nums):
if not (min(ans) == 0.0 and max(ans) == 1.0):
return False
a = min(nums)
b = max(nums)
for i in range(len(nums)):
x = a + (b - a) * ans[i]
if not abs(nums[i] - x) < 1e-06:
return False
return True | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ans\": [0.7155049786628734, 1.0, 1.0, 0.8933143669985776, 0.0], \"nums\": [13.0, 17.0, 17.0, 15.5, 2.94]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"ans\": [0.0, 1.0, 1.0], \"nums\": [939.7119884829771, 939.7119884829771, 939.7119884829771]}}, {\"i... |
73 | TP3/human_eval.FilterInts | C++ | Verifies that the inputs satisfy the problem:
Find vector of strings where the only valid integers are at the given indices
Sample input
---
[2, 4, 5]
Sample output
---
["cat", "2.7", "2", "", "3", "-17", "free"] | /**
* Verifies that the inputs satisfy the problem:
* Find vector of strings where the only valid integers are at the given indices
* Sample input
* ---
* [2, 4, 5]
* Sample output
* ---
* ["cat", "2.7", "2", "", "3", "-17", "free"]
*/
bool sat(vector<string> candidates, vector<int> int_indices) { | bool sat(vector<string> candidates, vector<int> int_indices) { | [
"candidates",
"int_indices"
] | def sat(candidates: List[str], int_indices):
for i in int_indices:
int(candidates[i])
for (i, s) in enumerate(candidates):
if i not in int_indices:
try:
int(s)
return False
except ValueError:
pass
return True | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"candidates\": [\"\", \"\", \"17\", \"\", \"17\", \"\", \"\", \"17\", \"\", \"17\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\... |
74 | TP3/human_eval.StrLength | C++ | Verifies that the inputs satisfy the problem:
Find the lengths of vector of non-empty strings
Sample input
---
["foo", "bars"]
Sample output
---
[3, 4] | /**
* Verifies that the inputs satisfy the problem:
* Find the lengths of vector of non-empty strings
* Sample input
* ---
* ["foo", "bars"]
* Sample output
* ---
* [3, 4]
*/
bool sat(vector<int> lengths, vector<string> strs) { | bool sat(vector<int> lengths, vector<string> strs) { | [
"lengths",
"strs"
] | def sat(lengths: List[int], strs):
for (length, s) in zip(lengths, strs):
try:
s[length]
return False
except IndexError:
s[length - 1]
return len(lengths) == len(strs) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"lengths\": [45, 1, 3, 3], \"strs\": [\"pneumonoultramicroscopicsilicovolcanoconiosis\", \" \", \"foo\", \"2.5\"]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"lengths\": [2, 10, 7, 33, 39, 25, 13, 14, 35, 31], \"strs\": [\"=i\", \"&?Jq 2aNHt\", \"?uC... |
75 | TP3/human_eval.LargestDivisor | C++ | Verifies that the inputs satisfy the problem:
Find the largest integer divisor of a number n that is less than n
Sample input
---
1000
Sample output
---
500 | /**
* Verifies that the inputs satisfy the problem:
* Find the largest integer divisor of a number n that is less than n
* Sample input
* ---
* 1000
* Sample output
* ---
* 500
*/
bool sat(int d, int n) { | bool sat(int d, int n) { | [
"d",
"n"
] | def sat(d: int, n):
return n % d == 0 and d < n and all((n % e for e in range(d + 1, n))) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"d\": 61728, \"n\": 123456}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"d\": 8918, \"n\": 17836}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"d\": 23931, \"n\": 71793}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"d\": 7733, \"n\": 15466}}, {\... |
76 | TP3/human_eval.PrimeFactorization | C++ | Verifies that the inputs satisfy the problem:
Factor number n into a given number of non-trivial factors
Sample input
---
1000, 6
Sample output
---
[2, 2, 2, 5, 5, 5] | /**
* Verifies that the inputs satisfy the problem:
* Factor number n into a given number of non-trivial factors
* Sample input
* ---
* 1000, 6
* Sample output
* ---
* [2, 2, 2, 5, 5, 5]
*/
bool sat(vector<int> factors, long long n, int num_factors) { | bool sat(vector<int> factors, long long n, int num_factors) { | [
"factors",
"n",
"num_factors"
] | def sat(factors: List[int], n, num_factors):
if not len(factors) == num_factors:
return False
prod = 1
for d in factors:
prod *= d
if not d > 1:
return False
return prod == n | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"factors\": [2, 2, 2, 2, 2, 2, 3, 643], \"n\": 123456, \"num_factors\": 8}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"factors\": [2, 5, 7, 11, 37, 47], \"n\": 1339030, \"num_factors\": 6}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"factors\": [... |
77 | TP3/human_eval.Dedup | C++ | Verifies that the inputs satisfy the problem:
Remove duplicates from vector of integers, preserving order
Sample input
---
[1, 3, 2, 9, 2, 1, 55]
Sample output
---
[1, 3, 2, 9, 55] | /**
* Verifies that the inputs satisfy the problem:
* Remove duplicates from vector of integers, preserving order
* Sample input
* ---
* [1, 3, 2, 9, 2, 1, 55]
* Sample output
* ---
* [1, 3, 2, 9, 55]
*/
bool sat(vector<int> ans, vector<int> li) { | bool sat(vector<int> ans, vector<int> li) { | [
"ans",
"li"
] | def sat(ans: List[int], li):
return set(ans) == set(li) and all((li.index(ans[i]) < li.index(ans[i + 1]) for i in range(len(ans) - 1))) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ans\": [2, 19, 53, 1, 44, 17, 0, 31], \"li\": [2, 19, 2, 53, 1, 1, 2, 44, 17, 0, 19, 31]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"ans\": [3, 7, 9, 2, 4, 1], \"li\": [3, 3, 7, 9, 7, 2, 9, 4, 1]}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"an... |
78 | TP3/human_eval.FlipCase | C++ | Verifies that the inputs satisfy the problem:
Flip case
Sample input
---
'cAt'
Sample output
---
'CaT' | /**
* Verifies that the inputs satisfy the problem:
* Flip case
* Sample input
* ---
* 'cAt'
* Sample output
* ---
* 'CaT'
*/
bool sat(string ans, string s) { | bool sat(string ans, string s) { | [
"ans",
"s"
] | def sat(ans: str, s):
return len(ans) == len(s) and all(({c, d} == {d.upper(), d.lower()} for (c, d) in zip(ans, s))) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ans\": \"fLiP me!\", \"s\": \"FlIp ME!\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"ans\": \"Mkc(k2.A!z|>SV3IZc3!\", \"s\": \"mKC(K2.a!Z|>sv3izC3!\"}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"ans\": \"k A&3 Te 1Tsg b3V3Y(\", \"s\": \"K a&3 ... |
79 | TP3/human_eval.CatStrings | C++ | Verifies that the inputs satisfy the problem:
Concatenate vector of strings
Sample input
---
['cat', 'dog', 'bird']
Sample output
---
'catdogbird' | /**
* Verifies that the inputs satisfy the problem:
* Concatenate vector of strings
* Sample input
* ---
* ['cat', 'dog', 'bird']
* Sample output
* ---
* 'catdogbird'
*/
bool sat(string cat, vector<string> strings) { | bool sat(string cat, vector<string> strings) { | [
"cat",
"strings"
] | def sat(cat: str, strings):
i = 0
for s in strings:
for c in s:
if not cat[i] == c:
return False
i += 1
return i == len(cat) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"cat\": \"WilliamNowhere\", \"strings\": [\"Will\", \"i\", \"am\", \"Now\", \"here\"]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"cat\": \"dufekeretkothihisedatextumuvapesicelynyzysukydewzukathubaki\", \"strings\": [\"dufe\", \"keret\", \"kothihised... |
80 | TP3/human_eval.FindExtensions | C++ | Verifies that the inputs satisfy the problem:
Find the strings in vector starting with a given prefix
Sample Input:
['cat', 'car', 'fear', 'center'], 'ca'
Sample Output:
['cat', 'car'] | /**
* Verifies that the inputs satisfy the problem:
* Find the strings in vector starting with a given prefix
* Sample Input:
* ['cat', 'car', 'fear', 'center'], 'ca'
* Sample Output:
* ['cat', 'car']
*/
bool sat(vector<string> extensions, vector<string> strings, string prefix) { | bool sat(vector<string> extensions, vector<string> strings, string prefix) { | [
"extensions",
"strings",
"prefix"
] | def sat(extensions: List[str], strings, prefix):
i = 0
for s in strings:
if s.startswith(prefix):
if not extensions[i] == s:
return False
i += 1
return i == len(extensions) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"extensions\": [\"dog\", \"donut\"], \"strings\": [\"cat\", \"dog\", \"shatter\", \"donut\", \"at\", \"todo\"], \"prefix\": \"do\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"extensions\": [], \"strings\": [\"cot\", \"z\"], \"prefix\": \"ca\"}}, {\"... |
81 | TP3/human_eval.FindPositives | C++ | Verifies that the inputs satisfy the problem:
Find the positive integers in a list
Sample Input:
[-1, 3, 19, -2, 0, 44, 0, 44, 11]
Sample Output:
[3, 19, 44, 44, 11] | /**
* Verifies that the inputs satisfy the problem:
* Find the positive integers in a list
* Sample Input:
* [-1, 3, 19, -2, 0, 44, 0, 44, 11]
* Sample Output:
* [3, 19, 44, 44, 11]
*/
bool sat(vector<int> positives, vector<int> nums) { | bool sat(vector<int> positives, vector<int> nums) { | [
"positives",
"nums"
] | def sat(positives: List[int], nums):
stack = positives[::-1]
for n in nums:
if not (n <= 0 or n == stack.pop()):
return False
return stack == [] | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"positives\": [2, 2342, 32, 2342, 44, 11], \"nums\": [2, 2342, -2, 32, -8, -5, 2342, 0, -9, 44, 11]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"positives\": [53, 33, 73, 47, 35, 24, 56, 89, 85], \"nums\": [53, 33, 73, 47, 35, 24, 56, 89, 85]}}, {\"i... |
82 | TP3/human_eval.FermatComposites | C++ | Verifies that the inputs satisfy the problem:
Find Fermat composite certificates for vector of numbers > 1
Sample Input:
[1469]
Sample Output:
[3] # because (3 ** 1468) % 1469 != 1 | /**
* Verifies that the inputs satisfy the problem:
* Find Fermat composite certificates for vector of numbers > 1
* Sample Input:
* [1469]
* Sample Output:
* [3] # because (3 ** 1468) % 1469 != 1
*/
bool sat(vector<int> certificates, vector<long long> nums) { | bool sat(vector<int> certificates, vector<long long> nums) { | [
"certificates",
"nums"
] | def sat(certificates: List[int], nums):
return all((pow(cert, n - 1, n) > 1 for (cert, n) in zip(certificates, nums))) and len(certificates) == len(nums) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"certificates\": [2, 2, 2, 2, 2], \"nums\": [1449, 14, 21, 105, 217]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"certificates\": [2, 2, 2, 2, 2, 2, 2, 2, 2], \"nums\": [2299290630, 2051931473, 1592080723, 533977507, 6381433197, 6645010323, 559035993... |
83 | TP3/human_eval.OddDegreePolynomialRoot | C++ | Verifies that the inputs satisfy the problem:
Find a real root of an odd degree polynomial from its coefficients
Sample Input:
[1, 0, 8]
Sample Output:
-2.0 # 1*(-2.0)^3 + 8 == 0 | /**
* Verifies that the inputs satisfy the problem:
* Find a real root of an odd degree polynomial from its coefficients
* Sample Input:
* [1, 0, 8]
* Sample Output:
* -2.0 # 1*(-2.0)^3 + 8 == 0
*/
bool sat(double root, vector<int> coeffs) { | bool sat(double root, vector<int> coeffs) { | [
"root",
"coeffs"
] | def sat(root: float, coeffs):
return abs(sum((coeff * root ** i for (i, coeff) in enumerate(coeffs)))) < 0.0001 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"root\": -0.33978271484375, \"coeffs\": [1, 2, 3, 17]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"root\": -0.1689453125, \"coeffs\": [-1, -5, 4, -8, 3, -1, 0, 7]}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"root\": -6.999969482421875, \"coeffs\... |
84 | TP3/human_eval.TwoThirdsSorted | C++ | Verifies that the inputs satisfy the problem:
Start with vector of integers, keep every third element in place and otherwise sort the list
Sample Input:
[8, 0, 7, 2, 9, 4, 1, 2, 8, 3]
Sample Output:
[8, 0, 2, 2, 4, 8, 1, 8, 9, 3] | /**
* Verifies that the inputs satisfy the problem:
* Start with vector of integers, keep every third element in place and otherwise sort the list
* Sample Input:
* [8, 0, 7, 2, 9, 4, 1, 2, 8, 3]
* Sample Output:
* [8, 0, 2, 2, 4, 8, 1, 8, 9, 3]
*/
bool sat(vector<int> li, vector<int> orig) { | bool sat(vector<int> li, vector<int> orig) { | [
"li",
"orig"
] | def sat(li: List[int], orig):
if not orig[::3] == li[::3]:
return False
if not sorted(li) == sorted(orig):
return False
if not all((li[i] <= li[i + 1] for i in range(1, len(li) - 1, 3))):
return False
if not all((li[i] <= li[i + 2] for i in range(2, len(li) - 2, 3))):
ret... | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [1, -29, -2, 17, 0, 3, 12, 3, 4, 5, 8, 18, 0], \"orig\": [1, -2, 3, 17, 8, 4, 12, 3, 18, 5, -29, 0, 0]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"li\": [-10, -9, -7, -6, -4, 0, -2, 0, 3, 2, 4, 8, -8, 9, 9, -4], \"orig\": [-10, 9, 0, -6, 0, -... |
85 | TP3/human_eval.UniqueSorted | C++ | Verifies that the inputs satisfy the problem:
Find an increasing sequence consisting of the elements of the original vector.
Sample Input:
[8, 0, 7, 2, 9, 4, 4, -2, 8, 3]
Sample Output:
[-2, 0, 2, 3, 4, 7, 8, 9] | /**
* Verifies that the inputs satisfy the problem:
* Find an increasing sequence consisting of the elements of the original vector.
* Sample Input:
* [8, 0, 7, 2, 9, 4, 4, -2, 8, 3]
* Sample Output:
* [-2, 0, 2, 3, 4, 7, 8, 9]
*/
bool sat(vector<int> li, vector<int> orig) { | bool sat(vector<int> li, vector<int> orig) { | [
"li",
"orig"
] | def sat(li: List[int], orig):
for i in range(len(li) - 1):
if not li[i] < li[i + 1]:
return False
if not li[i] in orig:
return False
for n in orig:
if not n in li:
return False
return True | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [-4, 0, 1, 2, 3, 8, 32], \"orig\": [1, 1, 3, 2, 0, 8, 32, -4, 0]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"li\": [-10, -9, -5, -2, -1, 1, 3, 5, 6, 8], \"orig\": [-9, 1, -5, 6, -1, 3, 5, 8, -10, -2, 3, -9, -10]}}, {\"idx\": 2, \"outputs\": t... |
86 | TP3/human_eval.MaxInt | C++ | Verifies that the inputs satisfy the problem:
Find the largest integer in a sequence
Sample Input:
[8, 0, 1, 4, 9, 3, 4, -2, 8, 3]
Sample Output:
9 | /**
* Verifies that the inputs satisfy the problem:
* Find the largest integer in a sequence
* Sample Input:
* [8, 0, 1, 4, 9, 3, 4, -2, 8, 3]
* Sample Output:
* 9
*/
bool sat(int m, vector<int> hello) { | bool sat(int m, vector<int> hello) { | [
"m",
"hello"
] | def sat(m: int, hello):
return m in hello and (not any((m < i for i in hello))) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"m\": 3502145, \"hello\": [1, 31, 3, 2, 0, 18, 32, -4, 2, -1000, 3502145, 3502145, 21, 18, 2, 60]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"m\": 2, \"hello\": [2, 2, 2, -4, -2, -5, -4, 0, -5, -10, 1, -1, -1, 2]}}, {\"idx\": 2, \"outputs\": true, \... |
87 | TP3/human_eval.SevenElevenThirteen | C++ | Verifies that the inputs satisfy the problem:
Find all 7's in integers less than n that are divisible by 11 or 13
Sample Input:
79, 3
Sample Output:
[[77, 0], [77, 1], [78, 0]] | /**
* Verifies that the inputs satisfy the problem:
* Find all 7's in integers less than n that are divisible by 11 or 13
* Sample Input:
* 79, 3
* Sample Output:
* [[77, 0], [77, 1], [78, 0]]
*/
bool sat(vector<vector<int>> li, int n, int lower) { | bool sat(vector<vector<int>> li, int n, int lower) { | [
"li",
"n",
"lower"
] | def sat(li: List[List[int]], n, lower):
if not len({(i, j) for (i, j) in li}) >= lower:
return False
return all((str(i)[j] == '7' and (i % 11 == 0 or i % 13 == 0) and (0 <= i < n) and (0 <= j) for (i, j) in li)) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [], \"n\": 5, \"lower\": 0}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"li\": [], \"n\": 8, \"lower\": 0}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"li\": [], \"n\": 11, \"lower\": 0}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"li\... |
88 | TP3/human_eval.HalfSorted | C++ | Verifies that the inputs satisfy the problem:
Start with vector of integers, keep every other element in place and otherwise sort the list
Sample Input:
[8, 0, 7, 2, 9, 4, 1, 2, 8, 3]
Sample Output:
[1, 0, 2, 2, 4, 8, 8, 8, 9, 3] | /**
* Verifies that the inputs satisfy the problem:
* Start with vector of integers, keep every other element in place and otherwise sort the list
* Sample Input:
* [8, 0, 7, 2, 9, 4, 1, 2, 8, 3]
* Sample Output:
* [1, 0, 2, 2, 4, 8, 8, 8, 9, 3]
*/
bool sat(vector<int> li, vector<int> orig) { | bool sat(vector<int> li, vector<int> orig) { | [
"li",
"orig"
] | def sat(li: List[int], orig):
return orig[1::2] == li[1::2] and li[::2] == sorted(orig[::2]) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [-29, 6, 1, 41, 3, 4, 12, 3, 18, 5, 19, 0, 19521], \"orig\": [1, 6, 3, 41, 19, 4, 12, 3, 18, 5, -29, 0, 19521]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"li\": [-8, -9, -7, 8, -1, 2, 7], \"orig\": [-1, -9, 7, 8, -8, 2, -7]}}, {\"idx\": 2, \"... |
89 | TP3/human_eval.ThreeCycle | C++ | Verifies that the inputs satisfy the problem:
Given a target string, find a string s such that when each group of three consecutive characters is cycled
forward one character, you achieve the target string.
Sample Input:
"This is a test"
Sample Output:
'hiT is aste st' | /**
* Verifies that the inputs satisfy the problem:
* Given a target string, find a string s such that when each group of three consecutive characters is cycled
* forward one character, you achieve the target string.
* Sample Input:
* "This is a test"
* Sample Output:
* 'hiT is aste st'
*/
bool sat(string s, st... | bool sat(string s, string target) { | [
"s",
"target"
] | def sat(s: str, target):
def cycle3(trip):
return trip if len(trip) != 3 else trip[2] + trip[:2]
return target == ''.join((cycle3(s[i:i + 3]) for i in range(0, len(s), 3))) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"elHo lorwld\", \"target\": \"Hello world\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"s\": \"ugrtyeextirtcuoertup\", \"target\": \"rugetytextirocuterup\"}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"s\": \"ortsauidjpaaicfreioht\", \"ta... |
90 | TP3/human_eval.PrimeFib | C++ | Verifies that the inputs satisfy the problem:
Find a prime Fibonacci number bigger than a certain threshold, using Ira Gessel's test for Fibonacci numbers.
Sample Input:
10
Sample Output:
11 | /**
* Verifies that the inputs satisfy the problem:
* Find a prime Fibonacci number bigger than a certain threshold, using Ira Gessel's test for Fibonacci numbers.
* Sample Input:
* 10
* Sample Output:
* 11
*/
bool sat(int n, int lower) { | bool sat(int n, int lower) { | [
"n",
"lower"
] | def sat(n: int, lower):
if not any(((i ** 0.5).is_integer() for i in [5 * n * n - 4, 5 * n * n + 4])):
return False
if not all((n % i for i in range(2, int(n ** 0.5) + 1))):
return False
return n > lower | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 514229, \"lower\": 123456}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 5, \"lower\": 3}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": 1597, \"lower\": 458}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"n\": 1597, \"lower\": 384}... |
91 | TP3/human_eval.TripleZeroSum | C++ | Verifies that the inputs satisfy the problem:
Find the indices of three numbers that sum to 0 in vector.
--- Example input ---
[1, 2, 4, -3, 5]
--- Example output ---
[0, 1, 3] | /**
* Verifies that the inputs satisfy the problem:
* Find the indices of three numbers that sum to 0 in vector.
* --- Example input ---
* [1, 2, 4, -3, 5]
* --- Example output ---
* [0, 1, 3]
*/
bool sat(vector<int> inds, vector<int> nums) { | bool sat(vector<int> inds, vector<int> nums) { | [
"inds",
"nums"
] | def sat(inds: List[int], nums):
return len(inds) == 3 and sum((nums[i] for i in inds)) == 0 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"inds\": [0, 4, 6], \"nums\": [12, 6, 41, 15, -10452, 18242, 10440, 6, 6, 6, 6]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"inds\": [0, 1, 2], \"nums\": [-52, -16, 68, -27, 3]}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"inds\": [0, 4, 6], \"nu... |
92 | TP3/human_eval.NumPasses | C++ | Verifies that the inputs satisfy the problem:
Given n cars traveling East and n cars traveling West on a road, how many passings will there be?
A passing is when one car passes another. The East-bound cars all begin further West than the West-bound cars.
--Sample input--
2
--Sample output--
4 | /**
* Verifies that the inputs satisfy the problem:
* Given n cars traveling East and n cars traveling West on a road, how many passings will there be?
* A passing is when one car passes another. The East-bound cars all begin further West than the West-bound cars.
* --Sample input--
* 2
* --Sample output--
* 4
... | bool sat(int count, int n) { | [
"count",
"n"
] | def sat(count: int, n):
for i in range(n):
for j in range(n):
count -= 1
return count == 0 | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"count\": 962361, \"n\": 981}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"count\": 15129, \"n\": 123}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"count\": 57121, \"n\": 239}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"count\": 142884, \"n\"... |
93 | TP3/human_eval.ListInc | C++ | Verifies that the inputs satisfy the problem:
Decrement each element of new_list by 1 and check that it's old_list
Sample Input:
[17, 15, 99]
Sample Output:
[18, 16, 100] | /**
* Verifies that the inputs satisfy the problem:
* Decrement each element of new_list by 1 and check that it's old_list
* Sample Input:
* [17, 15, 99]
* Sample Output:
* [18, 16, 100]
*/
bool sat(vector<int> new_list, vector<int> old_list) { | bool sat(vector<int> new_list, vector<int> old_list) { | [
"new_list",
"old_list"
] | def sat(new_list: List[int], old_list):
return [i - 1 for i in new_list] == old_list | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"new_list\": [322, 13, 533, 130, 10, -11, 5, 57, 91, 1], \"old_list\": [321, 12, 532, 129, 9, -12, 4, 56, 90, 0]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"new_list\": [19, 30, 41], \"old_list\": [18, 29, 40]}}, {\"idx\": 2, \"outputs\": true, \"in... |
94 | TP3/human_eval.PairZeroSum | C++ | Verifies that the inputs satisfy the problem:
Find the indices of two numbers that sum to 0 in vector.
Sample Input:
[1, -4, -4, 7, -3]
Sample Output:
[1, 2] | /**
* Verifies that the inputs satisfy the problem:
* Find the indices of two numbers that sum to 0 in vector.
* Sample Input:
* [1, -4, -4, 7, -3]
* Sample Output:
* [1, 2]
*/
bool sat(vector<int> inds, vector<int> nums) { | bool sat(vector<int> inds, vector<int> nums) { | [
"inds",
"nums"
] | def sat(inds: List[int], nums):
(a, b) = inds
return nums[a] + nums[b] == 0 and a >= 0 and (b >= 0) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"inds\": [2, 7], \"nums\": [12, -10452, 18242, 10440, 81, 241, 525, -18242, 91, 20]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"inds\": [46, 46], \"nums\": [50, 33, 12, -13, 65, -39, -12, -72, -61, -38, -58, -88, 70, -82, -80, 27, 68, 89, -57, 15, -... |
95 | TP3/human_eval.ChangeBase | C++ | Verifies that the inputs satisfy the problem:
Write n in the given base as a string
Sample Input:
n=23, base=12
Sample Output:
'1A' | /**
* Verifies that the inputs satisfy the problem:
* Write n in the given base as a string
* Sample Input:
* n=23, base=12
* Sample Output:
* '1A'
*/
bool sat(string s, int n, int base_arg2) { | bool sat(string s, int n, int base_arg2) { | [
"s",
"n",
"base_arg2"
] | def sat(s: str, n, base_arg2):
return int(s, base_arg2) == n | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"262\", \"n\": 142, \"base_arg2\": 7}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"s\": \"10100110101010000\", \"n\": 85328, \"base_arg2\": 2}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"s\": \"9576751\", \"n\": 9576751, \"base_arg2\": 10}... |
96 | TP3/human_eval.TriangleArea | C++ | Verifies that the inputs satisfy the problem:
Find the height of a triangle given the area and base. It is guaranteed that the answer is an integer.
Sample Input:
area = 6, base = 3
Sample Output:
4 | /**
* Verifies that the inputs satisfy the problem:
* Find the height of a triangle given the area and base. It is guaranteed that the answer is an integer.
* Sample Input:
* area = 6, base = 3
* Sample Output:
* 4
*/
bool sat(int height, long long area, int base_arg2) { | bool sat(int height, long long area, int base_arg2) { | [
"height",
"area",
"base_arg2"
] | def sat(height: int, area, base_arg2):
return base_arg2 * height == 2 * area | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"height\": 58462914, \"area\": 1319098728582, \"base_arg2\": 45126}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"height\": 25, \"area\": 2642925075, \"base_arg2\": 211434006}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"height\": 584, \"area\": 55... |
97 | TP3/human_eval.Fib4 | C++ | Verifies that the inputs satisfy the problem:
Define a four-wise Fibonacci sequence to be a sequence such that each number is the sum of the previous
four. Given a target number, find an initial four numbers such that the 100th number in the sequence is the
given target number.
Sample Input:
0
Sample Output:
[0, 0, 0, ... | /**
* Verifies that the inputs satisfy the problem:
* Define a four-wise Fibonacci sequence to be a sequence such that each number is the sum of the previous
* four. Given a target number, find an initial four numbers such that the 100th number in the sequence is the
* given target number.
* Sample Input:
* 0
* ... | bool sat(vector<long long> init, int target) { | [
"init",
"target"
] | def sat(init: List[int], target):
(a, b, c, d) = init
for i in range(99):
(a, b, c, d) = (b, c, d, a + b + c + d)
return a == target | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"init\": [-78438935137696, 61037589119992, -46883574455344, 36087218554357], \"target\": 2021}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"init\": [0, 0, 0, 0], \"target\": 0}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"init\": [-271683595232, 2... |
98 | TP3/human_eval.Median | C++ | Verifies that the inputs satisfy the problem:
Find an integer that minimizes the sum of absolute deviations with respect to the given numbers.
Sample Input:
[3, 6, 1, 2, 5, 4, 100], upper=105
Sample Output:
4 | /**
* Verifies that the inputs satisfy the problem:
* Find an integer that minimizes the sum of absolute deviations with respect to the given numbers.
* Sample Input:
* [3, 6, 1, 2, 5, 4, 100], upper=105
* Sample Output:
* 4
*/
bool sat(int x, vector<int> nums, int upper) { | bool sat(int x, vector<int> nums, int upper) { | [
"x",
"nums",
"upper"
] | def sat(x: int, nums, upper):
dev = sum((n - x for n in nums))
return dev <= upper | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": 28141, \"nums\": [132666041, 237412, 28141, -12, 11939, 912414, 17], \"upper\": 133658965}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": -46417950, \"nums\": [-25829995, -73994225, -82219866, 60695720, -46417950], \"upper\": 64323434}}, {\"i... |
99 | TP3/human_eval.Palindrome | C++ | Verifies that the inputs satisfy the problem:
Test whether the given strings are palindromes
Sample Input:
["aba", "no"]
Sample Output:
[True, False] | /**
* Verifies that the inputs satisfy the problem:
* Test whether the given strings are palindromes
* Sample Input:
* ["aba", "no"]
* Sample Output:
* [True, False]
*/
bool sat(vector<bool> pals, vector<string> strs) { | bool sat(vector<bool> pals, vector<string> strs) { | [
"pals",
"strs"
] | def sat(pals: List[bool], strs):
return all((pals[i] == (s == s[::-1]) for (i, s) in enumerate(strs))) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"pals\": [false, true, true, false, false, false], \"strs\": [\"palindrome\", \"madamimadam\", \"\", \"foo\", \"eyes\", \"(-:-)\"]}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"pals\": [true, true, true, false, true, true, false, true, true], \"strs\"... |
100 | TP3/human_eval.LittleFermat | C++ | Verifies that the inputs satisfy the problem:
Fermat's little theorem implies that any polynomial can be written equivalently as a degree p-1
polynomial (mod p).
Given the p coefficients of a polynomial poly, compute a polynomial equivalent to poly^d (mod p).
Sample Input:
d=2, poly=[1, 0, 0, 1, 0] # 1 + x^3
Sample Ou... | /**
* Verifies that the inputs satisfy the problem:
* Fermat's little theorem implies that any polynomial can be written equivalently as a degree p-1
* polynomial (mod p).
* Given the p coefficients of a polynomial poly, compute a polynomial equivalent to poly^d (mod p).
* Sample Input:
* d=2, poly=[1, 0, 0, 1, 0... | bool sat(vector<int> exp_poly, long long d, vector<int> poly) { | [
"exp_poly",
"d",
"poly"
] | def sat(exp_poly: List[int], d, poly):
p = len(poly)
if not (p > 2 and all((p % i for i in range(2, p)))):
return False
def val(coeffs, n):
return sum((c * pow(n, i, p) for (i, c) in enumerate(coeffs))) % p
return all((val(exp_poly, n) == pow(val(poly, n), d, p) for n in range(p))) | {
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"exp_poly\": [1, 6, 3, 1, 0, 4, 4], \"d\": 74152093423, \"poly\": [1, 6, 3, 1, 0, 4, 4]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"exp_poly\": [], \"d\": 74152093423, \"poly\": [1, 6, 3, 1, 0, 4, 4]}}, {\"idx\": 2, \"outputs\": false, \"inputs\": ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.