stop_tokens
sequencelengths 1
1
| prompt
stringlengths 99
1.02k
| prompt_terminology
stringclasses 1
value | doctests
stringclasses 1
value | name
stringlengths 15
44
| tests
stringlengths 133
2.09k
| original
stringlengths 130
159
| language
stringclasses 1
value |
|---|---|---|---|---|---|---|---|
[
"\n}"
] |
/// リストnumbersの中に、与えられたthresholdより近い2つの数値が存在するか判定する
/// >>> has_close_elements(vec![1.0, 2.0, 3.0], 0.5)
/// false
/// >>> has_close_elements(vec![1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
/// true
fn has_close_elements(numbers: Vec<f64>, threshold: f64) -> bool {
|
reworded
|
transform
|
HumanEval_0_has_close_elements
|
}
fn main() {
let candidate = has_close_elements;
assert_eq!(candidate(vec![1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.3), true);
assert_eq!(candidate(vec![1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.05), false);
assert_eq!(candidate(vec![1.0, 2.0, 5.9, 4.0, 5.0], 0.95), true);
assert_eq!(candidate(vec![1.0, 2.0, 5.9, 4.0, 5.0], 0.8), false);
assert_eq!(candidate(vec![1.0, 2.0, 3.0, 4.0, 5.0, 2.0], 0.1), true);
assert_eq!(candidate(vec![1.1, 2.2, 3.1, 4.1, 5.1], 1.0), true);
assert_eq!(candidate(vec![1.1, 2.2, 3.1, 4.1, 5.1], 0.5), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_0_has_close_elements.py
|
rs
|
[
"\n}"
] |
/// この関数への入力は、入れ子になった括弧が複数含まれる文字列である。
/// あなたの目的は、これらの括弧を別々の文字列に分割し、そのリストを返すことである。
/// 分離された括弧はバランスがとれ、つまり、開いた括弧はそれぞれ適切に閉じられていて、
/// 互いに入れ子になっていない。引数の文字列内の空白は無視せよ。
/// >>> separate_paren_groups(String::from("( ) (( )) (( )( ))"))
/// vec![String::from("()"), String::from("(())"), String::from("(()())")]
fn separate_paren_groups(paren_string: String) -> Vec<String> {
|
reworded
|
transform
|
HumanEval_1_separate_paren_groups
|
}
fn main() {
let candidate = separate_paren_groups;
assert_eq!(candidate(String::from("(()()) ((())) () ((())()())")), vec![String::from("(()())"), String::from("((()))"), String::from("()"), String::from("((())()())")]);
assert_eq!(candidate(String::from("() (()) ((())) (((())))")), vec![String::from("()"), String::from("(())"), String::from("((()))"), String::from("(((())))")]);
assert_eq!(candidate(String::from("(()(())((())))")), vec![String::from("(()(())((())))")]);
assert_eq!(candidate(String::from("( ) (( )) (( )( ))")), vec![String::from("()"), String::from("(())"), String::from("(()())")]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_1_separate_paren_groups.py
|
rs
|
[
"\n}"
] |
/// 正の浮動小数点数が与えられると、それを整数部(与えられた数より小さい最大の整数)
/// と小数部(常に1より小さい残余部分)に分解することができる。
/// 関数は、数値の小数部を返す。
/// >>> truncate_number(3.5)
/// 0.5
fn truncate_number(number: f64) -> f64 {
|
reworded
|
transform
|
HumanEval_2_truncate_number
|
}
fn main() {
let candidate = truncate_number;
assert_eq!(candidate(3.5), 0.5);
assert_eq!(candidate(1.25), 0.25);
assert_eq!(candidate(123.0), 0.0);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_2_truncate_number.py
|
rs
|
[
"\n}"
] |
/// 銀行口座に対する入出金操作のリストが与えられます。あなたのタスクは、残高ゼロから
/// 始まて、口座の残高がゼロ未満になったかどうかを検出し、その時点で関数がtrueを
/// 返すようにすることです。そうでなければfalseを返すようにしてください。
/// >>> below_zero(vec![1, 2, 3])
/// false
/// >>> below_zero(vec![1, 2, -4, 5])
/// true
fn below_zero(operations: Vec<isize>) -> bool {
|
reworded
|
transform
|
HumanEval_3_below_zero
|
}
fn main() {
let candidate = below_zero;
assert_eq!(candidate(Vec::<isize>::new()), false);
assert_eq!(candidate(vec![1, 2, -3, 1, 2, -3]), false);
assert_eq!(candidate(vec![1, 2, -4, 5, 6]), true);
assert_eq!(candidate(vec![1, -1, 2, -2, 5, -5, 4, -4]), false);
assert_eq!(candidate(vec![1, -1, 2, -2, 5, -5, 4, -5]), true);
assert_eq!(candidate(vec![1, -2, 2, -2, 5, -5, 4, -4]), true);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_3_below_zero.py
|
rs
|
[
"\n}"
] |
/// 第一引数の数値リストに対して、このデータセットの平均値を中心とした平均絶対偏差(MAD)を計算する。
/// 平均絶対偏差(MAD)とは、各要素と中心点(この場合は平均値)との差の絶対値の平均である:
/// MAD = 平均|x - x_mean|
/// >>> mean_absolute_deviation(vec![1.0, 2.0, 3.0, 4.0])
/// 1.0
fn mean_absolute_deviation(numbers: Vec<f64>) -> f64 {
|
reworded
|
transform
|
HumanEval_4_mean_absolute_deviation
|
}
fn main() {
let candidate = mean_absolute_deviation;
assert_eq!(candidate(vec![1.0, 2.0]), 0.5);
assert_eq!(candidate(vec![1.0, 2.0, 3.0, 4.0]), 1.0);
assert_eq!(candidate(vec![1.0, 2.0, 3.0, 4.0, 5.0]), 1.2);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_4_mean_absolute_deviation.py
|
rs
|
[
"\n}"
] |
/// 数値リスト numbers 中の全ての連続する二要素の間に、'delimeterの値を挿入する
/// >>> intersperse(vec![], 4)
/// Vec::<isize>::new()
/// >>> intersperse(vec![1, 2, 3], 4)
/// vec![1, 4, 2, 4, 3]
fn intersperse(numbers: Vec<isize>, delimeter: isize) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_5_intersperse
|
}
fn main() {
let candidate = intersperse;
assert_eq!(candidate(Vec::<isize>::new(), 7), Vec::<isize>::new());
assert_eq!(candidate(vec![5, 6, 3, 2], 8), vec![5, 8, 6, 8, 3, 8, 2]);
assert_eq!(candidate(vec![2, 2, 2], 2), vec![2, 2, 2, 2, 2]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_5_intersperse.py
|
rs
|
[
"\n}"
] |
/// この関数の入力は、空白で区切られた複数の入れ子になった括弧のグループを表す文字列です。
/// 各グループについて、括弧の最も深い入れ子のレベルを出力します。
/// 例えば、'(()())'は最大で2レベルの入れ子になっていますが、'((()))'は3レベルです。
/// >>> parse_nested_parens(String::from("(()()) ((())) () ((())()())"))
/// vec![2, 3, 1, 3]
fn parse_nested_parens(paren_string: String) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_6_parse_nested_parens
|
}
fn main() {
let candidate = parse_nested_parens;
assert_eq!(candidate(String::from("(()()) ((())) () ((())()())")), vec![2, 3, 1, 3]);
assert_eq!(candidate(String::from("() (()) ((())) (((())))")), vec![1, 2, 3, 4]);
assert_eq!(candidate(String::from("(()(())((())))")), vec![4]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_6_parse_nested_parens.py
|
rs
|
[
"\n}"
] |
/// 文字列リストstringsを、与えれた部分文字列substringを含むものだけにフィルタする
/// >>> filter_by_substring(vec![], String::from("a"))
/// Vec::<String>::new()
/// >>> filter_by_substring(vec![String::from("abc"), String::from("bacd"), String::from("cde"), String::from("array")], String::from("a"))
/// vec![String::from("abc"), String::from("bacd"), String::from("array")]
fn filter_by_substring(strings: Vec<String>, substring: String) -> Vec<String> {
|
reworded
|
transform
|
HumanEval_7_filter_by_substring
|
}
fn main() {
let candidate = filter_by_substring;
assert_eq!(candidate(Vec::<String>::new(), String::from("john")), Vec::<String>::new());
assert_eq!(candidate(vec![String::from("xxx"), String::from("asd"), String::from("xxy"), String::from("john doe"), String::from("xxxAAA"), String::from("xxx")], String::from("xxx")), vec![String::from("xxx"), String::from("xxxAAA"), String::from("xxx")]);
assert_eq!(candidate(vec![String::from("xxx"), String::from("asd"), String::from("aaaxxy"), String::from("john doe"), String::from("xxxAAA"), String::from("xxx")], String::from("xx")), vec![String::from("xxx"), String::from("aaaxxy"), String::from("xxxAAA"), String::from("xxx")]);
assert_eq!(candidate(vec![String::from("grunt"), String::from("trumpet"), String::from("prune"), String::from("gruesome")], String::from("run")), vec![String::from("grunt"), String::from("prune")]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_7_filter_by_substring.py
|
rs
|
[
"\n}"
] |
/// 与えられた整数リストに対して、リスト内のすべての整数の和と積からなるタプルを返す。
/// ただし、空の和は0、空の積は1とする。
/// >>> sum_product(vec![])
/// (0, 1)
/// >>> sum_product(vec![1, 2, 3, 4])
/// (10, 24)
fn sum_product(numbers: Vec<isize>) -> (isize, isize) {
|
reworded
|
transform
|
HumanEval_8_sum_product
|
}
fn main() {
let candidate = sum_product;
assert_eq!(candidate(Vec::<isize>::new()), (0, 1));
assert_eq!(candidate(vec![1, 1, 1]), (3, 1));
assert_eq!(candidate(vec![100, 0]), (100, 0));
assert_eq!(candidate(vec![3, 5, 7]), (15, 105));
assert_eq!(candidate(vec![10]), (10, 10));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_8_sum_product.py
|
rs
|
[
"\n}"
] |
/// 与えられた整数リストから、各要素のそこまでの最大値(ローリング最大値)のリストを生成する。
/// >>> rolling_max(vec![1, 2, 3, 2, 3, 4, 2])
/// vec![1, 2, 3, 3, 3, 4, 4]
fn rolling_max(numbers: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_9_rolling_max
|
}
fn main() {
let candidate = rolling_max;
assert_eq!(candidate(Vec::<isize>::new()), Vec::<isize>::new());
assert_eq!(candidate(vec![1, 2, 3, 4]), vec![1, 2, 3, 4]);
assert_eq!(candidate(vec![4, 3, 2, 1]), vec![4, 4, 4, 4]);
assert_eq!(candidate(vec![3, 2, 3, 100, 3]), vec![3, 3, 3, 100, 100]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_9_rolling_max.py
|
rs
|
[
"\n}"
] |
/// 与えられた文字列で始まる最短の回文を見つけてください。
/// アルゴリズムのアイデアは以下の通りです:
/// - 与えられた文字列の中で最も長い回文となる接尾辞を見つけます。
/// - その回文の接尾辞の前に来る接頭辞を逆順にして、文字列の末尾に追加します。
/// >>> make_palindrome(String::from(""))
/// String::from("")
/// >>> make_palindrome(String::from("cat"))
/// String::from("catac")
/// >>> make_palindrome(String::from("cata"))
/// String::from("catac")
fn make_palindrome(string: String) -> String {
|
reworded
|
transform
|
HumanEval_10_make_palindrome
|
}
fn main() {
let candidate = make_palindrome;
assert_eq!(candidate(String::from("")), String::from(""));
assert_eq!(candidate(String::from("x")), String::from("x"));
assert_eq!(candidate(String::from("xyz")), String::from("xyzyx"));
assert_eq!(candidate(String::from("xyx")), String::from("xyx"));
assert_eq!(candidate(String::from("jerry")), String::from("jerryrrej"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_10_make_palindrome.py
|
rs
|
[
"\n}"
] |
/// 引数は1と0のみからなる文字列aとbである。
/// これらの引数に対して排他論理和(XOR)を実行し、結果を文字列として返す。
/// >>> string_xor(String::from("010"), String::from("110"))
/// String::from("100")
fn string_xor(a: String, b: String) -> String {
|
reworded
|
transform
|
HumanEval_11_string_xor
|
}
fn main() {
let candidate = string_xor;
assert_eq!(candidate(String::from("111000"), String::from("101010")), String::from("010010"));
assert_eq!(candidate(String::from("1"), String::from("1")), String::from("0"));
assert_eq!(candidate(String::from("0101"), String::from("0000")), String::from("0101"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_11_string_xor.py
|
rs
|
[
"\n}"
] |
/// 文字列のリストのうち、最も長いものを返す。同じ長さの文字列が
/// 複数ある場合は最初のものを返す。入力リストが空の場合は None を返す。
/// >>> longest(vec![])
/// None
/// >>> longest(vec![String::from("a"), String::from("b"), String::from("c")])
/// Some(String::from("a"))
/// >>> longest(vec![String::from("a"), String::from("bb"), String::from("ccc")])
/// Some(String::from("ccc"))
fn longest(strings: Vec<String>) -> Option<String> {
|
reworded
|
transform
|
HumanEval_12_longest
|
}
fn main() {
let candidate = longest;
assert_eq!(candidate(Vec::<String>::new()), None);
assert_eq!(candidate(vec![String::from("x"), String::from("y"), String::from("z")]), Some(String::from("x")));
assert_eq!(candidate(vec![String::from("x"), String::from("yyy"), String::from("zzzz"), String::from("www"), String::from("kkkk"), String::from("abc")]), Some(String::from("zzzz")));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_12_longest.py
|
rs
|
[
"\n}"
] |
/// 整数 a と b の最大公約数を返す
/// >>> greatest_common_divisor(3, 5)
/// 1
/// >>> greatest_common_divisor(25, 15)
/// 5
fn greatest_common_divisor(a: isize, b: isize) -> isize {
|
reworded
|
transform
|
HumanEval_13_greatest_common_divisor
|
}
fn main() {
let candidate = greatest_common_divisor;
assert_eq!(candidate(3, 7), 1);
assert_eq!(candidate(10, 15), 5);
assert_eq!(candidate(49, 14), 7);
assert_eq!(candidate(144, 60), 12);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_13_greatest_common_divisor.py
|
rs
|
[
"\n}"
] |
/// 引数で与えられた文字列に対して、短いものから長いものへ、全ての接頭辞のリストを返す
/// >>> all_prefixes(String::from("abc"))
/// vec![String::from("a"), String::from("ab"), String::from("abc")]
fn all_prefixes(string: String) -> Vec<String> {
|
reworded
|
transform
|
HumanEval_14_all_prefixes
|
}
fn main() {
let candidate = all_prefixes;
assert_eq!(candidate(String::from("")), Vec::<String>::new());
assert_eq!(candidate(String::from("asdfgh")), vec![String::from("a"), String::from("as"), String::from("asd"), String::from("asdf"), String::from("asdfg"), String::from("asdfgh")]);
assert_eq!(candidate(String::from("WWW")), vec![String::from("W"), String::from("WW"), String::from("WWW")]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_14_all_prefixes.py
|
rs
|
[
"\n}"
] |
/// 0からnまでの数字を空白区切りで連結した文字列で返す。
/// >>> string_sequence(0)
/// String::from("0")
/// >>> string_sequence(5)
/// String::from("0 1 2 3 4 5")
fn string_sequence(n: isize) -> String {
|
reworded
|
transform
|
HumanEval_15_string_sequence
|
}
fn main() {
let candidate = string_sequence;
assert_eq!(candidate(0), String::from("0"));
assert_eq!(candidate(3), String::from("0 1 2 3"));
assert_eq!(candidate(10), String::from("0 1 2 3 4 5 6 7 8 9 10"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_15_string_sequence.py
|
rs
|
[
"\n}"
] |
/// 文字列が与えられたとき、その文字列が(大文字小文字に関係なく)いくつの異なる文字が含まれているか数える
/// >>> count_distinct_characters(String::from("xyzXYZ"))
/// 3
/// >>> count_distinct_characters(String::from("Jerry"))
/// 4
fn count_distinct_characters(string: String) -> isize {
|
reworded
|
transform
|
HumanEval_16_count_distinct_characters
|
}
fn main() {
let candidate = count_distinct_characters;
assert_eq!(candidate(String::from("")), 0);
assert_eq!(candidate(String::from("abcde")), 5);
assert_eq!(candidate(String::from("abcdecadeCADE")), 5);
assert_eq!(candidate(String::from("aaaaAAAAaaaa")), 1);
assert_eq!(candidate(String::from("Jerry jERRY JeRRRY")), 5);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_16_count_distinct_characters.py
|
rs
|
[
"\n}"
] |
/// この関数の引数は、特別なASCII形式の音符を表す文字列である。あなたの仕事は、この文字列を解析して、それぞれの音符が何拍続くかに対応する整数のリストを返すことである。
/// ここに凡例がある:
/// o' - 全音符、4拍続く
/// o|' - 2分音符、2拍続く
/// .|」-4分音符、1拍続く
/// >>> parse_music(String::from("o o| .| o| o| .| .| .| .| o o"))
/// vec![4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
fn parse_music(music_string: String) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_17_parse_music
|
}
fn main() {
let candidate = parse_music;
assert_eq!(candidate(String::from("")), Vec::<isize>::new());
assert_eq!(candidate(String::from("o o o o")), vec![4, 4, 4, 4]);
assert_eq!(candidate(String::from(".| .| .| .|")), vec![1, 1, 1, 1]);
assert_eq!(candidate(String::from("o| o| .| .| o o o o")), vec![2, 2, 1, 1, 4, 4, 4, 4]);
assert_eq!(candidate(String::from("o| .| o| .| o o| o o|")), vec![2, 1, 2, 1, 4, 2, 4, 2]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_17_parse_music.py
|
rs
|
[
"\n}"
] |
/// 部分文字列substringが文字列stringの中で何回見つかるか数える。
/// 重なるケースもカウントに含まれる。
/// >>> how_many_times(String::from(""), String::from("a"))
/// 0
/// >>> how_many_times(String::from("aaa"), String::from("a"))
/// 3
/// >>> how_many_times(String::from("aaaa"), String::from("aa"))
/// 3
fn how_many_times(string: String, substring: String) -> isize {
|
reworded
|
transform
|
HumanEval_18_how_many_times
|
}
fn main() {
let candidate = how_many_times;
assert_eq!(candidate(String::from(""), String::from("x")), 0);
assert_eq!(candidate(String::from("xyxyxyx"), String::from("x")), 4);
assert_eq!(candidate(String::from("cacacacac"), String::from("cac")), 4);
assert_eq!(candidate(String::from("john doe"), String::from("john")), 1);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_18_how_many_times.py
|
rs
|
[
"\n}"
] |
/// 引数は'zero'から'nine'までの英単語の数を空白で区切った文字列である。
/// 有効な英単語は''、'zero', 'one'、'two'、'three'、'four'、'five'、'six'、'seven'、'eight'、'nine'である。
/// 関数は、英単語の数を小さい方から大きい方へとソートした文字列を返す。
/// >>> sort_numbers(String::from("three one five"))
/// String::from("one three five")
fn sort_numbers(numbers: String) -> String {
|
reworded
|
transform
|
HumanEval_19_sort_numbers
|
}
fn main() {
let candidate = sort_numbers;
assert_eq!(candidate(String::from("")), String::from(""));
assert_eq!(candidate(String::from("three")), String::from("three"));
assert_eq!(candidate(String::from("three five nine")), String::from("three five nine"));
assert_eq!(candidate(String::from("five zero four seven nine eight")), String::from("zero four five seven eight nine"));
assert_eq!(candidate(String::from("six five four three two one zero")), String::from("zero one two three four five six"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_19_sort_numbers.py
|
rs
|
[
"\n}"
] |
/// (少なくとも長さ2以上の)リストnumbersから、互いに最も近いものを2つ選び、
/// 順番に(小さい数、大きい数)返す。
/// >>> find_closest_elements(vec![1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
/// (2.0, 2.2)
/// >>> find_closest_elements(vec![1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
/// (2.0, 2.0)
fn find_closest_elements(numbers: Vec<f64>) -> (f64, f64) {
|
reworded
|
transform
|
HumanEval_20_find_closest_elements
|
}
fn main() {
let candidate = find_closest_elements;
assert_eq!(candidate(vec![1.0, 2.0, 3.9, 4.0, 5.0, 2.2]), (3.9, 4.0));
assert_eq!(candidate(vec![1.0, 2.0, 5.9, 4.0, 5.0]), (5.0, 5.9));
assert_eq!(candidate(vec![1.0, 2.0, 3.0, 4.0, 5.0, 2.2]), (2.0, 2.2));
assert_eq!(candidate(vec![1.0, 2.0, 3.0, 4.0, 5.0, 2.0]), (2.0, 2.0));
assert_eq!(candidate(vec![1.1, 2.2, 3.1, 4.1, 5.1]), (2.2, 3.1));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_20_find_closest_elements.py
|
rs
|
[
"\n}"
] |
/// (少なくとも 2 つ以上の要素からなる) リストnumbersに線形変換を適用し、
/// 最小の数値が 0 になり、最大の数値が 1 になるリストを返す
/// >>> rescale_to_unit(vec![1.0, 2.0, 3.0, 4.0, 5.0])
/// vec![0.0, 0.25, 0.5, 0.75, 1.0]
fn rescale_to_unit(numbers: Vec<f64>) -> Vec<f64> {
|
reworded
|
transform
|
HumanEval_21_rescale_to_unit
|
}
fn main() {
let candidate = rescale_to_unit;
assert_eq!(candidate(vec![2.0, 49.9]), vec![0.0, 1.0]);
assert_eq!(candidate(vec![100.0, 49.9]), vec![1.0, 0.0]);
assert_eq!(candidate(vec![1.0, 2.0, 3.0, 4.0, 5.0]), vec![0.0, 0.25, 0.5, 0.75, 1.0]);
assert_eq!(candidate(vec![2.0, 1.0, 5.0, 3.0, 4.0]), vec![0.25, 0.0, 1.0, 0.5, 0.75]);
assert_eq!(candidate(vec![12.0, 11.0, 15.0, 13.0, 14.0]), vec![0.25, 0.0, 1.0, 0.5, 0.75]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_21_rescale_to_unit.py
|
rs
|
[
"\n}"
] |
/// 引数で与えられた文字列の長さを返す
/// >>> strlen(String::from(""))
/// 0
/// >>> strlen(String::from("abc"))
/// 3
fn strlen(string: String) -> isize {
|
reworded
|
transform
|
HumanEval_23_strlen
|
}
fn main() {
let candidate = strlen;
assert_eq!(candidate(String::from("")), 0);
assert_eq!(candidate(String::from("x")), 1);
assert_eq!(candidate(String::from("asdasnakj")), 9);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_23_strlen.py
|
rs
|
[
"\n}"
] |
/// 与えられた数nについて、nの約数のうち、nより小さい最大の数を求める
/// >>> largest_divisor(15)
/// 5
fn largest_divisor(n: isize) -> isize {
|
reworded
|
transform
|
HumanEval_24_largest_divisor
|
}
fn main() {
let candidate = largest_divisor;
assert_eq!(candidate(3), 1);
assert_eq!(candidate(7), 1);
assert_eq!(candidate(10), 5);
assert_eq!(candidate(100), 50);
assert_eq!(candidate(49), 7);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_24_largest_divisor.py
|
rs
|
[
"\n}"
] |
/// 与えられた整数の素因数のリストを小さいものから大きいものの順に返す。各因数は、
/// 因数分解で現れる回数分、リストに登場する。引数の整数は全ての因数の積に等しくな
/// ければならない。
/// >>> factorize(8)
/// vec![2, 2, 2]
/// >>> factorize(25)
/// vec![5, 5]
/// >>> factorize(70)
/// vec![2, 5, 7]
fn factorize(n: isize) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_25_factorize
|
}
fn main() {
let candidate = factorize;
assert_eq!(candidate(2), vec![2]);
assert_eq!(candidate(4), vec![2, 2]);
assert_eq!(candidate(8), vec![2, 2, 2]);
assert_eq!(candidate(57), vec![3, 19]);
assert_eq!(candidate(3249), vec![3, 3, 19, 19]);
assert_eq!(candidate(185193), vec![3, 3, 3, 19, 19, 19]);
assert_eq!(candidate(20577), vec![3, 19, 19, 19]);
assert_eq!(candidate(18), vec![2, 3, 3]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_25_factorize.py
|
rs
|
[
"\n}"
] |
/// 整数のリストから、複数回出現する要素をすべて取り除く。
/// 要素の順序は入力と同じようにする。
/// >>> remove_duplicates(vec![1, 2, 3, 2, 4])
/// vec![1, 3, 4]
fn remove_duplicates(numbers: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_26_remove_duplicates
|
}
fn main() {
let candidate = remove_duplicates;
assert_eq!(candidate(Vec::<isize>::new()), Vec::<isize>::new());
assert_eq!(candidate(vec![1, 2, 3, 4]), vec![1, 2, 3, 4]);
assert_eq!(candidate(vec![1, 2, 3, 2, 4, 3, 5]), vec![1, 4, 5]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_26_remove_duplicates.py
|
rs
|
[
"\n}"
] |
/// 与えられた文字列に対して、英小文字を英大文字に、英大文字を英小文字に変換する。
/// >>> flip_case(String::from("Hello"))
/// String::from("hELLO")
fn flip_case(string: String) -> String {
|
reworded
|
transform
|
HumanEval_27_flip_case
|
}
fn main() {
let candidate = flip_case;
assert_eq!(candidate(String::from("")), String::from(""));
assert_eq!(candidate(String::from("Hello!")), String::from("hELLO!"));
assert_eq!(candidate(String::from("These violent delights have violent ends")), String::from("tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_27_flip_case.py
|
rs
|
[
"\n}"
] |
/// 文字列のリストを1つの文字列に連結する
/// >>> concatenate(vec![])
/// String::from("")
/// >>> concatenate(vec![String::from("a"), String::from("b"), String::from("c")])
/// String::from("abc")
fn concatenate(strings: Vec<String>) -> String {
|
reworded
|
transform
|
HumanEval_28_concatenate
|
}
fn main() {
let candidate = concatenate;
assert_eq!(candidate(Vec::<String>::new()), String::from(""));
assert_eq!(candidate(vec![String::from("x"), String::from("y"), String::from("z")]), String::from("xyz"));
assert_eq!(candidate(vec![String::from("x"), String::from("y"), String::from("z"), String::from("w"), String::from("k")]), String::from("xyzwk"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_28_concatenate.py
|
rs
|
[
"\n}"
] |
/// 文字列のリストから、指定された接頭辞prefixで始まるものだけを取り出す。
/// >>> filter_by_prefix(vec![], String::from("a"))
/// Vec::<String>::new()
/// >>> filter_by_prefix(vec![String::from("abc"), String::from("bcd"), String::from("cde"), String::from("array")], String::from("a"))
/// vec![String::from("abc"), String::from("array")]
fn filter_by_prefix(strings: Vec<String>, prefix: String) -> Vec<String> {
|
reworded
|
transform
|
HumanEval_29_filter_by_prefix
|
}
fn main() {
let candidate = filter_by_prefix;
assert_eq!(candidate(Vec::<String>::new(), String::from("john")), Vec::<String>::new());
assert_eq!(candidate(vec![String::from("xxx"), String::from("asd"), String::from("xxy"), String::from("john doe"), String::from("xxxAAA"), String::from("xxx")], String::from("xxx")), vec![String::from("xxx"), String::from("xxxAAA"), String::from("xxx")]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_29_filter_by_prefix.py
|
rs
|
[
"\n}"
] |
/// リスト内の正の数だけを返す。
/// >>> get_positive(vec![-1, 2, -4, 5, 6])
/// vec![2, 5, 6]
/// >>> get_positive(vec![5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
/// vec![5, 3, 2, 3, 9, 123, 1]
fn get_positive(l: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_30_get_positive
|
}
fn main() {
let candidate = get_positive;
assert_eq!(candidate(vec![-1, -2, 4, 5, 6]), vec![4, 5, 6]);
assert_eq!(candidate(vec![5, 3, -5, 2, 3, 3, 9, 0, 123, 1, -10]), vec![5, 3, 2, 3, 3, 9, 123, 1]);
assert_eq!(candidate(vec![-1, -2]), Vec::<isize>::new());
assert_eq!(candidate(Vec::<isize>::new()), Vec::<isize>::new());
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_30_get_positive.py
|
rs
|
[
"\n}"
] |
/// 与えられた数が素数であれば真を、そうでなければ偽を返す。
/// >>> is_prime(6)
/// false
/// >>> is_prime(101)
/// true
/// >>> is_prime(11)
/// true
/// >>> is_prime(13441)
/// true
/// >>> is_prime(61)
/// true
/// >>> is_prime(4)
/// false
/// >>> is_prime(1)
/// false
fn is_prime(n: isize) -> bool {
|
reworded
|
transform
|
HumanEval_31_is_prime
|
}
fn main() {
let candidate = is_prime;
assert_eq!(candidate(6), false);
assert_eq!(candidate(101), true);
assert_eq!(candidate(11), true);
assert_eq!(candidate(13441), true);
assert_eq!(candidate(61), true);
assert_eq!(candidate(4), false);
assert_eq!(candidate(1), false);
assert_eq!(candidate(5), true);
assert_eq!(candidate(11), true);
assert_eq!(candidate(17), true);
assert_eq!(candidate(85), false);
assert_eq!(candidate(77), false);
assert_eq!(candidate(255379), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_31_is_prime.py
|
rs
|
[
"\n}"
] |
/// この関数はリストlを受け取り、l'を返す。l'は、インデックスが3で割り
/// 切れない場合はlと同じであるが、インデックスが3で割り切れる要素は
/// ソートされている。
/// >>> sort_third(vec![1, 2, 3])
/// vec![1, 2, 3]
/// >>> sort_third(vec![5, 6, 3, 4, 8, 9, 2])
/// vec![2, 6, 3, 4, 8, 9, 5]
fn sort_third(l: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_33_sort_third
|
}
fn main() {
let candidate = sort_third;
assert_eq!(candidate(vec![5, 6, 3, 4, 8, 9, 2]), vec![2, 6, 3, 4, 8, 9, 5]);
assert_eq!(candidate(vec![5, 8, 3, 4, 6, 9, 2]), vec![2, 8, 3, 4, 6, 9, 5]);
assert_eq!(candidate(vec![5, 6, 9, 4, 8, 3, 2]), vec![2, 6, 9, 4, 8, 3, 5]);
assert_eq!(candidate(vec![5, 6, 3, 4, 8, 9, 2, 1]), vec![2, 6, 3, 4, 8, 9, 5, 1]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_33_sort_third.py
|
rs
|
[
"\n}"
] |
/// リスト内のユニークな要素をソートして返す
/// >>> unique(vec![5, 3, 5, 2, 3, 3, 9, 0, 123])
/// vec![0, 2, 3, 5, 9, 123]
fn unique(l: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_34_unique
|
}
fn main() {
let candidate = unique;
assert_eq!(candidate(vec![5, 3, 5, 2, 3, 3, 9, 0, 123]), vec![0, 2, 3, 5, 9, 123]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_34_unique.py
|
rs
|
[
"\n}"
] |
/// リスト内の最大要素を返す。
/// >>> max_element(vec![1, 2, 3])
/// 3
/// >>> max_element(vec![5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
/// 123
fn max_element(l: Vec<isize>) -> isize {
|
reworded
|
transform
|
HumanEval_35_max_element
|
}
fn main() {
let candidate = max_element;
assert_eq!(candidate(vec![1, 2, 3]), 3);
assert_eq!(candidate(vec![5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10]), 124);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_35_max_element.py
|
rs
|
[
"\n}"
] |
/// 与えられたn未満の整数の中で、11または13で割り切れる数の中に'7'という数字が何回現れるかを返す
/// >>> fizz_buzz(50)
/// 0
/// >>> fizz_buzz(78)
/// 2
/// >>> fizz_buzz(79)
/// 3
fn fizz_buzz(n: isize) -> isize {
|
reworded
|
transform
|
HumanEval_36_fizz_buzz
|
}
fn main() {
let candidate = fizz_buzz;
assert_eq!(candidate(50), 0);
assert_eq!(candidate(78), 2);
assert_eq!(candidate(79), 3);
assert_eq!(candidate(100), 3);
assert_eq!(candidate(200), 6);
assert_eq!(candidate(4000), 192);
assert_eq!(candidate(10000), 639);
assert_eq!(candidate(100000), 8026);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_36_fizz_buzz.py
|
rs
|
[
"\n}"
] |
/// この関数はリスト l を受け取り、l' を返す。l'は、インデックスが奇数の
/// ときは l と同じで、インデックスが偶数のときはソートされている。
/// >>> sort_even(vec![1, 2, 3])
/// vec![1, 2, 3]
/// >>> sort_even(vec![5, 6, 3, 4])
/// vec![3, 6, 5, 4]
fn sort_even(l: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_37_sort_even
|
}
fn main() {
let candidate = sort_even;
assert_eq!(candidate(vec![1, 2, 3]), vec![1, 2, 3]);
assert_eq!(candidate(vec![5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]), vec![-10, 3, -5, 2, -3, 3, 5, 0, 9, 1, 123]);
assert_eq!(candidate(vec![5, 8, -12, 4, 23, 2, 3, 11, 12, -10]), vec![-12, 8, 3, 4, 5, 2, 12, 11, 23, -10]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_37_sort_even.py
|
rs
|
[
"\n}"
] |
/// prime_fib はフィボナッチ数で、かつ素数であるn番目の数を返す。
/// >>> prime_fib(1)
/// 2
/// >>> prime_fib(2)
/// 3
/// >>> prime_fib(3)
/// 5
/// >>> prime_fib(4)
/// 13
/// >>> prime_fib(5)
/// 89
fn prime_fib(n: isize) -> isize {
|
reworded
|
transform
|
HumanEval_39_prime_fib
|
}
fn main() {
let candidate = prime_fib;
assert_eq!(candidate(1), 2);
assert_eq!(candidate(2), 3);
assert_eq!(candidate(3), 5);
assert_eq!(candidate(4), 13);
assert_eq!(candidate(5), 89);
assert_eq!(candidate(6), 233);
assert_eq!(candidate(7), 1597);
assert_eq!(candidate(8), 28657);
assert_eq!(candidate(9), 514229);
assert_eq!(candidate(10), 433494437);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_39_prime_fib.py
|
rs
|
[
"\n}"
] |
/// triples_sum_to_zero は整数のリストを引数に取り、
/// リストの中に和が0になる3つの要素があればtrueを、
/// そうでなければfalseを返す。
/// >>> triples_sum_to_zero(vec![1, 3, 5, 0])
/// false
/// >>> triples_sum_to_zero(vec![1, 3, -2, 1])
/// true
/// >>> triples_sum_to_zero(vec![1, 2, 3, 7])
/// false
/// >>> triples_sum_to_zero(vec![2, 4, -5, 3, 9, 7])
/// true
/// >>> triples_sum_to_zero(vec![1])
/// false
fn triples_sum_to_zero(l: Vec<isize>) -> bool {
|
reworded
|
transform
|
HumanEval_40_triples_sum_to_zero
|
}
fn main() {
let candidate = triples_sum_to_zero;
assert_eq!(candidate(vec![1, 3, 5, 0]), false);
assert_eq!(candidate(vec![1, 3, 5, -1]), false);
assert_eq!(candidate(vec![1, 3, -2, 1]), true);
assert_eq!(candidate(vec![1, 2, 3, 7]), false);
assert_eq!(candidate(vec![1, 2, 5, 7]), false);
assert_eq!(candidate(vec![2, 4, -5, 3, 9, 7]), true);
assert_eq!(candidate(vec![1]), false);
assert_eq!(candidate(vec![1, 3, 5, -100]), false);
assert_eq!(candidate(vec![100, 3, 5, -100]), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_40_triples_sum_to_zero.py
|
rs
|
[
"\n}"
] |
/// 完全な直線で無限に長い道路を想像してほしい。
/// n台の車が左から右に向かって走っている。同時に、別のn台の車が
/// 右から左に向かって走っている。この2組の車は、最初は互いに非
/// 常に離れている。すべての車は同じ速度で動く。2台の車は次のよ
/// うに衝突する。左から右に動いている車が、右から左に動いている
/// 車にぶつかること。
/// しかし、車は限りなく頑丈で強い。あたかも衝突しなかったかのよ
/// うに、その軌道を進み続ける。
/// この関数は、このような衝突の回数を出力する。
fn car_race_collision(n: isize) -> isize {
|
reworded
|
transform
|
HumanEval_41_car_race_collision
|
}
fn main() {
let candidate = car_race_collision;
assert_eq!(candidate(2), 4);
assert_eq!(candidate(3), 9);
assert_eq!(candidate(4), 16);
assert_eq!(candidate(8), 64);
assert_eq!(candidate(10), 100);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_41_car_race_collision.py
|
rs
|
[
"\n}"
] |
/// 要素を1ずつ増やしたリストを返す。
/// >>> incr_list(vec![1, 2, 3])
/// vec![2, 3, 4]
/// >>> incr_list(vec![5, 3, 5, 2, 3, 3, 9, 0, 123])
/// vec![6, 4, 6, 3, 4, 4, 10, 1, 124]
fn incr_list(l: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_42_incr_list
|
}
fn main() {
let candidate = incr_list;
assert_eq!(candidate(Vec::<isize>::new()), Vec::<isize>::new());
assert_eq!(candidate(vec![3, 2, 1]), vec![4, 3, 2]);
assert_eq!(candidate(vec![5, 2, 5, 2, 3, 3, 9, 0, 123]), vec![6, 3, 6, 3, 4, 4, 10, 1, 124]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_42_incr_list.py
|
rs
|
[
"\n}"
] |
/// pairs_sum_to_zero は整数のリストを引数にとる。
/// リストの中に2つの要素の和がゼロになる要素があればtrueを、
/// そうでなければfalseを返す。
/// >>> pairs_sum_to_zero(vec![1, 3, 5, 0])
/// false
/// >>> pairs_sum_to_zero(vec![1, 3, -2, 1])
/// false
/// >>> pairs_sum_to_zero(vec![1, 2, 3, 7])
/// false
/// >>> pairs_sum_to_zero(vec![2, 4, -5, 3, 5, 7])
/// true
/// >>> pairs_sum_to_zero(vec![1])
/// false
fn pairs_sum_to_zero(l: Vec<isize>) -> bool {
|
reworded
|
transform
|
HumanEval_43_pairs_sum_to_zero
|
}
fn main() {
let candidate = pairs_sum_to_zero;
assert_eq!(candidate(vec![1, 3, 5, 0]), false);
assert_eq!(candidate(vec![1, 3, -2, 1]), false);
assert_eq!(candidate(vec![1, 2, 3, 7]), false);
assert_eq!(candidate(vec![2, 4, -5, 3, 5, 7]), true);
assert_eq!(candidate(vec![1]), false);
assert_eq!(candidate(vec![-3, 9, -1, 3, 2, 30]), true);
assert_eq!(candidate(vec![-3, 9, -1, 3, 2, 31]), true);
assert_eq!(candidate(vec![-3, 9, -1, 4, 2, 30]), false);
assert_eq!(candidate(vec![-3, 9, -1, 4, 2, 31]), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_43_pairs_sum_to_zero.py
|
rs
|
[
"\n}"
] |
/// 引数xの基数をbaseに変換する。
/// 返り値は変換後の文字列表現である。
/// 基数は10未満である。
/// >>> change_base(8, 3)
/// String::from("22")
/// >>> change_base(8, 2)
/// String::from("1000")
/// >>> change_base(7, 2)
/// String::from("111")
fn change_base(x: isize, base: isize) -> String {
|
reworded
|
transform
|
HumanEval_44_change_base
|
}
fn main() {
let candidate = change_base;
assert_eq!(candidate(8, 3), String::from("22"));
assert_eq!(candidate(9, 3), String::from("100"));
assert_eq!(candidate(234, 2), String::from("11101010"));
assert_eq!(candidate(16, 2), String::from("10000"));
assert_eq!(candidate(8, 2), String::from("1000"));
assert_eq!(candidate(7, 2), String::from("111"));
assert_eq!(candidate(2, 3), String::from("2"));
assert_eq!(candidate(3, 4), String::from("3"));
assert_eq!(candidate(4, 5), String::from("4"));
assert_eq!(candidate(5, 6), String::from("5"));
assert_eq!(candidate(6, 7), String::from("6"));
assert_eq!(candidate(7, 8), String::from("7"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_44_change_base.py
|
rs
|
[
"\n}"
] |
/// 三角形の一辺の長さと高さが与えられたとき、面積を返す。
/// >>> triangle_area(5, 3)
/// 7.5
fn triangle_area(a: isize, h: isize) -> f64 {
|
reworded
|
transform
|
HumanEval_45_triangle_area
|
}
fn main() {
let candidate = triangle_area;
assert_eq!(candidate(5, 3), 7.5);
assert_eq!(candidate(2, 2), 2.0);
assert_eq!(candidate(10, 8), 40.0);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_45_triangle_area.py
|
rs
|
[
"\n}"
] |
/// fib4数列はフィボナッチ数列に似た数列で、次のように定義される:
/// fib4(0) -> 0
/// fib4(1) -> 0
/// fib4(2) -> 2
/// fib4(3) -> 0
/// fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
/// fib4数列のn番目の要素を効率的に計算する関数を書け。再帰は使わないこと。
/// >>> fib4(5)
/// 4
/// >>> fib4(6)
/// 8
/// >>> fib4(7)
/// 14
fn fib4(n: isize) -> isize {
|
reworded
|
transform
|
HumanEval_46_fib4
|
}
fn main() {
let candidate = fib4;
assert_eq!(candidate(5), 4);
assert_eq!(candidate(8), 28);
assert_eq!(candidate(10), 104);
assert_eq!(candidate(12), 386);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_46_fib4.py
|
rs
|
[
"\n}"
] |
/// リスト l の要素の中央値を返す。
/// >>> median(vec![3, 1, 2, 4, 5])
/// 3.0
/// >>> median(vec![-10, 4, 6, 1000, 10, 20])
/// 15.0
fn median(l: Vec<isize>) -> f64 {
|
reworded
|
transform
|
HumanEval_47_median
|
}
fn main() {
let candidate = median;
assert_eq!(candidate(vec![3, 1, 2, 4, 5]), 3.0);
assert_eq!(candidate(vec![-10, 4, 6, 1000, 10, 20]), 8.0);
assert_eq!(candidate(vec![5]), 5.0);
assert_eq!(candidate(vec![6, 5]), 5.5);
assert_eq!(candidate(vec![8, 1, 3, 9, 9, 2, 7]), 7.0);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_47_median.py
|
rs
|
[
"\n}"
] |
/// 与えられた文字列が回文かどうかを判定する
/// >>> is_palindrome(String::from(""))
/// true
/// >>> is_palindrome(String::from("aba"))
/// true
/// >>> is_palindrome(String::from("aaaaa"))
/// true
/// >>> is_palindrome(String::from("zbcd"))
/// false
fn is_palindrome(text: String) -> bool {
|
reworded
|
transform
|
HumanEval_48_is_palindrome
|
}
fn main() {
let candidate = is_palindrome;
assert_eq!(candidate(String::from("")), true);
assert_eq!(candidate(String::from("aba")), true);
assert_eq!(candidate(String::from("aaaaa")), true);
assert_eq!(candidate(String::from("zbcd")), false);
assert_eq!(candidate(String::from("xywyx")), true);
assert_eq!(candidate(String::from("xywyz")), false);
assert_eq!(candidate(String::from("xywzx")), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_48_is_palindrome.py
|
rs
|
[
"\n}"
] |
/// 2^n を p で割ったモジュロを返す。計算精度に注意。
/// >>> modp(3, 5)
/// 3
/// >>> modp(1101, 101)
/// 2
/// >>> modp(0, 101)
/// 1
/// >>> modp(3, 11)
/// 8
/// >>> modp(100, 101)
/// 1
fn modp(n: isize, p: isize) -> isize {
|
reworded
|
transform
|
HumanEval_49_modp
|
}
fn main() {
let candidate = modp;
assert_eq!(candidate(3, 5), 3);
assert_eq!(candidate(1101, 101), 2);
assert_eq!(candidate(0, 101), 1);
assert_eq!(candidate(3, 11), 8);
assert_eq!(candidate(100, 101), 1);
assert_eq!(candidate(30, 5), 4);
assert_eq!(candidate(31, 5), 3);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_49_modp.py
|
rs
|
[
"\n}"
] |
/// remove_vowelsは文字列を引数に取り、母音を除いた文字列を返す関数である。
/// >>> remove_vowels(String::from(""))
/// String::from("")
/// >>> remove_vowels(String::from("abcdef"))
/// String::from("bcdf")
/// >>> remove_vowels(String::from("aaaaa"))
/// String::from("")
/// >>> remove_vowels(String::from("aaBAA"))
/// String::from("B")
/// >>> remove_vowels(String::from("zbcd"))
/// String::from("zbcd")
fn remove_vowels(text: String) -> String {
|
reworded
|
transform
|
HumanEval_51_remove_vowels
|
}
fn main() {
let candidate = remove_vowels;
assert_eq!(candidate(String::from("")), String::from(""));
assert_eq!(candidate(String::from("abcdef
ghijklm")), String::from("bcdf
ghjklm"));
assert_eq!(candidate(String::from("fedcba")), String::from("fdcb"));
assert_eq!(candidate(String::from("eeeee")), String::from(""));
assert_eq!(candidate(String::from("acBAA")), String::from("cB"));
assert_eq!(candidate(String::from("EcBOO")), String::from("cB"));
assert_eq!(candidate(String::from("ybcd")), String::from("ybcd"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_51_remove_vowels.py
|
rs
|
[
"\n}"
] |
/// リスト l 内の全ての数値が閾値 t 未満の場合、trueを返す。
/// >>> below_threshold(vec![1, 2, 4, 10], 100)
/// true
/// >>> below_threshold(vec![1, 20, 4, 10], 5)
/// false
fn below_threshold(l: Vec<isize>, t: isize) -> bool {
|
reworded
|
transform
|
HumanEval_52_below_threshold
|
}
fn main() {
let candidate = below_threshold;
assert_eq!(candidate(vec![1, 2, 4, 10], 100), true);
assert_eq!(candidate(vec![1, 20, 4, 10], 5), false);
assert_eq!(candidate(vec![1, 20, 4, 10], 21), true);
assert_eq!(candidate(vec![1, 20, 4, 10], 22), true);
assert_eq!(candidate(vec![1, 8, 4, 10], 11), true);
assert_eq!(candidate(vec![1, 8, 4, 10], 10), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_52_below_threshold.py
|
rs
|
[
"\n}"
] |
/// 2つの数xとyを足す
/// >>> add(2, 3)
/// 5
/// >>> add(5, 7)
/// 12
fn add(x: isize, y: isize) -> isize {
|
reworded
|
transform
|
HumanEval_53_add
|
}
fn main() {
let candidate = add;
assert_eq!(candidate(0, 1), 1);
assert_eq!(candidate(1, 0), 1);
assert_eq!(candidate(2, 3), 5);
assert_eq!(candidate(5, 7), 12);
assert_eq!(candidate(7, 5), 12);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_53_add.py
|
rs
|
[
"\n}"
] |
/// 2つの単語が同じ文字セットから構成されるかどうか判定する。
/// >>> same_chars(String::from("eabcdzzzz"), String::from("dddzzzzzzzddeddabc"))
/// true
/// >>> same_chars(String::from("abcd"), String::from("dddddddabc"))
/// true
/// >>> same_chars(String::from("dddddddabc"), String::from("abcd"))
/// true
/// >>> same_chars(String::from("eabcd"), String::from("dddddddabc"))
/// false
/// >>> same_chars(String::from("abcd"), String::from("dddddddabce"))
/// false
/// >>> same_chars(String::from("eabcdzzzz"), String::from("dddzzzzzzzddddabc"))
/// false
fn same_chars(s0: String, s1: String) -> bool {
|
reworded
|
transform
|
HumanEval_54_same_chars
|
}
fn main() {
let candidate = same_chars;
assert_eq!(candidate(String::from("eabcdzzzz"), String::from("dddzzzzzzzddeddabc")), true);
assert_eq!(candidate(String::from("abcd"), String::from("dddddddabc")), true);
assert_eq!(candidate(String::from("dddddddabc"), String::from("abcd")), true);
assert_eq!(candidate(String::from("eabcd"), String::from("dddddddabc")), false);
assert_eq!(candidate(String::from("abcd"), String::from("dddddddabcf")), false);
assert_eq!(candidate(String::from("eabcdzzzz"), String::from("dddzzzzzzzddddabc")), false);
assert_eq!(candidate(String::from("aabb"), String::from("aaccc")), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_54_same_chars.py
|
rs
|
[
"\n}"
] |
/// n番目のフィボナッチ数を返す。
/// >>> fib(10)
/// 55
/// >>> fib(1)
/// 1
/// >>> fib(8)
/// 21
fn fib(n: isize) -> isize {
|
reworded
|
transform
|
HumanEval_55_fib
|
}
fn main() {
let candidate = fib;
assert_eq!(candidate(10), 55);
assert_eq!(candidate(1), 1);
assert_eq!(candidate(8), 21);
assert_eq!(candidate(11), 89);
assert_eq!(candidate(12), 144);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_55_fib.py
|
rs
|
[
"\n}"
] |
/// 引数bracketsは"<"と">"の文字列である。
/// すべての開き括弧が対応する閉じ括弧を持つ場合、trueを返す。
/// >>> correct_bracketing(String::from("<"))
/// false
/// >>> correct_bracketing(String::from("<>"))
/// true
/// >>> correct_bracketing(String::from("<<><>>"))
/// true
/// >>> correct_bracketing(String::from("><<>"))
/// false
fn correct_bracketing(brackets: String) -> bool {
|
reworded
|
transform
|
HumanEval_56_correct_bracketing
|
}
fn main() {
let candidate = correct_bracketing;
assert_eq!(candidate(String::from("<>")), true);
assert_eq!(candidate(String::from("<<><>>")), true);
assert_eq!(candidate(String::from("<><><<><>><>")), true);
assert_eq!(candidate(String::from("<><><<<><><>><>><<><><<>>>")), true);
assert_eq!(candidate(String::from("<<<><>>>>")), false);
assert_eq!(candidate(String::from("><<>")), false);
assert_eq!(candidate(String::from("<")), false);
assert_eq!(candidate(String::from("<<<<")), false);
assert_eq!(candidate(String::from(">")), false);
assert_eq!(candidate(String::from("<<>")), false);
assert_eq!(candidate(String::from("<><><<><>><>><<>")), false);
assert_eq!(candidate(String::from("<><><<><>><>>><>")), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_56_correct_bracketing.py
|
rs
|
[
"\n}"
] |
/// リストの要素が単調増加または単調減少する場合にtrueを返す。
/// >>> monotonic(vec![1, 2, 4, 20])
/// true
/// >>> monotonic(vec![1, 20, 4, 10])
/// false
/// >>> monotonic(vec![4, 1, 0, -10])
/// true
fn monotonic(l: Vec<isize>) -> bool {
|
reworded
|
transform
|
HumanEval_57_monotonic
|
}
fn main() {
let candidate = monotonic;
assert_eq!(candidate(vec![1, 2, 4, 10]), true);
assert_eq!(candidate(vec![1, 2, 4, 20]), true);
assert_eq!(candidate(vec![1, 20, 4, 10]), false);
assert_eq!(candidate(vec![4, 1, 0, -10]), true);
assert_eq!(candidate(vec![4, 1, 1, 0]), true);
assert_eq!(candidate(vec![1, 2, 3, 2, 5, 60]), false);
assert_eq!(candidate(vec![1, 2, 3, 4, 5, 60]), true);
assert_eq!(candidate(vec![9, 9, 9, 9]), true);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_57_monotonic.py
|
rs
|
[
"\n}"
] |
/// 2つのリストについて、ユニークな共通要素をソートして返す。
/// >>> common(vec![1, 4, 3, 34, 653, 2, 5], vec![5, 7, 1, 5, 9, 653, 121])
/// vec![1, 5, 653]
/// >>> common(vec![5, 3, 2, 8], vec![3, 2])
/// vec![2, 3]
fn common(l1: Vec<isize>, l2: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_58_common
|
}
fn main() {
let candidate = common;
assert_eq!(candidate(vec![1, 4, 3, 34, 653, 2, 5], vec![5, 7, 1, 5, 9, 653, 121]), vec![1, 5, 653]);
assert_eq!(candidate(vec![5, 3, 2, 8], vec![3, 2]), vec![2, 3]);
assert_eq!(candidate(vec![4, 3, 2, 8], vec![3, 2, 4]), vec![2, 3, 4]);
assert_eq!(candidate(vec![4, 3, 2, 8], Vec::<isize>::new()), Vec::<isize>::new());
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_58_common.py
|
rs
|
[
"\n}"
] |
/// nの最大となる素因数を返す。ただし、 n > 1 を前提とし、素数ではないものとする。
/// >>> largest_prime_factor(13195)
/// 29
/// >>> largest_prime_factor(2048)
/// 2
fn largest_prime_factor(n: isize) -> isize {
|
reworded
|
transform
|
HumanEval_59_largest_prime_factor
|
}
fn main() {
let candidate = largest_prime_factor;
assert_eq!(candidate(15), 5);
assert_eq!(candidate(27), 3);
assert_eq!(candidate(63), 7);
assert_eq!(candidate(330), 11);
assert_eq!(candidate(13195), 29);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_59_largest_prime_factor.py
|
rs
|
[
"\n}"
] |
/// sum_to_nは1からnまでの総和を求める関数である。
/// >>> sum_to_n(30)
/// 465
/// >>> sum_to_n(100)
/// 5050
/// >>> sum_to_n(5)
/// 15
/// >>> sum_to_n(10)
/// 55
/// >>> sum_to_n(1)
/// 1
fn sum_to_n(n: isize) -> isize {
|
reworded
|
transform
|
HumanEval_60_sum_to_n
|
}
fn main() {
let candidate = sum_to_n;
assert_eq!(candidate(1), 1);
assert_eq!(candidate(6), 21);
assert_eq!(candidate(11), 66);
assert_eq!(candidate(30), 465);
assert_eq!(candidate(100), 5050);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_60_sum_to_n.py
|
rs
|
[
"\n}"
] |
/// 引数bracketsは"("と") "からなる文字列である。
/// すべての開き括弧が対応する閉じ括弧を持つ場合、trueを返す。
/// >>> correct_bracketing(String::from("("))
/// false
/// >>> correct_bracketing(String::from("()"))
/// true
/// >>> correct_bracketing(String::from("(()())"))
/// true
/// >>> correct_bracketing(String::from(")(()"))
/// false
fn correct_bracketing(brackets: String) -> bool {
|
reworded
|
transform
|
HumanEval_61_correct_bracketing
|
}
fn main() {
let candidate = correct_bracketing;
assert_eq!(candidate(String::from("()")), true);
assert_eq!(candidate(String::from("(()())")), true);
assert_eq!(candidate(String::from("()()(()())()")), true);
assert_eq!(candidate(String::from("()()((()()())())(()()(()))")), true);
assert_eq!(candidate(String::from("((()())))")), false);
assert_eq!(candidate(String::from(")(()")), false);
assert_eq!(candidate(String::from("(")), false);
assert_eq!(candidate(String::from("((((")), false);
assert_eq!(candidate(String::from(")")), false);
assert_eq!(candidate(String::from("(()")), false);
assert_eq!(candidate(String::from("()()(()())())(()")), false);
assert_eq!(candidate(String::from("()()(()())()))()")), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_61_correct_bracketing.py
|
rs
|
[
"\n}"
] |
/// xsは多項式の係数列を表す。
/// xs[0] + xs[1] * x + xs[2] * x^2 + ....
/// 関数は、この多項式の導関数を同じ形式で返す。
/// >>> derivative(vec![3, 1, 2, 4, 5])
/// vec![1, 4, 12, 20]
/// >>> derivative(vec![1, 2, 3])
/// vec![2, 6]
fn derivative(xs: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_62_derivative
|
}
fn main() {
let candidate = derivative;
assert_eq!(candidate(vec![3, 1, 2, 4, 5]), vec![1, 4, 12, 20]);
assert_eq!(candidate(vec![1, 2, 3]), vec![2, 6]);
assert_eq!(candidate(vec![3, 2, 1]), vec![2, 2]);
assert_eq!(candidate(vec![3, 2, 1, 0, 4]), vec![2, 2, 0, 16]);
assert_eq!(candidate(vec![1]), Vec::<isize>::new());
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_62_derivative.py
|
rs
|
[
"\n}"
] |
/// FibFib数列はフィボナッチ数列に似た数列で、以下のように定義される:
/// fibfib(0) == 0
/// fibfib(1) == 0
/// fibfib(2) == 1
/// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
/// fibfib数列のn番目の要素を効率よく計算する関数を書いてください。
/// >>> fibfib(1)
/// 0
/// >>> fibfib(5)
/// 4
/// >>> fibfib(8)
/// 24
fn fibfib(n: isize) -> isize {
|
reworded
|
transform
|
HumanEval_63_fibfib
|
}
fn main() {
let candidate = fibfib;
assert_eq!(candidate(2), 1);
assert_eq!(candidate(1), 0);
assert_eq!(candidate(5), 4);
assert_eq!(candidate(8), 24);
assert_eq!(candidate(10), 81);
assert_eq!(candidate(12), 274);
assert_eq!(candidate(14), 927);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_63_fibfib.py
|
rs
|
[
"\n}"
] |
/// 単語を表す文字列を引数とし、その文字列に含まれる母音の数を返す
/// 関数 vowels_count を書きなさい。この場合の母音は'a', 'e', 'i', 'o', 'u'である。
/// ここで、与えられた単語の末尾にある場合のみ、'y'も母音とする。
/// 例::
/// >>> vowels_count(String::from("abcde"))
/// 2
/// >>> vowels_count(String::from("ACEDY"))
/// 3
fn vowels_count(s: String) -> isize {
|
reworded
|
transform
|
HumanEval_64_vowels_count
|
}
fn main() {
let candidate = vowels_count;
assert_eq!(candidate(String::from("abcde")), 2);
assert_eq!(candidate(String::from("Alone")), 3);
assert_eq!(candidate(String::from("key")), 2);
assert_eq!(candidate(String::from("bye")), 1);
assert_eq!(candidate(String::from("keY")), 2);
assert_eq!(candidate(String::from("bYe")), 1);
assert_eq!(candidate(String::from("ACEDY")), 3);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_64_vowels_count.py
|
rs
|
[
"\n}"
] |
/// 整数 x の桁を循環シフトする。shift 分だけ桁を右にシフトし、結果を文字列として返す。
/// もし、shift > 桁数なら、桁を反転して返す。
/// >>> circular_shift(12, 1)
/// String::from("21")
/// >>> circular_shift(12, 2)
/// String::from("12")
fn circular_shift(x: isize, shift: isize) -> String {
|
reworded
|
transform
|
HumanEval_65_circular_shift
|
}
fn main() {
let candidate = circular_shift;
assert_eq!(candidate(100, 2), String::from("001"));
assert_eq!(candidate(12, 2), String::from("12"));
assert_eq!(candidate(97, 8), String::from("79"));
assert_eq!(candidate(12, 1), String::from("21"));
assert_eq!(candidate(11, 101), String::from("11"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_65_circular_shift.py
|
rs
|
[
"\n}"
] |
/// タスク
/// 文字列を引数にとり、英大文字のみのASCIIコードの和を返す関数を書く。
/// Examples:
/// >>> digitSum(String::from(""))
/// 0
/// >>> digitSum(String::from("abAB"))
/// 131
/// >>> digitSum(String::from("abcCd"))
/// 67
/// >>> digitSum(String::from("helloE"))
/// 69
/// >>> digitSum(String::from("woArBld"))
/// 131
/// >>> digitSum(String::from("aAaaaXa"))
/// 153
fn digitSum(s: String) -> isize {
|
reworded
|
transform
|
HumanEval_66_digitSum
|
}
fn main() {
let candidate = digitSum;
assert_eq!(candidate(String::from("")), 0);
assert_eq!(candidate(String::from("abAB")), 131);
assert_eq!(candidate(String::from("abcCd")), 67);
assert_eq!(candidate(String::from("helloE")), 69);
assert_eq!(candidate(String::from("woArBld")), 131);
assert_eq!(candidate(String::from("aAaaaXa")), 153);
assert_eq!(candidate(String::from(" How are yOu?")), 151);
assert_eq!(candidate(String::from("You arE Very Smart")), 327);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_66_digitSum.py
|
rs
|
[
"\n}"
] |
/// この課題では、果物の入ったカゴに配られたリンゴとオレンジの数を表す文字列が
/// 与えられ、このカゴにはリンゴ、オレンジ、マンゴーの果実が入っている。オレンジ
/// とリンゴの総数を表す文字列と、かごの中の果物の総数を表す整数が与えられたら、
/// かごの中のマンゴーの果物の数を返しなさい。
/// たとえば:
/// >>> fruit_distribution(String::from("5 apples and 6 oranges"), 19)
/// 8
/// >>> fruit_distribution(String::from("0 apples and 1 oranges"), 3)
/// 2
/// >>> fruit_distribution(String::from("2 apples and 3 oranges"), 100)
/// 95
/// >>> fruit_distribution(String::from("100 apples and 1 oranges"), 120)
/// 19
fn fruit_distribution(s: String, n: isize) -> isize {
|
reworded
|
transform
|
HumanEval_67_fruit_distribution
|
}
fn main() {
let candidate = fruit_distribution;
assert_eq!(candidate(String::from("5 apples and 6 oranges"), 19), 8);
assert_eq!(candidate(String::from("5 apples and 6 oranges"), 21), 10);
assert_eq!(candidate(String::from("0 apples and 1 oranges"), 3), 2);
assert_eq!(candidate(String::from("1 apples and 0 oranges"), 3), 2);
assert_eq!(candidate(String::from("2 apples and 3 oranges"), 100), 95);
assert_eq!(candidate(String::from("2 apples and 3 oranges"), 5), 0);
assert_eq!(candidate(String::from("1 apples and 100 oranges"), 120), 19);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_67_fruit_distribution.py
|
rs
|
[
"\n}"
] |
/// 非負整数のノードを持つ木の枝を表す配列が与えられたとする。あなたの仕事は、
/// ノードの1つを抜き取り、それを返すことである。
/// 摘出されるノードは、最小偶数値を持つノードでなければならない。
/// 同じ最小偶数値を持つノードが複数見つかった場合は、最小のインデックスを持つ
/// ノードを返す。
/// 摘出されたノードは [ smalest_value, its index ] というリストで返されなければならない。
/// 偶数値がない場合や与えられた配列が空の場合は [] を返します。
/// 例 1:
/// >>> pluck(vec![4, 2, 3])
/// vec![2, 1]
/// 解説: 2は最小偶数値を持ち、最小インデックスを持つ。
/// 例 2:
/// >>> pluck(vec![1, 2, 3])
/// vec![2, 1]
/// 解説: 2が最小偶数値で、2が最小インデックスを持つ。
/// 例 3:
/// >>> pluck(vec![])
/// Vec::<isize>::new()
/// 例 4:
/// >>> pluck(vec![5, 0, 3, 0, 4, 2])
/// vec![0, 1]
/// 解説: 0は最小値だが、0は2つあるので、最小インデックスを持つ最初の0を選ぶ。
/// 制約:
/// * 1 <= ノードの長さ <= 10000
/// * 0 <= ノードの値
fn pluck(arr: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_68_pluck
|
}
fn main() {
let candidate = pluck;
assert_eq!(candidate(vec![4, 2, 3]), vec![2, 1]);
assert_eq!(candidate(vec![1, 2, 3]), vec![2, 1]);
assert_eq!(candidate(Vec::<isize>::new()), Vec::<isize>::new());
assert_eq!(candidate(vec![5, 0, 3, 0, 4, 2]), vec![0, 1]);
assert_eq!(candidate(vec![1, 2, 3, 0, 5, 3]), vec![0, 3]);
assert_eq!(candidate(vec![5, 4, 8, 4, 8]), vec![4, 1]);
assert_eq!(candidate(vec![7, 6, 7, 1]), vec![6, 1]);
assert_eq!(candidate(vec![7, 9, 7, 1]), Vec::<isize>::new());
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_68_pluck.py
|
rs
|
[
"\n}"
] |
/// 正の整数の空でないリストが与えられる。0より大きく、その整数自身の値以上の頻度を
/// 持つ最大の整数を返せ。整数の頻度とは、それがリストに現れる回数である。
/// のような値が存在しない場合は -1 を返す。
/// 例:
/// >>> search(vec![4, 1, 2, 2, 3, 1])
/// 2
/// >>> search(vec![1, 2, 2, 3, 3, 3, 4, 4, 4])
/// 3
/// >>> search(vec![5, 5, 4, 4, 4])
/// -1
fn search(lst: Vec<isize>) -> isize {
|
reworded
|
transform
|
HumanEval_69_search
|
}
fn main() {
let candidate = search;
assert_eq!(candidate(vec![5, 5, 5, 5, 1]), 1);
assert_eq!(candidate(vec![4, 1, 4, 1, 4, 4]), 4);
assert_eq!(candidate(vec![3, 3]), -1);
assert_eq!(candidate(vec![8, 8, 8, 8, 8, 8, 8, 8]), 8);
assert_eq!(candidate(vec![2, 3, 3, 2, 2]), 2);
assert_eq!(candidate(vec![2, 7, 8, 8, 4, 8, 7, 3, 9, 6, 5, 10, 4, 3, 6, 7, 1, 7, 4, 10, 8, 1]), 1);
assert_eq!(candidate(vec![3, 2, 8, 2]), 2);
assert_eq!(candidate(vec![6, 7, 1, 8, 8, 10, 5, 8, 5, 3, 10]), 1);
assert_eq!(candidate(vec![8, 8, 3, 6, 5, 6, 4]), -1);
assert_eq!(candidate(vec![6, 9, 6, 7, 1, 4, 7, 1, 8, 8, 9, 8, 10, 10, 8, 4, 10, 4, 10, 1, 2, 9, 5, 7, 9]), 1);
assert_eq!(candidate(vec![1, 9, 10, 1, 3]), 1);
assert_eq!(candidate(vec![6, 9, 7, 5, 8, 7, 5, 3, 7, 5, 10, 10, 3, 6, 10, 2, 8, 6, 5, 4, 9, 5, 3, 10]), 5);
assert_eq!(candidate(vec![1]), 1);
assert_eq!(candidate(vec![8, 8, 10, 6, 4, 3, 5, 8, 2, 4, 2, 8, 4, 6, 10, 4, 2, 1, 10, 2, 1, 1, 5]), 4);
assert_eq!(candidate(vec![2, 10, 4, 8, 2, 10, 5, 1, 2, 9, 5, 5, 6, 3, 8, 6, 4, 10]), 2);
assert_eq!(candidate(vec![1, 6, 10, 1, 6, 9, 10, 8, 6, 8, 7, 3]), 1);
assert_eq!(candidate(vec![9, 2, 4, 1, 5, 1, 5, 2, 5, 7, 7, 7, 3, 10, 1, 5, 4, 2, 8, 4, 1, 9, 10, 7, 10, 2, 8, 10, 9, 4]), 4);
assert_eq!(candidate(vec![2, 6, 4, 2, 8, 7, 5, 6, 4, 10, 4, 6, 3, 7, 8, 8, 3, 1, 4, 2, 2, 10, 7]), 4);
assert_eq!(candidate(vec![9, 8, 6, 10, 2, 6, 10, 2, 7, 8, 10, 3, 8, 2, 6, 2, 3, 1]), 2);
assert_eq!(candidate(vec![5, 5, 3, 9, 5, 6, 3, 2, 8, 5, 6, 10, 10, 6, 8, 4, 10, 7, 7, 10, 8]), -1);
assert_eq!(candidate(vec![10]), -1);
assert_eq!(candidate(vec![9, 7, 7, 2, 4, 7, 2, 10, 9, 7, 5, 7, 2]), 2);
assert_eq!(candidate(vec![5, 4, 10, 2, 1, 1, 10, 3, 6, 1, 8]), 1);
assert_eq!(candidate(vec![7, 9, 9, 9, 3, 4, 1, 5, 9, 1, 2, 1, 1, 10, 7, 5, 6, 7, 6, 7, 7, 6]), 1);
assert_eq!(candidate(vec![3, 10, 10, 9, 2]), -1);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_69_search.py
|
rs
|
[
"\n}"
] |
/// 整数のリストが与えられたとき、リストを奇妙な順序で返す。
/// 奇妙なソートとは、最小値から始まり、残りの整数の最大値、最小値の順で
/// ソートすることである。
/// 例:
/// >>> strange_sort_list(vec![1, 2, 3, 4])
/// vec![1, 4, 2, 3]
/// >>> strange_sort_list(vec![5, 5, 5, 5])
/// vec![5, 5, 5, 5]
/// >>> strange_sort_list(vec![])
/// Vec::<isize>::new()
fn strange_sort_list(lst: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_70_strange_sort_list
|
}
fn main() {
let candidate = strange_sort_list;
assert_eq!(candidate(vec![1, 2, 3, 4]), vec![1, 4, 2, 3]);
assert_eq!(candidate(vec![5, 6, 7, 8, 9]), vec![5, 9, 6, 8, 7]);
assert_eq!(candidate(vec![1, 2, 3, 4, 5]), vec![1, 5, 2, 4, 3]);
assert_eq!(candidate(vec![5, 6, 7, 8, 9, 1]), vec![1, 9, 5, 8, 6, 7]);
assert_eq!(candidate(vec![5, 5, 5, 5]), vec![5, 5, 5, 5]);
assert_eq!(candidate(Vec::<isize>::new()), Vec::<isize>::new());
assert_eq!(candidate(vec![1, 2, 3, 4, 5, 6, 7, 8]), vec![1, 8, 2, 7, 3, 6, 4, 5]);
assert_eq!(candidate(vec![0, 2, 2, 2, 5, 5, -5, -5]), vec![-5, 5, -5, 5, 0, 2, 2, 2]);
assert_eq!(candidate(vec![111111]), vec![111111]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_70_strange_sort_list.py
|
rs
|
[
"\n}"
] |
/// 三角形の3辺の長さが与えられた。3辺が有効な三角形を形成していれば、
/// 三角形の面積を小数点以下2桁で四捨五入して返す。そうでない場合は-1を
/// 返す。
/// 任意の2辺の和が3辺より大きいとき、3辺は有効な三角形となる。
/// 例:
/// >>> triangle_area(3, 4, 5)
/// 6.0
/// >>> triangle_area(1, 2, 10)
/// -1.0
fn triangle_area(a: isize, b: isize, c: isize) -> f64 {
|
reworded
|
transform
|
HumanEval_71_triangle_area
|
}
fn main() {
let candidate = triangle_area;
assert_eq!(candidate(3, 4, 5), 6.0);
assert_eq!(candidate(1, 2, 10), -1.0);
assert_eq!(candidate(4, 8, 5), 8.18);
assert_eq!(candidate(2, 2, 2), 1.73);
assert_eq!(candidate(1, 2, 3), -1.0);
assert_eq!(candidate(10, 5, 7), 16.25);
assert_eq!(candidate(2, 6, 3), -1.0);
assert_eq!(candidate(1, 1, 1), 0.43);
assert_eq!(candidate(2, 2, 10), -1.0);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_71_triangle_area.py
|
rs
|
[
"\n}"
] |
/// 物体qが飛べばtrueを、そうでなければfalseを返す関数を書け。
/// 物体qはバランスが取れていて(つまり、リストが回文であって)、その要素の和が
/// 最大荷重w以下であれば飛ぶ。
/// 例:
/// >>> will_it_fly(vec![1, 2], 5)
/// false
/// # 1+2 は最大荷重以下であるが、バランスが取れていない
/// >>> will_it_fly(vec![3, 2, 3], 1)
/// false
/// # バランスが取れているが、3+2+3 は最大荷重を超える
/// >>> will_it_fly(vec![3, 2, 3], 9)
/// true
/// # 3+2+3 は最大荷重以下であり、バランスも取れている
/// >>> will_it_fly(vec![3], 5)
/// true
/// # 3 は最大荷重以下であり、バランスも取れている
fn will_it_fly(q: Vec<isize>, w: isize) -> bool {
|
reworded
|
transform
|
HumanEval_72_will_it_fly
|
}
fn main() {
let candidate = will_it_fly;
assert_eq!(candidate(vec![3, 2, 3], 9), true);
assert_eq!(candidate(vec![1, 2], 5), false);
assert_eq!(candidate(vec![3], 5), true);
assert_eq!(candidate(vec![3, 2, 3], 1), false);
assert_eq!(candidate(vec![1, 2, 3], 6), false);
assert_eq!(candidate(vec![5], 5), true);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_72_will_it_fly.py
|
rs
|
[
"\n}"
] |
/// 整数の配列arrが与えられたとき、その配列を回文配列にするために
/// 必要な要素の最小数を求めよ。回文配列とは、前からも後からも同じ
/// ようになる配列のことである。1回の変更で、1つの要素を他の任意の
/// 要素に変更できる。
/// 例えば:
/// >>> smallest_change(vec![1, 2, 3, 5, 4, 7, 9, 6])
/// 4
/// >>> smallest_change(vec![1, 2, 3, 4, 3, 2, 2])
/// 1
/// >>> smallest_change(vec![1, 2, 3, 2, 1])
/// 0
fn smallest_change(arr: Vec<isize>) -> isize {
|
reworded
|
transform
|
HumanEval_73_smallest_change
|
}
fn main() {
let candidate = smallest_change;
assert_eq!(candidate(vec![1, 2, 3, 5, 4, 7, 9, 6]), 4);
assert_eq!(candidate(vec![1, 2, 3, 4, 3, 2, 2]), 1);
assert_eq!(candidate(vec![1, 4, 2]), 1);
assert_eq!(candidate(vec![1, 4, 4, 2]), 1);
assert_eq!(candidate(vec![1, 2, 3, 2, 1]), 0);
assert_eq!(candidate(vec![3, 1, 1, 3]), 0);
assert_eq!(candidate(vec![1]), 0);
assert_eq!(candidate(vec![0, 1]), 1);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_73_smallest_change.py
|
rs
|
[
"\n}"
] |
/// 2つの文字列リストを受け取り、リストの全文字数の合計がもう一方
/// のリストより少ないリストを返す関数を書きなさい。
/// もし2つのリストの文字数が同じなら、最初のリストを返す。
/// 例
/// >>> total_match(vec![], vec![])
/// Vec::<String>::new()
/// >>> total_match(vec![String::from("hi"), String::from("admin")], vec![String::from("hI"), String::from("Hi")])
/// vec![String::from("hI"), String::from("Hi")]
/// >>> total_match(vec![String::from("hi"), String::from("admin")], vec![String::from("hi"), String::from("hi"), String::from("admin"), String::from("project")])
/// vec![String::from("hi"), String::from("admin")]
/// >>> total_match(vec![String::from("hi"), String::from("admin")], vec![String::from("hI"), String::from("hi"), String::from("hi")])
/// vec![String::from("hI"), String::from("hi"), String::from("hi")]
/// >>> total_match(vec![String::from("4")], vec![String::from("1"), String::from("2"), String::from("3"), String::from("4"), String::from("5")])
/// vec![String::from("4")]
fn total_match(lst1: Vec<String>, lst2: Vec<String>) -> Vec<String> {
|
reworded
|
transform
|
HumanEval_74_total_match
|
}
fn main() {
let candidate = total_match;
assert_eq!(candidate(Vec::<String>::new(), Vec::<String>::new()), Vec::<String>::new());
assert_eq!(candidate(vec![String::from("hi"), String::from("admin")], vec![String::from("hi"), String::from("hi")]), vec![String::from("hi"), String::from("hi")]);
assert_eq!(candidate(vec![String::from("hi"), String::from("admin")], vec![String::from("hi"), String::from("hi"), String::from("admin"), String::from("project")]), vec![String::from("hi"), String::from("admin")]);
assert_eq!(candidate(vec![String::from("4")], vec![String::from("1"), String::from("2"), String::from("3"), String::from("4"), String::from("5")]), vec![String::from("4")]);
assert_eq!(candidate(vec![String::from("hi"), String::from("admin")], vec![String::from("hI"), String::from("Hi")]), vec![String::from("hI"), String::from("Hi")]);
assert_eq!(candidate(vec![String::from("hi"), String::from("admin")], vec![String::from("hI"), String::from("hi"), String::from("hi")]), vec![String::from("hI"), String::from("hi"), String::from("hi")]);
assert_eq!(candidate(vec![String::from("hi"), String::from("admin")], vec![String::from("hI"), String::from("hi"), String::from("hii")]), vec![String::from("hi"), String::from("admin")]);
assert_eq!(candidate(Vec::<String>::new(), vec![String::from("this")]), Vec::<String>::new());
assert_eq!(candidate(vec![String::from("this")], Vec::<String>::new()), Vec::<String>::new());
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_74_total_match.py
|
rs
|
[
"\n}"
] |
/// 与えられた数が3つの素数の掛け算であればtrueを、そうでなければfalseを返す
/// 関数を書きなさい。
/// 引数 aは100以下を既知としていよい。
/// 例:
/// >>> is_multiply_prime(30)
/// true
/// 30 = 2 * 3 * 5
fn is_multiply_prime(a: isize) -> bool {
|
reworded
|
transform
|
HumanEval_75_is_multiply_prime
|
}
fn main() {
let candidate = is_multiply_prime;
assert_eq!(candidate(5), false);
assert_eq!(candidate(30), true);
assert_eq!(candidate(8), true);
assert_eq!(candidate(10), false);
assert_eq!(candidate(125), true);
assert_eq!(candidate(105), true);
assert_eq!(candidate(126), false);
assert_eq!(candidate(729), false);
assert_eq!(candidate(891), false);
assert_eq!(candidate(1001), true);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_75_is_multiply_prime.py
|
rs
|
[
"\n}"
] |
/// あなたのタスクは、ある数xがnの単純なべき乗である場合にtrueを、
/// それ以外の場合にfalseを返す関数を書くことである。
/// xは、n**int=xのとき、nの単純なべき乗である。
/// 例えば:
/// >>> is_simple_power(1, 4)
/// true
/// >>> is_simple_power(2, 2)
/// true
/// >>> is_simple_power(8, 2)
/// true
/// >>> is_simple_power(3, 2)
/// false
/// >>> is_simple_power(3, 1)
/// false
/// >>> is_simple_power(5, 3)
/// false
fn is_simple_power(x: isize, n: isize) -> bool {
|
reworded
|
transform
|
HumanEval_76_is_simple_power
|
}
fn main() {
let candidate = is_simple_power;
assert_eq!(candidate(16, 2), true);
assert_eq!(candidate(143214, 16), false);
assert_eq!(candidate(4, 2), true);
assert_eq!(candidate(9, 3), true);
assert_eq!(candidate(16, 4), true);
assert_eq!(candidate(24, 2), false);
assert_eq!(candidate(128, 4), false);
assert_eq!(candidate(12, 6), false);
assert_eq!(candidate(1, 1), true);
assert_eq!(candidate(1, 12), true);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_76_is_simple_power.py
|
rs
|
[
"\n}"
] |
/// 整数aを受け取り、この整数がある整数の3乗である場合にtrue
/// を返す関数を書きなさい。
/// 注意:入力は常に処理可能であると仮定してよい。
/// 例:
/// >>> iscube(1)
/// true
/// >>> iscube(2)
/// false
/// >>> iscube(-1)
/// true
/// >>> iscube(64)
/// true
/// >>> iscube(0)
/// true
/// >>> iscube(180)
/// false
fn iscube(a: isize) -> bool {
|
reworded
|
transform
|
HumanEval_77_iscube
|
}
fn main() {
let candidate = iscube;
assert_eq!(candidate(1), true);
assert_eq!(candidate(2), false);
assert_eq!(candidate(-1), true);
assert_eq!(candidate(64), true);
assert_eq!(candidate(180), false);
assert_eq!(candidate(1000), true);
assert_eq!(candidate(0), true);
assert_eq!(candidate(1729), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_77_iscube.py
|
rs
|
[
"\n}"
] |
/// 16進数の数字を文字列として受け取り、その中に含まれる素数である16進数の桁数を
/// カウントする関数を作成するタスクが与えられました。素数とは、1より大きく、
/// 2つのより小さい自然数の積でない自然数です。
/// 16進数の桁には0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, Fがあります。
/// 素数としては2, 3, 5, 7, 11, 13, 17,...があります。
/// したがって、次の数字のいずれかがいくつあるかを判定する必要があります:
/// 2, 3, 5, 7, B(=10進数で11), D(=10進数で13)
/// 注意:入力は常に正確、または空の文字列であり、記号A, B, C, D, E, Fは常に
/// 大文字であると仮定してよいです。
/// 例:
/// >>> hex_key(String::from("AB"))
/// 1
/// >>> hex_key(String::from("1077E"))
/// 2
/// >>> hex_key(String::from("ABED1A33"))
/// 4
/// >>> hex_key(String::from("123456789ABCDEF0"))
/// 6
/// >>> hex_key(String::from("2020"))
/// 2
fn hex_key(num: String) -> isize {
|
reworded
|
transform
|
HumanEval_78_hex_key
|
}
fn main() {
let candidate = hex_key;
assert_eq!(candidate(String::from("AB")), 1);
assert_eq!(candidate(String::from("1077E")), 2);
assert_eq!(candidate(String::from("ABED1A33")), 4);
assert_eq!(candidate(String::from("2020")), 2);
assert_eq!(candidate(String::from("123456789ABCDEF0")), 6);
assert_eq!(candidate(String::from("112233445566778899AABBCCDDEEFF00")), 12);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_78_hex_key.py
|
rs
|
[
"\n}"
] |
/// 10進数形式の数値が与えられ、あなたのタスクはそれを2進数形式に変換することである。
/// この関数は、文字列を返し、その各文字は2進数を表す。文字列の各文字は'0'か'1'である。
/// なお、文字列の最初と最後には'db'という余分な文字をつける。
/// この文字は書式を助けるためにある。
/// 例:
/// >>> decimal_to_binary(15)
/// String::from("db1111db")
/// >>> decimal_to_binary(32)
/// String::from("db100000db")
fn decimal_to_binary(decimal: isize) -> String {
|
reworded
|
transform
|
HumanEval_79_decimal_to_binary
|
}
fn main() {
let candidate = decimal_to_binary;
assert_eq!(candidate(0), String::from("db0db"));
assert_eq!(candidate(32), String::from("db100000db"));
assert_eq!(candidate(103), String::from("db1100111db"));
assert_eq!(candidate(15), String::from("db1111db"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_79_decimal_to_binary.py
|
rs
|
[
"\n}"
] |
/// あなたは文字列sが与えられる。
/// あなたのタスクは、その文字列が幸せかどうかをチェックすることである。
/// 文字列は幸せとは、文字列の長さが少なくとも3以上で、連続する3文字がすべて異なる場合である。
/// 例えば:
/// >>> is_happy(String::from("a"))
/// false
/// >>> is_happy(String::from("aa"))
/// false
/// >>> is_happy(String::from("abcd"))
/// true
/// >>> is_happy(String::from("aabb"))
/// false
/// >>> is_happy(String::from("adb"))
/// true
/// >>> is_happy(String::from("xyy"))
/// false
fn is_happy(s: String) -> bool {
|
reworded
|
transform
|
HumanEval_80_is_happy
|
}
fn main() {
let candidate = is_happy;
assert_eq!(candidate(String::from("a")), false);
assert_eq!(candidate(String::from("aa")), false);
assert_eq!(candidate(String::from("abcd")), true);
assert_eq!(candidate(String::from("aabb")), false);
assert_eq!(candidate(String::from("adb")), true);
assert_eq!(candidate(String::from("xyy")), false);
assert_eq!(candidate(String::from("iopaxpoi")), true);
assert_eq!(candidate(String::from("iopaxioi")), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_80_is_happy.py
|
rs
|
[
"\n}"
] |
/// 学期最終週、教師は生徒に成績をつけなければならない。教師は独自のアルゴリズムで採点している。
/// 問題は、彼女が成績評価に使ったコードを紛失してしまったことです。
/// 彼女は何人かの生徒のGPAのリストをあなたに渡したので、あなたは次の表を使って評点のリストを
/// 出力できる関数を書くことになりました。:
/// GPA | Letter grade
/// 4.0 A+
/// > 3.7 A
/// > 3.3 A-
/// > 3.0 B+
/// > 2.7 B
/// > 2.3 B-
/// > 2.0 C+
/// > 1.7 C
/// > 1.3 C-
/// > 1.0 D+
/// > 0.7 D
/// > 0.0 D-
/// 0.0 E
/// 例:
/// >>> grade_equation(vec![4.0, 3, 1.7, 2, 3.5])
/// vec![String::from("A+"), String::from("B"), String::from("C-"), String::from("C"), String::from("A-")]
fn numerical_letter_grade(grades: Vec<f64>) -> Vec<String> {
|
reworded
|
transform
|
HumanEval_81_numerical_letter_grade
|
}
fn main() {
let candidate = numerical_letter_grade;
assert_eq!(candidate(vec![4.0, 3.0, 1.7, 2.0, 3.5]), vec![String::from("A+"), String::from("B"), String::from("C-"), String::from("C"), String::from("A-")]);
assert_eq!(candidate(vec![1.2]), vec![String::from("D+")]);
assert_eq!(candidate(vec![0.5]), vec![String::from("D-")]);
assert_eq!(candidate(vec![0.0]), vec![String::from("E")]);
assert_eq!(candidate(vec![1.0, 0.3, 1.5, 2.8, 3.3]), vec![String::from("D"), String::from("D-"), String::from("C-"), String::from("B"), String::from("B+")]);
assert_eq!(candidate(vec![0.0, 0.7]), vec![String::from("E"), String::from("D-")]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_81_numerical_letter_grade.py
|
rs
|
[
"\n}"
] |
/// 文字列を受け取り、文字列の長さが素数であればtrueを、そうでなければfalseを返す関数を書く。
/// 例
/// >>> prime_length(String::from("Hello"))
/// true
/// >>> prime_length(String::from("abcdcba"))
/// true
/// >>> prime_length(String::from("kittens"))
/// true
/// >>> prime_length(String::from("orange"))
/// false
fn prime_length(string: String) -> bool {
|
reworded
|
transform
|
HumanEval_82_prime_length
|
}
fn main() {
let candidate = prime_length;
assert_eq!(candidate(String::from("Hello")), true);
assert_eq!(candidate(String::from("abcdcba")), true);
assert_eq!(candidate(String::from("kittens")), true);
assert_eq!(candidate(String::from("orange")), false);
assert_eq!(candidate(String::from("wow")), true);
assert_eq!(candidate(String::from("world")), true);
assert_eq!(candidate(String::from("MadaM")), true);
assert_eq!(candidate(String::from("Wow")), true);
assert_eq!(candidate(String::from("")), false);
assert_eq!(candidate(String::from("HI")), true);
assert_eq!(candidate(String::from("go")), true);
assert_eq!(candidate(String::from("gogo")), false);
assert_eq!(candidate(String::from("aaaaaaaaaaaaaaa")), false);
assert_eq!(candidate(String::from("Madam")), true);
assert_eq!(candidate(String::from("M")), false);
assert_eq!(candidate(String::from("0")), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_82_prime_length.py
|
rs
|
[
"\n}"
] |
/// 正の整数 n が与えられたとき、n 桁の正の整数で 1 で始まるか
/// もしくは終わる数のカウントを返す
fn starts_one_ends(n: isize) -> isize {
|
reworded
|
transform
|
HumanEval_83_starts_one_ends
|
}
fn main() {
let candidate = starts_one_ends;
assert_eq!(candidate(1), 1);
assert_eq!(candidate(2), 18);
assert_eq!(candidate(3), 180);
assert_eq!(candidate(4), 1800);
assert_eq!(candidate(5), 18000);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_83_starts_one_ends.py
|
rs
|
[
"\n}"
] |
/// 正の整数 N が与えられた時、その桁の総和を2進数で返す。
/// >>> solve(1000)
/// String::from("1")
/// >>> solve(150)
/// String::from("110")
/// >>> solve(147)
/// String::from("1100")
/// 数:
/// @N 整数
/// 制約: 0 ≤ N ≤ 10000.
/// 返り値:
/// 2進数表記の文字列
fn solve(N: isize) -> String {
|
reworded
|
transform
|
HumanEval_84_solve
|
}
fn main() {
let candidate = solve;
assert_eq!(candidate(1000), String::from("1"));
assert_eq!(candidate(150), String::from("110"));
assert_eq!(candidate(147), String::from("1100"));
assert_eq!(candidate(333), String::from("1001"));
assert_eq!(candidate(963), String::from("10010"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_84_solve.py
|
rs
|
[
"\n}"
] |
/// 空でない整数のリストlstが与えられたとき、奇数のインデックスにある偶数の要素を加える。
/// 例:
/// >>> add(vec![4, 2, 6, 7])
/// 2
fn add(lst: Vec<isize>) -> isize {
|
reworded
|
transform
|
HumanEval_85_add
|
}
fn main() {
let candidate = add;
assert_eq!(candidate(vec![4, 88]), 88);
assert_eq!(candidate(vec![4, 5, 6, 7, 2, 122]), 122);
assert_eq!(candidate(vec![4, 0, 6, 7]), 0);
assert_eq!(candidate(vec![4, 4, 6, 8]), 12);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_85_add.py
|
rs
|
[
"\n}"
] |
/// 文字列を引数として受け取り、その「順序付けられたバージョン」を返す関数を作成してください。
/// 順序付けられたバージョンとは、各単語(空白で区切られた)の文字がASCII値に基づいて昇順に
/// 並べ替えられた新しい単語に置き換えられた文字列です。
/// 注意:文章内の単語と空白の順序はそのまま保ってください。
/// 例えば:
/// >>> anti_shuffle(String::from("Hi"))
/// String::from("Hi")
/// >>> anti_shuffle(String::from("hello"))
/// String::from("ehllo")
/// >>> anti_shuffle(String::from("Hello World!!!"))
/// String::from("Hello !!!Wdlor")
fn anti_shuffle(s: String) -> String {
|
reworded
|
transform
|
HumanEval_86_anti_shuffle
|
}
fn main() {
let candidate = anti_shuffle;
assert_eq!(candidate(String::from("Hi")), String::from("Hi"));
assert_eq!(candidate(String::from("hello")), String::from("ehllo"));
assert_eq!(candidate(String::from("number")), String::from("bemnru"));
assert_eq!(candidate(String::from("abcd")), String::from("abcd"));
assert_eq!(candidate(String::from("Hello World!!!")), String::from("Hello !!!Wdlor"));
assert_eq!(candidate(String::from("")), String::from(""));
assert_eq!(candidate(String::from("Hi. My name is Mister Robot. How are you?")), String::from(".Hi My aemn is Meirst .Rboot How aer ?ouy"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_86_anti_shuffle.py
|
rs
|
[
"\n}"
] |
/// 2次元のデータがネストされたリストとして与えられる。これは行列に似ているが、
/// 列とは異なり、各行は異なる数の列を含むことができる。
/// lstと整数xが与えられたとき、リスト内の整数xを見つけ、各タプルが0から始まる
/// 座標(行、列)であるようなタプルのリスト[(x1, y1), (x2, y2) ...]を返す。
/// 座標を最初は行の昇順でソートする。
/// また、行の座標を列の降順でソートする。
/// 例:
/// >>> get_row(vec![vec![1, 2, 3, 4, 5, 6], vec![1, 2, 3, 4, 1, 6], vec![1, 2, 3, 4, 5, 1]], 1)
/// vec![(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]
/// >>> get_row(vec![], 1)
/// Vec::<(isize, isize)>::new()
/// >>> get_row(vec![vec![], vec![1], vec![1, 2, 3]], 3)
/// vec![(2, 2)]
fn get_row(lst: Vec<Vec<isize>>, x: isize) -> Vec<(isize, isize)> {
|
reworded
|
transform
|
HumanEval_87_get_row
|
}
fn main() {
let candidate = get_row;
assert_eq!(candidate(vec![vec![1, 2, 3, 4, 5, 6], vec![1, 2, 3, 4, 1, 6], vec![1, 2, 3, 4, 5, 1]], 1), vec![(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]);
assert_eq!(candidate(vec![vec![1, 2, 3, 4, 5, 6], vec![1, 2, 3, 4, 5, 6], vec![1, 2, 3, 4, 5, 6], vec![1, 2, 3, 4, 5, 6], vec![1, 2, 3, 4, 5, 6], vec![1, 2, 3, 4, 5, 6]], 2), vec![(0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1)]);
assert_eq!(candidate(vec![vec![1, 2, 3, 4, 5, 6], vec![1, 2, 3, 4, 5, 6], vec![1, 1, 3, 4, 5, 6], vec![1, 2, 1, 4, 5, 6], vec![1, 2, 3, 1, 5, 6], vec![1, 2, 3, 4, 1, 6], vec![1, 2, 3, 4, 5, 1]], 1), vec![(0, 0), (1, 0), (2, 1), (2, 0), (3, 2), (3, 0), (4, 3), (4, 0), (5, 4), (5, 0), (6, 5), (6, 0)]);
assert_eq!(candidate(Vec::<Vec<isize>>::new(), 1), Vec::<(isize, isize)>::new());
assert_eq!(candidate(vec![vec![1]], 2), Vec::<(isize, isize)>::new());
assert_eq!(candidate(vec![vec![], vec![1], vec![1, 2, 3]], 3), vec![(2, 2)]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_87_get_row.py
|
rs
|
[
"\n}"
] |
/// 非負の整数からなる配列が与えられた場合、配列をソートしたコピーを返してください。
/// 配列の最初の要素と最後の要素の和が奇数であれば、配列を昇順(小さい順)にソートします。
/// その和が偶数であれば、配列を降順(大きい順)にソートします。
/// 注意点:
/// * 与えられた配列自体を変更しないでください。
/// 例:
/// >>> sort_array(vec![])
/// Vec::<isize>::new()
/// >>> sort_array(vec![5])
/// vec![5]
/// >>> sort_array(vec![2, 4, 3, 0, 1, 5])
/// vec![0, 1, 2, 3, 4, 5]
/// >>> sort_array(vec![2, 4, 3, 0, 1, 5, 6])
/// vec![6, 5, 4, 3, 2, 1, 0]
fn sort_array(array: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_88_sort_array
|
}
fn main() {
let candidate = sort_array;
assert_eq!(candidate(Vec::<isize>::new()), Vec::<isize>::new());
assert_eq!(candidate(vec![5]), vec![5]);
assert_eq!(candidate(vec![2, 4, 3, 0, 1, 5]), vec![0, 1, 2, 3, 4, 5]);
assert_eq!(candidate(vec![2, 4, 3, 0, 1, 5, 6]), vec![6, 5, 4, 3, 2, 1, 0]);
assert_eq!(candidate(vec![2, 1]), vec![1, 2]);
assert_eq!(candidate(vec![15, 42, 87, 32, 11, 0]), vec![0, 11, 15, 32, 42, 87]);
assert_eq!(candidate(vec![21, 14, 23, 11]), vec![23, 21, 14, 11]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_88_sort_array.py
|
rs
|
[
"\n}"
] |
/// 文字列を引数にとり、アルファベットを回転させて暗号化した
/// 文字列を返す関数encryptを作成せよ。
/// アルファベットは、文字位置が2を2倍した4文字分だけ後ろにシフトされるように
/// 回転する。
/// 例:
/// >>> encrypt(String::from("hi"))
/// String::from("lm")
/// >>> encrypt(String::from("asdfghjkl"))
/// String::from("ewhjklnop")
/// >>> encrypt(String::from("gf"))
/// String::from("kj")
/// >>> encrypt(String::from("et"))
/// String::from("ix")
fn encrypt(s: String) -> String {
|
reworded
|
transform
|
HumanEval_89_encrypt
|
}
fn main() {
let candidate = encrypt;
assert_eq!(candidate(String::from("hi")), String::from("lm"));
assert_eq!(candidate(String::from("asdfghjkl")), String::from("ewhjklnop"));
assert_eq!(candidate(String::from("gf")), String::from("kj"));
assert_eq!(candidate(String::from("et")), String::from("ix"));
assert_eq!(candidate(String::from("faewfawefaewg")), String::from("jeiajeaijeiak"));
assert_eq!(candidate(String::from("hellomyfriend")), String::from("lippsqcjvmirh"));
assert_eq!(candidate(String::from("dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh")), String::from("hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl"));
assert_eq!(candidate(String::from("a")), String::from("e"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_89_encrypt.py
|
rs
|
[
"\n}"
] |
/// 整数のリストが与えられる。
/// リストの2番目に小さい要素を返す関数 next_smallest() を書きなさい。
/// そのような要素がない場合は None を返す。
/// >>> next_smallest(vec![1, 2, 3, 4, 5])
/// Some(2)
/// >>> next_smallest(vec![5, 1, 4, 3, 2])
/// Some(2)
/// >>> next_smallest(vec![])
/// None
/// >>> next_smallest(vec![1, 1])
/// None
fn next_smallest(lst: Vec<isize>) -> Option<isize> {
|
reworded
|
transform
|
HumanEval_90_next_smallest
|
}
fn main() {
let candidate = next_smallest;
assert_eq!(candidate(vec![1, 2, 3, 4, 5]), Some(2));
assert_eq!(candidate(vec![5, 1, 4, 3, 2]), Some(2));
assert_eq!(candidate(Vec::<isize>::new()), None);
assert_eq!(candidate(vec![1, 1]), None);
assert_eq!(candidate(vec![1, 1, 1, 1, 0]), Some(1));
assert_eq!(candidate(vec![1, 1]), None);
assert_eq!(candidate(vec![-35, 34, 12, -45]), Some(-35));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_90_next_smallest.py
|
rs
|
[
"\n}"
] |
/// 単語の文字列が与えられ、あなたのタスクは退屈指数を数える
/// ことである。退屈指数とは、"I "で始まる文のことである。
/// 文は'.'、’?’、'!'のいずれかで区切られる。
/// 例えば:
/// >>> is_bored(String::from("Hello world"))
/// 0
/// >>> is_bored(String::from("The sky is blue. The sun is shining. I love this weather"))
/// 1
fn is_bored(S: String) -> isize {
|
reworded
|
transform
|
HumanEval_91_is_bored
|
}
fn main() {
let candidate = is_bored;
assert_eq!(candidate(String::from("Hello world")), 0);
assert_eq!(candidate(String::from("Is the sky blue?")), 0);
assert_eq!(candidate(String::from("I love It !")), 1);
assert_eq!(candidate(String::from("bIt")), 0);
assert_eq!(candidate(String::from("I feel good today. I will be productive. will kill It")), 2);
assert_eq!(candidate(String::from("You and I are going for a walk")), 0);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_91_is_bored.py
|
rs
|
[
"\n}"
] |
/// 3つの数値を受け取る関数を作る。
/// 1つの数値が他の2つの数値の和と等しく、すべての数値が整数である場合にtrueを返す。
/// それ以外の場合はfalseを返す。
/// 例
/// >>> any_int(5, 2, 7)
/// true
/// >>> any_int(3, 2, 2)
/// false
/// >>> any_int(3, -2, 1)
/// true
/// >>> any_int(3.6, -2.2, 2)
/// false
fn any_int(x: f64, y: f64, z: f64) -> bool {
|
reworded
|
transform
|
HumanEval_92_any_int
|
}
fn main() {
let candidate = any_int;
assert_eq!(candidate(2.0, 3.0, 1.0), true);
assert_eq!(candidate(2.5, 2.0, 3.0), false);
assert_eq!(candidate(1.5, 5.0, 3.5), false);
assert_eq!(candidate(2.0, 6.0, 2.0), false);
assert_eq!(candidate(4.0, 2.0, 2.0), true);
assert_eq!(candidate(2.2, 2.2, 2.2), false);
assert_eq!(candidate(-4.0, 6.0, 2.0), true);
assert_eq!(candidate(2.0, 1.0, 1.0), true);
assert_eq!(candidate(3.0, 4.0, 7.0), true);
assert_eq!(candidate(3.0, 4.0, 7.0), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_92_any_int.py
|
rs
|
[
"\n}"
] |
/// メッセージを受け取り、すべての文字の大文字と小文字を入れ替え、
/// メッセージ中のすべての母音を英語の母音の2つ前に現れる文字に置
/// き換えるようにエンコードする関数を書きなさい。
/// 文字だけを想定する。
/// 例:
/// >>> encode(String::from("test"))
/// String::from("TGST")
/// >>> encode(String::from("This is a message"))
/// String::from("tHKS KS C MGSSCGG")
fn encode(message: String) -> String {
|
reworded
|
transform
|
HumanEval_93_encode
|
}
fn main() {
let candidate = encode;
assert_eq!(candidate(String::from("TEST")), String::from("tgst"));
assert_eq!(candidate(String::from("Mudasir")), String::from("mWDCSKR"));
assert_eq!(candidate(String::from("YES")), String::from("ygs"));
assert_eq!(candidate(String::from("This is a message")), String::from("tHKS KS C MGSSCGG"));
assert_eq!(candidate(String::from("I DoNt KnOw WhAt tO WrItE")), String::from("k dQnT kNqW wHcT Tq wRkTg"));
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_93_encode.py
|
rs
|
[
"\n}"
] |
/// 整数のリストが与えらる。
/// 最大の素数を求め、その桁数の和を返す必要がある。
/// 例:
/// >>> skjkasdkd(vec![0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3])
/// 10
/// >>> skjkasdkd(vec![1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1])
/// 25
/// >>> skjkasdkd(vec![1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 2323, 32, 30, 1, 9, 3])
/// 13
/// >>> skjkasdkd(vec![0, 724, 32, 71, 99, 32, 6, 0, 5, 91, 83, 0, 5, 6])
/// 11
/// >>> skjkasdkd(vec![0, 81, 12, 3, 1, 21])
/// 3
/// >>> skjkasdkd(vec![0, 8, 1, 2, 1, 7])
/// 7
fn skjkasdkd(lst: Vec<isize>) -> isize {
|
reworded
|
transform
|
HumanEval_94_skjkasdkd
|
}
fn main() {
let candidate = skjkasdkd;
assert_eq!(candidate(vec![0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3]), 10);
assert_eq!(candidate(vec![1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1]), 25);
assert_eq!(candidate(vec![1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 2323, 32, 30, 1, 9, 3]), 13);
assert_eq!(candidate(vec![0, 724, 32, 71, 99, 32, 6, 0, 5, 91, 83, 0, 5, 6]), 11);
assert_eq!(candidate(vec![0, 81, 12, 3, 1, 21]), 3);
assert_eq!(candidate(vec![0, 8, 1, 2, 1, 7]), 7);
assert_eq!(candidate(vec![8191]), 19);
assert_eq!(candidate(vec![8191, 123456, 127, 7]), 19);
assert_eq!(candidate(vec![127, 97, 8192]), 10);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_94_skjkasdkd.py
|
rs
|
[
"\n}"
] |
use std::collections::HashMap;
/// 辞書が与えられたとき、すべてのキーが小文字であればtrueを、
/// すべてのキーが大文字の文字列であればfalseを返す。
/// 与えられた辞書が空の場合、この関数は false を返す。
/// 例:
/// >>> check_dict_case(HashMap::from([(String::from("a"), String::from("apple")), (String::from("b"), String::from("banana"))]))
/// true
/// >>> check_dict_case(HashMap::from([(String::from("a"), String::from("apple")), (String::from("A"), String::from("banana")), (String::from("B"), String::from("banana"))]))
/// false
/// >>> check_dict_case(HashMap::from([(String::from("a"), String::from("apple")), (8, String::from("banana")), (String::from("a"), String::from("apple"))]))
/// false
/// >>> check_dict_case(HashMap::from([(String::from("Name"), String::from("John")), (String::from("Age"), String::from("36")), (String::from("City"), String::from("Houston"))]))
/// false
/// >>> check_dict_case(HashMap::from([(String::from("STATE"), String::from("NC")), (String::from("ZIP"), String::from("12345"))]))
/// true
fn check_dict_case(dict: HashMap<String, String>) -> bool {
|
reworded
|
transform
|
HumanEval_95_check_dict_case
|
}
fn main() {
let candidate = check_dict_case;
assert_eq!(candidate(HashMap::from([(String::from("p"), String::from("pineapple")), (String::from("b"), String::from("banana"))])), true);
assert_eq!(candidate(HashMap::from([(String::from("p"), String::from("pineapple")), (String::from("A"), String::from("banana")), (String::from("B"), String::from("banana"))])), false);
assert_eq!(candidate(HashMap::from([(String::from("p"), String::from("pineapple")), (String::from("5"), String::from("banana")), (String::from("a"), String::from("apple"))])), false);
assert_eq!(candidate(HashMap::from([(String::from("Name"), String::from("John")), (String::from("Age"), String::from("36")), (String::from("City"), String::from("Houston"))])), false);
assert_eq!(candidate(HashMap::from([(String::from("STATE"), String::from("NC")), (String::from("ZIP"), String::from("12345"))])), true);
assert_eq!(candidate(HashMap::from([(String::from("fruit"), String::from("Orange")), (String::from("taste"), String::from("Sweet"))])), true);
assert_eq!(candidate(HashMap::from([])), false);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_95_check_dict_case.py
|
rs
|
[
"\n}"
] |
/// 非負整数を受け取り、素数でnより小さい最初のn個の
/// 整数の配列を返す関数を実装せよ。
/// 例えば:
/// >>> count_up_to(5)
/// vec![2, 3]
/// >>> count_up_to(11)
/// vec![2, 3, 5, 7]
/// >>> count_up_to(0)
/// Vec::<isize>::new()
/// >>> count_up_to(20)
/// vec![2, 3, 5, 7, 11, 13, 17, 19]
/// >>> count_up_to(1)
/// Vec::<isize>::new()
/// >>> count_up_to(18)
/// vec![2, 3, 5, 7, 11, 13, 17]
fn count_up_to(n: isize) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_96_count_up_to
|
}
fn main() {
let candidate = count_up_to;
assert_eq!(candidate(5), vec![2, 3]);
assert_eq!(candidate(6), vec![2, 3, 5]);
assert_eq!(candidate(7), vec![2, 3, 5]);
assert_eq!(candidate(10), vec![2, 3, 5, 7]);
assert_eq!(candidate(0), Vec::<isize>::new());
assert_eq!(candidate(22), vec![2, 3, 5, 7, 11, 13, 17, 19]);
assert_eq!(candidate(1), Vec::<isize>::new());
assert_eq!(candidate(18), vec![2, 3, 5, 7, 11, 13, 17]);
assert_eq!(candidate(47), vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]);
assert_eq!(candidate(101), vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_96_count_up_to.py
|
rs
|
[
"\n}"
] |
/// 2つの整数を受け取り、その1の位の数の積を返す関数を完成させよ。
/// 入力は常に有効範囲にあるとする。
/// 例:
/// >>> multiply(148, 412)
/// 16
/// >>> multiply(19, 28)
/// 72
/// >>> multiply(2020, 1851)
/// 0
/// >>> multiply(14, -15)
/// 20
fn multiply(a: isize, b: isize) -> isize {
|
reworded
|
transform
|
HumanEval_97_multiply
|
}
fn main() {
let candidate = multiply;
assert_eq!(candidate(148, 412), 16);
assert_eq!(candidate(19, 28), 72);
assert_eq!(candidate(2020, 1851), 0);
assert_eq!(candidate(14, -15), 20);
assert_eq!(candidate(76, 67), 42);
assert_eq!(candidate(17, 27), 49);
assert_eq!(candidate(0, 1), 0);
assert_eq!(candidate(0, 0), 0);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_97_multiply.py
|
rs
|
[
"\n}"
] |
/// 文字列 s が与えられたとき、偶数のインデックスに含まれる大文字の母音の数を数える。
/// 例えば:
/// >>> count_upper(String::from("aBCdEf"))
/// 1
/// >>> count_upper(String::from("abcdefg"))
/// 0
/// >>> count_upper(String::from("dBBE"))
/// 0
fn count_upper(s: String) -> isize {
|
reworded
|
transform
|
HumanEval_98_count_upper
|
}
fn main() {
let candidate = count_upper;
assert_eq!(candidate(String::from("aBCdEf")), 1);
assert_eq!(candidate(String::from("abcdefg")), 0);
assert_eq!(candidate(String::from("dBBE")), 0);
assert_eq!(candidate(String::from("B")), 0);
assert_eq!(candidate(String::from("U")), 1);
assert_eq!(candidate(String::from("")), 0);
assert_eq!(candidate(String::from("EEEE")), 2);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_98_count_upper.py
|
rs
|
[
"\n}"
] |
/// 数値を表す文字列valueを受け取り、それに最も近い整数を返す関数を作る。
/// その数値が2つの整数から等距離にある場合は、ゼロから四捨五入する。
/// 例s
/// >>> closest_integer(String::from("10"))
/// 10
/// >>> closest_integer(String::from("15.3"))
/// 15
/// Note:
/// ゼロからの四捨五入とは、与えられた数値が2つの整数から
/// 等距離にある場合、ゼロから遠い方を返すという意味である。 例えば、 close_integer("14.5")は15を返し、closest_integer("-14.5")は-15を返す。
fn closest_integer(value: String) -> isize {
|
reworded
|
transform
|
HumanEval_99_closest_integer
|
}
fn main() {
let candidate = closest_integer;
assert_eq!(candidate(String::from("10")), 10);
assert_eq!(candidate(String::from("14.5")), 15);
assert_eq!(candidate(String::from("-15.5")), -16);
assert_eq!(candidate(String::from("15.3")), 15);
assert_eq!(candidate(String::from("0")), 0);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_99_closest_integer.py
|
rs
|
[
"\n}"
] |
/// 正の整数nが与えられたとき、n段の石の山を作らなければならない。
/// 最初の段にはn個の石がある。
/// 次の段の石の数は:
/// - nが奇数なら次の奇数。
/// - nが偶数なら次の偶数。
/// 各段の石の数をリストで返す。インデックス i の要素は、段 (i+1) の石の
/// 数を表すものとする。
/// 例:
/// >>> make_a_pile(3)
/// vec![3, 5, 7]
fn make_a_pile(n: isize) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_100_make_a_pile
|
}
fn main() {
let candidate = make_a_pile;
assert_eq!(candidate(3), vec![3, 5, 7]);
assert_eq!(candidate(4), vec![4, 6, 8, 10]);
assert_eq!(candidate(5), vec![5, 7, 9, 11, 13]);
assert_eq!(candidate(6), vec![6, 8, 10, 12, 14, 16]);
assert_eq!(candidate(8), vec![8, 10, 12, 14, 16, 18, 20, 22]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_100_make_a_pile.py
|
rs
|
[
"\n}"
] |
/// カンマまたは空白で区切られた単語の文字列が与えられる。あなたのタスクは、
/// 文字列を単語に分割し、単語の配列を返すことである。
/// 例えば:
/// >>> words_string(String::from("Hi, my name is John"))
/// vec![String::from("Hi"), String::from("my"), String::from("name"), String::from("is"), String::from("John")]
/// >>> words_string(String::from("One, two, three, four, five, six"))
/// vec![String::from("One"), String::from("two"), String::from("three"), String::from("four"), String::from("five"), String::from("six")]
fn words_string(s: String) -> Vec<String> {
|
reworded
|
transform
|
HumanEval_101_words_string
|
}
fn main() {
let candidate = words_string;
assert_eq!(candidate(String::from("Hi, my name is John")), vec![String::from("Hi"), String::from("my"), String::from("name"), String::from("is"), String::from("John")]);
assert_eq!(candidate(String::from("One, two, three, four, five, six")), vec![String::from("One"), String::from("two"), String::from("three"), String::from("four"), String::from("five"), String::from("six")]);
assert_eq!(candidate(String::from("Hi, my name")), vec![String::from("Hi"), String::from("my"), String::from("name")]);
assert_eq!(candidate(String::from("One,, two, three, four, five, six,")), vec![String::from("One"), String::from("two"), String::from("three"), String::from("four"), String::from("five"), String::from("six")]);
assert_eq!(candidate(String::from("")), Vec::<String>::new());
assert_eq!(candidate(String::from("ahmed , gamal")), vec![String::from("ahmed"), String::from("gamal")]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_101_words_string.py
|
rs
|
[
"\n}"
] |
/// この関数は2つの正の数xとyを受け取り、範囲[x, y](両端を含む)に含まれる
/// 最大の偶数整数を返す。そのような数がない場合、関数は-1を返す。
/// 例えば:
/// >>> choose_num(12, 15)
/// 14
/// >>> choose_num(13, 12)
/// -1
fn choose_num(x: isize, y: isize) -> isize {
|
reworded
|
transform
|
HumanEval_102_choose_num
|
}
fn main() {
let candidate = choose_num;
assert_eq!(candidate(12, 15), 14);
assert_eq!(candidate(13, 12), -1);
assert_eq!(candidate(33, 12354), 12354);
assert_eq!(candidate(5234, 5233), -1);
assert_eq!(candidate(6, 29), 28);
assert_eq!(candidate(27, 10), -1);
assert_eq!(candidate(7, 7), -1);
assert_eq!(candidate(546, 546), 546);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_102_choose_num.py
|
rs
|
[
"\n}"
] |
/// 正の整数xのリストが与えられたとき、偶数桁の要素を持たない全ての
/// 要素をソートしたリストを返す。
/// 注意: 返されるリストは昇順にソートされていなければならない。
/// 例えば:
/// >>> unique_digits(vec![15, 33, 1422, 1])
/// vec![1, 15, 33]
/// >>> unique_digits(vec![152, 323, 1422, 10])
/// Vec::<isize>::new()
fn unique_digits(x: Vec<isize>) -> Vec<isize> {
|
reworded
|
transform
|
HumanEval_104_unique_digits
|
}
fn main() {
let candidate = unique_digits;
assert_eq!(candidate(vec![15, 33, 1422, 1]), vec![1, 15, 33]);
assert_eq!(candidate(vec![152, 323, 1422, 10]), Vec::<isize>::new());
assert_eq!(candidate(vec![12345, 2033, 111, 151]), vec![111, 151]);
assert_eq!(candidate(vec![135, 103, 31]), vec![31, 135]);
}
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_104_unique_digits.py
|
rs
|
End of preview. Expand
in Data Studio
- Downloads last month
- 7