Prompt:
package strlen_test

import (
    "testing"
    "fmt"
)

// Return length of given string
// >>> strlen("")
// 0
// >>> strlen("abc")
// 3
func strlen(myString string) int {

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)
			}
		})
	}
}


Prompt:
package encrypt_test

import (
    "testing"
    "fmt"
)

// Create a function encrypt that takes a string as an argument and
// returns a string encrypted with the alphabet being rotated.
// The alphabet should be rotated in a manner such that the letters
// shift down by two multiplied to two places.
// For example:
// >>> encrypt("hi")
// "lm"
// >>> encrypt("asdfghjkl")
// "ewhjklnop"
// >>> encrypt("gf")
// "kj"
// >>> encrypt("et")
// "ix"
func encrypt(s string) string {

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)
			}
		})
	}
}


Prompt:
package check_dict_case_test

import (
    "testing"
    "fmt"
)

// Given a map, return true if all keys are strings in lower
// case or all keys are strings in upper case, else return false.
// The function should return false is the given map is empty.
// Examples:
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package add_test

import (
    "testing"
    "fmt"
)

// Given a non-empty list of integers lst. add the even elements that are at odd indices..
// Examples:
// >>> add([]int{4, 2, 6, 7})
// 2
func add(lst []int) int {

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)
			}
		})
	}
}


Prompt:
package fix_spaces_test

import (
    "testing"
    "fmt"
)

// Given a string text, replace all spaces in it with underscores,
// and if a string has more than 2 consecutive spaces,
// then replace all consecutive spaces with -
// >>> fix_spaces(" Example")
// "Example"
// >>> fix_spaces(" Example 1")
// "Example_1"
// >>> fix_spaces(" Example 2")
// "_Example_2"
// >>> fix_spaces(" Example 3")
// "_Example-3"
func fix_spaces(text string) string {

func TestFix_Spaces(t *testing.T) {
  candidate := fix_spaces
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate("Example"), expected: "Example" },
     { actual: candidate("Mudasir Hanif "), expected: "Mudasir_Hanif_" },
     { actual: candidate("Yellow Yellow  Dirty  Fellow"), expected: "Yellow_Yellow__Dirty__Fellow" },
     { actual: candidate("Exa   mple"), expected: "Exa-mple" },
     { actual: candidate("   Exa 1 2 2 mple"), expected: "-Exa_1_2_2_mple" },
   }

	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)
			}
		})
	}
}


Prompt:
package fibfib_test

import (
    "testing"
    "fmt"
)

// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Please write a function to efficiently compute the n-th element of the fibfib number sequence.
// >>> fibfib(1)
// 0
// >>> fibfib(5)
// 4
// >>> fibfib(8)
// 24
func fibfib(n int) int {

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)
			}
		})
	}
}


Prompt:
package double_the_difference_test

import (
    "testing"
    "fmt"
)

// Given a list of numbers, return the sum of squares of the numbers
// in the list that are odd. Ignore numbers that are negative or not integers.
// >>> double_the_difference([]int{1, 3, 2, 0})
// 10
// >>> double_the_difference([]int{-1, -2, 0})
// 0
// >>> double_the_difference([]int{9, -2})
// 81
// >>> double_the_difference([]int{0})
// 0
// If the input list is empty, return 0.
func double_the_difference(lst []float64) int {

func TestDouble_The_Difference(t *testing.T) {
  candidate := double_the_difference
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate([]float64{}), expected: 0 },
     { actual: candidate([]float64{5.0, 4.0}), expected: 25 },
     { actual: candidate([]float64{0.1, 0.2, 0.3}), expected: 0 },
     { actual: candidate([]float64{-10.0, -20.0, -30.0}), expected: 0 },
     { actual: candidate([]float64{-1.0, -2.0, 8.0}), expected: 0 },
     { actual: candidate([]float64{0.2, 3.0, 5.0}), expected: 34 },
     { actual: candidate([]float64{-9.0, -7.0, -5.0, -3.0, -1.0, 1.0, 3.0, 5.0, 7.0, 9.0}), expected: 165 },
   }

	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)
			}
		})
	}
}


Prompt:
package filter_integers_test

import (
    "testing"
    "fmt"
)

// Filter given list of any gothon values only for integers
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package car_race_collision_test

import (
    "testing"
    "fmt"
)

// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right;  simultaneously, a different set of n cars
// are driving right to left.   The two sets of cars start out being very far from
// each other.  All cars move in the same speed.  Two cars are said to collide
// when a car that's moving left to right hits a car that's moving right to left.
// However, the cars are infinitely sturdy and strong; as a result, they continue moving
// in their trajectory as if they did not collide.
// This function outputs the number of such collisions.
func car_race_collision(n int) int {

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)
			}
		})
	}
}


Prompt:
package parse_music_test

import (
    "testing"
    "fmt"
)

// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return list of integers corresponding to how many beats does each
// not last.
// Here is a legend:
// 'o' - whole note, lasts four beats
// 'o|' - half note, lasts two beats
// '.|' - quater note, lasts one beat
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package decimal_to_binary_test

import (
    "testing"
    "fmt"
)

// You will be given a number in decimal form and your task is to convert it to
// binary format. The function should return a string, with each character representing a binary
// number. Each character in the string will be '0' or '1'.
// There will be an extra couple of characters 'db' at the beginning and at the end of the string.
// The extra characters are there to help with the format.
// Examples:
// >>> decimal_to_binary(15)
// "db1111db"
// >>> decimal_to_binary(32)
// "db100000db"
func decimal_to_binary(decimal int) string {

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)
			}
		})
	}
}


Prompt:
package all_prefixes_test

import (
    "testing"
    "fmt"
)

// Return list of all prefixes from shortest to longest of the input string
// >>> all_prefixes("abc")
// []string{"a", "ab", "abc"}
func all_prefixes(myString string) []string {

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)
			}
		})
	}
}


Prompt:
package add_test

import (
    "testing"
    "fmt"
)

// Add two numbers x and y
// >>> add(2, 3)
// 5
// >>> add(5, 7)
// 12
func add(x int, y int) int {

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)
			}
		})
	}
}


