name
stringlengths 15
44
| language
stringclasses 1
value | prompt
stringlengths 142
837
| doctests
stringclasses 1
value | original
stringlengths 130
159
| prompt_terminology
stringclasses 1
value | tests
stringlengths 489
2.6k
| stop_tokens
sequencelengths 3
3
|
|---|---|---|---|---|---|---|---|
HumanEval_0_has_close_elements
|
go_test.go
|
package has_close_elements_test
import (
"testing"
"fmt"
)
// リストnumbersの中に、与えられたthresholdより近い2つの数値が存在するか判定する
// >>> has_close_elements([]float64{1.0, 2.0, 3.0}, 0.5)
// false
// >>> has_close_elements([]float64{1.0, 2.8, 3.0, 4.0, 5.0, 2.0}, 0.3)
// true
func has_close_elements(numbers []float64, threshold float64) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_0_has_close_elements.py
|
reworded
|
func TestHas_Close_Elements(t *testing.T) {
candidate := has_close_elements
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]float64{1.0, 2.0, 3.9, 4.0, 5.0, 2.2}, 0.3), expected: true },
{ actual: candidate([]float64{1.0, 2.0, 3.9, 4.0, 5.0, 2.2}, 0.05), expected: false },
{ actual: candidate([]float64{1.0, 2.0, 5.9, 4.0, 5.0}, 0.95), expected: true },
{ actual: candidate([]float64{1.0, 2.0, 5.9, 4.0, 5.0}, 0.8), expected: false },
{ actual: candidate([]float64{1.0, 2.0, 3.0, 4.0, 5.0, 2.0}, 0.1), expected: true },
{ actual: candidate([]float64{1.1, 2.2, 3.1, 4.1, 5.1}, 1.0), expected: true },
{ actual: candidate([]float64{1.1, 2.2, 3.1, 4.1, 5.1}, 0.5), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_1_separate_paren_groups
|
go_test.go
|
package separate_paren_groups_test
import (
"testing"
"fmt"
)
// この関数への入力は、入れ子になった括弧が複数含まれる文字列である。
// あなたの目的は、これらの括弧を別々の文字列に分割し、そのリストを返すことである。
// 分離された括弧はバランスがとれ、つまり、開いた括弧はそれぞれ適切に閉じられていて、
// 互いに入れ子になっていない。引数の文字列内の空白は無視せよ。
// >>> separate_paren_groups("( ) (( )) (( )( ))")
// []string{"()", "(())", "(()())"}
func separate_paren_groups(paren_string string) []string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_1_separate_paren_groups.py
|
reworded
|
func TestSeparate_Paren_Groups(t *testing.T) {
candidate := separate_paren_groups
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("(()()) ((())) () ((())()())"), expected: []string{"(()())", "((()))", "()", "((())()())"} },
{ actual: candidate("() (()) ((())) (((())))"), expected: []string{"()", "(())", "((()))", "(((())))"} },
{ actual: candidate("(()(())((())))"), expected: []string{"(()(())((())))"} },
{ actual: candidate("( ) (( )) (( )( ))"), expected: []string{"()", "(())", "(()())"} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_2_truncate_number
|
go_test.go
|
package truncate_number_test
import (
"testing"
"fmt"
)
// 正の浮動小数点数が与えられると、それを整数部(与えられた数より小さい最大の整数)
// と小数部(常に1より小さい残余部分)に分解することができる。
// 関数は、数値の小数部を返す。
// >>> truncate_number(3.5)
// 0.5
func truncate_number(number float64) float64 {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_2_truncate_number.py
|
reworded
|
func TestTruncate_Number(t *testing.T) {
candidate := truncate_number
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(3.5), expected: 0.5 },
{ actual: candidate(1.25), expected: 0.25 },
{ actual: candidate(123.0), expected: 0.0 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_3_below_zero
|
go_test.go
|
package below_zero_test
import (
"testing"
"fmt"
)
// 銀行口座に対する入出金操作のリストが与えられます。あなたのタスクは、残高ゼロから
// 始まて、口座の残高がゼロ未満になったかどうかを検出し、その時点で関数がtrueを
// 返すようにすることです。そうでなければfalseを返すようにしてください。
// >>> below_zero([]int{1, 2, 3})
// false
// >>> below_zero([]int{1, 2, -4, 5})
// true
func below_zero(operations []int) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_3_below_zero.py
|
reworded
|
func TestBelow_Zero(t *testing.T) {
candidate := below_zero
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{}), expected: false },
{ actual: candidate([]int{1, 2, -3, 1, 2, -3}), expected: false },
{ actual: candidate([]int{1, 2, -4, 5, 6}), expected: true },
{ actual: candidate([]int{1, -1, 2, -2, 5, -5, 4, -4}), expected: false },
{ actual: candidate([]int{1, -1, 2, -2, 5, -5, 4, -5}), expected: true },
{ actual: candidate([]int{1, -2, 2, -2, 5, -5, 4, -4}), expected: true },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_4_mean_absolute_deviation
|
go_test.go
|
package mean_absolute_deviation_test
import (
"testing"
"fmt"
)
// 第一引数の数値リストに対して、このデータセットの平均値を中心とした平均絶対偏差(MAD)を計算する。
// 平均絶対偏差(MAD)とは、各要素と中心点(この場合は平均値)との差の絶対値の平均である:
// MAD = 平均|x - x_mean|
// >>> mean_absolute_deviation([]float64{1.0, 2.0, 3.0, 4.0})
// 1.0
func mean_absolute_deviation(numbers []float64) float64 {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_4_mean_absolute_deviation.py
|
reworded
|
func TestMean_Absolute_Deviation(t *testing.T) {
candidate := mean_absolute_deviation
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]float64{1.0, 2.0}), expected: 0.5 },
{ actual: candidate([]float64{1.0, 2.0, 3.0, 4.0}), expected: 1.0 },
{ actual: candidate([]float64{1.0, 2.0, 3.0, 4.0, 5.0}), expected: 1.2 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_5_intersperse
|
go_test.go
|
package intersperse_test
import (
"testing"
"fmt"
)
// 数値リスト numbers 中の全ての連続する二要素の間に、'delimeterの値を挿入する
// >>> intersperse([]int{}, 4)
// []int{}
// >>> intersperse([]int{1, 2, 3}, 4)
// []int{1, 4, 2, 4, 3}
func intersperse(numbers []int, delimeter int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_5_intersperse.py
|
reworded
|
func TestIntersperse(t *testing.T) {
candidate := intersperse
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{}, 7), expected: []int{} },
{ actual: candidate([]int{5, 6, 3, 2}, 8), expected: []int{5, 8, 6, 8, 3, 8, 2} },
{ actual: candidate([]int{2, 2, 2}, 2), expected: []int{2, 2, 2, 2, 2} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_6_parse_nested_parens
|
go_test.go
|
package parse_nested_parens_test
import (
"testing"
"fmt"
)
// この関数の入力は、空白で区切られた複数の入れ子になった括弧のグループを表す文字列です。
// 各グループについて、括弧の最も深い入れ子のレベルを出力します。
// 例えば、'(()())'は最大で2レベルの入れ子になっていますが、'((()))'は3レベルです。
// >>> parse_nested_parens("(()()) ((())) () ((())()())")
// []int{2, 3, 1, 3}
func parse_nested_parens(paren_string string) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_6_parse_nested_parens.py
|
reworded
|
func TestParse_Nested_Parens(t *testing.T) {
candidate := parse_nested_parens
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("(()()) ((())) () ((())()())"), expected: []int{2, 3, 1, 3} },
{ actual: candidate("() (()) ((())) (((())))"), expected: []int{1, 2, 3, 4} },
{ actual: candidate("(()(())((())))"), expected: []int{4} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_7_filter_by_substring
|
go_test.go
|
package filter_by_substring_test
import (
"testing"
"fmt"
)
// 文字列リストstringsを、与えれた部分文字列substringを含むものだけにフィルタする
// >>> filter_by_substring([]string{}, "a")
// []string{}
// >>> filter_by_substring([]string{"abc", "bacd", "cde", "array"}, "a")
// []string{"abc", "bacd", "array"}
func filter_by_substring(strings []string, substring string) []string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_7_filter_by_substring.py
|
reworded
|
func TestFilter_By_Substring(t *testing.T) {
candidate := filter_by_substring
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]string{}, "john"), expected: []string{} },
{ actual: candidate([]string{"xxx", "asd", "xxy", "john doe", "xxxAAA", "xxx"}, "xxx"), expected: []string{"xxx", "xxxAAA", "xxx"} },
{ actual: candidate([]string{"xxx", "asd", "aaaxxy", "john doe", "xxxAAA", "xxx"}, "xx"), expected: []string{"xxx", "aaaxxy", "xxxAAA", "xxx"} },
{ actual: candidate([]string{"grunt", "trumpet", "prune", "gruesome"}, "run"), expected: []string{"grunt", "prune"} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_8_sum_product
|
go_test.go
|
package sum_product_test
import (
"testing"
"fmt"
)
// 与えられた整数リストに対して、リスト内のすべての整数の和と積からなるタプルを返す。
// ただし、空の和は0、空の積は1とする。
// >>> sum_product([]int{})
// []interface{}{0, 1}
// >>> sum_product([]int{1, 2, 3, 4})
// []interface{}{10, 24}
func sum_product(numbers []int) []interface{} {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_8_sum_product.py
|
reworded
|
func TestSum_Product(t *testing.T) {
candidate := sum_product
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{}), expected: []interface{}{0, 1} },
{ actual: candidate([]int{1, 1, 1}), expected: []interface{}{3, 1} },
{ actual: candidate([]int{100, 0}), expected: []interface{}{100, 0} },
{ actual: candidate([]int{3, 5, 7}), expected: []interface{}{15, 105} },
{ actual: candidate([]int{10}), expected: []interface{}{10, 10} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_9_rolling_max
|
go_test.go
|
package rolling_max_test
import (
"testing"
"fmt"
)
// 与えられた整数リストから、各要素のそこまでの最大値(ローリング最大値)のリストを生成する。
// >>> rolling_max([]int{1, 2, 3, 2, 3, 4, 2})
// []int{1, 2, 3, 3, 3, 4, 4}
func rolling_max(numbers []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_9_rolling_max.py
|
reworded
|
func TestRolling_Max(t *testing.T) {
candidate := rolling_max
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{}), expected: []int{} },
{ actual: candidate([]int{1, 2, 3, 4}), expected: []int{1, 2, 3, 4} },
{ actual: candidate([]int{4, 3, 2, 1}), expected: []int{4, 4, 4, 4} },
{ actual: candidate([]int{3, 2, 3, 100, 3}), expected: []int{3, 3, 3, 100, 100} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_10_make_palindrome
|
go_test.go
|
package make_palindrome_test
import (
"testing"
"fmt"
)
// 与えられた文字列で始まる最短の回文を見つけてください。
// アルゴリズムのアイデアは以下の通りです:
// - 与えられた文字列の中で最も長い回文となる接尾辞を見つけます。
// - その回文の接尾辞の前に来る接頭辞を逆順にして、文字列の末尾に追加します。
// >>> make_palindrome("")
// ""
// >>> make_palindrome("cat")
// "catac"
// >>> make_palindrome("cata")
// "catac"
func make_palindrome(myString string) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_10_make_palindrome.py
|
reworded
|
func TestMake_Palindrome(t *testing.T) {
candidate := make_palindrome
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(""), expected: "" },
{ actual: candidate("x"), expected: "x" },
{ actual: candidate("xyz"), expected: "xyzyx" },
{ actual: candidate("xyx"), expected: "xyx" },
{ actual: candidate("jerry"), expected: "jerryrrej" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_11_string_xor
|
go_test.go
|
package string_xor_test
import (
"testing"
"fmt"
)
// 引数は1と0のみからなる文字列aとbである。
// これらの引数に対して排他論理和(XOR)を実行し、結果を文字列として返す。
// >>> string_xor("010", "110")
// "100"
func string_xor(a string, b string) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_11_string_xor.py
|
reworded
|
func TestString_Xor(t *testing.T) {
candidate := string_xor
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("111000", "101010"), expected: "010010" },
{ actual: candidate("1", "1"), expected: "0" },
{ actual: candidate("0101", "0000"), expected: "0101" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_13_greatest_common_divisor
|
go_test.go
|
package greatest_common_divisor_test
import (
"testing"
"fmt"
)
// 整数 a と b の最大公約数を返す
// >>> greatest_common_divisor(3, 5)
// 1
// >>> greatest_common_divisor(25, 15)
// 5
func greatest_common_divisor(a int, b int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_13_greatest_common_divisor.py
|
reworded
|
func TestGreatest_Common_Divisor(t *testing.T) {
candidate := greatest_common_divisor
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(3, 7), expected: 1 },
{ actual: candidate(10, 15), expected: 5 },
{ actual: candidate(49, 14), expected: 7 },
{ actual: candidate(144, 60), expected: 12 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_14_all_prefixes
|
go_test.go
|
package all_prefixes_test
import (
"testing"
"fmt"
)
// 引数で与えられた文字列に対して、短いものから長いものへ、全ての接頭辞のリストを返す
// >>> all_prefixes("abc")
// []string{"a", "ab", "abc"}
func all_prefixes(myString string) []string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_14_all_prefixes.py
|
reworded
|
func TestAll_Prefixes(t *testing.T) {
candidate := all_prefixes
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(""), expected: []string{} },
{ actual: candidate("asdfgh"), expected: []string{"a", "as", "asd", "asdf", "asdfg", "asdfgh"} },
{ actual: candidate("WWW"), expected: []string{"W", "WW", "WWW"} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_15_string_sequence
|
go_test.go
|
package string_sequence_test
import (
"testing"
"fmt"
)
// 0からnまでの数字を空白区切りで連結した文字列で返す。
// >>> string_sequence(0)
// "0"
// >>> string_sequence(5)
// "0 1 2 3 4 5"
func string_sequence(n int) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_15_string_sequence.py
|
reworded
|
func TestString_Sequence(t *testing.T) {
candidate := string_sequence
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(0), expected: "0" },
{ actual: candidate(3), expected: "0 1 2 3" },
{ actual: candidate(10), expected: "0 1 2 3 4 5 6 7 8 9 10" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_16_count_distinct_characters
|
go_test.go
|
package count_distinct_characters_test
import (
"testing"
"fmt"
)
// 文字列が与えられたとき、その文字列が(大文字小文字に関係なく)いくつの異なる文字が含まれているか数える
// >>> count_distinct_characters("xyzXYZ")
// 3
// >>> count_distinct_characters("Jerry")
// 4
func count_distinct_characters(myString string) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_16_count_distinct_characters.py
|
reworded
|
func TestCount_Distinct_Characters(t *testing.T) {
candidate := count_distinct_characters
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(""), expected: 0 },
{ actual: candidate("abcde"), expected: 5 },
{ actual: candidate("abcdecadeCADE"), expected: 5 },
{ actual: candidate("aaaaAAAAaaaa"), expected: 1 },
{ actual: candidate("Jerry jERRY JeRRRY"), expected: 5 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_17_parse_music
|
go_test.go
|
package parse_music_test
import (
"testing"
"fmt"
)
// この関数の引数は、特別なASCII形式の音符を表す文字列である。あなたの仕事は、この文字列を解析して、それぞれの音符が何拍続くかに対応する整数のリストを返すことである。
// ここに凡例がある:
// o' - 全音符、4拍続く
// o|' - 2分音符、2拍続く
// .|」-4分音符、1拍続く
// >>> parse_music("o o| .| o| o| .| .| .| .| o o")
// []int{4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4}
func parse_music(music_string string) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_17_parse_music.py
|
reworded
|
func TestParse_Music(t *testing.T) {
candidate := parse_music
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(""), expected: []int{} },
{ actual: candidate("o o o o"), expected: []int{4, 4, 4, 4} },
{ actual: candidate(".| .| .| .|"), expected: []int{1, 1, 1, 1} },
{ actual: candidate("o| o| .| .| o o o o"), expected: []int{2, 2, 1, 1, 4, 4, 4, 4} },
{ actual: candidate("o| .| o| .| o o| o o|"), expected: []int{2, 1, 2, 1, 4, 2, 4, 2} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_18_how_many_times
|
go_test.go
|
package how_many_times_test
import (
"testing"
"fmt"
)
// 部分文字列substringが文字列stringの中で何回見つかるか数える。
// 重なるケースもカウントに含まれる。
// >>> how_many_times("", "a")
// 0
// >>> how_many_times("aaa", "a")
// 3
// >>> how_many_times("aaaa", "aa")
// 3
func how_many_times(myString string, substring string) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_18_how_many_times.py
|
reworded
|
func TestHow_Many_Times(t *testing.T) {
candidate := how_many_times
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("", "x"), expected: 0 },
{ actual: candidate("xyxyxyx", "x"), expected: 4 },
{ actual: candidate("cacacacac", "cac"), expected: 4 },
{ actual: candidate("john doe", "john"), expected: 1 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_19_sort_numbers
|
go_test.go
|
package sort_numbers_test
import (
"testing"
"fmt"
)
// 引数は'zero'から'nine'までの英単語の数を空白で区切った文字列である。
// 有効な英単語は''、'zero', 'one'、'two'、'three'、'four'、'five'、'six'、'seven'、'eight'、'nine'である。
// 関数は、英単語の数を小さい方から大きい方へとソートした文字列を返す。
// >>> sort_numbers("three one five")
// "one three five"
func sort_numbers(numbers string) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_19_sort_numbers.py
|
reworded
|
func TestSort_Numbers(t *testing.T) {
candidate := sort_numbers
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(""), expected: "" },
{ actual: candidate("three"), expected: "three" },
{ actual: candidate("three five nine"), expected: "three five nine" },
{ actual: candidate("five zero four seven nine eight"), expected: "zero four five seven eight nine" },
{ actual: candidate("six five four three two one zero"), expected: "zero one two three four five six" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_20_find_closest_elements
|
go_test.go
|
package find_closest_elements_test
import (
"testing"
"fmt"
)
// (少なくとも長さ2以上の)リストnumbersから、互いに最も近いものを2つ選び、
// 順番に(小さい数、大きい数)返す。
// >>> find_closest_elements([]float64{1.0, 2.0, 3.0, 4.0, 5.0, 2.2})
// []interface{}{2.0, 2.2}
// >>> find_closest_elements([]float64{1.0, 2.0, 3.0, 4.0, 5.0, 2.0})
// []interface{}{2.0, 2.0}
func find_closest_elements(numbers []float64) []interface{} {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_20_find_closest_elements.py
|
reworded
|
func TestFind_Closest_Elements(t *testing.T) {
candidate := find_closest_elements
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]float64{1.0, 2.0, 3.9, 4.0, 5.0, 2.2}), expected: []interface{}{3.9, 4.0} },
{ actual: candidate([]float64{1.0, 2.0, 5.9, 4.0, 5.0}), expected: []interface{}{5.0, 5.9} },
{ actual: candidate([]float64{1.0, 2.0, 3.0, 4.0, 5.0, 2.2}), expected: []interface{}{2.0, 2.2} },
{ actual: candidate([]float64{1.0, 2.0, 3.0, 4.0, 5.0, 2.0}), expected: []interface{}{2.0, 2.0} },
{ actual: candidate([]float64{1.1, 2.2, 3.1, 4.1, 5.1}), expected: []interface{}{2.2, 3.1} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_21_rescale_to_unit
|
go_test.go
|
package rescale_to_unit_test
import (
"testing"
"fmt"
)
// (少なくとも 2 つ以上の要素からなる) リストnumbersに線形変換を適用し、
// 最小の数値が 0 になり、最大の数値が 1 になるリストを返す
// >>> rescale_to_unit([]float64{1.0, 2.0, 3.0, 4.0, 5.0})
// []float64{0.0, 0.25, 0.5, 0.75, 1.0}
func rescale_to_unit(numbers []float64) []float64 {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_21_rescale_to_unit.py
|
reworded
|
func TestRescale_To_Unit(t *testing.T) {
candidate := rescale_to_unit
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]float64{2.0, 49.9}), expected: []float64{0.0, 1.0} },
{ actual: candidate([]float64{100.0, 49.9}), expected: []float64{1.0, 0.0} },
{ actual: candidate([]float64{1.0, 2.0, 3.0, 4.0, 5.0}), expected: []float64{0.0, 0.25, 0.5, 0.75, 1.0} },
{ actual: candidate([]float64{2.0, 1.0, 5.0, 3.0, 4.0}), expected: []float64{0.25, 0.0, 1.0, 0.5, 0.75} },
{ actual: candidate([]float64{12.0, 11.0, 15.0, 13.0, 14.0}), expected: []float64{0.25, 0.0, 1.0, 0.5, 0.75} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_22_filter_integers
|
go_test.go
|
package filter_integers_test
import (
"testing"
"fmt"
)
// 任意の種類の値が含まれるリストから整数値のみ抽出する
// >>> filter_integers([]float64{"a", 3.14, 5})
// []int{5}
// >>> filter_integers([]interface{}{1, 2, 3, "abc", map[interface{}]interface{}{}, []interface{}{}})
// []int{1, 2, 3}
func filter_integers(values []interface{}) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_22_filter_integers.py
|
reworded
|
func TestFilter_Integers(t *testing.T) {
candidate := filter_integers
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]interface{}{}), expected: []int{} },
{ actual: candidate([]interface{}{4, map[interface{}]interface{}{}, []interface{}{}, 23.2, 9, "adasd"}), expected: []int{4, 9} },
{ actual: candidate([]interface{}{3, "c", 3, 3, "a", "b"}), expected: []int{3, 3, 3} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_23_strlen
|
go_test.go
|
package strlen_test
import (
"testing"
"fmt"
)
// 引数で与えられた文字列の長さを返す
// >>> strlen("")
// 0
// >>> strlen("abc")
// 3
func strlen(myString string) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_23_strlen.py
|
reworded
|
func TestStrlen(t *testing.T) {
candidate := strlen
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(""), expected: 0 },
{ actual: candidate("x"), expected: 1 },
{ actual: candidate("asdasnakj"), expected: 9 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_24_largest_divisor
|
go_test.go
|
package largest_divisor_test
import (
"testing"
"fmt"
)
// 与えられた数nについて、nの約数のうち、nより小さい最大の数を求める
// >>> largest_divisor(15)
// 5
func largest_divisor(n int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_24_largest_divisor.py
|
reworded
|
func TestLargest_Divisor(t *testing.T) {
candidate := largest_divisor
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(3), expected: 1 },
{ actual: candidate(7), expected: 1 },
{ actual: candidate(10), expected: 5 },
{ actual: candidate(100), expected: 50 },
{ actual: candidate(49), expected: 7 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_25_factorize
|
go_test.go
|
package factorize_test
import (
"testing"
"fmt"
)
// 与えられた整数の素因数のリストを小さいものから大きいものの順に返す。各因数は、
// 因数分解で現れる回数分、リストに登場する。引数の整数は全ての因数の積に等しくな
// ければならない。
// >>> factorize(8)
// []int{2, 2, 2}
// >>> factorize(25)
// []int{5, 5}
// >>> factorize(70)
// []int{2, 5, 7}
func factorize(n int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_25_factorize.py
|
reworded
|
func TestFactorize(t *testing.T) {
candidate := factorize
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(2), expected: []int{2} },
{ actual: candidate(4), expected: []int{2, 2} },
{ actual: candidate(8), expected: []int{2, 2, 2} },
{ actual: candidate(57), expected: []int{3, 19} },
{ actual: candidate(3249), expected: []int{3, 3, 19, 19} },
{ actual: candidate(185193), expected: []int{3, 3, 3, 19, 19, 19} },
{ actual: candidate(20577), expected: []int{3, 19, 19, 19} },
{ actual: candidate(18), expected: []int{2, 3, 3} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_26_remove_duplicates
|
go_test.go
|
package remove_duplicates_test
import (
"testing"
"fmt"
)
// 整数のリストから、複数回出現する要素をすべて取り除く。
// 要素の順序は入力と同じようにする。
// >>> remove_duplicates([]int{1, 2, 3, 2, 4})
// []int{1, 3, 4}
func remove_duplicates(numbers []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_26_remove_duplicates.py
|
reworded
|
func TestRemove_Duplicates(t *testing.T) {
candidate := remove_duplicates
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{}), expected: []int{} },
{ actual: candidate([]int{1, 2, 3, 4}), expected: []int{1, 2, 3, 4} },
{ actual: candidate([]int{1, 2, 3, 2, 4, 3, 5}), expected: []int{1, 4, 5} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_27_flip_case
|
go_test.go
|
package flip_case_test
import (
"testing"
"fmt"
)
// 与えられた文字列に対して、英小文字を英大文字に、英大文字を英小文字に変換する。
// >>> flip_case("Hello")
// "hELLO"
func flip_case(myString string) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_27_flip_case.py
|
reworded
|
func TestFlip_Case(t *testing.T) {
candidate := flip_case
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(""), expected: "" },
{ actual: candidate("Hello!"), expected: "hELLO!" },
{ actual: candidate("These violent delights have violent ends"), expected: "tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_28_concatenate
|
go_test.go
|
package concatenate_test
import (
"testing"
"fmt"
)
// 文字列のリストを1つの文字列に連結する
// >>> concatenate([]string{})
// ""
// >>> concatenate([]string{"a", "b", "c"})
// "abc"
func concatenate(strings []string) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_28_concatenate.py
|
reworded
|
func TestConcatenate(t *testing.T) {
candidate := concatenate
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]string{}), expected: "" },
{ actual: candidate([]string{"x", "y", "z"}), expected: "xyz" },
{ actual: candidate([]string{"x", "y", "z", "w", "k"}), expected: "xyzwk" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_29_filter_by_prefix
|
go_test.go
|
package filter_by_prefix_test
import (
"testing"
"fmt"
)
// 文字列のリストから、指定された接頭辞prefixで始まるものだけを取り出す。
// >>> filter_by_prefix([]string{}, "a")
// []string{}
// >>> filter_by_prefix([]string{"abc", "bcd", "cde", "array"}, "a")
// []string{"abc", "array"}
func filter_by_prefix(strings []string, prefix string) []string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_29_filter_by_prefix.py
|
reworded
|
func TestFilter_By_Prefix(t *testing.T) {
candidate := filter_by_prefix
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]string{}, "john"), expected: []string{} },
{ actual: candidate([]string{"xxx", "asd", "xxy", "john doe", "xxxAAA", "xxx"}, "xxx"), expected: []string{"xxx", "xxxAAA", "xxx"} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_30_get_positive
|
go_test.go
|
package get_positive_test
import (
"testing"
"fmt"
)
// リスト内の正の数だけを返す。
// >>> get_positive([]int{-1, 2, -4, 5, 6})
// []int{2, 5, 6}
// >>> get_positive([]int{5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10})
// []int{5, 3, 2, 3, 9, 123, 1}
func get_positive(l []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_30_get_positive.py
|
reworded
|
func TestGet_Positive(t *testing.T) {
candidate := get_positive
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{-1, -2, 4, 5, 6}), expected: []int{4, 5, 6} },
{ actual: candidate([]int{5, 3, -5, 2, 3, 3, 9, 0, 123, 1, -10}), expected: []int{5, 3, 2, 3, 3, 9, 123, 1} },
{ actual: candidate([]int{-1, -2}), expected: []int{} },
{ actual: candidate([]int{}), expected: []int{} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_31_is_prime
|
go_test.go
|
package is_prime_test
import (
"testing"
"fmt"
)
// 与えられた数が素数であれば真を、そうでなければ偽を返す。
// >>> 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
func is_prime(n int) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_31_is_prime.py
|
reworded
|
func TestIs_Prime(t *testing.T) {
candidate := is_prime
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(6), expected: false },
{ actual: candidate(101), expected: true },
{ actual: candidate(11), expected: true },
{ actual: candidate(13441), expected: true },
{ actual: candidate(61), expected: true },
{ actual: candidate(4), expected: false },
{ actual: candidate(1), expected: false },
{ actual: candidate(5), expected: true },
{ actual: candidate(11), expected: true },
{ actual: candidate(17), expected: true },
{ actual: candidate(85), expected: false },
{ actual: candidate(77), expected: false },
{ actual: candidate(255379), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_33_sort_third
|
go_test.go
|
package sort_third_test
import (
"testing"
"fmt"
)
// この関数はリストlを受け取り、l'を返す。l'は、インデックスが3で割り
// 切れない場合はlと同じであるが、インデックスが3で割り切れる要素は
// ソートされている。
// >>> sort_third([]int{1, 2, 3})
// []int{1, 2, 3}
// >>> sort_third([]int{5, 6, 3, 4, 8, 9, 2})
// []int{2, 6, 3, 4, 8, 9, 5}
func sort_third(l []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_33_sort_third.py
|
reworded
|
func TestSort_Third(t *testing.T) {
candidate := sort_third
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{5, 6, 3, 4, 8, 9, 2}), expected: []int{2, 6, 3, 4, 8, 9, 5} },
{ actual: candidate([]int{5, 8, 3, 4, 6, 9, 2}), expected: []int{2, 8, 3, 4, 6, 9, 5} },
{ actual: candidate([]int{5, 6, 9, 4, 8, 3, 2}), expected: []int{2, 6, 9, 4, 8, 3, 5} },
{ actual: candidate([]int{5, 6, 3, 4, 8, 9, 2, 1}), expected: []int{2, 6, 3, 4, 8, 9, 5, 1} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_34_unique
|
go_test.go
|
package unique_test
import (
"testing"
"fmt"
)
// リスト内のユニークな要素をソートして返す
// >>> unique([]int{5, 3, 5, 2, 3, 3, 9, 0, 123})
// []int{0, 2, 3, 5, 9, 123}
func unique(l []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_34_unique.py
|
reworded
|
func TestUnique(t *testing.T) {
candidate := unique
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{5, 3, 5, 2, 3, 3, 9, 0, 123}), expected: []int{0, 2, 3, 5, 9, 123} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_35_max_element
|
go_test.go
|
package max_element_test
import (
"testing"
"fmt"
)
// リスト内の最大要素を返す。
// >>> max_element([]int{1, 2, 3})
// 3
// >>> max_element([]int{5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10})
// 123
func max_element(l []int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_35_max_element.py
|
reworded
|
func TestMax_Element(t *testing.T) {
candidate := max_element
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{1, 2, 3}), expected: 3 },
{ actual: candidate([]int{5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10}), expected: 124 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_36_fizz_buzz
|
go_test.go
|
package fizz_buzz_test
import (
"testing"
"fmt"
)
// 1与えられたn未満の整数の中で、11または13で割り切れる数の中に'7'という数字が何回現れるかを返す.
// >>> fizz_buzz(50)
// 0
// >>> fizz_buzz(78)
// 2
// >>> fizz_buzz(79)
// 3
func fizz_buzz(n int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_36_fizz_buzz.py
|
reworded
|
func TestFizz_Buzz(t *testing.T) {
candidate := fizz_buzz
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(50), expected: 0 },
{ actual: candidate(78), expected: 2 },
{ actual: candidate(79), expected: 3 },
{ actual: candidate(100), expected: 3 },
{ actual: candidate(200), expected: 6 },
{ actual: candidate(4000), expected: 192 },
{ actual: candidate(10000), expected: 639 },
{ actual: candidate(100000), expected: 8026 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_37_sort_even
|
go_test.go
|
package sort_even_test
import (
"testing"
"fmt"
)
// この関数はリスト l を受け取り、l' を返す。l'は、インデックスが奇数の
// ときは l と同じで、インデックスが偶数のときはソートされている。
// >>> sort_even([]int{1, 2, 3})
// []int{1, 2, 3}
// >>> sort_even([]int{5, 6, 3, 4})
// []int{3, 6, 5, 4}
func sort_even(l []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_37_sort_even.py
|
reworded
|
func TestSort_Even(t *testing.T) {
candidate := sort_even
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{1, 2, 3}), expected: []int{1, 2, 3} },
{ actual: candidate([]int{5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10}), expected: []int{-10, 3, -5, 2, -3, 3, 5, 0, 9, 1, 123} },
{ actual: candidate([]int{5, 8, -12, 4, 23, 2, 3, 11, 12, -10}), expected: []int{-12, 8, 3, 4, 5, 2, 12, 11, 23, -10} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_39_prime_fib
|
go_test.go
|
package prime_fib_test
import (
"testing"
"fmt"
)
// prime_fib はフィボナッチ数で、かつ素数であるn番目の数を返す。
// >>> prime_fib(1)
// 2
// >>> prime_fib(2)
// 3
// >>> prime_fib(3)
// 5
// >>> prime_fib(4)
// 13
// >>> prime_fib(5)
// 89
func prime_fib(n int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_39_prime_fib.py
|
reworded
|
func TestPrime_Fib(t *testing.T) {
candidate := prime_fib
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(1), expected: 2 },
{ actual: candidate(2), expected: 3 },
{ actual: candidate(3), expected: 5 },
{ actual: candidate(4), expected: 13 },
{ actual: candidate(5), expected: 89 },
{ actual: candidate(6), expected: 233 },
{ actual: candidate(7), expected: 1597 },
{ actual: candidate(8), expected: 28657 },
{ actual: candidate(9), expected: 514229 },
{ actual: candidate(10), expected: 433494437 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_40_triples_sum_to_zero
|
go_test.go
|
package triples_sum_to_zero_test
import (
"testing"
"fmt"
)
// triples_sum_to_zero は整数のリストを引数に取り、
// リストの中に和が0になる3つの要素があればtrueを、
// そうでなければfalseを返す。
// >>> triples_sum_to_zero([]int{1, 3, 5, 0})
// false
// >>> triples_sum_to_zero([]int{1, 3, -2, 1})
// true
// >>> triples_sum_to_zero([]int{1, 2, 3, 7})
// false
// >>> triples_sum_to_zero([]int{2, 4, -5, 3, 9, 7})
// true
// >>> triples_sum_to_zero([]int{1})
// false
func triples_sum_to_zero(l []int) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_40_triples_sum_to_zero.py
|
reworded
|
func TestTriples_Sum_To_Zero(t *testing.T) {
candidate := triples_sum_to_zero
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{1, 3, 5, 0}), expected: false },
{ actual: candidate([]int{1, 3, 5, -1}), expected: false },
{ actual: candidate([]int{1, 3, -2, 1}), expected: true },
{ actual: candidate([]int{1, 2, 3, 7}), expected: false },
{ actual: candidate([]int{1, 2, 5, 7}), expected: false },
{ actual: candidate([]int{2, 4, -5, 3, 9, 7}), expected: true },
{ actual: candidate([]int{1}), expected: false },
{ actual: candidate([]int{1, 3, 5, -100}), expected: false },
{ actual: candidate([]int{100, 3, 5, -100}), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_41_car_race_collision
|
go_test.go
|
package car_race_collision_test
import (
"testing"
"fmt"
)
// 完全な直線で無限に長い道路を想像してほしい。
// n台の車が左から右に向かって走っている。同時に、別のn台の車が
// 右から左に向かって走っている。この2組の車は、最初は互いに非
// 常に離れている。すべての車は同じ速度で動く。2台の車は次のよ
// うに衝突する。左から右に動いている車が、右から左に動いている
// 車にぶつかること。
// しかし、車は限りなく頑丈で強い。あたかも衝突しなかったかのよ
// うに、その軌道を進み続ける。
// この関数は、このような衝突の回数を出力する。
func car_race_collision(n int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_41_car_race_collision.py
|
reworded
|
func TestCar_Race_Collision(t *testing.T) {
candidate := car_race_collision
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(2), expected: 4 },
{ actual: candidate(3), expected: 9 },
{ actual: candidate(4), expected: 16 },
{ actual: candidate(8), expected: 64 },
{ actual: candidate(10), expected: 100 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_42_incr_list
|
go_test.go
|
package incr_list_test
import (
"testing"
"fmt"
)
// 要素を1ずつ増やしたリストを返す。
// >>> incr_list([]int{1, 2, 3})
// []int{2, 3, 4}
// >>> incr_list([]int{5, 3, 5, 2, 3, 3, 9, 0, 123})
// []int{6, 4, 6, 3, 4, 4, 10, 1, 124}
func incr_list(l []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_42_incr_list.py
|
reworded
|
func TestIncr_List(t *testing.T) {
candidate := incr_list
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{}), expected: []int{} },
{ actual: candidate([]int{3, 2, 1}), expected: []int{4, 3, 2} },
{ actual: candidate([]int{5, 2, 5, 2, 3, 3, 9, 0, 123}), expected: []int{6, 3, 6, 3, 4, 4, 10, 1, 124} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_43_pairs_sum_to_zero
|
go_test.go
|
package pairs_sum_to_zero_test
import (
"testing"
"fmt"
)
// pairs_sum_to_zero は整数のリストを引数にとる。
// リストの中に2つの要素の和がゼロになる要素があればtrueを、
// そうでなければfalseを返す。
// >>> pairs_sum_to_zero([]int{1, 3, 5, 0})
// false
// >>> pairs_sum_to_zero([]int{1, 3, -2, 1})
// false
// >>> pairs_sum_to_zero([]int{1, 2, 3, 7})
// false
// >>> pairs_sum_to_zero([]int{2, 4, -5, 3, 5, 7})
// true
// >>> pairs_sum_to_zero([]int{1})
// false
func pairs_sum_to_zero(l []int) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_43_pairs_sum_to_zero.py
|
reworded
|
func TestPairs_Sum_To_Zero(t *testing.T) {
candidate := pairs_sum_to_zero
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{1, 3, 5, 0}), expected: false },
{ actual: candidate([]int{1, 3, -2, 1}), expected: false },
{ actual: candidate([]int{1, 2, 3, 7}), expected: false },
{ actual: candidate([]int{2, 4, -5, 3, 5, 7}), expected: true },
{ actual: candidate([]int{1}), expected: false },
{ actual: candidate([]int{-3, 9, -1, 3, 2, 30}), expected: true },
{ actual: candidate([]int{-3, 9, -1, 3, 2, 31}), expected: true },
{ actual: candidate([]int{-3, 9, -1, 4, 2, 30}), expected: false },
{ actual: candidate([]int{-3, 9, -1, 4, 2, 31}), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_44_change_base
|
go_test.go
|
package change_base_test
import (
"testing"
"fmt"
)
// 引数xの基数をbaseに変換する。
// 返り値は変換後の文字列表現である。
// 基数は10未満である。
// >>> change_base(8, 3)
// "22"
// >>> change_base(8, 2)
// "1000"
// >>> change_base(7, 2)
// "111"
func change_base(x int, base int) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_44_change_base.py
|
reworded
|
func TestChange_Base(t *testing.T) {
candidate := change_base
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(8, 3), expected: "22" },
{ actual: candidate(9, 3), expected: "100" },
{ actual: candidate(234, 2), expected: "11101010" },
{ actual: candidate(16, 2), expected: "10000" },
{ actual: candidate(8, 2), expected: "1000" },
{ actual: candidate(7, 2), expected: "111" },
{ actual: candidate(2, 3), expected: "2" },
{ actual: candidate(3, 4), expected: "3" },
{ actual: candidate(4, 5), expected: "4" },
{ actual: candidate(5, 6), expected: "5" },
{ actual: candidate(6, 7), expected: "6" },
{ actual: candidate(7, 8), expected: "7" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_45_triangle_area
|
go_test.go
|
package triangle_area_test
import (
"testing"
"fmt"
)
// 三角形の一辺の長さと高さが与えられたとき、面積を返す。
// >>> triangle_area(5, 3)
// 7.5
func triangle_area(a int, h int) float64 {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_45_triangle_area.py
|
reworded
|
func TestTriangle_Area(t *testing.T) {
candidate := triangle_area
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(5, 3), expected: 7.5 },
{ actual: candidate(2, 2), expected: 2.0 },
{ actual: candidate(10, 8), expected: 40.0 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_46_fib4
|
go_test.go
|
package fib4_test
import (
"testing"
"fmt"
)
// 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
func fib4(n int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_46_fib4.py
|
reworded
|
func TestFib4(t *testing.T) {
candidate := fib4
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(5), expected: 4 },
{ actual: candidate(8), expected: 28 },
{ actual: candidate(10), expected: 104 },
{ actual: candidate(12), expected: 386 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_47_median
|
go_test.go
|
package median_test
import (
"testing"
"fmt"
)
// リスト l の要素の中央値を返す。
// >>> median([]int{3, 1, 2, 4, 5})
// 3
// >>> median([]int{-10, 4, 6, 1000, 10, 20})
// 15.0
func median(l []int) float64 {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_47_median.py
|
reworded
|
func TestMedian(t *testing.T) {
candidate := median
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{3, 1, 2, 4, 5}), expected: 3 },
{ actual: candidate([]int{-10, 4, 6, 1000, 10, 20}), expected: 8.0 },
{ actual: candidate([]int{5}), expected: 5 },
{ actual: candidate([]int{6, 5}), expected: 5.5 },
{ actual: candidate([]int{8, 1, 3, 9, 9, 2, 7}), expected: 7 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_48_is_palindrome
|
go_test.go
|
package is_palindrome_test
import (
"testing"
"fmt"
)
// 与えられた文字列が回文かどうかを判定する
// >>> is_palindrome("")
// true
// >>> is_palindrome("aba")
// true
// >>> is_palindrome("aaaaa")
// true
// >>> is_palindrome("zbcd")
// false
func is_palindrome(text string) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_48_is_palindrome.py
|
reworded
|
func TestIs_Palindrome(t *testing.T) {
candidate := is_palindrome
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(""), expected: true },
{ actual: candidate("aba"), expected: true },
{ actual: candidate("aaaaa"), expected: true },
{ actual: candidate("zbcd"), expected: false },
{ actual: candidate("xywyx"), expected: true },
{ actual: candidate("xywyz"), expected: false },
{ actual: candidate("xywzx"), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_49_modp
|
go_test.go
|
package modp_test
import (
"testing"
"fmt"
)
// 2^n を p で割ったモジュロを返す。計算精度に注意。
// >>> modp(3, 5)
// 3
// >>> modp(1101, 101)
// 2
// >>> modp(0, 101)
// 1
// >>> modp(3, 11)
// 8
// >>> modp(100, 101)
// 1
func modp(n int, p int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_49_modp.py
|
reworded
|
func TestModp(t *testing.T) {
candidate := modp
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(3, 5), expected: 3 },
{ actual: candidate(1101, 101), expected: 2 },
{ actual: candidate(0, 101), expected: 1 },
{ actual: candidate(3, 11), expected: 8 },
{ actual: candidate(100, 101), expected: 1 },
{ actual: candidate(30, 5), expected: 4 },
{ actual: candidate(31, 5), expected: 3 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_51_remove_vowels
|
go_test.go
|
package remove_vowels_test
import (
"testing"
"fmt"
)
// remove_vowelsは文字列を引数に取り、母音を除いた文字列を返す関数である。
// >>> remove_vowels("")
// ""
// >>> remove_vowels("abcdef")
// "bcdf"
// >>> remove_vowels("aaaaa")
// ""
// >>> remove_vowels("aaBAA")
// "B"
// >>> remove_vowels("zbcd")
// "zbcd"
func remove_vowels(text string) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_51_remove_vowels.py
|
reworded
|
func TestRemove_Vowels(t *testing.T) {
candidate := remove_vowels
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(""), expected: "" },
{ actual: candidate("abcdef\nghijklm"), expected: "bcdf\nghjklm" },
{ actual: candidate("fedcba"), expected: "fdcb" },
{ actual: candidate("eeeee"), expected: "" },
{ actual: candidate("acBAA"), expected: "cB" },
{ actual: candidate("EcBOO"), expected: "cB" },
{ actual: candidate("ybcd"), expected: "ybcd" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_52_below_threshold
|
go_test.go
|
package below_threshold_test
import (
"testing"
"fmt"
)
// リスト l 内の全ての数値が閾値 t 未満の場合、trueを返す。
// >>> below_threshold([]int{1, 2, 4, 10}, 100)
// true
// >>> below_threshold([]int{1, 20, 4, 10}, 5)
// false
func below_threshold(l []int, t int) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_52_below_threshold.py
|
reworded
|
func TestBelow_Threshold(t *testing.T) {
candidate := below_threshold
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{1, 2, 4, 10}, 100), expected: true },
{ actual: candidate([]int{1, 20, 4, 10}, 5), expected: false },
{ actual: candidate([]int{1, 20, 4, 10}, 21), expected: true },
{ actual: candidate([]int{1, 20, 4, 10}, 22), expected: true },
{ actual: candidate([]int{1, 8, 4, 10}, 11), expected: true },
{ actual: candidate([]int{1, 8, 4, 10}, 10), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_53_add
|
go_test.go
|
package add_test
import (
"testing"
"fmt"
)
// 2つの数xとyを足す
// >>> add(2, 3)
// 5
// >>> add(5, 7)
// 12
func add(x int, y int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_53_add.py
|
reworded
|
func TestAdd(t *testing.T) {
candidate := add
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(0, 1), expected: 1 },
{ actual: candidate(1, 0), expected: 1 },
{ actual: candidate(2, 3), expected: 5 },
{ actual: candidate(5, 7), expected: 12 },
{ actual: candidate(7, 5), expected: 12 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_54_same_chars
|
go_test.go
|
package same_chars_test
import (
"testing"
"fmt"
)
// 2つの単語が同じ文字セットから構成されるかどうか判定する。
// >>> same_chars("eabcdzzzz", "dddzzzzzzzddeddabc")
// true
// >>> same_chars("abcd", "dddddddabc")
// true
// >>> same_chars("dddddddabc", "abcd")
// true
// >>> same_chars("eabcd", "dddddddabc")
// false
// >>> same_chars("abcd", "dddddddabce")
// false
// >>> same_chars("eabcdzzzz", "dddzzzzzzzddddabc")
// false
func same_chars(s0 string, s1 string) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_54_same_chars.py
|
reworded
|
func TestSame_Chars(t *testing.T) {
candidate := same_chars
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("eabcdzzzz", "dddzzzzzzzddeddabc"), expected: true },
{ actual: candidate("abcd", "dddddddabc"), expected: true },
{ actual: candidate("dddddddabc", "abcd"), expected: true },
{ actual: candidate("eabcd", "dddddddabc"), expected: false },
{ actual: candidate("abcd", "dddddddabcf"), expected: false },
{ actual: candidate("eabcdzzzz", "dddzzzzzzzddddabc"), expected: false },
{ actual: candidate("aabb", "aaccc"), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_55_fib
|
go_test.go
|
package fib_test
import (
"testing"
"fmt"
)
// n番目のフィボナッチ数を返す。
// >>> fib(10)
// 55
// >>> fib(1)
// 1
// >>> fib(8)
// 21
func fib(n int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_55_fib.py
|
reworded
|
func TestFib(t *testing.T) {
candidate := fib
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(10), expected: 55 },
{ actual: candidate(1), expected: 1 },
{ actual: candidate(8), expected: 21 },
{ actual: candidate(11), expected: 89 },
{ actual: candidate(12), expected: 144 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_56_correct_bracketing
|
go_test.go
|
package correct_bracketing_test
import (
"testing"
"fmt"
)
// 引数bracketsは"<"と">"の文字列である。
// すべての開き括弧が対応する閉じ括弧を持つ場合、trueを返す。
// >>> correct_bracketing("<")
// false
// >>> correct_bracketing("<>")
// true
// >>> correct_bracketing("<<><>>")
// true
// >>> correct_bracketing("><<>")
// false
func correct_bracketing(brackets string) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_56_correct_bracketing.py
|
reworded
|
func TestCorrect_Bracketing(t *testing.T) {
candidate := correct_bracketing
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("<>"), expected: true },
{ actual: candidate("<<><>>"), expected: true },
{ actual: candidate("<><><<><>><>"), expected: true },
{ actual: candidate("<><><<<><><>><>><<><><<>>>"), expected: true },
{ actual: candidate("<<<><>>>>"), expected: false },
{ actual: candidate("><<>"), expected: false },
{ actual: candidate("<"), expected: false },
{ actual: candidate("<<<<"), expected: false },
{ actual: candidate(">"), expected: false },
{ actual: candidate("<<>"), expected: false },
{ actual: candidate("<><><<><>><>><<>"), expected: false },
{ actual: candidate("<><><<><>><>>><>"), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_57_monotonic
|
go_test.go
|
package monotonic_test
import (
"testing"
"fmt"
)
// リストの要素が単調増加または単調減少する場合にtrueを返す。
// >>> monotonic([]int{1, 2, 4, 20})
// true
// >>> monotonic([]int{1, 20, 4, 10})
// false
// >>> monotonic([]int{4, 1, 0, -10})
// true
func monotonic(l []int) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_57_monotonic.py
|
reworded
|
func TestMonotonic(t *testing.T) {
candidate := monotonic
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{1, 2, 4, 10}), expected: true },
{ actual: candidate([]int{1, 2, 4, 20}), expected: true },
{ actual: candidate([]int{1, 20, 4, 10}), expected: false },
{ actual: candidate([]int{4, 1, 0, -10}), expected: true },
{ actual: candidate([]int{4, 1, 1, 0}), expected: true },
{ actual: candidate([]int{1, 2, 3, 2, 5, 60}), expected: false },
{ actual: candidate([]int{1, 2, 3, 4, 5, 60}), expected: true },
{ actual: candidate([]int{9, 9, 9, 9}), expected: true },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_58_common
|
go_test.go
|
package common_test
import (
"testing"
"fmt"
)
// 2つのリストについて、ユニークな共通要素をソートして返す。
// >>> common([]int{1, 4, 3, 34, 653, 2, 5}, []int{5, 7, 1, 5, 9, 653, 121})
// []int{1, 5, 653}
// >>> common([]int{5, 3, 2, 8}, []int{3, 2})
// []int{2, 3}
func common(l1 []int, l2 []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_58_common.py
|
reworded
|
func TestCommon(t *testing.T) {
candidate := common
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{1, 4, 3, 34, 653, 2, 5}, []int{5, 7, 1, 5, 9, 653, 121}), expected: []int{1, 5, 653} },
{ actual: candidate([]int{5, 3, 2, 8}, []int{3, 2}), expected: []int{2, 3} },
{ actual: candidate([]int{4, 3, 2, 8}, []int{3, 2, 4}), expected: []int{2, 3, 4} },
{ actual: candidate([]int{4, 3, 2, 8}, []int{}), expected: []int{} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_59_largest_prime_factor
|
go_test.go
|
package largest_prime_factor_test
import (
"testing"
"fmt"
)
// nの最大となる素因数を返す。ただし、 n > 1 を前提とし、素数ではないものとする。
// >>> largest_prime_factor(13195)
// 29
// >>> largest_prime_factor(2048)
// 2
func largest_prime_factor(n int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_59_largest_prime_factor.py
|
reworded
|
func TestLargest_Prime_Factor(t *testing.T) {
candidate := largest_prime_factor
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(15), expected: 5 },
{ actual: candidate(27), expected: 3 },
{ actual: candidate(63), expected: 7 },
{ actual: candidate(330), expected: 11 },
{ actual: candidate(13195), expected: 29 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_60_sum_to_n
|
go_test.go
|
package sum_to_n_test
import (
"testing"
"fmt"
)
// 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
func sum_to_n(n int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_60_sum_to_n.py
|
reworded
|
func TestSum_To_N(t *testing.T) {
candidate := sum_to_n
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(1), expected: 1 },
{ actual: candidate(6), expected: 21 },
{ actual: candidate(11), expected: 66 },
{ actual: candidate(30), expected: 465 },
{ actual: candidate(100), expected: 5050 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_61_correct_bracketing
|
go_test.go
|
package correct_bracketing_test
import (
"testing"
"fmt"
)
// 引数bracketsは"("と") "からなる文字列である。
// すべての開き括弧が対応する閉じ括弧を持つ場合、trueを返す。
// >>> correct_bracketing("(")
// false
// >>> correct_bracketing("()")
// true
// >>> correct_bracketing("(()())")
// true
// >>> correct_bracketing(")(()")
// false
func correct_bracketing(brackets string) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_61_correct_bracketing.py
|
reworded
|
func TestCorrect_Bracketing(t *testing.T) {
candidate := correct_bracketing
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("()"), expected: true },
{ actual: candidate("(()())"), expected: true },
{ actual: candidate("()()(()())()"), expected: true },
{ actual: candidate("()()((()()())())(()()(()))"), expected: true },
{ actual: candidate("((()())))"), expected: false },
{ actual: candidate(")(()"), expected: false },
{ actual: candidate("("), expected: false },
{ actual: candidate("(((("), expected: false },
{ actual: candidate(")"), expected: false },
{ actual: candidate("(()"), expected: false },
{ actual: candidate("()()(()())())(()"), expected: false },
{ actual: candidate("()()(()())()))()"), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_62_derivative
|
go_test.go
|
package derivative_test
import (
"testing"
"fmt"
)
// xsは多項式の係数列を表す。
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// 関数は、この多項式の導関数を同じ形式で返す。
// >>> derivative([]int{3, 1, 2, 4, 5})
// []int{1, 4, 12, 20}
// >>> derivative([]int{1, 2, 3})
// []int{2, 6}
func derivative(xs []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_62_derivative.py
|
reworded
|
func TestDerivative(t *testing.T) {
candidate := derivative
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{3, 1, 2, 4, 5}), expected: []int{1, 4, 12, 20} },
{ actual: candidate([]int{1, 2, 3}), expected: []int{2, 6} },
{ actual: candidate([]int{3, 2, 1}), expected: []int{2, 2} },
{ actual: candidate([]int{3, 2, 1, 0, 4}), expected: []int{2, 2, 0, 16} },
{ actual: candidate([]int{1}), expected: []int{} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_63_fibfib
|
go_test.go
|
package fibfib_test
import (
"testing"
"fmt"
)
// 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
func fibfib(n int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_63_fibfib.py
|
reworded
|
func TestFibfib(t *testing.T) {
candidate := fibfib
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(2), expected: 1 },
{ actual: candidate(1), expected: 0 },
{ actual: candidate(5), expected: 4 },
{ actual: candidate(8), expected: 24 },
{ actual: candidate(10), expected: 81 },
{ actual: candidate(12), expected: 274 },
{ actual: candidate(14), expected: 927 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_64_vowels_count
|
go_test.go
|
package vowels_count_test
import (
"testing"
"fmt"
)
// 単語を表す文字列を引数とし、その文字列に含まれる母音の数を返す
// 関数 vowels_count を書きなさい。この場合の母音は'a', 'e', 'i', 'o', 'u'である。
// ここで、与えられた単語の末尾にある場合のみ、'y'も母音とする。
// 例::
// >>> vowels_count("abcde")
// 2
// >>> vowels_count("ACEDY")
// 3
func vowels_count(s string) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_64_vowels_count.py
|
reworded
|
func TestVowels_Count(t *testing.T) {
candidate := vowels_count
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("abcde"), expected: 2 },
{ actual: candidate("Alone"), expected: 3 },
{ actual: candidate("key"), expected: 2 },
{ actual: candidate("bye"), expected: 1 },
{ actual: candidate("keY"), expected: 2 },
{ actual: candidate("bYe"), expected: 1 },
{ actual: candidate("ACEDY"), expected: 3 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_65_circular_shift
|
go_test.go
|
package circular_shift_test
import (
"testing"
"fmt"
)
// 整数 x の桁を循環シフトする。shift 分だけ桁を右にシフトし、結果を文字列として返す。
// もし、shift > 桁数なら、桁を反転して返す。
// >>> circular_shift(12, 1)
// "21"
// >>> circular_shift(12, 2)
// "12"
func circular_shift(x int, shift int) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_65_circular_shift.py
|
reworded
|
func TestCircular_Shift(t *testing.T) {
candidate := circular_shift
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(100, 2), expected: "001" },
{ actual: candidate(12, 2), expected: "12" },
{ actual: candidate(97, 8), expected: "79" },
{ actual: candidate(12, 1), expected: "21" },
{ actual: candidate(11, 101), expected: "11" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_66_digitSum
|
go_test.go
|
package digitSum_test
import (
"testing"
"fmt"
)
// タスク
// 文字列を引数にとり、英大文字のみのASCIIコードの和を返す関数を書く。
// 例:
// >>> digitSum("")
// 0
// >>> digitSum("abAB")
// 131
// >>> digitSum("abcCd")
// 67
// >>> digitSum("helloE")
// 69
// >>> digitSum("woArBld")
// 131
// >>> digitSum("aAaaaXa")
// 153
func digitSum(s string) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_66_digitSum.py
|
reworded
|
func TestDigitsum(t *testing.T) {
candidate := digitSum
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(""), expected: 0 },
{ actual: candidate("abAB"), expected: 131 },
{ actual: candidate("abcCd"), expected: 67 },
{ actual: candidate("helloE"), expected: 69 },
{ actual: candidate("woArBld"), expected: 131 },
{ actual: candidate("aAaaaXa"), expected: 153 },
{ actual: candidate(" How are yOu?"), expected: 151 },
{ actual: candidate("You arE Very Smart"), expected: 327 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_67_fruit_distribution
|
go_test.go
|
package fruit_distribution_test
import (
"testing"
"fmt"
)
// この課題では、果物の入ったカゴに配られたリンゴとオレンジの数を表す文字列が
// 与えられ、このカゴにはリンゴ、オレンジ、マンゴーの果実が入っている。オレンジ
// とリンゴの総数を表す文字列と、かごの中の果物の総数を表す整数が与えられたら、
// かごの中のマンゴーの果物の数を返しなさい。
// たとえば:
// >>> fruit_distribution("5 apples and 6 oranges", 19)
// 8
// >>> fruit_distribution("0 apples and 1 oranges", 3)
// 2
// >>> fruit_distribution("2 apples and 3 oranges", 100)
// 95
// >>> fruit_distribution("100 apples and 1 oranges", 120)
// 19
func fruit_distribution(s string, n int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_67_fruit_distribution.py
|
reworded
|
func TestFruit_Distribution(t *testing.T) {
candidate := fruit_distribution
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("5 apples and 6 oranges", 19), expected: 8 },
{ actual: candidate("5 apples and 6 oranges", 21), expected: 10 },
{ actual: candidate("0 apples and 1 oranges", 3), expected: 2 },
{ actual: candidate("1 apples and 0 oranges", 3), expected: 2 },
{ actual: candidate("2 apples and 3 oranges", 100), expected: 95 },
{ actual: candidate("2 apples and 3 oranges", 5), expected: 0 },
{ actual: candidate("1 apples and 100 oranges", 120), expected: 19 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_68_pluck
|
go_test.go
|
package pluck_test
import (
"testing"
"fmt"
)
// 非負整数のノードを持つ木の枝を表す配列が与えられたとする。あなたの仕事は、
// ノードの1つを抜き取り、それを返すことである。
// 摘出されるノードは、最小偶数値を持つノードでなければならない。
// 同じ最小偶数値を持つノードが複数見つかった場合は、最小のインデックスを持つ
// ノードを返す。
// 摘出されたノードは [ smalest_value, its index ] というリストで返されなければならない。
// 偶数値がない場合や与えられた配列が空の場合は [] を返します。
// 例 1:
// >>> pluck([]int{4, 2, 3})
// []int{2, 1}
// 解説: 2は最小偶数値を持ち、最小インデックスを持つ。
// 例 2:
// >>> pluck([]int{1, 2, 3})
// []int{2, 1}
// 解説: 2が最小偶数値で、2が最小インデックスを持つ。
// 例 3:
// >>> pluck([]int{})
// []int{}
// 例 4:
// >>> pluck([]int{5, 0, 3, 0, 4, 2})
// []int{0, 1}
// 解説: 0は最小値だが、0は2つあるので、最小インデックスを持つ最初の0を選ぶ。
// 制約:
// * 1 <= ノードの長さ <= 10000
// * 0 <= ノードの値
func pluck(arr []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_68_pluck.py
|
reworded
|
func TestPluck(t *testing.T) {
candidate := pluck
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{4, 2, 3}), expected: []int{2, 1} },
{ actual: candidate([]int{1, 2, 3}), expected: []int{2, 1} },
{ actual: candidate([]int{}), expected: []int{} },
{ actual: candidate([]int{5, 0, 3, 0, 4, 2}), expected: []int{0, 1} },
{ actual: candidate([]int{1, 2, 3, 0, 5, 3}), expected: []int{0, 3} },
{ actual: candidate([]int{5, 4, 8, 4, 8}), expected: []int{4, 1} },
{ actual: candidate([]int{7, 6, 7, 1}), expected: []int{6, 1} },
{ actual: candidate([]int{7, 9, 7, 1}), expected: []int{} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_69_search
|
go_test.go
|
package search_test
import (
"testing"
"fmt"
)
// 正の整数の空でないリストが与えられる。0より大きく、その整数自身の値以上の頻度を
// 持つ最大の整数を返せ。整数の頻度とは、それがリストに現れる回数である。
// のような値が存在しない場合は -1 を返す。
// 例:
// >>> search([]int{4, 1, 2, 2, 3, 1})
// 2
// >>> search([]int{1, 2, 2, 3, 3, 3, 4, 4, 4})
// 3
// >>> search([]int{5, 5, 4, 4, 4})
// -1
func search(lst []int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_69_search.py
|
reworded
|
func TestSearch(t *testing.T) {
candidate := search
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{5, 5, 5, 5, 1}), expected: 1 },
{ actual: candidate([]int{4, 1, 4, 1, 4, 4}), expected: 4 },
{ actual: candidate([]int{3, 3}), expected: -1 },
{ actual: candidate([]int{8, 8, 8, 8, 8, 8, 8, 8}), expected: 8 },
{ actual: candidate([]int{2, 3, 3, 2, 2}), expected: 2 },
{ actual: candidate([]int{2, 7, 8, 8, 4, 8, 7, 3, 9, 6, 5, 10, 4, 3, 6, 7, 1, 7, 4, 10, 8, 1}), expected: 1 },
{ actual: candidate([]int{3, 2, 8, 2}), expected: 2 },
{ actual: candidate([]int{6, 7, 1, 8, 8, 10, 5, 8, 5, 3, 10}), expected: 1 },
{ actual: candidate([]int{8, 8, 3, 6, 5, 6, 4}), expected: -1 },
{ actual: candidate([]int{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}), expected: 1 },
{ actual: candidate([]int{1, 9, 10, 1, 3}), expected: 1 },
{ actual: candidate([]int{6, 9, 7, 5, 8, 7, 5, 3, 7, 5, 10, 10, 3, 6, 10, 2, 8, 6, 5, 4, 9, 5, 3, 10}), expected: 5 },
{ actual: candidate([]int{1}), expected: 1 },
{ actual: candidate([]int{8, 8, 10, 6, 4, 3, 5, 8, 2, 4, 2, 8, 4, 6, 10, 4, 2, 1, 10, 2, 1, 1, 5}), expected: 4 },
{ actual: candidate([]int{2, 10, 4, 8, 2, 10, 5, 1, 2, 9, 5, 5, 6, 3, 8, 6, 4, 10}), expected: 2 },
{ actual: candidate([]int{1, 6, 10, 1, 6, 9, 10, 8, 6, 8, 7, 3}), expected: 1 },
{ actual: candidate([]int{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}), expected: 4 },
{ actual: candidate([]int{2, 6, 4, 2, 8, 7, 5, 6, 4, 10, 4, 6, 3, 7, 8, 8, 3, 1, 4, 2, 2, 10, 7}), expected: 4 },
{ actual: candidate([]int{9, 8, 6, 10, 2, 6, 10, 2, 7, 8, 10, 3, 8, 2, 6, 2, 3, 1}), expected: 2 },
{ actual: candidate([]int{5, 5, 3, 9, 5, 6, 3, 2, 8, 5, 6, 10, 10, 6, 8, 4, 10, 7, 7, 10, 8}), expected: -1 },
{ actual: candidate([]int{10}), expected: -1 },
{ actual: candidate([]int{9, 7, 7, 2, 4, 7, 2, 10, 9, 7, 5, 7, 2}), expected: 2 },
{ actual: candidate([]int{5, 4, 10, 2, 1, 1, 10, 3, 6, 1, 8}), expected: 1 },
{ actual: candidate([]int{7, 9, 9, 9, 3, 4, 1, 5, 9, 1, 2, 1, 1, 10, 7, 5, 6, 7, 6, 7, 7, 6}), expected: 1 },
{ actual: candidate([]int{3, 10, 10, 9, 2}), expected: -1 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_70_strange_sort_list
|
go_test.go
|
package strange_sort_list_test
import (
"testing"
"fmt"
)
// 整数のリストが与えられたとき、リストを奇妙な順序で返す。
// 奇妙なソートとは、最小値から始まり、残りの整数の最大値、最小値の順で
// ソートすることである。
// 例:
// >>> strange_sort_list([]int{1, 2, 3, 4})
// []int{1, 4, 2, 3}
// >>> strange_sort_list([]int{5, 5, 5, 5})
// []int{5, 5, 5, 5}
// >>> strange_sort_list([]int{})
// []int{}
func strange_sort_list(lst []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_70_strange_sort_list.py
|
reworded
|
func TestStrange_Sort_List(t *testing.T) {
candidate := strange_sort_list
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{1, 2, 3, 4}), expected: []int{1, 4, 2, 3} },
{ actual: candidate([]int{5, 6, 7, 8, 9}), expected: []int{5, 9, 6, 8, 7} },
{ actual: candidate([]int{1, 2, 3, 4, 5}), expected: []int{1, 5, 2, 4, 3} },
{ actual: candidate([]int{5, 6, 7, 8, 9, 1}), expected: []int{1, 9, 5, 8, 6, 7} },
{ actual: candidate([]int{5, 5, 5, 5}), expected: []int{5, 5, 5, 5} },
{ actual: candidate([]int{}), expected: []int{} },
{ actual: candidate([]int{1, 2, 3, 4, 5, 6, 7, 8}), expected: []int{1, 8, 2, 7, 3, 6, 4, 5} },
{ actual: candidate([]int{0, 2, 2, 2, 5, 5, -5, -5}), expected: []int{-5, 5, -5, 5, 0, 2, 2, 2} },
{ actual: candidate([]int{111111}), expected: []int{111111} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_71_triangle_area
|
go_test.go
|
package triangle_area_test
import (
"testing"
"fmt"
)
// 三角形の3辺の長さが与えられた。3辺が有効な三角形を形成していれば、
// 三角形の面積を小数点以下2桁で四捨五入して返す。そうでない場合は-1を
// 返す。
// 任意の2辺の和が3辺より大きいとき、3辺は有効な三角形となる。
// 例:
// >>> triangle_area(3, 4, 5)
// 6.0
// >>> triangle_area(1, 2, 10)
// -1
func triangle_area(a int, b int, c int) float64 {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_71_triangle_area.py
|
reworded
|
func TestTriangle_Area(t *testing.T) {
candidate := triangle_area
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(3, 4, 5), expected: 6.0 },
{ actual: candidate(1, 2, 10), expected: -1 },
{ actual: candidate(4, 8, 5), expected: 8.18 },
{ actual: candidate(2, 2, 2), expected: 1.73 },
{ actual: candidate(1, 2, 3), expected: -1 },
{ actual: candidate(10, 5, 7), expected: 16.25 },
{ actual: candidate(2, 6, 3), expected: -1 },
{ actual: candidate(1, 1, 1), expected: 0.43 },
{ actual: candidate(2, 2, 10), expected: -1 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_72_will_it_fly
|
go_test.go
|
package will_it_fly_test
import (
"testing"
"fmt"
)
// 物体qが飛べばtrueを、そうでなければfalseを返す関数を書け。
// 物体qはバランスが取れていて(つまり、リストが回文であって)、その要素の和が
// 最大荷重w以下であれば飛ぶ。
// 例:
// >>> will_it_fly([]int{1, 2}, 5)
// false
// # 1+2 は最大荷重以下であるが、バランスが取れていない
// >>> will_it_fly([]int{3, 2, 3}, 1)
// false
// # バランスが取れているが、3+2+3 は最大荷重を超える
// >>> will_it_fly([]int{3, 2, 3}, 9)
// true
// # 3+2+3 は最大荷重以下であり、バランスも取れている
// >>> will_it_fly([]int{3}, 5)
// true
// # 3 は最大荷重以下であり、バランスも取れている
func will_it_fly(q []int, w int) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_72_will_it_fly.py
|
reworded
|
func TestWill_It_Fly(t *testing.T) {
candidate := will_it_fly
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{3, 2, 3}, 9), expected: true },
{ actual: candidate([]int{1, 2}, 5), expected: false },
{ actual: candidate([]int{3}, 5), expected: true },
{ actual: candidate([]int{3, 2, 3}, 1), expected: false },
{ actual: candidate([]int{1, 2, 3}, 6), expected: false },
{ actual: candidate([]int{5}, 5), expected: true },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_73_smallest_change
|
go_test.go
|
package smallest_change_test
import (
"testing"
"fmt"
)
// 整数の配列arrが与えられたとき、その配列を回文配列にするために
// 必要な要素の最小数を求めよ。回文配列とは、前からも後からも同じ
// ようになる配列のことである。1回の変更で、1つの要素を他の任意の
// 要素に変更できる。
// 例えば:
// >>> smallest_change([]int{1, 2, 3, 5, 4, 7, 9, 6})
// 4
// >>> smallest_change([]int{1, 2, 3, 4, 3, 2, 2})
// 1
// >>> smallest_change([]int{1, 2, 3, 2, 1})
// 0
func smallest_change(arr []int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_73_smallest_change.py
|
reworded
|
func TestSmallest_Change(t *testing.T) {
candidate := smallest_change
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{1, 2, 3, 5, 4, 7, 9, 6}), expected: 4 },
{ actual: candidate([]int{1, 2, 3, 4, 3, 2, 2}), expected: 1 },
{ actual: candidate([]int{1, 4, 2}), expected: 1 },
{ actual: candidate([]int{1, 4, 4, 2}), expected: 1 },
{ actual: candidate([]int{1, 2, 3, 2, 1}), expected: 0 },
{ actual: candidate([]int{3, 1, 1, 3}), expected: 0 },
{ actual: candidate([]int{1}), expected: 0 },
{ actual: candidate([]int{0, 1}), expected: 1 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_74_total_match
|
go_test.go
|
package total_match_test
import (
"testing"
"fmt"
)
// 2つの文字列リストを受け取り、リストの全文字数の合計がもう一方
// のリストより少ないリストを返す関数を書きなさい。
// もし2つのリストの文字数が同じなら、最初のリストを返す。
// 例
// >>> total_match([]string{}, []string{})
// []string{}
// >>> total_match([]string{"hi", "admin"}, []string{"hI", "Hi"})
// []string{"hI", "Hi"}
// >>> total_match([]string{"hi", "admin"}, []string{"hi", "hi", "admin", "project"})
// []string{"hi", "admin"}
// >>> total_match([]string{"hi", "admin"}, []string{"hI", "hi", "hi"})
// []string{"hI", "hi", "hi"}
// >>> total_match([]string{"4"}, []string{"1", "2", "3", "4", "5"})
// []string{"4"}
func total_match(lst1 []string, lst2 []string) []string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_74_total_match.py
|
reworded
|
func TestTotal_Match(t *testing.T) {
candidate := total_match
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]string{}, []string{}), expected: []string{} },
{ actual: candidate([]string{"hi", "admin"}, []string{"hi", "hi"}), expected: []string{"hi", "hi"} },
{ actual: candidate([]string{"hi", "admin"}, []string{"hi", "hi", "admin", "project"}), expected: []string{"hi", "admin"} },
{ actual: candidate([]string{"4"}, []string{"1", "2", "3", "4", "5"}), expected: []string{"4"} },
{ actual: candidate([]string{"hi", "admin"}, []string{"hI", "Hi"}), expected: []string{"hI", "Hi"} },
{ actual: candidate([]string{"hi", "admin"}, []string{"hI", "hi", "hi"}), expected: []string{"hI", "hi", "hi"} },
{ actual: candidate([]string{"hi", "admin"}, []string{"hI", "hi", "hii"}), expected: []string{"hi", "admin"} },
{ actual: candidate([]string{}, []string{"this"}), expected: []string{} },
{ actual: candidate([]string{"this"}, []string{}), expected: []string{} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_75_is_multiply_prime
|
go_test.go
|
package is_multiply_prime_test
import (
"testing"
"fmt"
)
// 与えられた数が3つの素数の掛け算であればtrueを、そうでなければfalseを返す
// 関数を書きなさい。
// 引数 aは100以下を既知としていよい。
// 例:
// >>> is_multiply_prime(30)
// true
// 30 = 2 * 3 * 5
func is_multiply_prime(a int) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_75_is_multiply_prime.py
|
reworded
|
func TestIs_Multiply_Prime(t *testing.T) {
candidate := is_multiply_prime
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(5), expected: false },
{ actual: candidate(30), expected: true },
{ actual: candidate(8), expected: true },
{ actual: candidate(10), expected: false },
{ actual: candidate(125), expected: true },
{ actual: candidate(105), expected: true },
{ actual: candidate(126), expected: false },
{ actual: candidate(729), expected: false },
{ actual: candidate(891), expected: false },
{ actual: candidate(1001), expected: true },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_76_is_simple_power
|
go_test.go
|
package is_simple_power_test
import (
"testing"
"fmt"
)
// あなたのタスクは、ある数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
func is_simple_power(x int, n int) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_76_is_simple_power.py
|
reworded
|
func TestIs_Simple_Power(t *testing.T) {
candidate := is_simple_power
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(16, 2), expected: true },
{ actual: candidate(143214, 16), expected: false },
{ actual: candidate(4, 2), expected: true },
{ actual: candidate(9, 3), expected: true },
{ actual: candidate(16, 4), expected: true },
{ actual: candidate(24, 2), expected: false },
{ actual: candidate(128, 4), expected: false },
{ actual: candidate(12, 6), expected: false },
{ actual: candidate(1, 1), expected: true },
{ actual: candidate(1, 12), expected: true },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_77_iscube
|
go_test.go
|
package iscube_test
import (
"testing"
"fmt"
)
// 整数aを受け取り、この整数がある整数の3乗である場合にtrue
// を返す関数を書きなさい。
// 注意:入力は常に処理可能であると仮定してよい。
// 例:
// >>> iscube(1)
// true
// >>> iscube(2)
// false
// >>> iscube(-1)
// true
// >>> iscube(64)
// true
// >>> iscube(0)
// true
// >>> iscube(180)
// false
func iscube(a int) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_77_iscube.py
|
reworded
|
func TestIscube(t *testing.T) {
candidate := iscube
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(1), expected: true },
{ actual: candidate(2), expected: false },
{ actual: candidate(-1), expected: true },
{ actual: candidate(64), expected: true },
{ actual: candidate(180), expected: false },
{ actual: candidate(1000), expected: true },
{ actual: candidate(0), expected: true },
{ actual: candidate(1729), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_78_hex_key
|
go_test.go
|
package hex_key_test
import (
"testing"
"fmt"
)
// 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("AB")
// 1
// >>> hex_key("1077E")
// 2
// >>> hex_key("ABED1A33")
// 4
// >>> hex_key("123456789ABCDEF0")
// 6
// >>> hex_key("2020")
// 2
func hex_key(num string) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_78_hex_key.py
|
reworded
|
func TestHex_Key(t *testing.T) {
candidate := hex_key
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("AB"), expected: 1 },
{ actual: candidate("1077E"), expected: 2 },
{ actual: candidate("ABED1A33"), expected: 4 },
{ actual: candidate("2020"), expected: 2 },
{ actual: candidate("123456789ABCDEF0"), expected: 6 },
{ actual: candidate("112233445566778899AABBCCDDEEFF00"), expected: 12 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_79_decimal_to_binary
|
go_test.go
|
package decimal_to_binary_test
import (
"testing"
"fmt"
)
// 10進数形式の数値が与えられ、あなたのタスクはそれを2進数形式に変換することである。
// この関数は、文字列を返し、その各文字は2進数を表す。文字列の各文字は'0'か'1'である。
// なお、文字列の最初と最後には'db'という余分な文字をつける。
// この文字は書式を助けるためにある。
// 例:
// >>> decimal_to_binary(15)
// "db1111db"
// >>> decimal_to_binary(32)
// "db100000db"
func decimal_to_binary(decimal int) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_79_decimal_to_binary.py
|
reworded
|
func TestDecimal_To_Binary(t *testing.T) {
candidate := decimal_to_binary
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(0), expected: "db0db" },
{ actual: candidate(32), expected: "db100000db" },
{ actual: candidate(103), expected: "db1100111db" },
{ actual: candidate(15), expected: "db1111db" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_80_is_happy
|
go_test.go
|
package is_happy_test
import (
"testing"
"fmt"
)
// あなたは文字列sが与えられる。
// あなたのタスクは、その文字列が幸せかどうかをチェックすることである。
// 文字列は幸せとは、文字列の長さが少なくとも3以上で、連続する3文字がすべて異なる場合である。
// 例えば:
// >>> is_happy("a")
// false
// >>> is_happy("aa")
// false
// >>> is_happy("abcd")
// true
// >>> is_happy("aabb")
// false
// >>> is_happy("adb")
// true
// >>> is_happy("xyy")
// false
func is_happy(s string) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_80_is_happy.py
|
reworded
|
func TestIs_Happy(t *testing.T) {
candidate := is_happy
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("a"), expected: false },
{ actual: candidate("aa"), expected: false },
{ actual: candidate("abcd"), expected: true },
{ actual: candidate("aabb"), expected: false },
{ actual: candidate("adb"), expected: true },
{ actual: candidate("xyy"), expected: false },
{ actual: candidate("iopaxpoi"), expected: true },
{ actual: candidate("iopaxioi"), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_81_numerical_letter_grade
|
go_test.go
|
package numerical_letter_grade_test
import (
"testing"
"fmt"
)
// 学期最終週、教師は生徒に成績をつけなければならない。教師は独自のアルゴリズムで採点している。
// 問題は、彼女が成績評価に使ったコードを紛失してしまったことです。
// 彼女は何人かの生徒の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([]float64{4.0, 3, 1.7, 2, 3.5})
// []string{"A+", "B", "C-", "C", "A-"}
func numerical_letter_grade(grades []float64) []string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_81_numerical_letter_grade.py
|
reworded
|
func TestNumerical_Letter_Grade(t *testing.T) {
candidate := numerical_letter_grade
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]float64{4.0, 3, 1.7, 2, 3.5}), expected: []string{"A+", "B", "C-", "C", "A-"} },
{ actual: candidate([]float64{1.2}), expected: []string{"D+"} },
{ actual: candidate([]float64{0.5}), expected: []string{"D-"} },
{ actual: candidate([]float64{0.0}), expected: []string{"E"} },
{ actual: candidate([]float64{1.0, 0.3, 1.5, 2.8, 3.3}), expected: []string{"D", "D-", "C-", "B", "B+"} },
{ actual: candidate([]float64{0.0, 0.7}), expected: []string{"E", "D-"} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_82_prime_length
|
go_test.go
|
package prime_length_test
import (
"testing"
"fmt"
)
// 文字列を受け取り、文字列の長さが素数であればtrueを、そうでなければfalseを返す関数を書く。
// 例
// >>> prime_length("Hello")
// true
// >>> prime_length("abcdcba")
// true
// >>> prime_length("kittens")
// true
// >>> prime_length("orange")
// false
func prime_length(myString string) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_82_prime_length.py
|
reworded
|
func TestPrime_Length(t *testing.T) {
candidate := prime_length
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("Hello"), expected: true },
{ actual: candidate("abcdcba"), expected: true },
{ actual: candidate("kittens"), expected: true },
{ actual: candidate("orange"), expected: false },
{ actual: candidate("wow"), expected: true },
{ actual: candidate("world"), expected: true },
{ actual: candidate("MadaM"), expected: true },
{ actual: candidate("Wow"), expected: true },
{ actual: candidate(""), expected: false },
{ actual: candidate("HI"), expected: true },
{ actual: candidate("go"), expected: true },
{ actual: candidate("gogo"), expected: false },
{ actual: candidate("aaaaaaaaaaaaaaa"), expected: false },
{ actual: candidate("Madam"), expected: true },
{ actual: candidate("M"), expected: false },
{ actual: candidate("0"), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_83_starts_one_ends
|
go_test.go
|
package starts_one_ends_test
import (
"testing"
"fmt"
)
// 正の整数 n が与えられたとき、n 桁の正の整数で 1 で始まるか
// もしくは終わる数のカウントを返す
func starts_one_ends(n int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_83_starts_one_ends.py
|
reworded
|
func TestStarts_One_Ends(t *testing.T) {
candidate := starts_one_ends
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(1), expected: 1 },
{ actual: candidate(2), expected: 18 },
{ actual: candidate(3), expected: 180 },
{ actual: candidate(4), expected: 1800 },
{ actual: candidate(5), expected: 18000 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_84_solve
|
go_test.go
|
package solve_test
import (
"testing"
"fmt"
)
// 正の整数 N が与えられた時、その桁の総和を2進数で返す。
// 例/
// >>> solve(1000)
// "1"
// >>> solve(150)
// "110"
// >>> solve(147)
// "1100"
// 数:
// @N 整数
// 制約: 0 ≤ N ≤ 10000.
// 返り値:
// 2進数表記の文字列
func solve(N int) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_84_solve.py
|
reworded
|
func TestSolve(t *testing.T) {
candidate := solve
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(1000), expected: "1" },
{ actual: candidate(150), expected: "110" },
{ actual: candidate(147), expected: "1100" },
{ actual: candidate(333), expected: "1001" },
{ actual: candidate(963), expected: "10010" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_85_add
|
go_test.go
|
package add_test
import (
"testing"
"fmt"
)
// 空でない整数のリストlstが与えられたとき、奇数のインデックスにある偶数の要素を加える。
// 例:
// >>> add([]int{4, 2, 6, 7})
// 2
func add(lst []int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_85_add.py
|
reworded
|
func TestAdd(t *testing.T) {
candidate := add
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{4, 88}), expected: 88 },
{ actual: candidate([]int{4, 5, 6, 7, 2, 122}), expected: 122 },
{ actual: candidate([]int{4, 0, 6, 7}), expected: 0 },
{ actual: candidate([]int{4, 4, 6, 8}), expected: 12 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_86_anti_shuffle
|
go_test.go
|
package anti_shuffle_test
import (
"testing"
"fmt"
)
// 文字列を引数として受け取り、その「順序付けられたバージョン」を返す関数を作成してください。
// 順序付けられたバージョンとは、各単語(空白で区切られた)の文字がASCII値に基づいて昇順に
// 並べ替えられた新しい単語に置き換えられた文字列です。
// 注意:文章内の単語と空白の順序はそのまま保ってください。
// 例えば:
// >>> anti_shuffle("Hi")
// "Hi"
// >>> anti_shuffle("hello")
// "ehllo"
// >>> anti_shuffle("Hello World!!!")
// "Hello !!!Wdlor"
func anti_shuffle(s string) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_86_anti_shuffle.py
|
reworded
|
func TestAnti_Shuffle(t *testing.T) {
candidate := anti_shuffle
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("Hi"), expected: "Hi" },
{ actual: candidate("hello"), expected: "ehllo" },
{ actual: candidate("number"), expected: "bemnru" },
{ actual: candidate("abcd"), expected: "abcd" },
{ actual: candidate("Hello World!!!"), expected: "Hello !!!Wdlor" },
{ actual: candidate(""), expected: "" },
{ actual: candidate("Hi. My name is Mister Robot. How are you?"), expected: ".Hi My aemn is Meirst .Rboot How aer ?ouy" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_87_get_row
|
go_test.go
|
package get_row_test
import (
"testing"
"fmt"
)
// 2次元のデータがネストされたリストとして与えられる。これは行列に似ているが、
// 列とは異なり、各行は異なる数の列を含むことができる。
// lstと整数xが与えられたとき、リスト内の整数xを見つけ、各タプルが0から始まる
// 座標(行、列)であるようなタプルのリスト[(x1, y1), (x2, y2) ...]を返す。
// 座標を最初は行の昇順でソートする。
// また、行の座標を列の降順でソートする。
// 例:
// >>> get_row([][]int{[]int{1, 2, 3, 4, 5, 6}, []int{1, 2, 3, 4, 1, 6}, []int{1, 2, 3, 4, 5, 1}}, 1)
// [][]int{[]interface{}{0, 0}, []interface{}{1, 4}, []interface{}{1, 0}, []interface{}{2, 5}, []interface{}{2, 0}}
// >>> get_row([][]int{}, 1)
// [][]interface{}{}
// >>> get_row([]interface{}{[]interface{}{}, []int{1}, []int{1, 2, 3}}, 3)
// [][]int{[]interface{}{2, 2}}
func get_row(lst [][]int, x int) [][]interface{} {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_87_get_row.py
|
reworded
|
func TestGet_Row(t *testing.T) {
candidate := get_row
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([][]int{[]int{1, 2, 3, 4, 5, 6}, []int{1, 2, 3, 4, 1, 6}, []int{1, 2, 3, 4, 5, 1}}, 1), expected: [][]int{[]interface{}{0, 0}, []interface{}{1, 4}, []interface{}{1, 0}, []interface{}{2, 5}, []interface{}{2, 0}} },
{ actual: candidate([][]int{[]int{1, 2, 3, 4, 5, 6}, []int{1, 2, 3, 4, 5, 6}, []int{1, 2, 3, 4, 5, 6}, []int{1, 2, 3, 4, 5, 6}, []int{1, 2, 3, 4, 5, 6}, []int{1, 2, 3, 4, 5, 6}}, 2), expected: [][]int{[]interface{}{0, 1}, []interface{}{1, 1}, []interface{}{2, 1}, []interface{}{3, 1}, []interface{}{4, 1}, []interface{}{5, 1}} },
{ actual: candidate([][]int{[]int{1, 2, 3, 4, 5, 6}, []int{1, 2, 3, 4, 5, 6}, []int{1, 1, 3, 4, 5, 6}, []int{1, 2, 1, 4, 5, 6}, []int{1, 2, 3, 1, 5, 6}, []int{1, 2, 3, 4, 1, 6}, []int{1, 2, 3, 4, 5, 1}}, 1), expected: [][]int{[]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{2, 1}, []interface{}{2, 0}, []interface{}{3, 2}, []interface{}{3, 0}, []interface{}{4, 3}, []interface{}{4, 0}, []interface{}{5, 4}, []interface{}{5, 0}, []interface{}{6, 5}, []interface{}{6, 0}} },
{ actual: candidate([][]int{}, 1), expected: [][]interface{}{} },
{ actual: candidate([][]int{[]int{1}}, 2), expected: [][]interface{}{} },
{ actual: candidate([]interface{}{[]interface{}{}, []int{1}, []int{1, 2, 3}}, 3), expected: [][]int{[]interface{}{2, 2}} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_88_sort_array
|
go_test.go
|
package sort_array_test
import (
"testing"
"fmt"
)
// 非負の整数からなる配列が与えられた場合、配列をソートしたコピーを返してください。
// 配列の最初の要素と最後の要素の和が奇数であれば、配列を昇順(小さい順)にソートします。
// その和が偶数であれば、配列を降順(大きい順)にソートします。
// 注意点:
// * 与えられた配列自体を変更しないでください。
// 例:
// >>> sort_array([]int{})
// []int{}
// >>> sort_array([]int{5})
// []int{5}
// >>> sort_array([]int{2, 4, 3, 0, 1, 5})
// []int{0, 1, 2, 3, 4, 5}
// >>> sort_array([]int{2, 4, 3, 0, 1, 5, 6})
// []int{6, 5, 4, 3, 2, 1, 0}
func sort_array(array []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_88_sort_array.py
|
reworded
|
func TestSort_Array(t *testing.T) {
candidate := sort_array
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{}), expected: []int{} },
{ actual: candidate([]int{5}), expected: []int{5} },
{ actual: candidate([]int{2, 4, 3, 0, 1, 5}), expected: []int{0, 1, 2, 3, 4, 5} },
{ actual: candidate([]int{2, 4, 3, 0, 1, 5, 6}), expected: []int{6, 5, 4, 3, 2, 1, 0} },
{ actual: candidate([]int{2, 1}), expected: []int{1, 2} },
{ actual: candidate([]int{15, 42, 87, 32, 11, 0}), expected: []int{0, 11, 15, 32, 42, 87} },
{ actual: candidate([]int{21, 14, 23, 11}), expected: []int{23, 21, 14, 11} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_89_encrypt
|
go_test.go
|
package encrypt_test
import (
"testing"
"fmt"
)
// 文字列を引数にとり、アルファベットを回転させて暗号化した
// 文字列を返す関数encryptを作成せよ。
// アルファベットは、文文字位置が2を2倍した4文字分だけ後ろにシフトされるように
// 回転する。
// 例:
// >>> encrypt("hi")
// "lm"
// >>> encrypt("asdfghjkl")
// "ewhjklnop"
// >>> encrypt("gf")
// "kj"
// >>> encrypt("et")
// "ix"
func encrypt(s string) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_89_encrypt.py
|
reworded
|
func TestEncrypt(t *testing.T) {
candidate := encrypt
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("hi"), expected: "lm" },
{ actual: candidate("asdfghjkl"), expected: "ewhjklnop" },
{ actual: candidate("gf"), expected: "kj" },
{ actual: candidate("et"), expected: "ix" },
{ actual: candidate("faewfawefaewg"), expected: "jeiajeaijeiak" },
{ actual: candidate("hellomyfriend"), expected: "lippsqcjvmirh" },
{ actual: candidate("dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh"), expected: "hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl" },
{ actual: candidate("a"), expected: "e" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_91_is_bored
|
go_test.go
|
package is_bored_test
import (
"testing"
"fmt"
)
// 単語の文字列が与えられ、あなたのタスクは退屈指数を数える
// ことである。退屈指数とは、"I "で始まる文のことである。
// 文は'.'、’?’、'!'のいずれかで区切られる。
// 例えば:
// >>> is_bored("Hello world")
// 0
// >>> is_bored("The sky is blue. The sun is shining. I love this weather")
// 1
func is_bored(S string) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_91_is_bored.py
|
reworded
|
func TestIs_Bored(t *testing.T) {
candidate := is_bored
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("Hello world"), expected: 0 },
{ actual: candidate("Is the sky blue?"), expected: 0 },
{ actual: candidate("I love It !"), expected: 1 },
{ actual: candidate("bIt"), expected: 0 },
{ actual: candidate("I feel good today. I will be productive. will kill It"), expected: 2 },
{ actual: candidate("You and I are going for a walk"), expected: 0 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_92_any_int
|
go_test.go
|
package any_int_test
import (
"testing"
"fmt"
)
// 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
func any_int(x float64, y float64, z float64) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_92_any_int.py
|
reworded
|
func TestAny_Int(t *testing.T) {
candidate := any_int
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(2, 3, 1), expected: true },
{ actual: candidate(2.5, 2, 3), expected: false },
{ actual: candidate(1.5, 5, 3.5), expected: false },
{ actual: candidate(2, 6, 2), expected: false },
{ actual: candidate(4, 2, 2), expected: true },
{ actual: candidate(2.2, 2.2, 2.2), expected: false },
{ actual: candidate(-4, 6, 2), expected: true },
{ actual: candidate(2, 1, 1), expected: true },
{ actual: candidate(3, 4, 7), expected: true },
{ actual: candidate(3.0, 4, 7), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_93_encode
|
go_test.go
|
package encode_test
import (
"testing"
"fmt"
)
// メッセージを受け取り、すべての文字の大文字と小文字を入れ替え、
// メッセージ中のすべての母音を英語の母音の2つ前に現れる文字に置
// き換えるようにエンコードする関数を書きなさい。
// 文字だけを想定する。
// 例:
// >>> encode("test")
// "TGST"
// >>> encode("This is a message")
// "tHKS KS C MGSSCGG"
func encode(message string) string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_93_encode.py
|
reworded
|
func TestEncode(t *testing.T) {
candidate := encode
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("TEST"), expected: "tgst" },
{ actual: candidate("Mudasir"), expected: "mWDCSKR" },
{ actual: candidate("YES"), expected: "ygs" },
{ actual: candidate("This is a message"), expected: "tHKS KS C MGSSCGG" },
{ actual: candidate("I DoNt KnOw WhAt tO WrItE"), expected: "k dQnT kNqW wHcT Tq wRkTg" },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_94_skjkasdkd
|
go_test.go
|
package skjkasdkd_test
import (
"testing"
"fmt"
)
// 整数のリストが与えらる。
// 最大の素数を求め、その桁数の和を返す必要がある。
// 例:
// >>> skjkasdkd([]int{0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3})
// 10
// >>> skjkasdkd([]int{1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1})
// 25
// >>> skjkasdkd([]int{1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 2323, 32, 30, 1, 9, 3})
// 13
// >>> skjkasdkd([]int{0, 724, 32, 71, 99, 32, 6, 0, 5, 91, 83, 0, 5, 6})
// 11
// >>> skjkasdkd([]int{0, 81, 12, 3, 1, 21})
// 3
// >>> skjkasdkd([]int{0, 8, 1, 2, 1, 7})
// 7
func skjkasdkd(lst []int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_94_skjkasdkd.py
|
reworded
|
func TestSkjkasdkd(t *testing.T) {
candidate := skjkasdkd
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3}), expected: 10 },
{ actual: candidate([]int{1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1}), expected: 25 },
{ actual: candidate([]int{1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 2323, 32, 30, 1, 9, 3}), expected: 13 },
{ actual: candidate([]int{0, 724, 32, 71, 99, 32, 6, 0, 5, 91, 83, 0, 5, 6}), expected: 11 },
{ actual: candidate([]int{0, 81, 12, 3, 1, 21}), expected: 3 },
{ actual: candidate([]int{0, 8, 1, 2, 1, 7}), expected: 7 },
{ actual: candidate([]int{8191}), expected: 19 },
{ actual: candidate([]int{8191, 123456, 127, 7}), expected: 19 },
{ actual: candidate([]int{127, 97, 8192}), expected: 10 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_95_check_dict_case
|
go_test.go
|
package check_dict_case_test
import (
"testing"
"fmt"
)
// 辞書が与えられたとき、すべてのキーが小文字であればtrueを、
// すべてのキーが大文字の文字列であればfalseを返す。
// 与えられた辞書が空の場合、この関数は false を返す。
// 例:
// >>> check_dict_case(map[string]string{"a": "apple", "b": "banana"})
// true
// >>> check_dict_case(map[string]string{"a": "apple", "A": "banana", "B": "banana"})
// false
// >>> check_dict_case(map[interface{}]string{"a": "apple", 8: "banana", "a": "apple"})
// false
// >>> check_dict_case(map[string]string{"Name": "John", "Age": "36", "City": "Houston"})
// false
// >>> check_dict_case(map[string]string{"STATE": "NC", "ZIP": "12345"})
// true
func check_dict_case(dict map[string]string) bool {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_95_check_dict_case.py
|
reworded
|
func TestCheck_Dict_Case(t *testing.T) {
candidate := check_dict_case
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(map[string]string{"p": "pineapple", "b": "banana"}), expected: true },
{ actual: candidate(map[string]string{"p": "pineapple", "A": "banana", "B": "banana"}), expected: false },
{ actual: candidate(map[string]string{"p": "pineapple", "5": "banana", "a": "apple"}), expected: false },
{ actual: candidate(map[string]string{"Name": "John", "Age": "36", "City": "Houston"}), expected: false },
{ actual: candidate(map[string]string{"STATE": "NC", "ZIP": "12345"}), expected: true },
{ actual: candidate(map[string]string{"fruit": "Orange", "taste": "Sweet"}), expected: true },
{ actual: candidate(map[string]string{}), expected: false },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_96_count_up_to
|
go_test.go
|
package count_up_to_test
import (
"testing"
"fmt"
)
// 非負整数を受け取り、素数でnより小さい最初のn個の
// 整数の配列を返す関数を実装せよ。
// 例えば:
// >>> count_up_to(5)
// []int{2, 3}
// >>> count_up_to(11)
// []int{2, 3, 5, 7}
// >>> count_up_to(0)
// []int{}
// >>> count_up_to(20)
// []int{2, 3, 5, 7, 11, 13, 17, 19}
// >>> count_up_to(1)
// []int{}
// >>> count_up_to(18)
// []int{2, 3, 5, 7, 11, 13, 17}
func count_up_to(n int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_96_count_up_to.py
|
reworded
|
func TestCount_Up_To(t *testing.T) {
candidate := count_up_to
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(5), expected: []int{2, 3} },
{ actual: candidate(6), expected: []int{2, 3, 5} },
{ actual: candidate(7), expected: []int{2, 3, 5} },
{ actual: candidate(10), expected: []int{2, 3, 5, 7} },
{ actual: candidate(0), expected: []int{} },
{ actual: candidate(22), expected: []int{2, 3, 5, 7, 11, 13, 17, 19} },
{ actual: candidate(1), expected: []int{} },
{ actual: candidate(18), expected: []int{2, 3, 5, 7, 11, 13, 17} },
{ actual: candidate(47), expected: []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43} },
{ actual: candidate(101), expected: []int{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} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_97_multiply
|
go_test.go
|
package multiply_test
import (
"testing"
"fmt"
)
// 2つの整数を受け取り、その1の位の数の積を返す関数を完成させよ。
// 入力は常に有効範囲にあるとする。
// 例:
// >>> multiply(148, 412)
// 16
// >>> multiply(19, 28)
// 72
// >>> multiply(2020, 1851)
// 0
// >>> multiply(14, -15)
// 20
func multiply(a int, b int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_97_multiply.py
|
reworded
|
func TestMultiply(t *testing.T) {
candidate := multiply
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(148, 412), expected: 16 },
{ actual: candidate(19, 28), expected: 72 },
{ actual: candidate(2020, 1851), expected: 0 },
{ actual: candidate(14, -15), expected: 20 },
{ actual: candidate(76, 67), expected: 42 },
{ actual: candidate(17, 27), expected: 49 },
{ actual: candidate(0, 1), expected: 0 },
{ actual: candidate(0, 0), expected: 0 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_98_count_upper
|
go_test.go
|
package count_upper_test
import (
"testing"
"fmt"
)
// 文字列 s が与えられたとき、偶数のインデックスに含まれる大文字の母音の数を数える。
// 例えば:
// >>> count_upper("aBCdEf")
// 1
// >>> count_upper("abcdefg")
// 0
// >>> count_upper("dBBE")
// 0
func count_upper(s string) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_98_count_upper.py
|
reworded
|
func TestCount_Upper(t *testing.T) {
candidate := count_upper
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("aBCdEf"), expected: 1 },
{ actual: candidate("abcdefg"), expected: 0 },
{ actual: candidate("dBBE"), expected: 0 },
{ actual: candidate("B"), expected: 0 },
{ actual: candidate("U"), expected: 1 },
{ actual: candidate(""), expected: 0 },
{ actual: candidate("EEEE"), expected: 2 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_99_closest_integer
|
go_test.go
|
package closest_integer_test
import (
"testing"
"fmt"
)
// 数値を表す文字列valueを受け取り、それに最も近い整数を返す関数を作る。
// その数値が2つの整数から等距離にある場合は、ゼロから四捨五入する。
// 例
// >>> closest_integer("10")
// 10
// >>> closest_integer("15.3")
// 15
// Note:
// ゼロからの四捨五入とは、与えられた数値が2つの整数から
// 等距離にある場合、ゼロから遠い方を返すという意味である。 例えば、 close_integer("14.5")は15を返し、closest_integer("-14.5")は-15を返す。
func closest_integer(value string) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_99_closest_integer.py
|
reworded
|
func TestClosest_Integer(t *testing.T) {
candidate := closest_integer
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("10"), expected: 10 },
{ actual: candidate("14.5"), expected: 15 },
{ actual: candidate("-15.5"), expected: -16 },
{ actual: candidate("15.3"), expected: 15 },
{ actual: candidate("0"), expected: 0 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_100_make_a_pile
|
go_test.go
|
package make_a_pile_test
import (
"testing"
"fmt"
)
// 正の整数nが与えられたとき、n段の石の山を作らなければならない。
// 最初の段にはn個の石がある。
// 次の段の石の数は:
// - nが奇数なら次の奇数。
// - nが偶数なら次の偶数。
// 各段の石の数をリストで返す。インデックス i の要素は、段 (i+1) の石の
// 数を表すものとする。
// 例:
// >>> make_a_pile(3)
// []int{3, 5, 7}
func make_a_pile(n int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_100_make_a_pile.py
|
reworded
|
func TestMake_A_Pile(t *testing.T) {
candidate := make_a_pile
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(3), expected: []int{3, 5, 7} },
{ actual: candidate(4), expected: []int{4, 6, 8, 10} },
{ actual: candidate(5), expected: []int{5, 7, 9, 11, 13} },
{ actual: candidate(6), expected: []int{6, 8, 10, 12, 14, 16} },
{ actual: candidate(8), expected: []int{8, 10, 12, 14, 16, 18, 20, 22} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_101_words_string
|
go_test.go
|
package words_string_test
import (
"testing"
"fmt"
)
// カンマまたは空白で区切られた単語の文字列が与えられる。あなたのタスクは、
// 文字列を単語に分割し、単語の配列を返すことである。
// 例えば:
// >>> words_string("Hi, my name is John")
// []string{"Hi", "my", "name", "is", "John"}
// >>> words_string("One, two, three, four, five, six")
// []string{"One", "two", "three", "four", "five", "six"}
func words_string(s string) []string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_101_words_string.py
|
reworded
|
func TestWords_String(t *testing.T) {
candidate := words_string
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate("Hi, my name is John"), expected: []string{"Hi", "my", "name", "is", "John"} },
{ actual: candidate("One, two, three, four, five, six"), expected: []string{"One", "two", "three", "four", "five", "six"} },
{ actual: candidate("Hi, my name"), expected: []string{"Hi", "my", "name"} },
{ actual: candidate("One,, two, three, four, five, six,"), expected: []string{"One", "two", "three", "four", "five", "six"} },
{ actual: candidate(""), expected: []string{} },
{ actual: candidate("ahmed , gamal"), expected: []string{"ahmed", "gamal"} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_102_choose_num
|
go_test.go
|
package choose_num_test
import (
"testing"
"fmt"
)
// この関数は2つの正の数xとyを受け取り、範囲[x, y](両端を含む)に含まれる
// 最大の偶数整数を返す。そのような数がない場合、関数は-1を返す。
// 例えば:
// >>> choose_num(12, 15)
// 14
// >>> choose_num(13, 12)
// -1
func choose_num(x int, y int) int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_102_choose_num.py
|
reworded
|
func TestChoose_Num(t *testing.T) {
candidate := choose_num
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate(12, 15), expected: 14 },
{ actual: candidate(13, 12), expected: -1 },
{ actual: candidate(33, 12354), expected: 12354 },
{ actual: candidate(5234, 5233), expected: -1 },
{ actual: candidate(6, 29), expected: 28 },
{ actual: candidate(27, 10), expected: -1 },
{ actual: candidate(7, 7), expected: -1 },
{ actual: candidate(546, 546), expected: 546 },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_104_unique_digits
|
go_test.go
|
package unique_digits_test
import (
"testing"
"fmt"
)
// 正の整数xのリストが与えられたとき、偶数桁の要素を持たない全ての
// 要素をソートしたリストを返す。
// 注意: 返されるリストは昇順にソートされていなければならない。
// 例えば:
// >>> unique_digits([]int{15, 33, 1422, 1})
// []int{1, 15, 33}
// >>> unique_digits([]int{152, 323, 1422, 10})
// []int{}
func unique_digits(x []int) []int {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_104_unique_digits.py
|
reworded
|
func TestUnique_Digits(t *testing.T) {
candidate := unique_digits
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{15, 33, 1422, 1}), expected: []int{1, 15, 33} },
{ actual: candidate([]int{152, 323, 1422, 10}), expected: []int{} },
{ actual: candidate([]int{12345, 2033, 111, 151}), expected: []int{111, 151} },
{ actual: candidate([]int{135, 103, 31}), expected: []int{31, 135} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
HumanEval_105_by_length
|
go_test.go
|
package by_length_test
import (
"testing"
"fmt"
)
// 整数の配列が与えられたとき、1から9までの整数をソートし、
// 得られた配列を逆順にし、各桁を以下の数字に相当する名前に置き換える。
// "One"、"Two"、"Three"、"Four"、"Five"、"Six"、"Seven"、"Eight"、"Nine "
// 例えば:
// >>> by_length([]int{2, 1, 1, 4, 5, 8, 2, 3})
// []string{"Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"}
//
// もし空配列なら、空配列を返す:
// >>> by_length([]int{})
// []string{}
// もし変な数値が配列に含まれていたら無視せよ:
// >>> by_length([]int{1, -1, 55})
// []string{"One"}
func by_length(arr []int) []string {
|
transform
|
/work/arjunguha-research-group/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_105_by_length.py
|
reworded
|
func TestBy_Length(t *testing.T) {
candidate := by_length
type test struct {
actual interface{}
expected interface{}
}
tests := []test{
{ actual: candidate([]int{2, 1, 1, 4, 5, 8, 2, 3}), expected: []string{"Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"} },
{ actual: candidate([]int{}), expected: []string{} },
{ actual: candidate([]int{1, -1, 55}), expected: []string{"One"} },
{ actual: candidate([]int{1, -1, 3, 2}), expected: []string{"Three", "Two", "One"} },
{ actual: candidate([]int{9, 4, 8}), expected: []string{"Nine", "Eight", "Four"} },
}
for i, tc := range tests {
t.Run(fmt.Sprintf("test num % d", i), func(t *testing.T) {
if fmt.Sprintf("%v", tc.actual) != fmt.Sprintf("%v", tc.expected) {
t.Errorf("expected '%s', got '%s'", tc.expected, tc.actual)
}
})
}
}
|
[
"\nfunc",
"struct",
"\n// "
] |
End of preview. Expand
in Data Studio
- Downloads last month
- 28