stop_tokens sequencelengths 1 1 | prompt stringlengths 98 766 | prompt_terminology stringclasses 1
value | doctests stringclasses 1
value | name stringlengths 15 44 | tests stringlengths 326 1.94k | original stringlengths 130 159 | language stringclasses 1
value |
|---|---|---|---|---|---|---|---|
[
"\n}"
] |
/// リストnumbersの中に、与えられたthresholdより近い2つの数値が存在するか判定する
/// >>> has_close_elements(numbers: [1.0, 2.0, 3.0], threshold: 0.5)
/// false
/// >>> has_close_elements(numbers: [1.0, 2.8, 3.0, 4.0, 5.0, 2.0], threshold: 0.3)
/// true
func has_close_elements(numbers: [Double], threshold: Double) -> Bool {
| reworded | transform | HumanEval_0_has_close_elements | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(has_close_elements(numbers: [1.0, 2.0, 3.9, 4.0, 5.0, 2.2],... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_0_has_close_elements.py | swift |
[
"\n}"
] |
/// この関数への入力は、入れ子になった括弧が複数含まれる文字列である。
/// あなたの目的は、これらの括弧を別々の文字列に分割し、そのリストを返すことである。
/// 分離された括弧はバランスがとれ、つまり、開いた括弧はそれぞれ適切に閉じられていて、
/// 互いに入れ子になっていない。引数の文字列内の空白は無視せよ。
/// >>> separate_paren_groups(paren_string: "( ) (( )) (( )( ))")
/// ["()", "(())", "(()())"]
func separate_paren_groups(paren_string: String) -> [String]... | reworded | transform | HumanEval_1_separate_paren_groups | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(separate_paren_groups(paren_string: "(()()) ((())) () ((())... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_1_separate_paren_groups.py | swift |
[
"\n}"
] |
/// 正の浮動小数点数が与えられると、それを整数部(与えられた数より小さい最大の整数)
/// と小数部(常に1より小さい残余部分)に分解することができる。
/// 関数は、数値の小数部を返す。
/// >>> truncate_number(number: 3.5)
/// 0.5
func truncate_number(number: Double) -> Double {
| reworded | transform | HumanEval_2_truncate_number | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(truncate_number(number: 3.5) == 0.5)
assert(truncate_number... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_2_truncate_number.py | swift |
[
"\n}"
] |
/// 銀行口座に対する入出金操作のリストが与えられます。あなたのタスクは、残高ゼロから
/// 始まて、口座の残高がゼロ未満になったかどうかを検出し、その時点で関数がtrueを
/// 返すようにすることです。そうでなければfalseを返すようにしてください。
/// >>> below_zero(operations: [1, 2, 3])
/// false
/// >>> below_zero(operations: [1, 2, -4, 5])
/// true
func below_zero(operations: [Int]) -> Bool {
| reworded | transform | HumanEval_3_below_zero | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(below_zero(operations: [] as [Int]) == false)
assert(below_... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_3_below_zero.py | swift |
[
"\n}"
] |
/// 第一引数の数値リストに対して、このデータセットの平均値を中心とした平均絶対偏差(MAD)を計算する。
/// 平均絶対偏差(MAD)とは、各要素と中心点(この場合は平均値)との差の絶対値の平均である:
/// MAD = 平均|x - x_mean|
/// >>> mean_absolute_deviation(numbers: [1.0, 2.0, 3.0, 4.0])
/// 1.0
func mean_absolute_deviation(numbers: [Double]) -> Double {
| reworded | transform | HumanEval_4_mean_absolute_deviation | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(mean_absolute_deviation(numbers: [1.0, 2.0]) == 0.5)
assert... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_4_mean_absolute_deviation.py | swift |
[
"\n}"
] |
/// 数値リスト numbers 中の全ての連続する二要素の間に、'delimeterの値を挿入する
/// >>> intersperse(numbers: [] as [Int], delimeter: 4)
/// [] as [Int]
/// >>> intersperse(numbers: [1, 2, 3], delimeter: 4)
/// [1, 4, 2, 4, 3]
func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
| reworded | transform | HumanEval_5_intersperse | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(intersperse(numbers: [] as [Int], delimeter: 7) == [] as [I... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_5_intersperse.py | swift |
[
"\n}"
] |
/// この関数の入力は、空白で区切られた複数の入れ子になった括弧のグループを表す文字列です。
/// 各グループについて、括弧の最も深い入れ子のレベルを出力します。
/// 例えば、'(()())'は最大で2レベルの入れ子になっていますが、'((()))'は3レベルです。
/// >>> parse_nested_parens(paren_string: "(()()) ((())) () ((())()())")
/// [2, 3, 1, 3]
func parse_nested_parens(paren_string: String) -> [Int] {
| reworded | transform | HumanEval_6_parse_nested_parens | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(parse_nested_parens(paren_string: "(()()) ((())) () ((())()... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_6_parse_nested_parens.py | swift |
[
"\n}"
] |
/// 文字列リストstringsを、与えれた部分文字列substringを含むものだけにフィルタする
/// >>> filter_by_substring(strings: [] as [String], substring: "a")
/// [] as [String]
/// >>> filter_by_substring(strings: ["abc", "bacd", "cde", "array"], substring: "a")
/// ["abc", "bacd", "array"]
func filter_by_substring(strings: [String], substring: String) -... | reworded | transform | HumanEval_7_filter_by_substring | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(filter_by_substring(strings: [] as [String], substring: "jo... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_7_filter_by_substring.py | swift |
[
"\n}"
] |
/// 与えられた整数リストに対して、リスト内のすべての整数の和と積からなるタプルを返す。
/// ただし、空の和は0、空の積は1とする。
/// >>> sum_product(numbers: [] as [Int])
/// (0, 1)
/// >>> sum_product(numbers: [1, 2, 3, 4])
/// (10, 24)
func sum_product(numbers: [Int]) -> (Int, Int) {
| reworded | transform | HumanEval_8_sum_product | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sum_product(numbers: [] as [Int]) == (0, 1))
assert(sum_pro... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_8_sum_product.py | swift |
[
"\n}"
] |
/// 与えられた整数リストから、各要素のそこまでの最大値(ローリング最大値)のリストを生成する。
/// >>> rolling_max(numbers: [1, 2, 3, 2, 3, 4, 2])
/// [1, 2, 3, 3, 3, 4, 4]
func rolling_max(numbers: [Int]) -> [Int] {
| reworded | transform | HumanEval_9_rolling_max | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(rolling_max(numbers: [] as [Int]) == [] as [Int])
assert(ro... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_9_rolling_max.py | swift |
[
"\n}"
] |
/// 与えられた文字列で始まる最短の回文を見つけてください。
/// アルゴリズムのアイデアは以下の通りです:
/// - 与えられた文字列の中で最も長い回文となる接尾辞を見つけます。
/// - その回文の接尾辞の前に来る接頭辞を逆順にして、文字列の末尾に追加します。
/// >>> make_palindrome(string: "")
/// ""
/// >>> make_palindrome(string: "cat")
/// "catac"
/// >>> make_palindrome(string: "cata")
/// "catac"
func make_palindrome(string: String)... | reworded | transform | HumanEval_10_make_palindrome | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(make_palindrome(string: "") == "")
assert(make_palindrome(s... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_10_make_palindrome.py | swift |
[
"\n}"
] |
/// 引数は1と0のみからなる文字列aとbである。
/// これらの引数に対して排他論理和(XOR)を実行し、結果を文字列として返す。
/// >>> string_xor(a: "010", b: "110")
/// "100"
func string_xor(a: String, b: String) -> String {
| reworded | transform | HumanEval_11_string_xor | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(string_xor(a: "111000", b: "101010") == "010010")
assert(st... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_11_string_xor.py | swift |
[
"\n}"
] |
/// 文字列のリストのうち、最も長いものを返す。同じ長さの文字列が
/// 複数ある場合は最初のものを返す。入力リストが空の場合は nil を返す。
/// >>> longest(strings: [] as [String])
/// nil
/// >>> longest(strings: ["a", "b", "c"])
/// "a"
/// >>> longest(strings: ["a", "bb", "ccc"])
/// "ccc"
func longest(strings: [String]) -> String? {
| reworded | transform | HumanEval_12_longest | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(longest(strings: [] as [String]) == nil)
assert(longest(str... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_12_longest.py | swift |
[
"\n}"
] |
/// 整数 a と b の最大公約数を返す
/// >>> greatest_common_divisor(a: 3, b: 5)
/// 1
/// >>> greatest_common_divisor(a: 25, b: 15)
/// 5
func greatest_common_divisor(a: Int, b: Int) -> Int {
| reworded | transform | HumanEval_13_greatest_common_divisor | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(greatest_common_divisor(a: 3, b: 7) == 1)
assert(greatest_c... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_13_greatest_common_divisor.py | swift |
[
"\n}"
] |
/// 引数で与えられた文字列に対して、短いものから長いものへ、全ての接頭辞のリストを返す
/// >>> all_prefixes(string: "abc")
/// ["a", "ab", "abc"]
func all_prefixes(string: String) -> [String] {
| reworded | transform | HumanEval_14_all_prefixes | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(all_prefixes(string: "") == [] as [String])
assert(all_pref... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_14_all_prefixes.py | swift |
[
"\n}"
] |
/// 0からnまでの数字を空白区切りで連結した文字列で返す。
/// >>> string_sequence(n: 0)
/// "0"
/// >>> string_sequence(n: 5)
/// "0 1 2 3 4 5"
func string_sequence(n: Int) -> String {
| reworded | transform | HumanEval_15_string_sequence | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(string_sequence(n: 0) == "0")
assert(string_sequence(n: 3) ... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_15_string_sequence.py | swift |
[
"\n}"
] |
/// 文字列が与えられたとき、その文字列が(大文字小文字に関係なく)いくつの異なる文字が含まれているか数える
/// >>> count_distinct_characters(string: "xyzXYZ")
/// 3
/// >>> count_distinct_characters(string: "Jerry")
/// 4
func count_distinct_characters(string: String) -> Int {
| reworded | transform | HumanEval_16_count_distinct_characters | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(count_distinct_characters(string: "") == 0)
assert(count_di... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_16_count_distinct_characters.py | swift |
[
"\n}"
] |
/// この関数の引数は、特別なASCII形式の音符を表す文字列である。あなたの仕事は、この文字列を解析して、それぞれの音符が何拍続くかに対応する整数のリストを返すことである。
/// ここに凡例がある:
/// o' - 全音符、4拍続く
/// o|' - 2分音符、2拍続く
/// .|」-4分音符、1拍続く
/// >>> parse_music(music_string: "o o| .| o| o| .| .| .| .| o o")
/// [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
func parse_music(music_string: String) -> [Int] {
| reworded | transform | HumanEval_17_parse_music | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(parse_music(music_string: "") == [] as [Int])
assert(parse_... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_17_parse_music.py | swift |
[
"\n}"
] |
/// 部分文字列substringが文字列stringの中で何回見つかるか数える。
/// 重なるケースもカウントに含まれる。
/// >>> how_many_times(string: "", substring: "a")
/// 0
/// >>> how_many_times(string: "aaa", substring: "a")
/// 3
/// >>> how_many_times(string: "aaaa", substring: "aa")
/// 3
func how_many_times(string: String, substring: String) -> Int {
| reworded | transform | HumanEval_18_how_many_times | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(how_many_times(string: "", substring: "x") == 0)
assert(how... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_18_how_many_times.py | swift |
[
"\n}"
] |
/// 引数は'zero'から'nine'までの英単語の数を空白で区切った文字列である。
/// 有効な英単語は''、'zero', 'one'、'two'、'three'、'four'、'five'、'six'、'seven'、'eight'、'nine'である。
/// 関数は、英単語の数を小さい方から大きい方へとソートした文字列を返す。
/// >>> sort_numbers(numbers: "three one five")
/// "one three five"
func sort_numbers(numbers: String) -> String {
| reworded | transform | HumanEval_19_sort_numbers | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sort_numbers(numbers: "") == "")
assert(sort_numbers(number... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_19_sort_numbers.py | swift |
[
"\n}"
] |
/// (少なくとも長さ2以上の)リストnumbersから、互いに最も近いものを2つ選び、
/// 順番に(小さい数、大きい数)返す。
/// >>> find_closest_elements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
/// (2.0, 2.2)
/// >>> find_closest_elements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
/// (2.0, 2.0)
func find_closest_elements(numbers: [Double]) -> (Double, Double) {
| reworded | transform | HumanEval_20_find_closest_elements | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(find_closest_elements(numbers: [1.0, 2.0, 3.9, 4.0, 5.0, 2.... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_20_find_closest_elements.py | swift |
[
"\n}"
] |
/// (少なくとも 2 つ以上の要素からなる) リストnumbersに線形変換を適用し、
/// 最小の数値が 0 になり、最大の数値が 1 になるリストを返す
/// >>> rescale_to_unit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0])
/// [0.0, 0.25, 0.5, 0.75, 1.0]
func rescale_to_unit(numbers: [Double]) -> [Double] {
| reworded | transform | HumanEval_21_rescale_to_unit | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(rescale_to_unit(numbers: [2.0, 49.9]) == [0.0, 1.0])
assert... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_21_rescale_to_unit.py | swift |
[
"\n}"
] |
/// 任意の種類の値が含まれるリストから整数値のみ抽出する
/// >>> filter_integers(values: ["a", 3.14, 5])
/// [5]
/// >>> filter_integers(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]])
/// [1, 2, 3]
func filter_integers(values: [AnyHashable]) -> [Int] {
| reworded | transform | HumanEval_22_filter_integers | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(filter_integers(values: [] as [AnyHashable]) == [] as [Int]... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_22_filter_integers.py | swift |
[
"\n}"
] |
/// 引数で与えられた文字列の長さを返す
/// >>> strlen(string: "")
/// 0
/// >>> strlen(string: "abc")
/// 3
func strlen(string: String) -> Int {
| reworded | transform | HumanEval_23_strlen | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(strlen(string: "") == 0)
assert(strlen(string: "x") == 1)
a... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_23_strlen.py | swift |
[
"\n}"
] |
/// 与えられた数nについて、nの約数のうち、nより小さい最大の数を求める
/// >>> largest_divisor(n: 15)
/// 5
func largest_divisor(n: Int) -> Int {
| reworded | transform | HumanEval_24_largest_divisor | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(largest_divisor(n: 3) == 1)
assert(largest_divisor(n: 7) ==... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_24_largest_divisor.py | swift |
[
"\n}"
] |
/// 与えられた整数の素因数のリストを小さいものから大きいものの順に返す。各因数は、
/// 因数分解で現れる回数分、リストに登場する。引数の整数は全ての因数の積に等しくな
/// ければならない。
/// >>> factorize(n: 8)
/// [2, 2, 2]
/// >>> factorize(n: 25)
/// [5, 5]
/// >>> factorize(n: 70)
/// [2, 5, 7]
func factorize(n: Int) -> [Int] {
| reworded | transform | HumanEval_25_factorize | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(factorize(n: 2) == [2])
assert(factorize(n: 4) == [2, 2])
a... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_25_factorize.py | swift |
[
"\n}"
] |
/// 整数のリストから、複数回出現する要素をすべて取り除く。
/// 要素の順序は入力と同じようにする。
/// >>> remove_duplicates(numbers: [1, 2, 3, 2, 4])
/// [1, 3, 4]
func remove_duplicates(numbers: [Int]) -> [Int] {
| reworded | transform | HumanEval_26_remove_duplicates | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(remove_duplicates(numbers: [] as [Int]) == [] as [Int])
ass... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_26_remove_duplicates.py | swift |
[
"\n}"
] |
/// 与えられた文字列に対して、英小文字を英大文字に、英大文字を英小文字に変換する。
/// >>> flip_case(string: "Hello")
/// "hELLO"
func flip_case(string: String) -> String {
| reworded | transform | HumanEval_27_flip_case | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(flip_case(string: "") == "")
assert(flip_case(string: "Hell... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_27_flip_case.py | swift |
[
"\n}"
] |
/// 文字列のリストを1つの文字列に連結する
/// >>> concatenate(strings: [] as [String])
/// ""
/// >>> concatenate(strings: ["a", "b", "c"])
/// "abc"
func concatenate(strings: [String]) -> String {
| reworded | transform | HumanEval_28_concatenate | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(concatenate(strings: [] as [String]) == "")
assert(concaten... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_28_concatenate.py | swift |
[
"\n}"
] |
/// 文字列のリストから、指定された接頭辞prefixで始まるものだけを取り出す。
/// >>> filter_by_prefix(strings: [] as [String], prefix: "a")
/// [] as [String]
/// >>> filter_by_prefix(strings: ["abc", "bcd", "cde", "array"], prefix: "a")
/// ["abc", "array"]
func filter_by_prefix(strings: [String], prefix: String) -> [String] {
| reworded | transform | HumanEval_29_filter_by_prefix | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(filter_by_prefix(strings: [] as [String], prefix: "john") =... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_29_filter_by_prefix.py | swift |
[
"\n}"
] |
/// リスト内の正の数だけを返す。
/// >>> get_positive(l: [-1, 2, -4, 5, 6])
/// [2, 5, 6]
/// >>> get_positive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
/// [5, 3, 2, 3, 9, 123, 1]
func get_positive(l: [Int]) -> [Int] {
| reworded | transform | HumanEval_30_get_positive | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(get_positive(l: [-1, -2, 4, 5, 6]) == [4, 5, 6])
assert(get... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_30_get_positive.py | swift |
[
"\n}"
] |
/// 与えられた数が素数であれば真を、そうでなければ偽を返す。
/// >>> is_prime(n: 6)
/// false
/// >>> is_prime(n: 101)
/// true
/// >>> is_prime(n: 11)
/// true
/// >>> is_prime(n: 13441)
/// true
/// >>> is_prime(n: 61)
/// true
/// >>> is_prime(n: 4)
/// false
/// >>> is_prime(n: 1)
/// false
func is_prime(n: Int) -> Bool {
| reworded | transform | HumanEval_31_is_prime | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(is_prime(n: 6) == false)
assert(is_prime(n: 101) == true)
a... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_31_is_prime.py | swift |
[
"\n}"
] |
/// この関数はリストlを受け取り、l'を返す。l'は、インデックスが3で割り
/// 切れない場合はlと同じであるが、インデックスが3で割り切れる要素は
/// ソートされている。
/// >>> sort_third(l: [1, 2, 3])
/// [1, 2, 3]
/// >>> sort_third(l: [5, 6, 3, 4, 8, 9, 2])
/// [2, 6, 3, 4, 8, 9, 5]
func sort_third(l: [Int]) -> [Int] {
| reworded | transform | HumanEval_33_sort_third | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sort_third(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, ... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_33_sort_third.py | swift |
[
"\n}"
] |
/// リスト内のユニークな要素をソートして返す
/// >>> unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123])
/// [0, 2, 3, 5, 9, 123]
func unique(l: [Int]) -> [Int] {
| reworded | transform | HumanEval_34_unique | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9,... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_34_unique.py | swift |
[
"\n}"
] |
/// リスト内の最大要素を返す。
/// >>> max_element(l: [1, 2, 3])
/// 3
/// >>> max_element(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
/// 123
func max_element(l: [Int]) -> Int {
| reworded | transform | HumanEval_35_max_element | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(max_element(l: [1, 2, 3]) == 3)
assert(max_element(l: [5, 3... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_35_max_element.py | swift |
[
"\n}"
] |
/// 与えられたn未満の整数の中で、11または13で割り切れる数の中に'7'という数字が何回現れるかを返す
/// >>> fizz_buzz(n: 50)
/// 0
/// >>> fizz_buzz(n: 78)
/// 2
/// >>> fizz_buzz(n: 79)
/// 3
func fizz_buzz(n: Int) -> Int {
| reworded | transform | HumanEval_36_fizz_buzz | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(fizz_buzz(n: 50) == 0)
assert(fizz_buzz(n: 78) == 2)
assert... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_36_fizz_buzz.py | swift |
[
"\n}"
] |
/// この関数はリスト l を受け取り、l' を返す。l'は、インデックスが奇数の
/// ときは l と同じで、インデックスが偶数のときはソートされている。
/// >>> sort_even(l: [1, 2, 3])
/// [1, 2, 3]
/// >>> sort_even(l: [5, 6, 3, 4])
/// [3, 6, 5, 4]
func sort_even(l: [Int]) -> [Int] {
| reworded | transform | HumanEval_37_sort_even | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sort_even(l: [1, 2, 3]) == [1, 2, 3])
assert(sort_even(l: [... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_37_sort_even.py | swift |
[
"\n}"
] |
/// prime_fib はフィボナッチ数で、かつ素数であるn番目の数を返す。
/// >>> prime_fib(n: 1)
/// 2
/// >>> prime_fib(n: 2)
/// 3
/// >>> prime_fib(n: 3)
/// 5
/// >>> prime_fib(n: 4)
/// 13
/// >>> prime_fib(n: 5)
/// 89
func prime_fib(n: Int) -> Int {
| reworded | transform | HumanEval_39_prime_fib | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(prime_fib(n: 1) == 2)
assert(prime_fib(n: 2) == 3)
assert(p... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_39_prime_fib.py | swift |
[
"\n}"
] |
/// triples_sum_to_zero は整数のリストを引数に取り、
/// リストの中に和が0になる3つの要素があればtrueを、
/// そうでなければfalseを返す。
/// >>> triples_sum_to_zero(l: [1, 3, 5, 0])
/// false
/// >>> triples_sum_to_zero(l: [1, 3, -2, 1])
/// true
/// >>> triples_sum_to_zero(l: [1, 2, 3, 7])
/// false
/// >>> triples_sum_to_zero(l: [2, 4, -5, 3, 9, 7])
/// true
/... | reworded | transform | HumanEval_40_triples_sum_to_zero | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(triples_sum_to_zero(l: [1, 3, 5, 0]) == false)
assert(tripl... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_40_triples_sum_to_zero.py | swift |
[
"\n}"
] |
/// 完全な直線で無限に長い道路を想像してほしい。
/// n台の車が左から右に向かって走っている。同時に、別のn台の車が
/// 右から左に向かって走っている。この2組の車は、最初は互いに非
/// 常に離れている。すべての車は同じ速度で動く。2台の車は次のよ
/// うに衝突する。左から右に動いている車が、右から左に動いている
/// 車にぶつかること。
/// しかし、車は限りなく頑丈で強い。あたかも衝突しなかったかのよ
/// うに、その軌道を進み続ける。
/// この関数は、このような衝突の回数を出力する。
func car_race_collision(n: Int) -> Int {
| reworded | transform | HumanEval_41_car_race_collision | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(car_race_collision(n: 2) == 4)
assert(car_race_collision(n:... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_41_car_race_collision.py | swift |
[
"\n}"
] |
/// 要素を1ずつ増やしたリストを返す。
/// >>> incr_list(l: [1, 2, 3])
/// [2, 3, 4]
/// >>> incr_list(l: [5, 3, 5, 2, 3, 3, 9, 0, 123])
/// [6, 4, 6, 3, 4, 4, 10, 1, 124]
func incr_list(l: [Int]) -> [Int] {
| reworded | transform | HumanEval_42_incr_list | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(incr_list(l: [] as [Int]) == [] as [Int])
assert(incr_list(... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_42_incr_list.py | swift |
[
"\n}"
] |
/// pairs_sum_to_zero は整数のリストを引数にとる。
/// リストの中に2つの要素の和がゼロになる要素があればtrueを、
/// そうでなければfalseを返す。
/// >>> pairs_sum_to_zero(l: [1, 3, 5, 0])
/// false
/// >>> pairs_sum_to_zero(l: [1, 3, -2, 1])
/// false
/// >>> pairs_sum_to_zero(l: [1, 2, 3, 7])
/// false
/// >>> pairs_sum_to_zero(l: [2, 4, -5, 3, 5, 7])
/// true
/// >>... | reworded | transform | HumanEval_43_pairs_sum_to_zero | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(pairs_sum_to_zero(l: [1, 3, 5, 0]) == false)
assert(pairs_s... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_43_pairs_sum_to_zero.py | swift |
[
"\n}"
] |
/// 引数xの基数をbaseに変換する。
/// 返り値は変換後の文字列表現である。
/// 基数は10未満である。
/// >>> change_base(x: 8, base: 3)
/// "22"
/// >>> change_base(x: 8, base: 2)
/// "1000"
/// >>> change_base(x: 7, base: 2)
/// "111"
func change_base(x: Int, base: Int) -> String {
| reworded | transform | HumanEval_44_change_base | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(change_base(x: 8, base: 3) == "22")
assert(change_base(x: 9... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_44_change_base.py | swift |
[
"\n}"
] |
/// 三角形の一辺の長さと高さが与えられたとき、面積を返す。
/// >>> triangle_area(a: 5, h: 3)
/// 7.5
func triangle_area(a: Int, h: Int) -> Double {
| reworded | transform | HumanEval_45_triangle_area | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(triangle_area(a: 5, h: 3) == 7.5)
assert(triangle_area(a: 2... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_45_triangle_area.py | swift |
[
"\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(n: 5)
/// 4
/// >>> fib4(n: 6)
/// 8
/// >>> fib4(n: 7)
/// 14
func fib4(n: Int) -> Int {
| reworded | transform | HumanEval_46_fib4 | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(fib4(n: 5) == 4)
assert(fib4(n: 8) == 28)
assert(fib4(n: 10... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_46_fib4.py | swift |
[
"\n}"
] |
/// リスト l の要素の中央値を返す。
/// >>> median(l: [3, 1, 2, 4, 5])
/// 3
/// >>> median(l: [-10, 4, 6, 1000, 10, 20])
/// 15.0
func median(l: [Int]) -> Double {
| reworded | transform | HumanEval_47_median | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(median(l: [3, 1, 2, 4, 5]) == 3)
assert(median(l: [-10, 4, ... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_47_median.py | swift |
[
"\n}"
] |
/// 与えられた文字列が回文かどうかを判定する
/// >>> is_palindrome(text: "")
/// true
/// >>> is_palindrome(text: "aba")
/// true
/// >>> is_palindrome(text: "aaaaa")
/// true
/// >>> is_palindrome(text: "zbcd")
/// false
func is_palindrome(text: String) -> Bool {
| reworded | transform | HumanEval_48_is_palindrome | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(is_palindrome(text: "") == true)
assert(is_palindrome(text:... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_48_is_palindrome.py | swift |
[
"\n}"
] |
/// 2^n を p で割ったモジュロを返す。計算精度に注意。
/// >>> modp(n: 3, p: 5)
/// 3
/// >>> modp(n: 1101, p: 101)
/// 2
/// >>> modp(n: 0, p: 101)
/// 1
/// >>> modp(n: 3, p: 11)
/// 8
/// >>> modp(n: 100, p: 101)
/// 1
func modp(n: Int, p: Int) -> Int {
| reworded | transform | HumanEval_49_modp | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(modp(n: 3, p: 5) == 3)
assert(modp(n: 1101, p: 101) == 2)
a... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_49_modp.py | swift |
[
"\n}"
] |
/// remove_vowelsは文字列を引数に取り、母音を除いた文字列を返す関数である。
/// >>> remove_vowels(text: "")
/// ""
/// >>> remove_vowels(text: "abcdef")
/// "bcdf"
/// >>> remove_vowels(text: "aaaaa")
/// ""
/// >>> remove_vowels(text: "aaBAA")
/// "B"
/// >>> remove_vowels(text: "zbcd")
/// "zbcd"
func remove_vowels(text: String) -> String {
| reworded | transform | HumanEval_51_remove_vowels | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(remove_vowels(text: "") == "")
assert(remove_vowels(text: "... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_51_remove_vowels.py | swift |
[
"\n}"
] |
/// リスト l 内の全ての数値が閾値 t 未満の場合、trueを返す。
/// >>> below_threshold(l: [1, 2, 4, 10], t: 100)
/// true
/// >>> below_threshold(l: [1, 20, 4, 10], t: 5)
/// false
func below_threshold(l: [Int], t: Int) -> Bool {
| reworded | transform | HumanEval_52_below_threshold | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(below_threshold(l: [1, 2, 4, 10], t: 100) == true)
assert(b... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_52_below_threshold.py | swift |
[
"\n}"
] |
/// 2つの数xとyを足す
/// >>> add(x: 2, y: 3)
/// 5
/// >>> add(x: 5, y: 7)
/// 12
func add(x: Int, y: Int) -> Int {
| reworded | transform | HumanEval_53_add | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(add(x: 0, y: 1) == 1)
assert(add(x: 1, y: 0) == 1)
assert(a... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_53_add.py | swift |
[
"\n}"
] |
/// 2つの単語が同じ文字セットから構成されるかどうか判定する。
/// >>> same_chars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc")
/// true
/// >>> same_chars(s0: "abcd", s1: "dddddddabc")
/// true
/// >>> same_chars(s0: "dddddddabc", s1: "abcd")
/// true
/// >>> same_chars(s0: "eabcd", s1: "dddddddabc")
/// false
/// >>> same_chars(s0: "abcd", s1: "dd... | reworded | transform | HumanEval_54_same_chars | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(same_chars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc") == tr... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_54_same_chars.py | swift |
[
"\n}"
] |
/// n番目のフィボナッチ数を返す。
/// >>> fib(n: 10)
/// 55
/// >>> fib(n: 1)
/// 1
/// >>> fib(n: 8)
/// 21
func fib(n: Int) -> Int {
| reworded | transform | HumanEval_55_fib | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(fib(n: 10) == 55)
assert(fib(n: 1) == 1)
assert(fib(n: 8) =... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_55_fib.py | swift |
[
"\n}"
] |
/// 引数bracketsは"<"と">"の文字列である。
/// すべての開き括弧が対応する閉じ括弧を持つ場合、trueを返す。
/// >>> correct_bracketing(brackets: "<")
/// false
/// >>> correct_bracketing(brackets: "<>")
/// true
/// >>> correct_bracketing(brackets: "<<><>>")
/// true
/// >>> correct_bracketing(brackets: "><<>")
/// false
func correct_bracketing(brackets: Str... | reworded | transform | HumanEval_56_correct_bracketing | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(correct_bracketing(brackets: "<>") == true)
assert(correct_... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_56_correct_bracketing.py | swift |
[
"\n}"
] |
/// リストの要素が単調増加または単調減少する場合にtrueを返す。
/// >>> monotonic(l: [1, 2, 4, 20])
/// true
/// >>> monotonic(l: [1, 20, 4, 10])
/// false
/// >>> monotonic(l: [4, 1, 0, -10])
/// true
func monotonic(l: [Int]) -> Bool {
| reworded | transform | HumanEval_57_monotonic | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(monotonic(l: [1, 2, 4, 10]) == true)
assert(monotonic(l: [1... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_57_monotonic.py | swift |
[
"\n}"
] |
/// 2つのリストについて、ユニークな共通要素をソートして返す。
/// >>> common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 653, 121])
/// [1, 5, 653]
/// >>> common(l1: [5, 3, 2, 8], l2: [3, 2])
/// [2, 3]
func common(l1: [Int], l2: [Int]) -> [Int] {
| reworded | transform | HumanEval_58_common | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 65... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_58_common.py | swift |
[
"\n}"
] |
/// nの最大となる素因数を返す。ただし、 n > 1 を前提とし、素数ではないものとする。
/// >>> largest_prime_factor(n: 13195)
/// 29
/// >>> largest_prime_factor(n: 2048)
/// 2
func largest_prime_factor(n: Int) -> Int {
| reworded | transform | HumanEval_59_largest_prime_factor | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(largest_prime_factor(n: 15) == 5)
assert(largest_prime_fact... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_59_largest_prime_factor.py | swift |
[
"\n}"
] |
/// sum_to_nは1からnまでの総和を求める関数である。
/// >>> sum_to_n(n: 30)
/// 465
/// >>> sum_to_n(n: 100)
/// 5050
/// >>> sum_to_n(n: 5)
/// 15
/// >>> sum_to_n(n: 10)
/// 55
/// >>> sum_to_n(n: 1)
/// 1
func sum_to_n(n: Int) -> Int {
| reworded | transform | HumanEval_60_sum_to_n | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sum_to_n(n: 1) == 1)
assert(sum_to_n(n: 6) == 21)
assert(su... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_60_sum_to_n.py | swift |
[
"\n}"
] |
/// 引数bracketsは"("と") "からなる文字列である。
/// すべての開き括弧が対応する閉じ括弧を持つ場合、trueを返す。
/// >>> correct_bracketing(brackets: "(")
/// false
/// >>> correct_bracketing(brackets: "()")
/// true
/// >>> correct_bracketing(brackets: "(()())")
/// true
/// >>> correct_bracketing(brackets: ")(()")
/// false
func correct_bracketing(brackets:... | reworded | transform | HumanEval_61_correct_bracketing | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(correct_bracketing(brackets: "()") == true)
assert(correct_... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_61_correct_bracketing.py | swift |
[
"\n}"
] |
/// xsは多項式の係数列を表す。
/// xs[0] + xs[1] * x + xs[2] * x^2 + ....
/// 関数は、この多項式の導関数を同じ形式で返す。
/// >>> derivative(xs: [3, 1, 2, 4, 5])
/// [1, 4, 12, 20]
/// >>> derivative(xs: [1, 2, 3])
/// [2, 6]
func derivative(xs: [Int]) -> [Int] {
| reworded | transform | HumanEval_62_derivative | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(derivative(xs: [3, 1, 2, 4, 5]) == [1, 4, 12, 20])
assert(d... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_62_derivative.py | swift |
[
"\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(n: 1)
/// 0
/// >>> fibfib(n: 5)
/// 4
/// >>> fibfib(n: 8)
/// 24
func fibfib(n: Int) -> Int {
| reworded | transform | HumanEval_63_fibfib | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(fibfib(n: 2) == 1)
assert(fibfib(n: 1) == 0)
assert(fibfib(... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_63_fibfib.py | swift |
[
"\n}"
] |
/// 単語を表す文字列を引数とし、その文字列に含まれる母音の数を返す
/// 関数 vowels_count を書きなさい。この場合の母音は'a', 'e', 'i', 'o', 'u'である。
/// ここで、与えられた単語の末尾にある場合のみ、'y'も母音とする。
/// 例:
/// >>> vowels_count(s: "abcde")
/// 2
/// >>> vowels_count(s: "ACEDY")
/// 3
func vowels_count(s: String) -> Int {
| reworded | transform | HumanEval_64_vowels_count | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(vowels_count(s: "abcde") == 2)
assert(vowels_count(s: "Alon... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_64_vowels_count.py | swift |
[
"\n}"
] |
/// 整数 x の桁を循環シフトする。shift 分だけ桁を右にシフトし、結果を文字列として返す。
/// もし、shift > 桁数なら、桁を反転して返す。
/// >>> circular_shift(x: 12, shift: 1)
/// "21"
/// >>> circular_shift(x: 12, shift: 2)
/// "12"
func circular_shift(x: Int, shift: Int) -> String {
| reworded | transform | HumanEval_65_circular_shift | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(circular_shift(x: 100, shift: 2) == "001")
assert(circular_... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_65_circular_shift.py | swift |
[
"\n}"
] |
/// タスク
/// 文字列を引数にとり、英大文字のみのASCIIコードの和を返す関数を書く。
/// 例:
/// >>> digitSum(s: "")
/// 0
/// >>> digitSum(s: "abAB")
/// 131
/// >>> digitSum(s: "abcCd")
/// 67
/// >>> digitSum(s: "helloE")
/// 69
/// >>> digitSum(s: "woArBld")
/// 131
/// >>> digitSum(s: "aAaaaXa")
/// 153
func digitSum(s: String) -> Int {
| reworded | transform | HumanEval_66_digitSum | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(digitSum(s: "") == 0)
assert(digitSum(s: "abAB") == 131)
as... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_66_digitSum.py | swift |
[
"\n}"
] |
/// この課題では、果物の入ったカゴに配られたリンゴとオレンジの数を表す文字列が
/// 与えられ、このカゴにはリンゴ、オレンジ、マンゴーの果実が入っている。オレンジ
/// とリンゴの総数を表す文字列と、かごの中の果物の総数を表す整数が与えられたら、
/// かごの中のマンゴーの果物の数を返しなさい。
/// たとえば:
/// >>> fruit_distribution(s: "5 apples and 6 oranges", n: 19)
/// 8
/// >>> fruit_distribution(s: "0 apples and 1 oranges", n: 3)
/// 2
/// >>> fruit_dist... | reworded | transform | HumanEval_67_fruit_distribution | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(fruit_distribution(s: "5 apples and 6 oranges", n: 19) == 8... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_67_fruit_distribution.py | swift |
[
"\n}"
] |
/// 非負整数のノードを持つ木の枝を表す配列が与えられたとする。あなたの仕事は、
/// ノードの1つを抜き取り、それを返すことである。
/// 摘出されるノードは、最小偶数値を持つノードでなければならない。
/// 同じ最小偶数値を持つノードが複数見つかった場合は、最小のインデックスを持つ
/// ノードを返す。
/// 摘出されたノードは [ smalest_value, its index ] というリストで返されなければならない。
/// 偶数値がない場合や与えられた配列が空の場合は [] を返します。
/// 例 1:
/// >>> pluck(arr: [4, 2, 3])
/// [2, 1]
/// 解説: 2... | reworded | transform | HumanEval_68_pluck | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(pluck(arr: [4, 2, 3]) == [2, 1])
assert(pluck(arr: [1, 2, 3... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_68_pluck.py | swift |
[
"\n}"
] |
/// 正の整数の空でないリストが与えられる。0より大きく、その整数自身の値以上の頻度を
/// 持つ最大の整数を返せ。整数の頻度とは、それがリストに現れる回数である。
/// のような値が存在しない場合は -1 を返す。
/// 例:
/// >>> search(lst: [4, 1, 2, 2, 3, 1])
/// 2
/// >>> search(lst: [1, 2, 2, 3, 3, 3, 4, 4, 4])
/// 3
/// >>> search(lst: [5, 5, 4, 4, 4])
/// -1
func search(lst: [Int]) -> Int {
| reworded | transform | HumanEval_69_search | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(search(lst: [5, 5, 5, 5, 1]) == 1)
assert(search(lst: [4, 1... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_69_search.py | swift |
[
"\n}"
] |
/// 整数のリストが与えられたとき、リストを奇妙な順序で返す。
/// 奇妙なソートとは、最小値から始まり、残りの整数の最大値、最小値の順で
/// ソートすることである。
/// 例:
/// >>> strange_sort_list(lst: [1, 2, 3, 4])
/// [1, 4, 2, 3]
/// >>> strange_sort_list(lst: [5, 5, 5, 5])
/// [5, 5, 5, 5]
/// >>> strange_sort_list(lst: [] as [Int])
/// [] as [Int]
func strange_sort_list(lst: [Int]) -> [I... | reworded | transform | HumanEval_70_strange_sort_list | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(strange_sort_list(lst: [1, 2, 3, 4]) == [1, 4, 2, 3])
asser... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_70_strange_sort_list.py | swift |
[
"\n}"
] |
/// 三角形の3辺の長さが与えられた。3辺が有効な三角形を形成していれば、
/// 三角形の面積を小数点以下2桁で四捨五入して返す。そうでない場合は-1を
/// 返す。
/// 任意の2辺の和が3辺より大きいとき、3辺は有効な三角形となる。
/// 例:
/// >>> triangle_area(a: 3, b: 4, c: 5)
/// 6.0
/// >>> triangle_area(a: 1, b: 2, c: 10)
/// -1
func triangle_area(a: Int, b: Int, c: Int) -> Double {
| reworded | transform | HumanEval_71_triangle_area | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(triangle_area(a: 3, b: 4, c: 5) == 6.0)
assert(triangle_are... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_71_triangle_area.py | swift |
[
"\n}"
] |
/// 物体qが飛べばtrueを、そうでなければfalseを返す関数を書け。
/// 物体qはバランスが取れていて(つまり、リストが回文であって)、その要素の和が
/// 最大荷重w以下であれば飛ぶ。
/// 例:
/// >>> will_it_fly(q: [1, 2], w: 5)
/// false
/// # 1+2 は最大荷重以下であるが、バランスが取れていない
/// >>> will_it_fly(q: [3, 2, 3], w: 1)
/// false
/// # バランスが取れているが、3+2+3 は最大荷重を超える
/// >>> will_it_fly(q: [3, 2, 3], w: 9)
/// tr... | reworded | transform | HumanEval_72_will_it_fly | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(will_it_fly(q: [3, 2, 3], w: 9) == true)
assert(will_it_fly... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_72_will_it_fly.py | swift |
[
"\n}"
] |
/// 整数の配列arrが与えられたとき、その配列を回文配列にするために
/// 必要な要素の最小数を求めよ。回文配列とは、前からも後からも同じ
/// ようになる配列のことである。1回の変更で、1つの要素を他の任意の
/// 要素に変更できる。
/// 例えば:
/// >>> smallest_change(arr: [1, 2, 3, 5, 4, 7, 9, 6])
/// 4
/// >>> smallest_change(arr: [1, 2, 3, 4, 3, 2, 2])
/// 1
/// >>> smallest_change(arr: [1, 2, 3, 2, 1])
/// 0
func smallest_c... | reworded | transform | HumanEval_73_smallest_change | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(smallest_change(arr: [1, 2, 3, 5, 4, 7, 9, 6]) == 4)
assert... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_73_smallest_change.py | swift |
[
"\n}"
] |
/// 2つの文字列リストを受け取り、リストの全文字数の合計がもう一方
/// のリストより少ないリストを返す関数を書きなさい。
/// もし2つのリストの文字数が同じなら、最初のリストを返す。
/// 例
/// >>> total_match(lst1: [] as [String], lst2: [] as [String])
/// [] as [String]
/// >>> total_match(lst1: ["hi", "admin"], lst2: ["hI", "Hi"])
/// ["hI", "Hi"]
/// >>> total_match(lst1: ["hi", "admin"], lst2: ["h... | reworded | transform | HumanEval_74_total_match | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(total_match(lst1: [] as [String], lst2: [] as [String]) == ... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_74_total_match.py | swift |
[
"\n}"
] |
/// 与えられた数が3つの素数の掛け算であればtrueを、そうでなければfalseを返す
/// 関数を書きなさい。
/// 引数 aは100以下を既知としていよい。
/// 例:
/// >>> is_multiply_prime(a: 30)
/// true
/// 30 = 2 * 3 * 5
func is_multiply_prime(a: Int) -> Bool {
| reworded | transform | HumanEval_75_is_multiply_prime | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(is_multiply_prime(a: 5) == false)
assert(is_multiply_prime(... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_75_is_multiply_prime.py | swift |
[
"\n}"
] |
/// あなたのタスクは、ある数xがnの単純なべき乗である場合にtrueを、
/// それ以外の場合にfalseを返す関数を書くことである。
/// xは、n**int=xのとき、nの単純なべき乗である。
/// 例えば:
/// >>> is_simple_power(x: 1, n: 4)
/// true
/// >>> is_simple_power(x: 2, n: 2)
/// true
/// >>> is_simple_power(x: 8, n: 2)
/// true
/// >>> is_simple_power(x: 3, n: 2)
/// false
/// >>> is_simple_power(x:... | reworded | transform | HumanEval_76_is_simple_power | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(is_simple_power(x: 16, n: 2) == true)
assert(is_simple_powe... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_76_is_simple_power.py | swift |
[
"\n}"
] |
/// 整数aを受け取り、この整数がある整数の3乗である場合にtrue
/// を返す関数を書きなさい。
/// 注意:入力は常に処理可能であると仮定してよい。
/// 例:
/// >>> iscube(a: 1)
/// true
/// >>> iscube(a: 2)
/// false
/// >>> iscube(a: -1)
/// true
/// >>> iscube(a: 64)
/// true
/// >>> iscube(a: 0)
/// true
/// >>> iscube(a: 180)
/// false
func iscube(a: Int) -> Bool {
| reworded | transform | HumanEval_77_iscube | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(iscube(a: 1) == true)
assert(iscube(a: 2) == false)
assert(... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_77_iscube.py | swift |
[
"\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)
/// 注意:入力は常に正確... | reworded | transform | HumanEval_78_hex_key | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(hex_key(num: "AB") == 1)
assert(hex_key(num: "1077E") == 2)... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_78_hex_key.py | swift |
[
"\n}"
] |
/// 10進数形式の数値が与えられ、あなたのタスクはそれを2進数形式に変換することである。
/// この関数は、文字列を返し、その各文字は2進数を表す。文字列の各文字は'0'か'1'である。
/// なお、文字列の最初と最後には'db'という余分な文字をつける。
/// この文字は書式を助けるためにある。
/// 例:
/// >>> decimal_to_binary(decimal: 15)
/// "db1111db"
/// >>> decimal_to_binary(decimal: 32)
/// "db100000db"
func decimal_to_binary(decimal: Int) -> String ... | reworded | transform | HumanEval_79_decimal_to_binary | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(decimal_to_binary(decimal: 0) == "db0db")
assert(decimal_to... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_79_decimal_to_binary.py | swift |
[
"\n}"
] |
/// あなたは文字列sが与えられる。
/// あなたのタスクは、その文字列が幸せかどうかをチェックすることである。
/// 文字列は幸せとは、文字列の長さが少なくとも3以上で、連続する3文字がすべて異なる場合である。
/// 例えば:
/// >>> is_happy(s: "a")
/// false
/// >>> is_happy(s: "aa")
/// false
/// >>> is_happy(s: "abcd")
/// true
/// >>> is_happy(s: "aabb")
/// false
/// >>> is_happy(s: "adb")
/// true
/// >>> is_happy(s... | reworded | transform | HumanEval_80_is_happy | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(is_happy(s: "a") == false)
assert(is_happy(s: "aa") == fals... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_80_is_happy.py | swift |
[
"\n}"
] |
/// 学期最終週、教師は生徒に成績をつけなければならない。教師は独自のアルゴリズムで採点している。
/// 問題は、彼女が成績評価に使ったコードを紛失してしまったことです。
/// 彼女は何人かの生徒のGPAのリストをあなたに渡したので、あなたは次の表を使って評点のリストを
/// 出力できる関数を書くことになりました。:
/// GPA | Letter grade
/// 4.0 A+
/// > 3.7 A
/// > 3.3 A-
/// > 3.0 B+
/// > 2.7 ... | reworded | transform | HumanEval_81_numerical_letter_grade | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(numerical_letter_grade(grades: [4.0, 3, 1.7, 2, 3.5]) == ["... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_81_numerical_letter_grade.py | swift |
[
"\n}"
] |
/// 文字列を受け取り、文字列の長さが素数であればtrueを、そうでなければfalseを返す関数を書く。
/// 例
/// >>> prime_length(string: "Hello")
/// true
/// >>> prime_length(string: "abcdcba")
/// true
/// >>> prime_length(string: "kittens")
/// true
/// >>> prime_length(string: "orange")
/// false
func prime_length(string: String) -> Bool {
| reworded | transform | HumanEval_82_prime_length | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(prime_length(string: "Hello") == true)
assert(prime_length(... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_82_prime_length.py | swift |
[
"\n}"
] |
/// 正の整数 n が与えられたとき、n 桁の正の整数で 1 で始まるか
/// もしくは終わる数のカウントを返す
func starts_one_ends(n: Int) -> Int {
| reworded | transform | HumanEval_83_starts_one_ends | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(starts_one_ends(n: 1) == 1)
assert(starts_one_ends(n: 2) ==... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_83_starts_one_ends.py | swift |
[
"\n}"
] |
/// 正の整数 N が与えられた時、その桁の総和を2進数で返す。
/// >>> solve(N: 1000)
/// "1"
/// >>> solve(N: 150)
/// "110"
/// >>> solve(N: 147)
/// "1100"
/// 数:
/// @N 整数
/// 制約: 0 ≤ N ≤ 10000.
/// 返り値:
/// 2進数表記の文字列
func solve(N: Int) -> String {
| reworded | transform | HumanEval_84_solve | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(solve(N: 1000) == "1")
assert(solve(N: 150) == "110")
asser... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_84_solve.py | swift |
[
"\n}"
] |
/// 空でない整数のリストlstが与えられたとき、奇数のインデックスにある偶数の要素を加える。
/// 例:
/// >>> add(lst: [4, 2, 6, 7])
/// 2
func add(lst: [Int]) -> Int {
| reworded | transform | HumanEval_85_add | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(add(lst: [4, 88]) == 88)
assert(add(lst: [4, 5, 6, 7, 2, 12... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_85_add.py | swift |
[
"\n}"
] |
/// 文字列を引数として受け取り、その「順序付けられたバージョン」を返す関数を作成してください。
/// 順序付けられたバージョンとは、各単語(空白で区切られた)の文字がASCII値に基づいて昇順に
/// 並べ替えられた新しい単語に置き換えられた文字列です。
/// 注意:文章内の単語と空白の順序はそのまま保ってください。
/// 例えば:
/// >>> anti_shuffle(s: "Hi")
/// "Hi"
/// >>> anti_shuffle(s: "hello")
/// "ehllo"
/// >>> anti_shuffle(s: "Hello World!!!")
/// "Hello !!!Wdlor... | reworded | transform | HumanEval_86_anti_shuffle | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(anti_shuffle(s: "Hi") == "Hi")
assert(anti_shuffle(s: "hell... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_86_anti_shuffle.py | swift |
[
"\n}"
] |
/// 2次元のデータがネストされたリストとして与えられる。これは行列に似ているが、
/// 列とは異なり、各行は異なる数の列を含むことができる。
/// lstと整数xが与えられたとき、リスト内の整数xを見つけ、各タプルが0から始まる
/// 座標(行、列)であるようなタプルのリスト[(x1, y1), (x2, y2) ...]を返す。
/// 座標を最初は行の昇順でソートする。
/// また、行の座標を列の降順でソートする。
/// 例:
/// >>> get_row(lst: [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 1, 6], [1, 2, 3, 4, 5, 1]], x: 1)
/// [... | reworded | transform | HumanEval_87_get_row | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(get_row(lst: [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 1, 6], [1, 2... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_87_get_row.py | swift |
[
"\n}"
] |
/// 非負の整数からなる配列が与えられた場合、配列をソートしたコピーを返してください。
/// 配列の最初の要素と最後の要素の和が奇数であれば、配列を昇順(小さい順)にソートします。
/// その和が偶数であれば、配列を降順(大きい順)にソートします。
/// 注意点:
/// * 与えられた配列自体を変更しないでください。
/// :
/// >>> sort_array(array: [] as [Int])
/// [] as [Int]
/// >>> sort_array(array: [5])
/// [5]
/// >>> sort_array(array: [2, 4, 3, 0, 1, 5])
/// [0, ... | reworded | transform | HumanEval_88_sort_array | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sort_array(array: [] as [Int]) == [] as [Int])
assert(sort_... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_88_sort_array.py | swift |
[
"\n}"
] |
/// 文字列を引数にとり、アルファベットを回転させて暗号化した
/// 文字列を返す関数encryptを作成せよ。
/// アルファベットは、文字位置を2倍して2つ下にシフトするように
/// 回転する。
/// 例:
/// >>> encrypt(s: "hi")
/// "lm"
/// >>> encrypt(s: "asdfghjkl")
/// "ewhjklnop"
/// >>> encrypt(s: "gf")
/// "kj"
/// >>> encrypt(s: "et")
/// "ix"
func encrypt(s: String) -> String {
| reworded | transform | HumanEval_89_encrypt | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(encrypt(s: "hi") == "lm")
assert(encrypt(s: "asdfghjkl") ==... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_89_encrypt.py | swift |
[
"\n}"
] |
/// 整数のリストが与えられる。
/// リストの2番目に小さい要素を返す関数 next_smallest() を書きなさい。
/// そのような要素がない場合は nil を返す。
/// >>> next_smallest(lst: [1, 2, 3, 4, 5])
/// 2
/// >>> next_smallest(lst: [5, 1, 4, 3, 2])
/// 2
/// >>> next_smallest(lst: [] as [Int])
/// nil
/// >>> next_smallest(lst: [1, 1])
/// nil
func next_smallest(lst: [Int]) -> In... | reworded | transform | HumanEval_90_next_smallest | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(next_smallest(lst: [1, 2, 3, 4, 5]) == 2)
assert(next_small... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_90_next_smallest.py | swift |
[
"\n}"
] |
/// 単語の文字列が与えられ、あなたのタスクは退屈指数を数える
/// ことである。退屈指数とは、"I "で始まる文のことである。
/// 文は'.'、’?’、'!'のいずれかで区切られる。
/// 例えば::
/// >>> is_bored(S: "Hello world")
/// 0
/// >>> is_bored(S: "The sky is blue. The sun is shining. I love this weather")
/// 1
func is_bored(S: String) -> Int {
| reworded | transform | HumanEval_91_is_bored | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(is_bored(S: "Hello world") == 0)
assert(is_bored(S: "Is the... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_91_is_bored.py | swift |
[
"\n}"
] |
/// 3つの数値を受け取る関数を作る。
/// 1つの数値が他の2つの数値の和と等しく、すべての数値が整数である場合にtrueを返す。
/// それ以外の場合はfalseを返す。
/// 例
/// >>> any_int(x: 5, y: 2, z: 7)
/// true
/// >>> any_int(x: 3, y: 2, z: 2)
/// false
/// >>> any_int(x: 3, y: -2, z: 1)
/// true
/// >>> any_int(x: 3.6, y: -2.2, z: 2)
/// false
func any_int(x: Double, y: Double, z: Doub... | reworded | transform | HumanEval_92_any_int | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(any_int(x: 2, y: 3, z: 1) == true)
assert(any_int(x: 2.5, y... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_92_any_int.py | swift |
[
"\n}"
] |
/// メッセージを受け取り、すべての文字の大文字と小文字を入れ替え、
/// メッセージ中のすべての母音を英語の母音の2つ前に現れる文字に置
/// き換えるようにエンコードする関数を書きなさい。
/// 文字だけを想定する。
/// 例:
/// >>> encode(message: "test")
/// "TGST"
/// >>> encode(message: "This is a message")
/// "tHKS KS C MGSSCGG"
func encode(message: String) -> String {
| reworded | transform | HumanEval_93_encode | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(encode(message: "TEST") == "tgst")
assert(encode(message: "... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_93_encode.py | swift |
[
"\n}"
] |
/// 整数のリストが与えらる。
/// 最大の素数を求め、その桁数の和を返す必要がある。
/// 例:
/// >>> skjkasdkd(lst: [0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3])
/// 10
/// >>> skjkasdkd(lst: [1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1])
/// 25
/// >>> skjkasdkd(lst: [1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 232... | reworded | transform | HumanEval_94_skjkasdkd | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(skjkasdkd(lst: [0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_94_skjkasdkd.py | swift |
[
"\n}"
] |
/// 非負整数を受け取り、素数でnより小さい最初のn個の
/// 整数の配列を返す関数を実装せよ。
/// 例えば:
/// >>> count_up_to(n: 5)
/// [2, 3]
/// >>> count_up_to(n: 11)
/// [2, 3, 5, 7]
/// >>> count_up_to(n: 0)
/// [] as [Int]
/// >>> count_up_to(n: 20)
/// [2, 3, 5, 7, 11, 13, 17, 19]
/// >>> count_up_to(n: 1)
/// [] as [Int]
/// >>> count_up_to(n: 18)
/// [2,... | reworded | transform | HumanEval_96_count_up_to | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(count_up_to(n: 5) == [2, 3])
assert(count_up_to(n: 6) == [2... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_96_count_up_to.py | swift |
[
"\n}"
] |
/// 2つの整数を受け取り、その1の位の数の積を返す関数を完成させよ。
/// 入力は常に有効範囲にあるとする。
/// 例:
/// >>> multiply(a: 148, b: 412)
/// 16
/// >>> multiply(a: 19, b: 28)
/// 72
/// >>> multiply(a: 2020, b: 1851)
/// 0
/// >>> multiply(a: 14, b: -15)
/// 20
func multiply(a: Int, b: Int) -> Int {
| reworded | transform | HumanEval_97_multiply | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(multiply(a: 148, b: 412) == 16)
assert(multiply(a: 19, b: 2... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_97_multiply.py | swift |
[
"\n}"
] |
/// 文字列 s が与えられたとき、偶数のインデックスに含まれる大文字の母音の数を数える。
/// 例えば:
/// >>> count_upper(s: "aBCdEf")
/// 1
/// >>> count_upper(s: "abcdefg")
/// 0
/// >>> count_upper(s: "dBBE")
/// 0
func count_upper(s: String) -> Int {
| reworded | transform | HumanEval_98_count_upper | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(count_upper(s: "aBCdEf") == 1)
assert(count_upper(s: "abcde... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_98_count_upper.py | swift |
[
"\n}"
] |
/// 数値を表す文字列valueを受け取り、それに最も近い整数を返す関数を作る。
/// その数値が2つの整数から等距離にある場合は、ゼロから四捨五入する。
/// 例
/// >>> closest_integer(value: "10")
/// 10
/// >>> closest_integer(value: "15.3")
/// 15
/// Note:
/// Rounding away from zero means that if the given number is equidistant
/// from two integers, the one you should return is the one... | reworded | transform | HumanEval_99_closest_integer | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(closest_integer(value: "10") == 10)
assert(closest_integer(... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_99_closest_integer.py | swift |
[
"\n}"
] |
/// 正の整数nが与えられたとき、n段の石の山を作らなければならない。
/// 最初の段にはn個の石がある。
/// 次の段の石の数は:
/// - nが奇数なら次の奇数。
/// - nが偶数なら次の偶数。
/// 各段の石の数をリストで返す。インデックス i の要素は、段 (i+1) の石の
// 数を表すものとする。
/// 例:
/// >>> make_a_pile(n: 3)
/// [3, 5, 7]
func make_a_pile(n: Int) -> [Int] {
| reworded | transform | HumanEval_100_make_a_pile | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(make_a_pile(n: 3) == [3, 5, 7])
assert(make_a_pile(n: 4) ==... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_100_make_a_pile.py | swift |
[
"\n}"
] |
/// カンマまたは空白で区切られた単語の文字列が与えられる。あなたのタスクは、
/// 文字列を単語に分割し、単語の配列を返すことである。
/// 例えば:
/// >>> words_string(s: "Hi, my name is John")
/// ["Hi", "my", "name", "is", "John"]
/// >>> words_string(s: "One, two, three, four, five, six")
/// ["One", "two", "three", "four", "five", "six"]
func words_string(s: String) -> [String] {... | reworded | transform | HumanEval_101_words_string | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(words_string(s: "Hi, my name is John") == ["Hi", "my", "nam... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_101_words_string.py | swift |
[
"\n}"
] |
/// この関数は2つの正の数xとyを受け取り、範囲[x, y](両端を含む)に含まれる
/// 最大の偶数整数を返す。そのような数がない場合、関数は-1を返す。
/// 例えば:
/// >>> choose_num(x: 12, y: 15)
/// 14
/// >>> choose_num(x: 13, y: 12)
/// -1
func choose_num(x: Int, y: Int) -> Int {
| reworded | transform | HumanEval_102_choose_num | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(choose_num(x: 12, y: 15) == 14)
assert(choose_num(x: 13, y:... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_102_choose_num.py | swift |
[
"\n}"
] |
extension Int: Error {}
/// 2つの正の整数nとmが与えられており、あなたのタスクはnからmまでの
/// 整数(nとmを含む)の平均を計算することである。
/// 答えを最も近い整数に丸め、2進数に変換せよ。
/// nがmより大きい場合は-1を返す。
/// 例:
/// >>> rounded_avg(n: 1, m: 5)
/// .success("0b11")
/// >>> rounded_avg(n: 7, m: 5)
/// .failure(-1)
/// >>> rounded_avg(n: 10, m: 20)
/// .success("0b1111")
///... | reworded | transform | HumanEval_103_rounded_avg | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(rounded_avg(n: 1, m: 5) == .success("0b11"))
assert(rounded... | /work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_103_rounded_avg.py | swift |
End of preview. Expand in Data Studio
- Downloads last month
- 6