Prompt:
package eat_test

import (
    "testing"
    "fmt"
)

// You're a hungry rabbit, and you already have eaten a certain number of carrots,
// but now you need to eat more carrots to complete the day's meals.
// you should return a list of [ total number of eaten carrots after your meals,
// the number of carrots left after your meals ]
// if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.
// Example:
// >>> eat(5, 6, 10)
// []int{11, 4}
// >>> eat(4, 8, 9)
// []int{12, 1}
// >>> eat(1, 10, 10)
// []int{11, 0}
// >>> eat(2, 11, 5)
// []int{7, 0}
// Variables:
// @number : integer
// the number of carrots that you have eaten.
// @need : integer
// the number of carrots that you need to eat.
// @remaining : integer
// the number of remaining carrots thet exist in stock
// Constrain:
// * 0 <= number <= 1000
// * 0 <= need <= 1000
// * 0 <= remaining <= 1000
// Have fun :)
func eat(number int, need int, remaining int) []int {

func TestEat(t *testing.T) {
  candidate := eat
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate(5, 6, 10), expected: []int{11, 4} },
     { actual: candidate(4, 8, 9), expected: []int{12, 1} },
     { actual: candidate(1, 10, 10), expected: []int{11, 0} },
     { actual: candidate(2, 11, 5), expected: []int{7, 0} },
     { actual: candidate(4, 5, 7), expected: []int{9, 2} },
     { actual: candidate(4, 5, 1), expected: []int{5, 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)
			}
		})
	}
}


Prompt:
package max_fill_test

import (
    "testing"
    "fmt"
)

// You are given a rectangular grid of wells. Each row represents a single well,
// and each 1 in a row represents a single unit of water.
// Each well has a corresponding bucket that can be used to extract water from it,
// and all buckets have the same capacity.
// Your task is to use the buckets to empty the wells.
// Output the number of times you need to lower the buckets.
// Example 1:
// >>> max_fill([][]int{[]int{0, 0, 1, 0}, []int{0, 1, 0, 0}, []int{1, 1, 1, 1}}, 1)
// 6
// Example 2:
// >>> max_fill([][]int{[]int{0, 0, 1, 1}, []int{0, 0, 0, 0}, []int{1, 1, 1, 1}, []int{0, 1, 1, 1}}, 2)
// 5
// Example 3:
// >>> max_fill([][]int{[]int{0, 0, 0}, []int{0, 0, 0}}, 5)
// 0
// Constraints:
// * all wells have the same length
// * 1 <= grid.length <= 10^2
// * 1 <= grid[:,1].length <= 10^2
// * grid[i][j] -> 0 | 1
// * 1 <= capacity <= 10
func max_fill(grid [][]int, capacity int) int {

func TestMax_Fill(t *testing.T) {
  candidate := max_fill
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate([][]int{[]int{0, 0, 1, 0}, []int{0, 1, 0, 0}, []int{1, 1, 1, 1}}, 1), expected: 6 },
     { actual: candidate([][]int{[]int{0, 0, 1, 1}, []int{0, 0, 0, 0}, []int{1, 1, 1, 1}, []int{0, 1, 1, 1}}, 2), expected: 5 },
     { actual: candidate([][]int{[]int{0, 0, 0}, []int{0, 0, 0}}, 5), expected: 0 },
     { actual: candidate([][]int{[]int{1, 1, 1, 1}, []int{1, 1, 1, 1}}, 2), expected: 4 },
     { actual: candidate([][]int{[]int{1, 1, 1, 1}, []int{1, 1, 1, 1}}, 9), 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)
			}
		})
	}
}


Prompt:
package do_algebra_test

import (
    "testing"
    "fmt"
)

// Given two lists operator, and operand. The first list has basic algebra operations, and
// the second list is a list of integers. Use the two given lists to build the algebric
// expression and return the evaluation of this expression.
// The basic algebra operations:
// Addition ( + )
// Subtraction ( - )
// Multiplication ( * )
// Floor division ( // )
// Exponentiation ( ** )
// Example:
// operator['+', '*', '-']
// list = [2, 3, 4, 5]
// result = 2 + 3 * 4 - 5
// => result = 9
// Note:
// The length of operator list is equal to the length of operand list minus one.
// Operand is a list of of non-negative integers.
// Operator list has at least one operator, and operand list has at least two operands.
func do_algebra(operator []string, operand []int) int {

func TestDo_Algebra(t *testing.T) {
  candidate := do_algebra
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate([]string{"**", "*", "+"}, []int{2, 3, 4, 5}), expected: 37 },
     { actual: candidate([]string{"+", "*", "-"}, []int{2, 3, 4, 5}), expected: 9 },
     { actual: candidate([]string{"//", "*"}, []int{7, 3, 4}), expected: 8 },
   }

	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)
			}
		})
	}
}


Prompt:
package flip_case_test

import (
    "testing"
    "fmt"
)

// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// >>> flip_case("Hello")
// "hELLO"
func flip_case(myString string) string {

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)
			}
		})
	}
}


Prompt:
package by_length_test

import (
    "testing"
    "fmt"
)

// Given a list of integers, sort the integers that are between 1 and 9 inclusive,
// reverse the resulting list, and then replace each digit by its corresponding name from
// "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine".
// For example:
// >>> by_length([]int{2, 1, 1, 4, 5, 8, 2, 3})
// []string{"Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"}
// If the list is empty, return an empty list:
// >>> by_length([]int{})
// []string{}
// If the list has any strange number ignore it:
// >>> by_length([]int{1, -1, 55})
// []string{"One"}
func by_length(arr []int) []string {

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)
			}
		})
	}
}


Prompt:
package factorize_test

import (
    "testing"
    "fmt"
)

// Return list of prime factors of given integer in the order from smallest to largest.
// Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
// Input number should be equal to the product of all factors
// >>> factorize(8)
// []int{2, 2, 2}
// >>> factorize(25)
// []int{5, 5}
// >>> factorize(70)
// []int{2, 5, 7}
func factorize(n int) []int {

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)
			}
		})
	}
}


Prompt:
package count_up_to_test

import (
    "testing"
    "fmt"
)

