Datasets:
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 sequence | 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 | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"hohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohoh... |
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) | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"hohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohohoh... |
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)))) | {
"extension": "cpp",
"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... |
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 | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"li\": []}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>... |
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)]) | {
"extension": "cpp",
"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\": []}}]",
"entry_cls_name": "Solu... |
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 | {
"extension": "cpp",
"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, \"inp... |
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 | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"672\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"s\": \"\"}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#incl... |
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') | {
"extension": "cpp",
"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\": []}}]",
"entry_cls_name": "Solution",
... |
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) | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"8834117114388\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"s\": \"\"}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <m... |
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)) | {
"extension": "cpp",
"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, \"outp... |
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 | {
"extension": "cpp",
"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, ... |
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') | {
"extension": "cpp",
"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, ... |
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)]) | {
"extension": "cpp",
"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\": []}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include ... |
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))) | {
"extension": "cpp",
"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\": []}}]",
"entry_cls_name": "Solution",
"test_code": "#inc... |
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 | {
"extension": "cpp",
"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\"}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>\n#include <asse... |
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)) | {
"extension": "cpp",
"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\":... |
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() | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ls\": [\"ber\", \"lin\", \"ger\"]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"ls\": []}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#... |
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} | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [0, 1, 2, 3, 17]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"li\": []}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <ma... |
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]))) | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [1, 3, 4, 12, 13, 14, 42, 126, 127]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"li\": []}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iost... |
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 | {
"extension": "cpp",
"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, \"inp... |
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 | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"abacadaeaaaaaaaaaa\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"s\": \"\"}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#inclu... |
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!') | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ls\": [\"d\", \"d\", \"d\"]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"ls\": []}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#includ... |
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 | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"li\": [17, 17, 17, 3, 3]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"li\": []}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <... |
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] | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \" eemrtuPutrmee \"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"s\": \"\"}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include ... |
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)) | {
"extension": "cpp",
"test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"ls\": [\"29642774\", \"84475294\", \"60284341\", \"72162224\", \"10441043\", \"71160744\", \"03984394\", \"10114150\", \"60257611\", \"87823616\"]}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"ls\": []}}]",
"entry_cls_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]]] | {
"extension": "cpp",
"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]}}]",
"entry_cls_name": "Solution",
"test_code": "#include <algorithm>... |
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 | {
"extension": "cpp",
"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, 4... |
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 | {
"extension": "cpp",
"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, ... |
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)]) | {
"extension": "cpp",
"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,... |
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] == [] | {
"extension": "cpp",
"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]... |
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))) | {
"extension": "cpp",
"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, ... |
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))) | {
"extension": "cpp",
"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, \"outp... |
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 | {
"extension": "cpp",
"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, \"in... |
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 | {
"extension": "cpp",
"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'\"}}]",
"entry_cls_name": "Solution",
"test_code": "#i... |
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())) | {
"extension": "cpp",
"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,... |
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] | {
"extension": "cpp",
"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... |
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 | {
"extension": "cpp",
"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\":... |
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... | {
"extension": "cpp",
"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\"... |
YAML Metadata Warning:The task_categories "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other
Dataset Card for Translating Python Programming Puzzles (TP3)
How To Use This Dataset
To use this dataset, you can either use the original BabelCode Repo, or you can use the bc_eval Metric.
Dataset Summary
The Translating Python Programming Puzzles (TP3) dataset is created from the verification functions in the Python Programming Puzzles dataset (Schuster et al., 2021) to create this dataset. These functions are hand-crafted by the authors and are used to check if an answer satisfies the constraints of the puzzle. These puzzles range in difficulty from basic character checking to competitive programming problems.
Supported Tasks and Leaderboards
Languages
BC-TP3 supports:
- C++
- C#
- Dart
- Go
- Haskell
- Java
- Javascript
- Julia
- Kotlin
- Lua
- PHP
- R
- Rust
- Scala
- TypeScript
Dataset Structure
>>> from datasets import load_dataset
>>> load_dataset("gabeorlanski/tp3")
DatasetDict({
test: Dataset({
features: ['qid', 'title', 'language', 'text', 'signature_with_docstring', 'signature', 'arguments', 'source', 'question_info'],
num_rows: 5920
})
})
Data Fields
qid: The question ID used for running tests.title: The title of the question.language: The programming language of the example.text: The description of the problem.signature: The signature for the problem.signature_with_docstring: The signature with the adequately formatted docstring for the given problem.arguments: The arguments of the problem.source: The source solution in Python.question_info: The dict of information used for executing predictions. It has the keys:test_code: The raw testing script used in the language. If you want to use this, replacePLACEHOLDER_FN_NAME(andPLACEHOLDER_CLS_NAMEif needed) with the corresponding entry points. Next, replacePLACEHOLDER_CODE_BODYwith the postprocessed prediction.test_list: The raw json line of the list of tests for the problem. To load them, usejson.loadstest_case_ids: The list of test case ids for the problem. These are used to determine if a prediction passes or not.entry_fn_name: The function's name to use an entry point.entry_cls_name: The class name to use an entry point.commands: The commands used to execute the prediction. Includes a__FILENAME__hole that is replaced with the filename.timeouts: The default timeouts for each command.extension: The extension for the prediction file.
NOTE: If you want to use a different function name (or class name for languages that require class names) for the prediction, you must update the entry_fn_name and entry_cls_name accordingly. For example, if you have the original question with entry_fn_name of add, but want to change it to f, you must update ds["question_info"]["entry_fn_name"] to f:
>>> from datasets import load_dataset
>>> ds = load_dataset("gabeorlanski/bc-mbpp")['test']
>>> # The original entry_fn_name
>>> ds[0]['question_info']['entry_fn_name']
removeOcc
>>> # You MUST update the corresponding entry_fn_name
>>> ds[0]['question_info']['entry_fn_name'] = 'f'
>>> ds[0]['question_info']['entry_fn_name']
f
Dataset Creation
See section 2 and section 4.4 of the BabelCode Paper to learn more about how the datasets are translated.
For information on how the original P3 dataset was collected, please see Programming Puzzles paper.
Dataset Curators
Google Research
Licensing Information
CC-BY-4.0
Citation Information
@article{orlanski2023measuring,
title={Measuring The Impact Of Programming Language Distribution},
author={Orlanski, Gabriel and Xiao, Kefan and Garcia, Xavier and Hui, Jeffrey and Howland, Joshua and Malmaud, Jonathan and Austin, Jacob and Singh, Rishah and Catasta, Michele},
journal={arXiv preprint arXiv:2302.01973},
year={2023}
}
@inproceedings{
schuster2021programming,
title={Programming Puzzles},
author={Tal Schuster and Ashwin Kalyan and Alex Polozov and Adam Tauman Kalai},
booktitle={Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track},
year={2021},
url={https://arxiv.org/abs/2106.05784}
}
- Downloads last month
- 61