// Implement a function that takes an non-negative integer and returns a list of the first n
// integers that are prime numbers and less than n.
// for example:
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package unique_test

import (
    "testing"
    "fmt"
)

// Return sorted unique elements in a list
// >>> unique([]int{5, 3, 5, 2, 3, 3, 9, 0, 123})
// []int{0, 2, 3, 5, 9, 123}
func unique(l []int) []int {

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)
			}
		})
	}
}


Prompt:
package total_match_test

import (
    "testing"
    "fmt"
)

// Write a function that accepts two lists of strings and returns the list that has
// total number of chars in the all strings of the list less than the other list.
// if the two lists have the same number of chars, return the first list.
// Examples
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package max_element_test

import (
    "testing"
    "fmt"
)

// Return maximum element in the list.
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package is_nested_test

import (
    "testing"
    "fmt"
)

// Create a function that takes a string as input which contains only square brackets.
// The function should return true if and only if there is a valid subsequence of brackets
// where at least one bracket in the subsequence is nested.
// >>> is_nested("[[]]")
// true
// >>> is_nested("[]]]]]]][[[[[]")
// false
// >>> is_nested("[][]")
// false
// >>> is_nested("[]")
// false
// >>> is_nested("[[][]]")
// true
// >>> is_nested("[[]][[")
// true
func is_nested(myString string) bool {

func TestIs_Nested(t *testing.T) {
  candidate := is_nested
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate("[[]]"), expected: true },
     { actual: candidate("[]]]]]]][[[[[]"), expected: false },
     { actual: candidate("[][]"), expected: false },
     { actual: candidate("[]"), expected: false },
     { actual: candidate("[[[[]]]]"), expected: true },
     { actual: candidate("[]]]]]]]]]]"), expected: false },
     { actual: candidate("[][][[]]"), expected: true },
     { actual: candidate("[[]"), expected: false },
     { actual: candidate("[]]"), expected: false },
     { actual: candidate("[[]][["), expected: true },
     { actual: candidate("[[][]]"), expected: true },
     { 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)
			}
		})
	}
}


Prompt:
package odd_count_test

import (
    "testing"
    "fmt"
)

// Given a list of strings, where each string consists of only digits, return a list.
// Each element i of the output should be "the number of odd elements in the
// string i of the input." where all the i's should be replaced by the number
// of odd digits in the i'th string of the input.
// >>> odd_count([]string{"1234567"})
// []string{"the number of odd elements 4n the str4ng 4 of the 4nput."}
// >>> odd_count([]string{"3", "11111111"})
// []string{"the number of odd elements 1n the str1ng 1 of the 1nput.", "the number of odd elements 8n the str8ng 8 of the 8nput."}
func odd_count(lst []string) []string {

func TestOdd_Count(t *testing.T) {
  candidate := odd_count
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate([]string{"1234567"}), expected: []string{"the number of odd elements 4n the str4ng 4 of the 4nput."} },
     { actual: candidate([]string{"3", "11111111"}), expected: []string{"the number of odd elements 1n the str1ng 1 of the 1nput.", "the number of odd elements 8n the str8ng 8 of the 8nput."} },
     { actual: candidate([]string{"271", "137", "314"}), expected: []string{"the number of odd elements 2n the str2ng 2 of the 2nput.", "the number of odd elements 3n the str3ng 3 of the 3nput.", "the number of odd elements 2n the str2ng 2 of the 2nput."} },
   }

	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)
			}
		})
	}
}


Prompt:
package move_one_ball_test

import (
    "testing"
    "fmt"
)

// We have a list 'arr' of N integers arr[1], arr[2], ..., arr[N].The
// numbers in the list will be randomly ordered. Your task is to determine if
// it is possible to get a list sorted in non-decreasing order by performing
// the following operation on the given list:
// You are allowed to perform right shift operation any number of times.
// One right shift operation means shifting all elements of the list by one
// position in the right direction. The last element of the list will be moved to
// the starting position in the list i.e. 0th index.
// If it is possible to obtain the sorted list by performing the above operation
// then return true else return false.
// If the given list is empty then return true.
// Note: The given list is guaranteed to have unique elements.
// For Example:
// >>> move_one_ball([]int{3, 4, 5, 1, 2})
// true
// Explanation: By performin 2 right shift operations, non-decreasing order can
// be achieved for the given list.
// >>> move_one_ball([]int{3, 5, 4, 1, 2})
// false
// Explanation:It is not possible to get non-decreasing order for the given
// list by performing any number of right shift operations.
func move_one_ball(arr []int) bool {

func TestMove_One_Ball(t *testing.T) {
  candidate := move_one_ball
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate([]int{3, 4, 5, 1, 2}), expected: true },
     { actual: candidate([]int{3, 5, 10, 1, 2}), expected: true },
     { actual: candidate([]int{4, 3, 1, 2}), expected: false },
     { actual: candidate([]int{3, 5, 4, 1, 2}), expected: false },
     { actual: candidate([]int{}), 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)
			}
		})
	}
}


Prompt:
package even_odd_palindrome_test

import (
    "testing"
    "fmt"
)

// Given a positive integer n, return a list that has the number of even and odd
// integer palindromes that fall within the range(1, n), inclusive.
// Example 1:
// >>> even_odd_palindrome(3)
// []interface{}{1, 2}
// Explanation:
// Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
// Example 2:
// >>> even_odd_palindrome(12)
// []interface{}{4, 6}
// Explanation:
// Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.
// Note:
// 1. 1 <= n <= 10^3
// 2. returned list has the number of even and odd integer palindromes respectively.
func even_odd_palindrome(n int) []interface{} {

func TestEven_Odd_Palindrome(t *testing.T) {
  candidate := even_odd_palindrome
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate(123), expected: []interface{}{8, 13} },
     { actual: candidate(12), expected: []interface{}{4, 6} },
     { actual: candidate(3), expected: []interface{}{1, 2} },
     { actual: candidate(63), expected: []interface{}{6, 8} },
     { actual: candidate(25), expected: []interface{}{5, 6} },
     { actual: candidate(19), expected: []interface{}{4, 6} },
     { actual: candidate(9), expected: []interface{}{4, 5} },
     { actual: candidate(1), expected: []interface{}{0, 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)
			}
		})
	}
}


Prompt:
package is_equal_to_sum_even_test

import (
    "testing"
    "fmt"
)

// Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
// Example
// >>> is_equal_to_sum_even(4)
// false
// >>> is_equal_to_sum_even(6)
// false
// >>> is_equal_to_sum_even(8)
// true
func is_equal_to_sum_even(n int) bool {

func TestIs_Equal_To_Sum_Even(t *testing.T) {
  candidate := is_equal_to_sum_even
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate(4), expected: false },
     { actual: candidate(6), expected: false },
     { actual: candidate(8), expected: true },
     { actual: candidate(10), expected: true },
     { actual: candidate(11), expected: false },
     { actual: candidate(12), expected: true },
     { actual: candidate(13), expected: false },
     { actual: candidate(16), 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)
			}
		})
	}
}


Prompt:
package derivative_test

import (
    "testing"
    "fmt"
)

// xs represent coefficients of a polynomial.
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// Return derivative of this polynomial in the same form.
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package is_sorted_test

import (
    "testing"
    "fmt"
)

// Given a list of numbers, return whether or not they are sorted
// in ascending order. If list has more than 1 duplicate of the same
// number, return false. Assume no negative numbers and only integers.
// Examples
// >>> is_sorted([]int{5})
// true
// >>> is_sorted([]int{1, 2, 3, 4, 5})
// true
// >>> is_sorted([]int{1, 3, 2, 4, 5})
// false
// >>> is_sorted([]int{1, 2, 3, 4, 5, 6})
// true
// >>> is_sorted([]int{1, 2, 3, 4, 5, 6, 7})
// true
// >>> is_sorted([]int{1, 3, 2, 4, 5, 6, 7})
// false
// >>> is_sorted([]int{1, 2, 2, 3, 3, 4})
// true
// >>> is_sorted([]int{1, 2, 2, 2, 3, 4})
// false
func is_sorted(lst []int) bool {

func TestIs_Sorted(t *testing.T) {
  candidate := is_sorted
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate([]int{5}), expected: true },
     { actual: candidate([]int{1, 2, 3, 4, 5}), expected: true },
     { actual: candidate([]int{1, 3, 2, 4, 5}), expected: false },
     { actual: candidate([]int{1, 2, 3, 4, 5, 6}), expected: true },
     { actual: candidate([]int{1, 2, 3, 4, 5, 6, 7}), expected: true },
     { actual: candidate([]int{1, 3, 2, 4, 5, 6, 7}), expected: false },
     { actual: candidate([]int{}), expected: true },
     { actual: candidate([]int{1}), expected: true },
     { actual: candidate([]int{3, 2, 1}), expected: false },
     { actual: candidate([]int{1, 2, 2, 2, 3, 4}), expected: false },
     { actual: candidate([]int{1, 2, 3, 3, 3, 4}), expected: false },
     { actual: candidate([]int{1, 2, 2, 3, 3, 4}), expected: true },
     { actual: candidate([]int{1, 2, 3, 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)
			}
		})
	}
}


Prompt:
package solve_test

import (
    "testing"
    "fmt"
)

// You are given a string s.
// if s[i] is a letter, reverse its case from lower to upper or vise versa,
// otherwise keep it as it is.
// If the string contains no letters, reverse the string.
// The function should return the resulted string.
// Examples
// >>> solve("1234")
// "4321"
// >>> solve("ab")
// "AB"
// >>> solve("#a@C")
// "#A@c"
func solve(s string) string {

func TestSolve(t *testing.T) {
  candidate := solve
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate("AsDf"), expected: "aSdF" },
     { actual: candidate("1234"), expected: "4321" },
     { actual: candidate("ab"), expected: "AB" },
     { actual: candidate("#a@C"), expected: "#A@c" },
     { actual: candidate("#AsdfW^45"), expected: "#aSDFw^45" },
     { actual: candidate("#6@2"), expected: "2@6#" },
     { actual: candidate("#$a^D"), expected: "#$A^d" },
     { actual: candidate("#ccc"), expected: "#CCC" },
   }

	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)
			}
		})
	}
}


Prompt:
package tri_test

import (
    "testing"
    "fmt"
)

// Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
// the last couple centuries. However, what people don't know is Tribonacci sequence.
// Tribonacci sequence is defined by the recurrence:
// tri(1) = 3
// tri(n) = 1 + n / 2, if n is even.
// tri(n) =  tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.
// For example:
// tri(2) = 1 + (2 / 2) = 2
// tri(4) = 3
// tri(3) = tri(2) + tri(1) + tri(4)
// = 2 + 3 + 3 = 8
// You are given a non-negative integer number n, you have to a return a list of the
// first n + 1 numbers of the Tribonacci sequence.
// Examples:
// >>> tri(3)
// []int{1, 3, 2, 8}
func tri(n int) []int {

func TestTri(t *testing.T) {
  candidate := tri
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate(3), expected: []int{1, 3, 2, 8} },
     { actual: candidate(4), expected: []int{1, 3, 2, 8, 3} },
     { actual: candidate(5), expected: []int{1, 3, 2, 8, 3, 15} },
     { actual: candidate(6), expected: []int{1, 3, 2, 8, 3, 15, 4} },
     { actual: candidate(7), expected: []int{1, 3, 2, 8, 3, 15, 4, 24} },
     { actual: candidate(8), expected: []int{1, 3, 2, 8, 3, 15, 4, 24, 5} },
     { actual: candidate(9), expected: []int{1, 3, 2, 8, 3, 15, 4, 24, 5, 35} },
     { actual: candidate(20), expected: []int{1, 3, 2, 8, 3, 15, 4, 24, 5, 35, 6, 48, 7, 63, 8, 80, 9, 99, 10, 120, 11} },
     { actual: candidate(0), expected: []int{1} },
     { actual: candidate(1), expected: []int{1, 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)
			}
		})
	}
}


Prompt:
package fizz_buzz_test

import (
    "testing"
    "fmt"
)

// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// >>> fizz_buzz(50)
// 0
// >>> fizz_buzz(78)
// 2
// >>> fizz_buzz(79)
// 3
func fizz_buzz(n int) int {

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)
			}
		})
	}
}


Prompt:
package filter_by_prefix_test

import (
    "testing"
    "fmt"
)

// Filter an input list of strings only for ones that start with a given 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 {

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)
			}
		})
	}
}


Prompt:
package solve_test

import (
    "testing"
    "fmt"
)

// Given a positive integer N, return the total sum of its digits in binary.
// Example
// >>> solve(1000)
// "1"
// >>> solve(150)
// "110"
// >>> solve(147)
// "1100"
// Variables:
// @N integer
// Constraints: 0 ≤ N ≤ 10000.
// Output:
// a string of binary number
func solve(N int) string {

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)
			}
		})
	}
}


Prompt:
package minPath_test

import (
    "testing"
    "fmt"
)

// Given a grid with N rows and N columns (N >= 2) and a positive integer k,
// each cell of the grid contains a value. Every integer in the range [1, N * N]
// inclusive appears exactly once on the cells of the grid.
// You have to find the minimum path of length k in the grid. You can start
// from any cell, and in each step you can move to any of the neighbor cells,
// in other words, you can go to cells which share an edge with you current
// cell.
// Please note that a path of length k means visiting exactly k cells (not
// necessarily distinct).
// You CANNOT go off the grid.
// A path A (of length k) is considered less than a path B (of length k) if
// after making the ordered lists of the values on the cells that A and B go
// through (let's call them lst_A and lst_B), lst_A is lexicographically less
// than lst_B, in other words, there exist an integer index i (1 <= i <= k)
// such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have
// lst_A[j] = lst_B[j].
// It is guaranteed that the answer is unique.
// Return an ordered list of the values on the cells that the minimum path go through.
// Examples:
// >>> minPath([][]int{[]int{1, 2, 3}, []int{4, 5, 6}, []int{7, 8, 9}}, 3)
// []int{1, 2, 1}
// >>> minPath([][]int{[]int{5, 9, 3}, []int{4, 1, 6}, []int{7, 8, 2}}, 1)
// []int{1}
func minPath(grid [][]int, k int) []int {


Prompt:
package count_upper_test

import (
    "testing"
    "fmt"
)

// Given a string s, count the number of uppercase vowels in even indices.
// For example:
// >>> count_upper("aBCdEf")
// 1
// >>> count_upper("abcdefg")
// 0
// >>> count_upper("dBBE")
// 0
func count_upper(s string) int {

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)
			}
		})
	}
}


Prompt:
package maximum_test

import (
    "testing"
    "fmt"
)

// Given a list arr of integers and a positive integer k, return a sorted list
// of length k with the maximum k numbers in arr.
// Example 1:
// >>> maximum([]int{-3, -4, 5}, 3)
// []int{-4, -3, 5}
// Example 2:
// >>> maximum([]int{4, -4, 4}, 2)
// []int{4, 4}
// Example 3:
// >>> maximum([]int{-3, 2, 1, 2, -1, -2, 1}, 1)
// []int{2}
// Note:
// 1. The length of the list will be in the range of [1, 1000].
// 2. The elements in the list will be in the range of [-1000, 1000].
// 3. 0 <= k <= len(arr)
func maximum(arr []int, k int) []int {

func TestMaximum(t *testing.T) {
  candidate := maximum
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate([]int{-3, -4, 5}, 3), expected: []int{-4, -3, 5} },
     { actual: candidate([]int{4, -4, 4}, 2), expected: []int{4, 4} },
     { actual: candidate([]int{-3, 2, 1, 2, -1, -2, 1}, 1), expected: []int{2} },
     { actual: candidate([]int{123, -123, 20, 0, 1, 2, -3}, 3), expected: []int{2, 20, 123} },
     { actual: candidate([]int{-123, 20, 0, 1, 2, -3}, 4), expected: []int{0, 1, 2, 20} },
     { actual: candidate([]int{5, 15, 0, 3, -13, -8, 0}, 7), expected: []int{-13, -8, 0, 0, 3, 5, 15} },
     { actual: candidate([]int{-1, 0, 2, 5, 3, -10}, 2), expected: []int{3, 5} },
     { actual: candidate([]int{1, 0, 5, -7}, 1), expected: []int{5} },
     { actual: candidate([]int{4, -4}, 2), expected: []int{-4, 4} },
     { actual: candidate([]int{-10, 10}, 2), expected: []int{-10, 10} },
     { actual: candidate([]int{1, 2, 3, -23, 243, -400, 0}, 0), 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)
			}
		})
	}
}


Prompt:
package largest_divisor_test

import (
    "testing"
    "fmt"
)

// For a given number n, find the largest number that divides n evenly, smaller than n
// >>> largest_divisor(15)
// 5
func largest_divisor(n int) int {

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)
			}
		})
	}
}


Prompt:
package sort_array_test

import (
    "testing"
    "fmt"
)

// Given a list of non-negative integers, return a cogo of the given list after sorting,
// you will sort the given list in ascending order if the sum( first index value, last index value) is odd,
// or sort it in descending order if the sum( first index value, last index value) is even.
// Note:
// * don't change the given list.
// Examples:
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package f_test

import (
    "testing"
    "fmt"
)

// Implement the function f that takes n as a parameter,
// and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even
// or the sum of numbers from 1 to i otherwise.
// i starts from 1.
// the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).
// Example:
// >>> f(5)
// []int{1, 2, 6, 24, 15}
func f(n int) []int {

func TestF(t *testing.T) {
  candidate := f
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate(5), expected: []int{1, 2, 6, 24, 15} },
     { actual: candidate(7), expected: []int{1, 2, 6, 24, 15, 720, 28} },
     { actual: candidate(1), expected: []int{1} },
     { actual: candidate(3), expected: []int{1, 2, 6} },
   }

	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)
			}
		})
	}
}


Prompt:
package iscube_test

import (
    "testing"
    "fmt"
)

// Write a function that takes an integer a and returns true
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// >>> iscube(1)
// true
// >>> iscube(2)
// false
// >>> iscube(-1)
// true
// >>> iscube(64)
// true
// >>> iscube(0)
// true
// >>> iscube(180)
// false
func iscube(a int) bool {

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)
			}
		})
	}
}


Prompt:
package encode_test

import (
    "testing"
    "fmt"
)

// Write a function that takes a message, and encodes in such a
// way that it swaps case of all letters, replaces all vowels in
// the message with the letter that appears 2 places ahead of that
// vowel in the english alphabet.
// Assume only letters.
// Examples:
// >>> encode("test")
// "TGST"
// >>> encode("This is a message")
// "tHKS KS C MGSSCGG"
func encode(message string) string {

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)
			}
		})
	}
}


Prompt:
package is_bored_test

import (
    "testing"
    "fmt"
)

// You'll be given a string of words, and your task is to count the number
// of boredoms. A boredom is a sentence that starts with the word "I".
// Sentences are delimited by '.', '?' or '!'.
// For example:
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package pairs_sum_to_zero_test

import (
    "testing"
    "fmt"
)

// pairs_sum_to_zero takes a list of integers as an input.
// it returns true if there are two distinct elements in the list that
// sum to zero, and false otherwise.
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package triangle_area_test

import (
    "testing"
    "fmt"
)

// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle.
// Otherwise return -1
// Three sides make a valid triangle when the sum of any two sides is greater
// than the third side.
// Example:
// >>> triangle_area(3, 4, 5)
// 6.0
// >>> triangle_area(1, 2, 10)
// -1
func triangle_area(a int, b int, c int) float64 {

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)
			}
		})
	}
}


Prompt:
package bf_test

import (
    "testing"
    "fmt"
)

// There are eight planets in our solar system: the closerst to the Sun
// is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
// Uranus, Neptune.
// Write a function that takes two planet names as strings planet1 and planet2.
// The function should return a list containing all planets whose orbits are
// located between the orbit of planet1 and the orbit of planet2, sorted by
// the proximity to the sun.
// The function should return an empty list if planet1 or planet2
// are not correct planet names.
// Examples
// >>> bf("Jupiter", "Neptune")
// []interface{}{"Saturn", "Uranus"}
// >>> bf("Earth", "Mercury")
// "Venus"
// >>> bf("Mercury", "Uranus")
// []interface{}{"Venus", "Earth", "Mars", "Jupiter", "Saturn"}
func bf(planet1 string, planet2 string) []interface{} {

func TestBf(t *testing.T) {
  candidate := bf
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate("Jupiter", "Neptune"), expected: []interface{}{"Saturn", "Uranus"} },
     { actual: candidate("Earth", "Mercury"), expected: []interface{}{"Venus"} },
     { actual: candidate("Mercury", "Uranus"), expected: []interface{}{"Venus", "Earth", "Mars", "Jupiter", "Saturn"} },
     { actual: candidate("Neptune", "Venus"), expected: []interface{}{"Earth", "Mars", "Jupiter", "Saturn", "Uranus"} },
     { actual: candidate("Earth", "Earth"), expected: []interface{}{} },
     { actual: candidate("Mars", "Earth"), expected: []interface{}{} },
     { actual: candidate("Jupiter", "Makemake"), expected: []interface{}{} },
   }

	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)
			}
		})
	}
}


Prompt:
package digits_test

import (
    "testing"
    "fmt"
)

// Given a positive integer n, return the product of the odd digits.
// Return 0 if all digits are even.
// For example:
// >>> digits(1)
// 1
// >>> digits(4)
// 0
// >>> digits(235)
// 15
func digits(n int) int {

func TestDigits(t *testing.T) {
  candidate := digits
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate(5), expected: 5 },
     { actual: candidate(54), expected: 5 },
     { actual: candidate(120), expected: 1 },
     { actual: candidate(5014), expected: 5 },
     { actual: candidate(98765), expected: 315 },
     { actual: candidate(5576543), expected: 2625 },
     { actual: candidate(2468), 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)
			}
		})
	}
}


Prompt:
package words_string_test

import (
    "testing"
    "fmt"
)

// You will be given a string of words separated by commas or spaces. Your task is
// to split the string into words and return a list of the words.
// For example:
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package how_many_times_test

import (
    "testing"
    "fmt"
)

// Find how many times a given substring can be found in the original string. Count overlaping cases.
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package remove_vowels_test

import (
    "testing"
    "fmt"
)

// remove_vowels is a function that takes string and returns string without vowels.
// >>> remove_vowels("")
// ""
// >>> remove_vowels("abcdef")
// "bcdf"
// >>> remove_vowels("aaaaa")
// ""
// >>> remove_vowels("aaBAA")
// "B"
// >>> remove_vowels("zbcd")
// "zbcd"
func remove_vowels(text string) string {

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)
			}
		})
	}
}


Prompt:
package strange_sort_list_test

import (
    "testing"
    "fmt"
)

// Given list of integers, return list in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package find_closest_elements_test

import (
    "testing"
    "fmt"
)

// From a supplied list of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// >>> 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{} {

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)
			}
		})
	}
}


Prompt:
package is_simple_power_test

import (
    "testing"
    "fmt"
)

// Your task is to write a function that returns true if a number x is a simple
// power of n and false in other cases.
// x is a simple power of n if n**int=x
// For example:
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package prime_fib_test

import (
    "testing"
    "fmt"
)

// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package order_by_points_test

import (
    "testing"
    "fmt"
)

// Write a function which sorts the given list of integers
// in ascending order according to the sum of their digits.
// Note: if there are several items with similar sum of their digits,
// order them based on their index in original list.
// For example:
// >>> order_by_points([]int{1, 11, -1, -11, -12})
// []int{-1, -11, 1, -12, 11}
// >>> order_by_points([]int{})
// []int{}
func order_by_points(nums []int) []int {


Prompt:
package has_close_elements_test

import (
    "testing"
    "fmt"
)

// Check if in given list of numbers, are any two numbers closer to each other than
// given threshold.
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package make_palindrome_test

import (
    "testing"
    "fmt"
)

// Find the shortest palindrome that begins with a supplied string.
// Algorithm idea is simple:
// - Find the longest postfix of supplied string that is a palindrome.
// - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
// >>> make_palindrome("")
// ""
// >>> make_palindrome("cat")
// "catac"
// >>> make_palindrome("cata")
// "catac"
func make_palindrome(myString string) string {

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)
			}
		})
	}
}


Prompt:
package string_xor_test

import (
    "testing"
    "fmt"
)

// Input are two strings a and b consisting only of 1s and 0s.
// Perform binary XOR on these inputs and return result also as a string.
// >>> string_xor("010", "110")
// "100"
func string_xor(a string, b string) string {

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)
			}
		})
	}
}


Prompt:
package special_factorial_test

import (
    "testing"
    "fmt"
)

// The Brazilian factorial is defined as:
// brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
// where n > 0
// For example:
// >>> special_factorial(4)
// 288
// The function will receive an integer as input and should return the special
// factorial of this integer.
func special_factorial(n int) int {

func TestSpecial_Factorial(t *testing.T) {
  candidate := special_factorial
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate(4), expected: 288 },
     { actual: candidate(5), expected: 34560 },
     { actual: candidate(7), expected: 125411328000 },
     { actual: candidate(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)
			}
		})
	}
}


Prompt:
package add_elements_test

import (
    "testing"
    "fmt"
)

// Given a non-empty list of integers arr and an integer k, return
// the sum of the elements with at most two digits from the first k elements of arr.
// Example:
// >>> add_elements([]int{111, 21, 3, 4000, 5, 6, 7, 8, 9}, 4)
// 24
// Constraints:
// 1. 1 <= len(arr) <= 100
// 2. 1 <= k <= len(arr)
func add_elements(arr []int, k int) int {

func TestAdd_Elements(t *testing.T) {
  candidate := add_elements
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate([]int{1, -2, -3, 41, 57, 76, 87, 88, 99}, 3), expected: -4 },
     { actual: candidate([]int{111, 121, 3, 4000, 5, 6}, 2), expected: 0 },
     { actual: candidate([]int{11, 21, 3, 90, 5, 6, 7, 8, 9}, 4), expected: 125 },
     { actual: candidate([]int{111, 21, 3, 4000, 5, 6, 7, 8, 9}, 4), expected: 24 },
     { actual: candidate([]int{1}, 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)
			}
		})
	}
}


Prompt:
package fib4_test

import (
    "testing"
    "fmt"
)

// The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// 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).
// Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
// >>> fib4(5)
// 4
// >>> fib4(6)
// 8
// >>> fib4(7)
// 14
func fib4(n int) int {

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)
			}
		})
	}
}


Prompt:
package unique_digits_test

import (
    "testing"
    "fmt"
)

// Given a list of positive integers x. return a sorted list of all
// elements that hasn't any even digit.
// Note: Returned list should be sorted in increasing order.
// For example:
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package select_words_test

import (
    "testing"
    "fmt"
)

// Given a string s and a natural number n, you have been tasked to implement
// a function that returns a list of all words from string s that contain exactly
// n consonants, in order these words appear in the string s.
// If the string s is empty then the function should return an empty list.
// Note: you may assume the input string contains only letters and spaces.
// Examples:
// >>> select_words("Mary had a little lamb", 4)
// []string{"little"}
// >>> select_words("Mary had a little lamb", 3)
// []string{"Mary", "lamb"}
// >>> select_words("simple white space", 2)
// []string{}
// >>> select_words("Hello world", 4)
// []string{"world"}
// >>> select_words("Uncle sam", 3)
// []string{"Uncle"}
func select_words(s string, n int) []string {

func TestSelect_Words(t *testing.T) {
  candidate := select_words
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate("Mary had a little lamb", 4), expected: []string{"little"} },
     { actual: candidate("Mary had a little lamb", 3), expected: []string{"Mary", "lamb"} },
     { actual: candidate("simple white space", 2), expected: []string{} },
     { actual: candidate("Hello world", 4), expected: []string{"world"} },
     { actual: candidate("Uncle sam", 3), expected: []string{"Uncle"} },
     { actual: candidate("", 4), expected: []string{} },
     { actual: candidate("a b c d e f", 1), expected: []string{"b", "c", "d", "f"} },
   }

	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)
			}
		})
	}
}


Prompt:
package will_it_fly_test

import (
    "testing"
    "fmt"
)

// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// >>> will_it_fly([]int{1, 2}, 5)
// false
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// >>> will_it_fly([]int{3, 2, 3}, 1)
// false
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// >>> will_it_fly([]int{3, 2, 3}, 9)
// true
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// >>> will_it_fly([]int{3}, 5)
// true
// # 3 is less than the maximum possible weight, and it's balanced.
func will_it_fly(q []int, w int) bool {

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)
			}
		})
	}
}


Prompt:
package fib_test

import (
    "testing"
    "fmt"
)

// Return n-th Fibonacci number.
// >>> fib(10)
// 55
// >>> fib(1)
// 1
// >>> fib(8)
// 21
func fib(n int) int {

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)
			}
		})
	}
}


Prompt:
package Strongest_Extension_test

import (
    "testing"
    "fmt"
)

// You will be given the name of a class (a string) and a list of extensions.
// The extensions are to be used to load additional classes to the class. The
// strength of the extension is as follows: Let CAP be the number of the uppercase
// letters in the extension's name, and let SM be the number of lowercase letters
// in the extension's name, the strength is given by the fraction CAP - SM.
// You should find the strongest extension and return a string in this
// format: ClassName.StrongestExtensionName.
// If there are two or more extensions with the same strength, you should
// choose the one that comes first in the list.
// For example, if you are given "Slices" as the class and a list of the
// extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
// return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
// (its strength is -1).
// Example:
// >>> Strongest_Extension("my_class", []string{"AA", "Be", "CC"})
// "my_class.AA"
func Strongest_Extension(class_name string, extensions []string) string {

func TestStrongest_Extension(t *testing.T) {
  candidate := Strongest_Extension
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate("Watashi", []string{"tEN", "niNE", "eIGHt8OKe"}), expected: "Watashi.eIGHt8OKe" },
     { actual: candidate("Boku123", []string{"nani", "NazeDa", "YEs.WeCaNe", "32145tggg"}), expected: "Boku123.YEs.WeCaNe" },
     { actual: candidate("__YESIMHERE", []string{"t", "eMptY", "nothing", "zeR00", "NuLl__", "123NoooneB321"}), expected: "__YESIMHERE.NuLl__" },
     { actual: candidate("K", []string{"Ta", "TAR", "t234An", "cosSo"}), expected: "K.TAR" },
     { actual: candidate("__HAHA", []string{"Tab", "123", "781345", "-_-"}), expected: "__HAHA.123" },
     { actual: candidate("YameRore", []string{"HhAas", "okIWILL123", "WorkOut", "Fails", "-_-"}), expected: "YameRore.okIWILL123" },
     { actual: candidate("finNNalLLly", []string{"Die", "NowW", "Wow", "WoW"}), expected: "finNNalLLly.WoW" },
     { actual: candidate("_", []string{"Bb", "91245"}), expected: "_.Bb" },
     { actual: candidate("Sp", []string{"671235", "Bb"}), expected: "Sp.671235" },
   }

	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)
			}
		})
	}
}


Prompt:
package match_parens_test

import (
    "testing"
    "fmt"
)

// You are given a list of two strings, both strings consist of open
// parentheses '(' or close parentheses ')' only.
// Your job is to check if it is possible to concatenate the two strings in
// some order, that the resulting string will be good.
// A string S is considered to be good if and only if all parentheses in S
// are balanced. For example: the string '(())()' is good, while the string
// '())' is not.
// Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.
// Examples:
// >>> match_parens([]string{"()(", ")"})
// "Yes"
// >>> match_parens([]string{")", ")"})
// "No"
func match_parens(lst []string) string {

func TestMatch_Parens(t *testing.T) {
  candidate := match_parens
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate([]string{"()(", ")"}), expected: "Yes" },
     { actual: candidate([]string{")", ")"}), expected: "No" },
     { actual: candidate([]string{"(()(())", "())())"}), expected: "No" },
     { actual: candidate([]string{")())", "(()()("}), expected: "Yes" },
     { actual: candidate([]string{"(())))", "(()())(("}), expected: "Yes" },
     { actual: candidate([]string{"()", "())"}), expected: "No" },
     { actual: candidate([]string{"(()(", "()))()"}), expected: "Yes" },
     { actual: candidate([]string{"((((", "((())"}), expected: "No" },
     { actual: candidate([]string{")(()", "(()("}), expected: "No" },
     { actual: candidate([]string{")(", ")("}), expected: "No" },
     { actual: candidate([]string{"(", ")"}), expected: "Yes" },
     { actual: candidate([]string{")", "("}), expected: "Yes" },
   }

	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)
			}
		})
	}
}


Prompt:
package any_int_test

import (
    "testing"
    "fmt"
)

// Create a function that takes 3 numbers.
// Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
// Returns false in any other cases.
// Examples
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package truncate_number_test

import (
    "testing"
    "fmt"
)

// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
// >>> truncate_number(3.5)
// 0.5
func truncate_number(number float64) float64 {

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)
			}
		})
	}
}


Prompt:
package incr_list_test

import (
    "testing"
    "fmt"
)

// Return list with elements incremented by 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 {

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)
			}
		})
	}
}


Prompt:
package x_or_y_test

import (
    "testing"
    "fmt"
)

// A simple program which should return the value of x if n is
// a prime number and should return the value of y otherwise.
// Examples:
// >>> x_or_y(7, 34, 12)
// 34
// >>> x_or_y(15, 8, 5)
// 5
func x_or_y(n int, x int, y int) int {

func TestX_Or_Y(t *testing.T) {
  candidate := x_or_y
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate(7, 34, 12), expected: 34 },
     { actual: candidate(15, 8, 5), expected: 5 },
     { actual: candidate(3, 33, 5212), expected: 33 },
     { actual: candidate(1259, 3, 52), expected: 3 },
     { actual: candidate(7919, -1, 12), expected: -1 },
     { actual: candidate(3609, 1245, 583), expected: 583 },
     { actual: candidate(91, 56, 129), expected: 129 },
     { actual: candidate(6, 34, 1234), expected: 1234 },
     { actual: candidate(1, 2, 0), expected: 0 },
     { actual: candidate(2, 2, 0), 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)
			}
		})
	}
}


Prompt:
package modp_test

import (
    "testing"
    "fmt"
)

// Return 2^n modulo p (be aware of numerics).
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package even_odd_count_test

import (
    "testing"
    "fmt"
)

// Given an integer. return a list that has the number of even and odd digits respectively.
// Example:
// >>> even_odd_count(-12)
// []interface{}{1, 1}
// >>> even_odd_count(123)
// []interface{}{1, 2}
func even_odd_count(num int) []interface{} {

func TestEven_Odd_Count(t *testing.T) {
  candidate := even_odd_count
	type test struct {
		actual   interface{}
		expected interface{}
	}
   tests := []test{
     { actual: candidate(7), expected: []interface{}{0, 1} },
     { actual: candidate(-78), expected: []interface{}{1, 1} },
     { actual: candidate(3452), expected: []interface{}{2, 2} },
     { actual: candidate(346211), expected: []interface{}{3, 3} },
     { actual: candidate(-345821), expected: []interface{}{3, 3} },
     { actual: candidate(-2), expected: []interface{}{1, 0} },
     { actual: candidate(-45347), expected: []interface{}{2, 3} },
     { actual: candidate(0), expected: []interface{}{1, 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)
			}
		})
	}
}


Prompt:
package is_happy_test

import (
    "testing"
    "fmt"
)

// You are given a string s.
// Your task is to check if the string is hapgo or not.
// A string is hapgo if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// >>> 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 {

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)
			}
		})
	}
}


Prompt:
package largest_prime_factor_test

import (
    "testing"
    "fmt"
)

// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// >>> largest_prime_factor(13195)
// 29
// >>> largest_prime_factor(2048)
// 2
func largest_prime_factor(n int) int {

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)
			}
		})
	}
}