Prompt:
// You are given a string s.
// Your task is to check if the string is happy or not.
// A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// IsHappy(a) => false
// IsHappy(aa) => false
// IsHappy(abcd) => true
// IsHappy(aabb) => false
// IsHappy(adb) => true
// IsHappy(xyy) => false
func IsHappy(s string) bool {

    if len(s) < 3 {
        return false
    }
    for i := 0; i < len(s)-2; i++ {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}

func TestIsHappy(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(false, IsHappy("a"), "a")
    assert.Equal(false, IsHappy("aa"), "aa")
    assert.Equal(true, IsHappy("abcd"), "abcd")
    assert.Equal(false, IsHappy("aabb"), "aabb")
    assert.Equal(true, IsHappy("adb"), "adb")
    assert.Equal(false, IsHappy("xyy"), "xyy")
    assert.Equal(true, IsHappy("iopaxpoi"), "iopaxpoi")
    assert.Equal(false, IsHappy("iopaxioi"), "iopaxioi")
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestIsHappy(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(false, IsHappy("a"), "a")
    assert.Equal(false, IsHappy("aa"), "aa")
    assert.Equal(true, IsHappy("abcd"), "abcd")
    assert.Equal(false, IsHappy("aabb"), "aabb")
    assert.Equal(true, IsHappy("adb"), "adb")
    assert.Equal(false, IsHappy("xyy"), "xyy")
}


Prompt:
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you a list of GPAs for some students and you have to write
// a function that can output a list of letter grades using the following table:
// GPA       |    Letter grade
// 4.0                A+
// > 3.7                A
// > 3.3                A-
// > 3.0                B+
// > 2.7                B
// > 2.3                B-
// > 2.0                C+
// > 1.7                C
// > 1.3                C-
// > 1.0                D+
// > 0.7                D
// > 0.0                D-
// 0.0                E
//
//
// Example:
// grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> ["A+", "B", "C-", "C", "A-"]
func NumericalLetterGrade(grades []float64) []string {

letter_grade := make([]string, 0, len(grades))
    for _, gpa := range grades {
        switch {
        case gpa == 4.0:
            letter_grade = append(letter_grade, "A+")
        case gpa > 3.7:
            letter_grade = append(letter_grade, "A")
        case gpa > 3.3:
            letter_grade = append(letter_grade, "A-")
        case gpa > 3.0:
            letter_grade = append(letter_grade, "B+")
        case gpa > 2.7:
            letter_grade = append(letter_grade, "B")
        case gpa > 2.3:
            letter_grade = append(letter_grade, "B-")
        case gpa > 2.0:
            letter_grade = append(letter_grade, "C+")
        case gpa > 1.7:
            letter_grade = append(letter_grade, "C")
        case gpa > 1.3:
            letter_grade = append(letter_grade, "C-")
        case gpa > 1.0:
            letter_grade = append(letter_grade, "D+")
        case gpa > 0.7:
            letter_grade = append(letter_grade, "D")
        case gpa > 0.0:
            letter_grade = append(letter_grade, "D-")
        default:
            letter_grade = append(letter_grade, "E")
        }

    }
    return letter_grade
}

func TestNumericalLetterGrade(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"A+", "B", "C-", "C", "A-"}, NumericalLetterGrade([]float64{4.0, 3, 1.7, 2, 3.5}))
    assert.Equal([]string{"D+"}, NumericalLetterGrade([]float64{1.2}))
    assert.Equal([]string{"D-"}, NumericalLetterGrade([]float64{0.5}))
    assert.Equal([]string{"E"}, NumericalLetterGrade([]float64{0.0}))
    assert.Equal([]string{"D", "D-", "C-", "B", "B+"}, NumericalLetterGrade([]float64{1, 0.3, 1.5, 2.8, 3.3}))
    assert.Equal([]string{"E", "D-"}, NumericalLetterGrade([]float64{0, 0.7}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestNumericalLetterGrade(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"A+", "B", "C-", "C", "A-"}, NumericalLetterGrade([]float64{4.0, 3, 1.7, 2, 3.5}))
}


Prompt:
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// PrimeLength('Hello') == true
// PrimeLength('abcdcba') == true
// PrimeLength('kittens') == true
// PrimeLength('orange') == false
func PrimeLength(s string) bool {

    l := len(s)
    if l == 0 || l == 1 {
        return false
    }
    for i := 2; i < l; i++ {
        if l%i == 0 {
            return false
        }
    }
    return true
}

func TestPrimeLength(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, PrimeLength("Hello"))
    assert.Equal(true, PrimeLength("abcdcba"))
    assert.Equal(true, PrimeLength("kittens"))
    assert.Equal(false, PrimeLength("orange"))
    assert.Equal(true, PrimeLength("wow"))
    assert.Equal(true, PrimeLength("world"))
    assert.Equal(true, PrimeLength("MadaM"))
    assert.Equal(true, PrimeLength("Wow"))
    assert.Equal(false, PrimeLength(""))
    assert.Equal(true, PrimeLength("HI"))
    assert.Equal(true, PrimeLength("go"))
    assert.Equal(false, PrimeLength("gogo"))
    assert.Equal(false, PrimeLength("aaaaaaaaaaaaaaa"))
    assert.Equal(true, PrimeLength("Madam"))
    assert.Equal(false, PrimeLength("M"))
    assert.Equal(false, PrimeLength("0"))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestPrimeLength(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, PrimeLength("Hello"))
    assert.Equal(true, PrimeLength("abcdcba"))
    assert.Equal(true, PrimeLength("kittens"))
    assert.Equal(false, PrimeLength("orange"))
}


Prompt:
import (
    "math"
)

// Given a positive integer n, return the count of the numbers of n-digit
// positive integers that start or end with 1.
func StartsOneEnds(n int) int {

    if n == 1 {
        return 1
    }
    return 18 * int(math.Pow(10, float64(n-2)))
}

func TestStartsOneEnds(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(1, StartsOneEnds(1))
    assert.Equal(18, StartsOneEnds(2))
    assert.Equal(180, StartsOneEnds(3))
    assert.Equal(1800, StartsOneEnds(4))
    assert.Equal(18000, StartsOneEnds(5))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)


Prompt:
import (
    "fmt"
    "strconv"
)

// Given a positive integer N, return the total sum of its digits in binary.
//
// Example
// For N = 1000, the sum of digits will be 1 the output should be "1".
// For N = 150, the sum of digits will be 6 the output should be "110".
// For N = 147, the sum of digits will be 12 the output should be "1100".
//
// Variables:
// @N integer
// Constraints: 0 ≤ N ≤ 10000.
// Output:
// a string of binary number
func Solve(N int) string {

    sum := 0
    for _, c := range strconv.Itoa(N) {
        sum += int(c - '0')
    }
    return fmt.Sprintf("%b", sum)
}

func TestSolve(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("1", Solve(1000), "Error")
    assert.Equal("110", Solve(150), "Error")
    assert.Equal("1100", Solve(147), "Error")
    assert.Equal("1001", Solve(333), "Error")
    assert.Equal("10010", Solve(963), "Error")
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)


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

    sum := 0
    for i := 1; i < len(lst); i += 2 {
        if lst[i]%2 == 0 {
            sum += lst[i]
        }
    }
    return sum
}

func TestAdd(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(88, Add([]int{4, 88}))
    assert.Equal(122, Add([]int{4, 5, 6, 7, 2, 122}))
    assert.Equal(0, Add([]int{4, 0, 6, 7}))
    assert.Equal(12, Add([]int{4, 4, 6, 8}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestAdd(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(2, Add([]int{4, 2, 6, 7}))
}


Prompt:
import (
    "sort"
    "strings"
)

// Write a function that takes a string and returns an ordered version of it.
// Ordered version of string, is a string where all words (separated by space)
// are replaced by a new word where all the characters arranged in
// ascending order based on ascii value.
// Note: You should keep the order of words and blank spaces in the sentence.
//
// For example:
// AntiShuffle('Hi') returns 'Hi'
// AntiShuffle('hello') returns 'ehllo'
// AntiShuffle('Hello World!!!') returns 'Hello !!!Wdlor'
func AntiShuffle(s string) string {

    strs := make([]string, 0)
    for _, i := range strings.Fields(s) {
        word := []rune(i)
        sort.Slice(word, func(i, j int) bool {
            return word[i] < word[j]
        })
        strs = append(strs, string(word))
    }
    return strings.Join(strs, " ")
}

func TestAntiShuffle(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("Hi", AntiShuffle("Hi"))
    assert.Equal("ehllo", AntiShuffle("hello"))
    assert.Equal("bemnru", AntiShuffle("number"))
    assert.Equal("abcd", AntiShuffle("abcd"))
    assert.Equal("Hello !!!Wdlor", AntiShuffle("Hello World!!!"))
    assert.Equal("", AntiShuffle(""))
    assert.Equal(".Hi My aemn is Meirst .Rboot How aer ?ouy", AntiShuffle("Hi. My name is Mister Robot. How are you?"))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestAntiShuffle(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("Hi", AntiShuffle("Hi"))
    assert.Equal("ehllo", AntiShuffle("hello"))
    assert.Equal("Hello !!!Wdlor", AntiShuffle("Hello World!!!"))
}


Prompt:
import (
    "sort"
)

// You are given a 2 dimensional data, as a nested lists,
// which is similar to matrix, however, unlike matrices,
// each row may contain a different number of columns.
// Given lst, and integer x, find integers x in the list,
// and return list of tuples, [(x1, y1), (x2, y2) ...] such that
// each tuple is a coordinate - (row, columns), starting with 0.
// Sort coordinates initially by rows in ascending order.
// Also, sort coordinates of the row by columns in descending order.
//
// Examples:
// GetRow([
// [1,2,3,4,5,6],
// [1,2,3,4,1,6],
// [1,2,3,4,5,1]
// ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]
// GetRow([], 1) == []
// GetRow([[], [1], [1, 2, 3]], 3) == [(2, 2)]
func GetRow(lst [][]int, x int) [][2]int {

    coords := make([][2]int, 0)
    for i, row := range lst {
        for j, item := range row {
            if item == x {
                coords = append(coords, [2]int{i, j})
            }
        }
    }
    sort.Slice(coords, func(i, j int) bool {
        if coords[i][0] == coords[j][0] {
            return coords[i][1] > coords[j][1]
        }
        return coords[i][0] < coords[j][0]
    })

    return coords
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)


Prompt:
import (
    "sort"
)

// Given an array of non-negative integers, return a copy of the given array after sorting,
// you will sort the given array 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 array.
//
// Examples:
// * SortArray([]) => []
// * SortArray([5]) => [5]
// * SortArray([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
// * SortArray([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
func SortArray(array []int) []int {

    arr := make([]int, len(array))
    copy(arr, array)
    if len(arr) == 0 {
        return arr
    }
    if (arr[0]+arr[len(arr)-1])%2 == 0 {
        sort.Slice(arr, func(i, j int) bool {
            return arr[i] > arr[j]
        })
    } else {
        sort.Slice(arr, func(i, j int) bool {
            return arr[i] < arr[j]
        })
    }
    return arr
}

func TestSortArray(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{}, SortArray([]int{}), "Error")
    assert.Equal([]int{5}, SortArray([]int{5}), "Error")
    assert.Equal([]int{0, 1, 2, 3, 4, 5}, SortArray([]int{2, 4, 3, 0, 1, 5}), "Error")
    assert.Equal([]int{6, 5, 4, 3, 2, 1, 0}, SortArray([]int{2, 4, 3, 0, 1, 5, 6}), "Error")
    assert.Equal([]int{1, 2}, SortArray([]int{2, 1}), "Error")
    assert.Equal([]int{0, 11, 15, 32, 42, 87}, SortArray([]int{15, 42, 87, 32, 11, 0}), "Error")
    assert.Equal([]int{23, 21, 14, 11}, SortArray([]int{21, 14, 23, 11}), "Error")
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestSortArray(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{}, SortArray([]int{}), "Error")
    assert.Equal([]int{5}, SortArray([]int{5}), "Error")
    assert.Equal([]int{0, 1, 2, 3, 4, 5}, SortArray([]int{2, 4, 3, 0, 1, 5}), "Error")
    assert.Equal([]int{6, 5, 4, 3, 2, 1, 0}, SortArray([]int{2, 4, 3, 0, 1, 5, 6}), "Error")
}


Prompt:
import (
    "strings"
)

// 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') returns 'lm'
// Encrypt('asdfghjkl') returns 'ewhjklnop'
// Encrypt('gf') returns 'kj'
// Encrypt('et') returns 'ix'
func Encrypt(s string) string {

    d := "abcdefghijklmnopqrstuvwxyz"
    out := make([]rune, 0, len(s))
    for _, c := range s {
        pos := strings.IndexRune(d, c)
        if pos != -1 {
            out = append(out, []rune(d)[(pos+2*2)%26])
        } else {
            out = append(out, c)
        }
    }
    return string(out)
}

func TestEncrypt(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("lm", Encrypt("hi"))
    assert.Equal("ewhjklnop", Encrypt("asdfghjkl"))
    assert.Equal("kj", Encrypt("gf"))
    assert.Equal("ix", Encrypt("et"))
    assert.Equal("jeiajeaijeiak", Encrypt("faewfawefaewg"))
    assert.Equal("lippsqcjvmirh", Encrypt("hellomyfriend"))
    assert.Equal("hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl", Encrypt("dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh"))
    assert.Equal("e", Encrypt("a"))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestEncrypt(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("lm", Encrypt("hi"))
    assert.Equal("ewhjklnop", Encrypt("asdfghjkl"))
    assert.Equal("kj", Encrypt("gf"))
    assert.Equal("ix", Encrypt("et"))
}


Prompt:
import (
    "math"
    "sort"
)

// You are given a list of integers.
// Write a function NextSmallest() that returns the 2nd smallest element of the list.
// Return nil if there is no such element.
//
// NextSmallest([1, 2, 3, 4, 5]) == 2
// NextSmallest([5, 1, 4, 3, 2]) == 2
// NextSmallest([]) == nil
// NextSmallest([1, 1]) == nil
func NextSmallest(lst []int) interface{} {

    set := make(map[int]struct{})
    for _, i := range lst {
        set[i] = struct{}{}
    }
    vals := make([]int, 0, len(set))
    for k := range set {
        vals = append(vals, k)
    }
    sort.Slice(vals, func(i, j int) bool {
        return vals[i] < vals[j]
    })
    if len(vals) < 2 {
        return nil
    }
    return vals[1]
}

func TestNextSmallest(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(2, NextSmallest([]int{1, 2, 3, 4, 5}))
    assert.Equal(2, NextSmallest([]int{5, 1, 4, 3, 2}))
    assert.Equal(nil, NextSmallest([]int{}))
    assert.Equal(nil, NextSmallest([]int{1, 1}))
    assert.Equal(1, NextSmallest([]int{1,1,1,1,0}))
    assert.Equal(nil, NextSmallest([]int{1, int(math.Pow(0, 0))}))
    assert.Equal(-35, NextSmallest([]int{-35, 34, 12, -45}))
}

package main

import (
    "testing"
    "math"
    "github.com/stretchr/testify/assert"
)

func TestNextSmallest(t *testing.T) {
  assert := assert.New(t)
   assert.Equal(2+0*int(math.Pow(0, 0)), NextSmallest([]int{1, 2, 3, 4, 5}))
    assert.Equal(2, NextSmallest([]int{5, 1, 4, 3, 2}))
    assert.Equal(nil, NextSmallest([]int{}))
    assert.Equal(nil, NextSmallest([]int{1, 1}))
}


Prompt:
import (
    "regexp"
)

// 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:
// >>> IsBored("Hello world")
// 0
// >>> IsBored("The sky is blue. The sun is shining. I love this weather")
// 1
func IsBored(S string) int {

    r, _ := regexp.Compile(`[.?!]\s*`)
    sentences := r.Split(S, -1)
    sum := 0
    for _, s := range sentences {
        if len(s) >= 2 && s[:2] == "I " {
            sum++
        }
    }
    return sum
}

func TestIsBored(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(0, IsBored("Hello world"), "Test 1")
    assert.Equal(0, IsBored("Is the sky blue?"), "Test 2")
    assert.Equal(1, IsBored("I love It !"), "Test 3")
    assert.Equal(0, IsBored("bIt"), "Test 4")
    assert.Equal(2, IsBored("I feel good today. I will be productive. will kill It"), "Test 5")
    assert.Equal(0, IsBored("You and I are going for a walk"), "Test 6")
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestIsBored(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(0, IsBored("Hello world"), "Test 1")
    assert.Equal(1, IsBored("The sky is blue. The sun is shining. I love this weather"), "Test 3")
}


Prompt:
// 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
// AnyInt(5, 2, 7) ➞ true
//
// AnyInt(3, 2, 2) ➞ false
//
// AnyInt(3, -2, 1) ➞ true
//
// AnyInt(3.6, -2.2, 2) ➞ false
func AnyInt(x, y, z interface{}) bool {

    xx, ok := x.(int)
    if !ok {
        return false
    }
    yy, ok := y.(int)
    if !ok {
        return false
    }
    zz, ok := z.(int)
    if !ok {
        return false
    }

    if (xx+yy == zz) || (xx+zz == yy) || (yy+zz == xx) {
        return true
    }
    return false
}

func TestAnyInt(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, AnyInt(2, 3, 1))
    assert.Equal(false, AnyInt(2.5, 2, 3))
    assert.Equal(false, AnyInt(1.5, 5, 3.5))
    assert.Equal(false, AnyInt(2, 6, 2))
    assert.Equal(true, AnyInt(4, 2, 2))
    assert.Equal(false, AnyInt(2.2, 2.2, 2.2))
    assert.Equal(true, AnyInt(-4, 6, 2))
    assert.Equal(true, AnyInt(2, 1, 1))
    assert.Equal(true, AnyInt(3, 4, 7))
    assert.Equal(false, AnyInt(3.0, 4, 7))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestAnyInt(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, AnyInt(5, 2, 7))
    assert.Equal(false, AnyInt(3, 2, 2))
    assert.Equal(true, AnyInt(3, -2, 1))
    assert.Equal(false, AnyInt(3.6, -2.2, 2))
}


Prompt:
import (
    "strings"
)

// 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 {

    vowels := "aeiouAEIOU"
    vowels_replace := make(map[rune]rune)
    for _, c := range vowels {
        vowels_replace[c] = c + 2
    }
    result := make([]rune, 0, len(message))
    for _, c := range message {
        if 'a' <= c && c <= 'z' {
            c += 'A' - 'a'
        } else if 'A' <= c && c <= 'Z' {
            c += 'a' - 'A'
        }
        if strings.ContainsRune(vowels, c) {
            result = append(result, vowels_replace[c])
        } else {
            result = append(result, c)
        }
    }
    return string(result)
}

func TestEncode(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("tgst", Encode("TEST"))
    assert.Equal("mWDCSKR", Encode("Mudasir"))
    assert.Equal("ygs", Encode("YES"))
    assert.Equal("tHKS KS C MGSSCGG", Encode("This is a message"))
    assert.Equal("k dQnT kNqW wHcT Tq wRkTg", Encode("I DoNt KnOw WhAt tO WrItE"))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestEncode(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("TGST", Encode("test"))
    assert.Equal("tHKS KS C MGSSCGG", Encode("This is a message"))
}


Prompt:
import (
    "math"
    "strconv"
)

// You are given a list of integers.
// You need to find the largest prime value and return the sum of its digits.
//
// Examples:
// For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10
// For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25
// For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13
// For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11
// For lst = [0,81,12,3,1,21] the output should be 3
// For lst = [0,8,1,2,1,7] the output should be 7
func Skjkasdkd(lst []int) int {

    isPrime := func(n int) bool {
        for i := 2; i < int(math.Pow(float64(n), 0.5)+1); i++ {
            if n%i == 0 {
                return false
            }
        }
        return true
    }
    maxx := 0
    i := 0
    for i < len(lst) {
        if lst[i] > maxx && isPrime(lst[i]) {
            maxx = lst[i]
        }
        i++
    }
    sum := 0
    for _, d := range strconv.Itoa(maxx) {
        sum += int(d - '0')
    }
    return sum
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)


Prompt:
import (
    "strings"
)

// Given a dictionary, 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 dictionary is empty.
// Examples:
// CheckDictCase({"a":"apple", "b":"banana"}) should return true.
// CheckDictCase({"a":"apple", "A":"banana", "B":"banana"}) should return false.
// CheckDictCase({"a":"apple", 8:"banana", "a":"apple"}) should return false.
// CheckDictCase({"Name":"John", "Age":"36", "City":"Houston"}) should return false.
// CheckDictCase({"STATE":"NC", "ZIP":"12345" }) should return true.
func CheckDictCase(dict map[interface{}]interface{}) bool {

    if len(dict) == 0 {
        return false
    }
    state := "start"
    key := ""
    ok := false
    for k := range dict {
        if key, ok = k.(string); !ok {
            state = "mixed"
            break
        }
        if state == "start" {
            if key == strings.ToUpper(key) {
                state = "upper"
            } else if key == strings.ToLower(key) {
                state = "lower"
            } else {
                break
            }
        } else if (state == "upper" && key != strings.ToUpper(key)) || (state == "lower" && key != strings.ToLower(key)) {
            state = "mixed"
            break
        } else {
            break
        }
    }
    return state == "upper" || state == "lower"
}

func TestCheckDictCase(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, CheckDictCase(map[interface{}]interface{}{"p": "pineapple", "b": "banana"}))
    assert.Equal(false, CheckDictCase(map[interface{}]interface{}{"p": "pineapple", "A": "banana", "B": "banana"}))
    assert.Equal(false, CheckDictCase(map[interface{}]interface{}{"p": "pineapple", 5: "banana", "a": "apple"}))
    assert.Equal(false, CheckDictCase(map[interface{}]interface{}{"Name": "John", "Age": "36", "City": "Houston"}))
    assert.Equal(true, CheckDictCase(map[interface{}]interface{}{"STATE": "NC", "ZIP": "12345"}))
    assert.Equal(true, CheckDictCase(map[interface{}]interface{}{"fruit": "Orange", "taste": "Sweet"}))
    assert.Equal(false, CheckDictCase(map[interface{}]interface{}{}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestCheckDictCase(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, CheckDictCase(map[interface{}]interface{}{"p": "pineapple", "b": "banana"}))
    assert.Equal(false, CheckDictCase(map[interface{}]interface{}{"p": "pineapple", "A": "banana", "B": "banana"}))
    assert.Equal(false, CheckDictCase(map[interface{}]interface{}{"p": "pineapple", 8: "banana", "a": "apple"}))
    assert.Equal(false, CheckDictCase(map[interface{}]interface{}{"Name": "John", "Age": "36", "City": "Houston"}))
    assert.Equal(true, CheckDictCase(map[interface{}]interface{}{"STATE": "NC", "ZIP": "12345"}))
}


Prompt:
// Implement a function that takes an non-negative integer and returns an array of the first n
// integers that are prime numbers and less than n.
// for example:
// CountUpTo(5) => [2,3]
// CountUpTo(11) => [2,3,5,7]
// CountUpTo(0) => []
// CountUpTo(20) => [2,3,5,7,11,13,17,19]
// CountUpTo(1) => []
// CountUpTo(18) => [2,3,5,7,11,13,17]
func CountUpTo(n int) []int {

    primes := make([]int, 0)
    for i := 2; i < n; i++ {
        is_prime := true
        for j := 2; j < i; j++ {
            if i%j == 0 {
                is_prime = false
                break
            }
        }
        if is_prime {
            primes = append(primes, i)
        }
    }
    return primes
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestCountUpTo(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{2, 3}, CountUpTo(5))
    assert.Equal([]int{2, 3, 5, 7}, CountUpTo(11))
    assert.Equal([]int{}, CountUpTo(0))
    assert.Equal([]int{2, 3, 5, 7, 11, 13, 17, 19}, CountUpTo(20))
    assert.Equal([]int{}, CountUpTo(1))
    assert.Equal([]int{2, 3, 5, 7, 11, 13, 17}, CountUpTo(18))
}


Prompt:
import (
    "math"
)

// Complete the function that takes two integers and returns
// the product of their unit digits.
// Assume the input is always valid.
// Examples:
// Multiply(148, 412) should return 16.
// Multiply(19, 28) should return 72.
// Multiply(2020, 1851) should return 0.
// Multiply(14,-15) should return 20.
func Multiply(a, b int) int {

    return int(math.Abs(float64(a%10)) * math.Abs(float64(b%10)))
}

func TestMultiply(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(16, Multiply(148, 412))
    assert.Equal(72, Multiply(19, 28))
    assert.Equal(0, Multiply(2020, 1851))
    assert.Equal(20, Multiply(14, -15))
    assert.Equal(42, Multiply(76, 67))
    assert.Equal(49, Multiply(17, 27))
    assert.Equal(0, Multiply(0, 1))
    assert.Equal(0, Multiply(0, 0))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestMultiply(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(16, Multiply(148, 412))
    assert.Equal(72, Multiply(19, 28))
    assert.Equal(0, Multiply(2020, 1851))
    assert.Equal(20, Multiply(14, -15))
}


Prompt:
import (
    "strings"
)

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

    count := 0
    runes := []rune(s)
    for i := 0; i < len(runes); i += 2 {
        if strings.ContainsRune("AEIOU", runes[i]) {
            count += 1
        }
    }
    return count
}

func TestCountUpper(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(1, CountUpper("aBCdEf"))
    assert.Equal(0, CountUpper("abcdefg"))
    assert.Equal(0, CountUpper("dBBE"))
    assert.Equal(0, CountUpper("B"))
    assert.Equal(1, CountUpper("U"))
    assert.Equal(0, CountUpper(""))
    assert.Equal(2, CountUpper("EEEE"))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestCountUpper(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(1, CountUpper("aBCdEf"))
    assert.Equal(0, CountUpper("abcdefg"))
    assert.Equal(0, CountUpper("dBBE"))
}


Prompt:
import (
    "math"
    "strconv"
    "strings"
)

// Create a function that takes a value (string) representing a number
// and returns the closest integer to it. If the number is equidistant
// from two integers, round it away from zero.
//
// Examples
// >>> ClosestInteger("10")
// 10
// >>> ClosestInteger("15.3")
// 15
//
// Note:
// Rounding away from zero means that if the given number is equidistant
// from two integers, the one you should return is the one that is the
// farthest from zero. For example ClosestInteger("14.5") should
// return 15 and ClosestInteger("-14.5") should return -15.
func ClosestInteger(value string) int {

import (
    "math"
    "strconv"
    "strings"
)

    if strings.Count(value, ".") == 1 {
        // remove trailing zeros
        for value[len(value)-1] == '0' {
            value = value[:len(value)-1]
        }
    }
    var res float64
    num, _ := strconv.ParseFloat(value, 64)
    if len(value) >= 2 && value[len(value)-2:] == ".5" {
        if num > 0 {
            res = math.Ceil(num)
        } else {
            res = math.Floor(num)
        }
    } else if len(value) > 0 {
        res = math.Round(num)
    } else {
        res = 0
    }

    return int(res)
}

func TestClosestInteger(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(10, ClosestInteger("10"))
    assert.Equal(15, ClosestInteger("14.5"))
    assert.Equal(-16, ClosestInteger("-15.5"))
    assert.Equal(15, ClosestInteger("15.3"))
    assert.Equal(0, ClosestInteger("0"))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestClosestInteger(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(10, ClosestInteger("10"))
    assert.Equal(15, ClosestInteger("15.3"))
}


Prompt:
// Given a positive integer n, you have to make a pile of n levels of stones.
// The first level has n stones.
// The number of stones in the next level is:
// - the next odd number if n is odd.
// - the next even number if n is even.
// Return the number of stones in each level in a list, where element at index
// i represents the number of stones in the level (i+1).
//
// Examples:
// >>> MakeAPile(3)
// [3, 5, 7]
func MakeAPile(n int) []int {

    result := make([]int, 0, n)
    for i := 0; i < n; i++ {
        result = append(result, n+2*i)
    }
    return result
}

func TestMakeAPile(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{3, 5, 7}, MakeAPile(3))
    assert.Equal([]int{4, 6, 8, 10}, MakeAPile(4))
    assert.Equal([]int{5, 7, 9, 11, 13}, MakeAPile(5))
    assert.Equal([]int{6, 8, 10, 12, 14, 16}, MakeAPile(6))
    assert.Equal([]int{8, 10, 12, 14, 16, 18, 20, 22}, MakeAPile(8))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestMakeAPile(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{3, 5, 7}, MakeAPile(3))
}


Prompt:
import (
    "strings"
)

// You will be given a string of words separated by commas or spaces. Your task is
// to split the string into words and return an array of the words.
//
// For example:
// WordsString("Hi, my name is John") == ["Hi", "my", "name", "is", "John"]
// WordsString("One, two, three, four, five, six") == ["One", "two", "three", "four", "five", "six"]
func WordsString(s string) []string {

    s_list := make([]rune, 0)

    for _, c := range s {
        if c == ',' {
            s_list = append(s_list, ' ')
        } else {
            s_list = append(s_list, c)
        }
    }
    return strings.Fields(string(s_list))
}

func TestWordsString(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"Hi", "my", "name", "is", "John"}, WordsString("Hi, my name is John"))
    assert.Equal([]string{"One", "two", "three", "four", "five", "six"}, WordsString("One, two, three, four, five, six"))
    assert.Equal([]string{}, WordsString(""))
    assert.Equal([]string{"Hi", "my", "name"}, WordsString("Hi, my name"))
    assert.Equal([]string{"One", "two", "three", "four", "five", "six"}, WordsString("One,, two, three, four, five, six,"))
    assert.Equal([]string{"ahmed", "gamal"}, WordsString("ahmed     , gamal"))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestWordsString(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"Hi", "my", "name", "is", "John"}, WordsString("Hi, my name is John"))
    assert.Equal([]string{"One", "two", "three", "four", "five", "six"}, WordsString("One, two, three, four, five, six"))
}


Prompt:
// This function takes two positive numbers x and y and returns the
// biggest even integer number that is in the range [x, y] inclusive. If
// there's no such number, then the function should return -1.
//
// For example:
// ChooseNum(12, 15) = 14
// ChooseNum(13, 12) = -1
func ChooseNum(x, y int) int {

    if x > y {
        return -1
    }
    if y % 2 == 0 {
        return y
    }
    if x == y {
        return -1
    }
    return y - 1
}

func TestChooseNum(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(14, ChooseNum(12,15))
    assert.Equal(-1, ChooseNum(13,12))
    assert.Equal(12354, ChooseNum(33,12354))
    assert.Equal(-1, ChooseNum(5234,5233))
    assert.Equal(28, ChooseNum(6,29))
    assert.Equal(-1, ChooseNum(27,10))
    assert.Equal(-1, ChooseNum(7,7))
    assert.Equal(546, ChooseNum(546,546))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestChooseNum(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(14, ChooseNum(12,15))
    assert.Equal(-1, ChooseNum(13,12))
}


Prompt:
import (
    "fmt"
    "math"
)

// You are given two positive integers n and m, and your task is to compute the
// average of the integers from n through m (including n and m).
// Round the answer to the nearest integer and convert that to binary.
// If n is greater than m, return -1.
// Example:
// RoundedAvg(1, 5) => "0b11"
// RoundedAvg(7, 5) => -1
// RoundedAvg(10, 20) => "0b1111"
// RoundedAvg(20, 33) => "0b11010"
func RoundedAvg(n, m int) interface{} {

    if m < n {
        return -1
    }
    summation := 0
    for i := n;i < m+1;i++{
        summation += i
    }
    return fmt.Sprintf("0b%b", int(math.Round(float64(summation)/float64(m - n + 1))))
}

func TestRoundedAvg(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("0b11", RoundedAvg(1, 5))
    assert.Equal("0b1010", RoundedAvg(7, 13))
    assert.Equal("0b1111001011", RoundedAvg(964, 977))
    assert.Equal("0b1111100101", RoundedAvg(996, 997))
    assert.Equal("0b1011000010", RoundedAvg(560, 851))
    assert.Equal("0b101101110", RoundedAvg(185, 546))
    assert.Equal("0b110101101", RoundedAvg(362, 496))
    assert.Equal("0b1001110010", RoundedAvg(350, 902))
    assert.Equal("0b11010111", RoundedAvg(197, 233))
    assert.Equal(-1, RoundedAvg(7, 5))
    assert.Equal(-1, RoundedAvg(5, 1))
    assert.Equal("0b101", RoundedAvg(5, 5))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestRoundedAvg(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("0b11", RoundedAvg(1, 5))
    assert.Equal(-1, RoundedAvg(7, 5))
    assert.Equal("0b1111", RoundedAvg(10, 20))
    assert.Equal("0b11011", RoundedAvg(20, 33))
}


Prompt:
import (
    "sort"
    "strconv"
)

// 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:
// >>> UniqueDigits([15, 33, 1422, 1])
// [1, 15, 33]
// >>> UniqueDigits([152, 323, 1422, 10])
// []
func UniqueDigits(x []int) []int {

    odd_digit_elements := make([]int, 0)
    OUTER:
    for _, i := range x {
        for _, c := range strconv.Itoa(i) {
            if (c - '0') % 2 == 0 {
                continue OUTER
            }
        }
            odd_digit_elements = append(odd_digit_elements, i)
    }
    sort.Slice(odd_digit_elements, func(i, j int) bool {
        return odd_digit_elements[i] < odd_digit_elements[j]
    })
    return odd_digit_elements
}

func TestUniqueDigits(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{1, 15, 33}, UniqueDigits([]int{15, 33, 1422, 1}))
    assert.Equal([]int{}, UniqueDigits([]int{152, 323, 1422, 10}))
    assert.Equal([]int{111, 151}, UniqueDigits([]int{12345, 2033, 111, 151}))
    assert.Equal([]int{31, 135}, UniqueDigits([]int{135, 103, 31}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestUniqueDigits(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{1, 15, 33}, UniqueDigits([]int{15, 33, 1422, 1}))
    assert.Equal([]int{}, UniqueDigits([]int{152, 323, 1422, 10}))
}


Prompt:
import (
    "sort"
)

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

    dic := map[int]string{
        1: "One",
        2: "Two",
        3: "Three",
        4: "Four",
        5: "Five",
        6: "Six",
        7: "Seven",
        8: "Eight",
        9: "Nine",
    }
    sort.Slice(arr, func(i, j int) bool {
        return arr[i] > arr[j]
    })
    new_arr := make([]string, 0)
    for _, item := range arr {
        if v, ok := dic[item]; ok {
            new_arr = append(new_arr, v)
        }
    }
    return new_arr
}

func TestByLength(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"}, ByLength([]int{2, 1, 1, 4, 5, 8, 2, 3}))
    assert.Equal([]string{}, ByLength([]int{}))
    assert.Equal([]string{"One"}, ByLength([]int{1, -1 , 55}))
    assert.Equal([]string{"Three", "Two", "One"}, ByLength([]int{1, -1, 3, 2}))
    assert.Equal([]string{"Nine", "Eight", "Four"}, ByLength([]int{9, 4, 8}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)


Prompt:
// 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) == [1, 2, 6, 24, 15]
func F(n int) []int {

// 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) == [1, 2, 6, 24, 15]

    ret := make([]int, 0, 5)
    for i:=1;i<n+1;i++{
        if i%2 == 0 {
            x := 1
            for j:=1;j<i+1;j++{
                x*=j
            }
            ret = append(ret, x)
        }else {
            x := 0
            for j:=1;j<i+1;j++{
                x+=j
            }
            ret = append(ret, x)
        }
    }
    return ret
}

func TestF(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{1, 2, 6, 24, 15}, F(5))
    assert.Equal([]int{1, 2, 6, 24, 15, 720, 28}, F(7))
    assert.Equal([]int{1}, F(1))
    assert.Equal([]int{1,2,6}, F(3))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestF(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{1, 2, 6, 24, 15}, F(5))
}


Prompt:
import (
    "strconv"
)

// Given a positive integer n, return a tuple that has the number of even and odd
// integer palindromes that fall within the range(1, n), inclusive.
//
// Example 1:
//
// Input: 3
// Output: (1, 2)
// Explanation:
// Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
//
// Example 2:
//
// Input: 12
// Output: (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 tuple has the number of even and odd integer palindromes respectively.
func EvenOddPalindrome(n int) [2]int {

    is_palindrome := func (n int) bool {
        s := strconv.Itoa(n)
        for i := 0;i < len(s)>>1;i++ {
            if s[i] != s[len(s)-i-1] {
                return false
            }
        }
        return true
    }

    even_palindrome_count := 0
    odd_palindrome_count := 0

    for i :=1;i<n+1;i++ {
        if i%2 == 1 && is_palindrome(i){
                odd_palindrome_count ++
        } else if i%2 == 0 && is_palindrome(i) {
            even_palindrome_count ++
        }
    }
    return [2]int{even_palindrome_count, odd_palindrome_count}
}

func TestEvenOddPalindrome(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([2]int{8,13}, EvenOddPalindrome(123))
    assert.Equal([2]int{4,6}, EvenOddPalindrome(12))
    assert.Equal([2]int{1,2}, EvenOddPalindrome(3))
    assert.Equal([2]int{6,8}, EvenOddPalindrome(63))
    assert.Equal([2]int{5,6}, EvenOddPalindrome(25))
    assert.Equal([2]int{4,6}, EvenOddPalindrome(19))
    assert.Equal([2]int{4,5}, EvenOddPalindrome(9))
    assert.Equal([2]int{0,1}, EvenOddPalindrome(1))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestEvenOddPalindrome(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([2]int{4,6}, EvenOddPalindrome(12))
    assert.Equal([2]int{1,2}, EvenOddPalindrome(3))
}


Prompt:
import (
    "math"
    "strconv"
)

// Write a function CountNums which takes an array of integers and returns
// the number of elements which has a sum of digits > 0.
// If a number is negative, then its first signed digit will be negative:
// e.g. -123 has signed digits -1, 2, and 3.
// >>> CountNums([]) == 0
// >>> CountNums([-1, 11, -11]) == 1
// >>> CountNums([1, 1, 2]) == 3
func CountNums(arr []int) int {

    digits_sum:= func (n int) int {
        neg := 1
        if n < 0 {
             n, neg = -1 * n, -1
        }
        r := make([]int,0)
        for _, c := range strconv.Itoa(n) {
            r = append(r, int(c-'0'))
        }
        r[0] *= neg
        sum := 0
        for _, i := range r {
            sum += i
        }
        return sum
    }
    count := 0
    for _, i := range arr {
        x := digits_sum(i)
        if x > 0 {
            count++
        }
    }
    return count
}

func TestCountNums(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(0, CountNums([]int{}))
    assert.Equal(0, CountNums([]int{-1, -2, 0}))
    assert.Equal(6, CountNums([]int{1, 1, 2, -2, 3, 4, 5}))
    assert.Equal(5, CountNums([]int{1, 6, 9, -6, 0, 1, 5}))
    assert.Equal(4, CountNums([]int{1, 100, 98, -7, 1, -1}))
    assert.Equal(5, CountNums([]int{12, 23, 34, -45, -56, 0}))
    assert.Equal(1, CountNums([]int{-0, int(math.Pow(1, 0))}))
    assert.Equal(1, CountNums([]int{1}))
}

package main

import (
    "testing"
    "math"
    "github.com/stretchr/testify/assert"
)

func TestCountNums(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(0+0*int(math.Pow(0, 0)), CountNums([]int{}))
    assert.Equal(1, CountNums([]int{-1, 11, -11}))
    assert.Equal(3, CountNums([]int{1, 1, 2}))
}


Prompt:
import (
    "math"
    "sort"
)

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

    if len(arr)==0 {
      return true
    }
    sorted_array := make([]int, len(arr))
    copy(sorted_array, arr)
    sort.Slice(sorted_array, func(i, j int) bool {
        return sorted_array[i] < sorted_array[j]
    })
    min_value := math.MaxInt
    min_index := -1
    for i, x := range arr {
        if i < min_value {
            min_index, min_value = i, x
        }
    }
    my_arr := make([]int, len(arr[min_index:]))
    copy(my_arr, arr[min_index:])
    my_arr = append(my_arr, arr[0:min_index]...)
    for i :=0;i<len(arr);i++ {
      if my_arr[i]!=sorted_array[i]{
        return false
      }
    }
    return true
}

func TestMoveOneBall(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, MoveOneBall([]int{3, 4, 5, 1, 2}))
    assert.Equal(true, MoveOneBall([]int{3, 5, 10, 1, 2}))
    assert.Equal(false, MoveOneBall([]int{4, 3, 1, 2}))
    assert.Equal(false, MoveOneBall([]int{3, 5, 4, 1, 2}))
    assert.Equal(true, MoveOneBall([]int{}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestMoveOneBall(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, MoveOneBall([]int{3, 4, 5, 1, 2}))
    assert.Equal(false, MoveOneBall([]int{3, 5, 4, 1, 2}))
}


Prompt:
// In this problem, you will implement a function that takes two lists of numbers,
// and determines whether it is possible to perform an Exchange of elements
// between them to make lst1 a list of only even numbers.
// There is no limit on the number of Exchanged elements between lst1 and lst2.
// If it is possible to Exchange elements between the lst1 and lst2 to make
// all the elements of lst1 to be even, return "YES".
// Otherwise, return "NO".
// For example:
// Exchange([1, 2, 3, 4], [1, 2, 3, 4]) => "YES"
// Exchange([1, 2, 3, 4], [1, 5, 3, 4]) => "NO"
// It is assumed that the input lists will be non-empty.
func Exchange(lst1, lst2 []int) string {

    odd := 0
    even := 0
    for _, i := range lst1 {
        if i%2 == 1 {
            odd++
        }
    }
    for _, i := range lst2 {
        if i%2 == 0 {
            even++
        }
    }
    if even >= odd {
        return "YES"
    }
    return "NO"
}

func TestExchange(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("YES", Exchange([]int{1, 2, 3, 4}, []int{1, 2, 3, 4}))
    assert.Equal("NO", Exchange([]int{1, 2, 3, 4}, []int{1, 5, 3, 4}))
    assert.Equal("YES", Exchange([]int{1, 2, 3, 4}, []int{2, 1, 4, 3}))
    assert.Equal("YES", Exchange([]int{5, 7, 3}, []int{2, 6, 4}))
    assert.Equal("NO", Exchange([]int{5, 7, 3}, []int{2, 6, 3}))
    assert.Equal("NO", Exchange([]int{3, 2, 6, 1, 8, 9}, []int{3, 5, 5, 1, 1, 1}))
    assert.Equal("YES", Exchange([]int{100, 200}, []int{200, 200}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestExchange(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("YES", Exchange([]int{1, 2, 3, 4}, []int{1, 2, 3, 4}))
    assert.Equal("NO", Exchange([]int{1, 2, 3, 4}, []int{1, 5, 3, 4}))
}


Prompt:
import (
    "strings"
)

// Given a string representing a space separated lowercase letters, return a dictionary
// of the letter with the most repetition and containing the corresponding count.
// If several letters have the same occurrence, return all of them.
//
// Example:
// Histogram('a b c') == {'a': 1, 'b': 1, 'c': 1}
// Histogram('a b b a') == {'a': 2, 'b': 2}
// Histogram('a b c a b') == {'a': 2, 'b': 2}
// Histogram('b b b b a') == {'b': 4}
// Histogram('') == {}
func Histogram(test string) map[rune]int {

    dict1 := make(map[rune]int)
    list1 := strings.Fields(test)
    t := 0
    count := func(lst []string, v string) int {
        cnt := 0
        for _, i := range lst {
            if i == v {
                cnt++
            }
        }
        return cnt
    }
    for _, i := range list1 {
        if c := count(list1, i); c>t && i!="" {
            t=c
        }
    }
    if t>0 {
        for _, i := range list1 {
            if count(list1, i)==t {
                dict1[[]rune(i)[0]]=t
            }
        }
    }
    return dict1
}

func TestHistogram(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(map[rune]int{'a':2,'b': 2}, Histogram("a b b a"))
    assert.Equal(map[rune]int{'a': 2, 'b': 2}, Histogram("a b c a b"))
    assert.Equal(map[rune]int{'a': 1, 'b': 1, 'c': 1, 'd': 1, 'g': 1}, Histogram("a b c d g"))
    assert.Equal(map[rune]int{'r': 1,'t': 1,'g': 1}, Histogram("r t g"))
    assert.Equal(map[rune]int{'b': 4}, Histogram("b b b b a"))
    assert.Equal(map[rune]int{}, Histogram(""))
    assert.Equal(map[rune]int{'a': 1}, Histogram("a"))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestHistogram(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(map[rune]int{'a':2,'b': 2}, Histogram("a b b a"))
    assert.Equal(map[rune]int{'a': 2, 'b': 2}, Histogram("a b c a b"))
    assert.Equal(map[rune]int{'a': 1,'b': 1,'c': 1}, Histogram("a b c"))
    assert.Equal(map[rune]int{'b': 4}, Histogram("b b b b a"))
    assert.Equal(map[rune]int{}, Histogram(""))
}


Prompt:
import (
    "strings"
)

// Task
// We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
// then check if the result string is palindrome.
// A string is called palindrome if it reads the same backward as forward.
// You should return a tuple containing the result string and true/false for the check.
// Example
// For s = "abcde", c = "ae", the result should be ('bcd',false)
// For s = "abcdef", c = "b"  the result should be ('acdef',false)
// For s = "abcdedcba", c = "ab", the result should be ('cdedc',true)
func ReverseDelete(s,c string) [2]interface{} {

    rs := make([]rune, 0)
    for _, r := range s {
        if !strings.ContainsRune(c, r) {
            rs = append(rs, r)
        }
    }
    t := true
    for i := 0;i < len(rs)>>1;i++ {
        if rs[i] != rs[len(rs)-i-1] {
            t=false
            break
        }
    }
    return [2]interface{}{string(rs), t}
}

func TestReverseDelete(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([2]interface{}{"bcd", false}, ReverseDelete("abcde","ae"))
    assert.Equal([2]interface{}{"acdef", false}, ReverseDelete("abcdef", "b"))
    assert.Equal([2]interface{}{"cdedc", true}, ReverseDelete("abcdedcba","ab"))
    assert.Equal([2]interface{}{"dik", false}, ReverseDelete("dwik","w"))
    assert.Equal([2]interface{}{"", true}, ReverseDelete("a","a"))
    assert.Equal([2]interface{}{"abcdedcba", true}, ReverseDelete("abcdedcba",""))
    assert.Equal([2]interface{}{"abcdedcba", true}, ReverseDelete("abcdedcba","v"))
    assert.Equal([2]interface{}{"abba", true}, ReverseDelete("vabba","v"))
    assert.Equal([2]interface{}{"", true}, ReverseDelete("mamma","mia"))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestReverseDelete(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([2]interface{}{"bcd", false}, ReverseDelete("abcde","ae"))
    assert.Equal([2]interface{}{"acdef", false}, ReverseDelete("abcdef", "b"))
    assert.Equal([2]interface{}{"cdedc", true}, ReverseDelete("abcdedcba","ab"))
}


Prompt:
import (
    "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.
//
// >>> OddCount(['1234567'])
// ["the number of odd elements 4n the str4ng 4 of the 4nput."]
// >>> OddCount(['3',"11111111"])
// ["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 OddCount(lst []string) []string {

    res := make([]string, 0, len(lst))
    for _, arr := range lst {
        n := 0
        for _, d := range arr {
            if (d - '0') % 2 == 1 {
                n++
            }
        }
        res = append(res, fmt.Sprintf("the number of odd elements %dn the str%dng %d of the %dnput.", n,n,n,n))
    }
    return res
}

func TestOddCount(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"the number of odd elements 4n the str4ng 4 of the 4nput."}, OddCount([]string{"1234567"}))
    assert.Equal([]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."}, OddCount([]string{"3", "11111111"}))
    assert.Equal([]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.",
    }, OddCount([]string{"271", "137", "314"}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestOddCount(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"the number of odd elements 4n the str4ng 4 of the 4nput."}, OddCount([]string{"1234567"}))
    assert.Equal([]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."}, OddCount([]string{"3", "11111111"}))
}


Prompt:
import (
    "math"
)

// Given an array of integers nums, find the minimum sum of any non-empty sub-array
// of nums.
// Example
// Minsubarraysum([2, 3, 4, 1, 2, 4]) == 1
// Minsubarraysum([-1, -2, -3]) == -6
func Minsubarraysum(nums []int) int {

    max_sum := 0
    s := 0
    for _, num := range nums {
        s += -num
        if s < 0 {
            s = 0
        }
        if s > max_sum {
            max_sum = s
        }
    }
    if max_sum == 0 {
        max_sum = math.MinInt
        for _, i := range nums {
            if -i > max_sum {
                max_sum = -i
            }
        }
    }
    return -max_sum
}

func TestMinSubArraySum(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(1, Minsubarraysum([]int{2, 3, 4, 1, 2, 4}))
    assert.Equal(-6, Minsubarraysum([]int{-1, -2, -3}))
    assert.Equal(-14, Minsubarraysum([]int{-1, -2, -3, 2, -10}))
    assert.Equal(-9999999999999999, Minsubarraysum([]int{-9999999999999999}))
    assert.Equal(0, Minsubarraysum([]int{0, 10, 20, 1000000}))
    assert.Equal(-6, Minsubarraysum([]int{-1, -2, -3, 10, -5}))
    assert.Equal(-6, Minsubarraysum([]int{100, -1, -2, -3, 10, -5}))
    assert.Equal(3, Minsubarraysum([]int{10, 11, 13, 8, 3, 4}))
    assert.Equal(-33, Minsubarraysum([]int{100, -33, 32, -1, 0, -2}))
    assert.Equal(-10, Minsubarraysum([]int{-10}))
    assert.Equal(7, Minsubarraysum([]int{7}))
    assert.Equal(-1, Minsubarraysum([]int{1, -1}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestMinSubArraySum(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(1, Minsubarraysum([]int{2, 3, 4, 1, 2, 4}))
    assert.Equal(-6, Minsubarraysum([]int{-1, -2, -3}))
}


Prompt:
import (
    "math"
)

// 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:
// Input:
// grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]]
// bucket_capacity : 1
// Output: 6
//
// Example 2:
// Input:
// grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]]
// bucket_capacity : 2
// Output: 5
//
// Example 3:
// Input:
// grid : [[0,0,0], [0,0,0]]
// bucket_capacity : 5
// Output: 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 MaxFill(grid [][]int, capacity int) int {

    result := 0
    for _, arr := range grid {
        sum := 0
        for _, i := range arr {
            sum += i
        }
        result += int(math.Ceil(float64(sum) / float64(capacity)))
    }
    return result
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)


Prompt:
import (
    "fmt"
    "sort"
)

// In this Kata, you have to sort an array of non-negative integers according to
// number of ones in their binary representation in ascending order.
// For similar number of ones, sort based on decimal value.
//
// It must be implemented like this:
// >>> SortArray([1, 5, 2, 3, 4]) == [1, 2, 3, 4, 5]
// >>> SortArray([-2, -3, -4, -5, -6]) == [-6, -5, -4, -3, -2]
// >>> SortArray([1, 0, 2, 3, 4]) [0, 1, 2, 3, 4]
func SortArray(arr []int) []int {

    sort.Slice(arr, func(i, j int) bool {
        return arr[i] < arr[j]
    })
    sort.Slice(arr, func(i, j int) bool {
        key := func(x int) int {
            b := fmt.Sprintf("%b", x)
            cnt := 0
            for _, r := range b {
                if r == '1' {
                    cnt++
                }
            }
            return cnt
        }
        return key(arr[i]) < key(arr[j])
    })
    return arr
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestSortArray(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{1, 2, 4, 3, 5}, SortArray([]int{1,5,2,3,4}))
    assert.Equal([]int{-4, -2, -6, -5, -3}, SortArray([]int{-2,-3,-4,-5,-6}))
    assert.Equal([]int{0, 1, 2, 4, 3}, SortArray([]int{1,0,2,3,4}))
}


Prompt:
import (
    "bytes"
    "strings"
)

// 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:
// SelectWords("Mary had a little lamb", 4) ==> ["little"]
// SelectWords("Mary had a little lamb", 3) ==> ["Mary", "lamb"]
// SelectWords("simple white space", 2) ==> []
// SelectWords("Hello world", 4) ==> ["world"]
// SelectWords("Uncle sam", 3) ==> ["Uncle"]
func SelectWords(s string, n int) []string {

    result := make([]string, 0)
    for _, word := range strings.Fields(s) {
        n_consonants := 0
        lower := strings.ToLower(word)
        for i := 0;i < len(word); i++ {
            if !bytes.Contains([]byte("aeiou"), []byte{lower[i]}) {
                n_consonants++
            }
        }
        if n_consonants == n{
            result = append(result, word)
        }
    }
    return result
}

func TestSelectWords(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"little"}, SelectWords("Mary had a little lamb", 4))
    assert.Equal([]string{"Mary", "lamb"}, SelectWords("Mary had a little lamb", 3))
    assert.Equal([]string{}, SelectWords("simple white space", 2))
    assert.Equal([]string{"world"}, SelectWords("Hello world", 4))
    assert.Equal([]string{"Uncle"}, SelectWords("Uncle sam", 3))
    assert.Equal([]string{}, SelectWords("", 4))
    assert.Equal([]string{"b", "c", "d", "f"}, SelectWords("a b c d e f", 1))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestSelectWords(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"little"}, SelectWords("Mary had a little lamb", 4))
    assert.Equal([]string{"Mary", "lamb"}, SelectWords("Mary had a little lamb", 3))
    assert.Equal([]string{}, SelectWords("simple white space", 2))
    assert.Equal([]string{"world"}, SelectWords("Hello world", 4))
    assert.Equal([]string{"Uncle"}, SelectWords("Uncle sam", 3))
}


Prompt:
import (
    "bytes"
)

// You are given a word. Your task is to find the closest vowel that stands between
// two consonants from the right side of the word (case sensitive).
//
// Vowels in the beginning and ending doesn't count. Return empty string if you didn't
// find any vowel met the above condition.
//
// You may assume that the given string contains English letter only.
//
// Example:
// GetClosestVowel("yogurt") ==> "u"
// GetClosestVowel("FULL") ==> "U"
// GetClosestVowel("quick") ==> ""
// GetClosestVowel("ab") ==> ""
func GetClosestVowel(word string) string {

    if len(word) < 3 {
        return ""
    }

    vowels := []byte("aeiouAEOUI")
    for i := len(word)-2; i > 0; i-- {
        if bytes.Contains(vowels, []byte{word[i]}) {
            if !bytes.Contains(vowels, []byte{word[i+1]}) && !bytes.Contains(vowels, []byte{word[i-1]}) {
                return string(word[i])
            }
        }
    }
    return ""
}

func TestGetClosestVowel(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("u", GetClosestVowel("yogurt"))
    assert.Equal("u", GetClosestVowel("full"))
    assert.Equal("", GetClosestVowel("easy"))
    assert.Equal("", GetClosestVowel("eAsy"))
    assert.Equal("", GetClosestVowel("ali"))
    assert.Equal("a", GetClosestVowel("bad"))
    assert.Equal("o", GetClosestVowel("most"))
    assert.Equal("", GetClosestVowel("ab"))
    assert.Equal("", GetClosestVowel("ba"))
    assert.Equal("", GetClosestVowel("quick"))
    assert.Equal("i", GetClosestVowel("anime"))
    assert.Equal("", GetClosestVowel("Asia"))
    assert.Equal("o", GetClosestVowel("Above"))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestGetClosestVowel(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("u", GetClosestVowel("yogurt"))
    assert.Equal("U", GetClosestVowel("FULL"))
    assert.Equal("", GetClosestVowel("ab"))
    assert.Equal("", GetClosestVowel("quick"))
}


Prompt:
// 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:
// MatchParens(['()(', ')']) == 'Yes'
// MatchParens([')', ')']) == 'No'
func MatchParens(lst []string) string {

    check := func(s string) bool {
        val := 0
        for _, i := range s {
            if i == '(' {
                val++
            } else {
                val--
            }
            if val < 0 {
                return false
            }
        }
        return val == 0
    }

    S1 := lst[0] + lst[1]
    S2 := lst[1] + lst[0]
    if check(S1) || check(S2) {
        return "Yes"
    }
    return "No"
}

func TestMatchParens(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("Yes", MatchParens([]string{"()(", ")"}))
    assert.Equal("No", MatchParens([]string{")", ")"}))
    assert.Equal("No", MatchParens([]string{"(()(())", "())())"}))
    assert.Equal("Yes", MatchParens([]string{")())", "(()()("}))
    assert.Equal("Yes", MatchParens([]string{"(())))", "(()())(("}))
    assert.Equal("No", MatchParens([]string{"()", "())"}))
    assert.Equal("Yes", MatchParens([]string{"(()(", "()))()"}))
    assert.Equal("No", MatchParens([]string{"((((", "((())"}))
    assert.Equal("No", MatchParens([]string{")(()", "(()("}))
    assert.Equal("No", MatchParens([]string{")(", ")("}))
    assert.Equal("Yes", MatchParens([]string{"(", ")"}))
    assert.Equal("Yes", MatchParens([]string{")", "("}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestMatchParens(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("Yes", MatchParens([]string{"()(", ")"}))
    assert.Equal("No", MatchParens([]string{")", ")"}))
}


Prompt:
import (
    "sort"
)

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

    if k == 0 {
        return []int{}
    }
    sort.Slice(arr, func(i, j int) bool {
        return arr[i] < arr[j]
    })
    return arr[len(arr)-k:]
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestMaximum(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{-4, -3, 5}, Maximum([]int{-3, -4, 5}, 3))
    assert.Equal([]int{4, 4}, Maximum([]int{4, -4, 4}, 2))
    assert.Equal([]int{2}, Maximum([]int{-3, 2, 1, 2, -1, -2, 1}, 1))
  }


Prompt:
// Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
//
// Examples
// Solution([5, 8, 7, 1]) ==> 12
// Solution([3, 3, 3, 3, 3]) ==> 9
// Solution([30, 13, 24, 321]) ==>0
func Solution(lst []int) int {

    sum:=0
    for i, x := range lst {
        if i&1==0&&x&1==1 {
            sum+=x
        }
    }
    return sum
}

func TestSolution(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(12, Solution([]int{5, 8, 7, 1}))
    assert.Equal(9, Solution([]int{3, 3, 3, 3, 3}))
    assert.Equal(0, Solution([]int{30, 13, 24, 321}))
    assert.Equal(5, Solution([]int{5, 9}))
    assert.Equal(0, Solution([]int{2, 4, 8}))
    assert.Equal(23, Solution([]int{30, 13, 23, 32}))
    assert.Equal(3, Solution([]int{3, 13, 2, 9}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestSolution(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(12, Solution([]int{5, 8, 7, 1}))
    assert.Equal(9, Solution([]int{3, 3, 3, 3, 3}))
    assert.Equal(0, Solution([]int{30, 13, 24, 321}))
}


Prompt:
import (
    "strconv"
)

// Given a non-empty array 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:
//
// Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4
// Output: 24 # sum of 21 + 3
//
// Constraints:
// 1. 1 <= len(arr) <= 100
// 2. 1 <= k <= len(arr)
func AddElements(arr []int, k int) int {

    sum := 0
    for _, elem := range arr[:k] {
        if len(strconv.Itoa(elem)) <= 2 {
            sum += elem
        }
    }
    return sum
}

func TestAddElements(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(-4, AddElements([]int{1,-2,-3,41,57,76,87,88,99}, 3))
    assert.Equal(0, AddElements([]int{111,121,3,4000,5,6}, 2))
    assert.Equal(125, AddElements([]int{11,21,3,90,5,6,7,8,9}, 4))
    assert.Equal(24, AddElements([]int{111,21,3,4000,5,6,7,8,9}, 4))
    assert.Equal(1, AddElements([]int{1}, 1))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestAddElements(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(24, AddElements([]int{111,21,3,4000,5,6,7,8,9}, 4))
}


Prompt:
import (
    "sort"
)

// Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
//
// The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
// as follows: start with any positive integer n. Then each term is obtained from the
// previous term as follows: if the previous term is even, the next term is one half of
// the previous term. If the previous term is odd, the next term is 3 times the previous
// term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.
//
// Note:
// 1. Collatz(1) is [1].
// 2. returned list sorted in increasing order.
//
// For example:
// GetOddCollatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.
func GetOddCollatz(n int) []int {

    odd_collatz := make([]int, 0)
    if n&1==1 {
        odd_collatz = append(odd_collatz, n)
    }
    for n > 1 {
        if n &1==0 {
            n>>=1
        } else {
            n = n*3 + 1
        }
        if n&1 == 1 {
            odd_collatz = append(odd_collatz, n)
        }
    }
    sort.Slice(odd_collatz, func(i, j int) bool {
        return odd_collatz[i] < odd_collatz[j]
    })
    return odd_collatz
}

func TestGetOddCollatz(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{1, 5, 7, 11, 13, 17}, GetOddCollatz(14))
    assert.Equal([]int{1, 5}, GetOddCollatz(5))
    assert.Equal([]int{1, 3, 5}, GetOddCollatz(12))
    assert.Equal([]int{1}, GetOddCollatz(1))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestGetOddCollatz(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{1, 5}, GetOddCollatz(5))
}


Prompt:
import (
    "strconv"
    "strings"
)

// You have to write a function which validates a given date string and
// returns true if the date is valid otherwise false.
// The date is valid if all of the following rules are satisfied:
// 1. The date string is not empty.
// 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.
// 3. The months should not be less than 1 or higher than 12.
// 4. The date should be in the format: mm-dd-yyyy
//
// for example:
// ValidDate('03-11-2000') => true
//
// ValidDate('15-01-2012') => false
//
// ValidDate('04-0-2040') => false
//
// ValidDate('06-04-2020') => true
//
// ValidDate('06/04/2020') => false
func ValidDate(date string) bool {

    isInArray := func(arr []int, i int) bool {
        for _, x := range arr {
            if i == x {
                return true
            }
        }
        return false
    }

    date = strings.TrimSpace(date)
    split := strings.SplitN(date, "-", 3)
    if len(split) != 3 {
        return false
    }
    month, err := strconv.Atoi(split[0])
    if err != nil {
        return false
    }
    day, err := strconv.Atoi(split[1])
    if err != nil {
        return false
    }
    _, err = strconv.Atoi(split[2])
    if err != nil {
        return false
    }
    if month < 1 || month > 12 {
        return false
    }

    if isInArray([]int{1,3,5,7,8,10,12}, month) && day < 1 || day > 31 {
        return false
    }
    if isInArray([]int{4,6,9,11}, month) && day < 1 || day > 30 {
        return false
    }
    if month == 2 && day < 1 || day > 29 {
        return false
    }

    return true
}

func TestValidDate(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, ValidDate("03-11-2000"))
    assert.Equal(false, ValidDate("15-01-2012"))
    assert.Equal(false, ValidDate("04-0-2040"))
    assert.Equal(true, ValidDate("06-04-2020"))
    assert.Equal(true, ValidDate("01-01-2007"))
    assert.Equal(false, ValidDate("03-32-2011"))
    assert.Equal(false, ValidDate(""))
    assert.Equal(false, ValidDate("04-31-3000"))
    assert.Equal(true, ValidDate("06-06-2005"))
    assert.Equal(false, ValidDate("21-31-2000"))
    assert.Equal(true, ValidDate("04-12-2003"))
    assert.Equal(false, ValidDate("04122003"))
    assert.Equal(false, ValidDate("20030412"))
    assert.Equal(false, ValidDate("2003-04"))
    assert.Equal(false, ValidDate("2003-04-12"))
    assert.Equal(false, ValidDate("04-2003"))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestValidDate(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, ValidDate("03-11-2000"))
    assert.Equal(false, ValidDate("15-01-2012"))
    assert.Equal(false, ValidDate("04-0-2040"))
    assert.Equal(true, ValidDate("06-04-2020"))
    assert.Equal(false, ValidDate("06/04/2020"))
}


Prompt:
import (
    "strings"
)

// Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
// should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
// alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
// Examples
// SplitWords("Hello world!") ➞ ["Hello", "world!"]
// SplitWords("Hello,world!") ➞ ["Hello", "world!"]
// SplitWords("abcdef") == 3
func SplitWords(txt string) interface{} {

    if strings.Contains(txt, " ") {
        return strings.Fields(txt)
    } else if strings.Contains(txt, ",") {
        return strings.Split(txt, ",")
    }
    cnt := 0
    for _, r := range txt {
        if 'a' <= r && r <= 'z' && (r-'a')&1==1 {
            cnt++
        }
    }
    return cnt
}

func TestSplitWords(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"Hello", "world!"}, SplitWords("Hello world!"))
    assert.Equal([]string{"Hello", "world!"}, SplitWords("Hello,world!"))
    assert.Equal([]string{"Hello", "world,!"}, SplitWords("Hello world,!"))
    assert.Equal([]string{"Hello,Hello,world", "!"}, SplitWords("Hello,Hello,world !"))
    assert.Equal(3, SplitWords("abcdef"))
    assert.Equal(2, SplitWords("aaabb"))
    assert.Equal(1, SplitWords("aaaBb"))
    assert.Equal(0, SplitWords(""))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestSplitWords(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"Hello", "world!"}, SplitWords("Hello world!"))
    assert.Equal([]string{"Hello", "world!"}, SplitWords("Hello,world!"))
    assert.Equal(3, SplitWords("abcdef"))
}


Prompt:
// 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
// IsSorted([5]) ➞ true
// IsSorted([1, 2, 3, 4, 5]) ➞ true
// IsSorted([1, 3, 2, 4, 5]) ➞ false
// IsSorted([1, 2, 3, 4, 5, 6]) ➞ true
// IsSorted([1, 2, 3, 4, 5, 6, 7]) ➞ true
// IsSorted([1, 3, 2, 4, 5, 6, 7]) ➞ false
// IsSorted([1, 2, 2, 3, 3, 4]) ➞ true
// IsSorted([1, 2, 2, 2, 3, 4]) ➞ false
func IsSorted(lst []int) bool {

    count_digit := make(map[int]int)
    for _, i := range lst {
        count_digit[i] = 0
    }
    for _, i := range lst {
        count_digit[i]++
    }
    for _, i := range lst {
        if count_digit[i] > 2 {
            return false
        }
    }
    for i := 1;i < len(lst);i++ {
        if lst[i-1] > lst[i] {
            return false
        }
    }
    return true
}

func TestIsSorted(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, IsSorted([]int{5}))
    assert.Equal(true, IsSorted([]int{1, 2, 3, 4, 5}))
    assert.Equal(false, IsSorted([]int{1, 3, 2, 4, 5}))
    assert.Equal(true, IsSorted([]int{1, 2, 3, 4, 5, 6}))
    assert.Equal(true, IsSorted([]int{1, 2, 3, 4, 5, 6, 7}))
    assert.Equal(false, IsSorted([]int{1, 3, 2, 4, 5, 6, 7}))
    assert.Equal(true, IsSorted([]int{}))
    assert.Equal(true, IsSorted([]int{1}))
    assert.Equal(false, IsSorted([]int{3, 2, 1}))
    assert.Equal(false, IsSorted([]int{1, 2, 2, 2, 3, 4}))
    assert.Equal(false, IsSorted([]int{1, 2, 3, 3, 3, 4}))
    assert.Equal(true, IsSorted([]int{1, 2, 2, 3, 3, 4}))
    assert.Equal(true, IsSorted([]int{1, 2, 3, 4}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestIsSorted(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, IsSorted([]int{5}))
    assert.Equal(true, IsSorted([]int{1, 2, 3, 4, 5}))
    assert.Equal(false, IsSorted([]int{1, 3, 2, 4, 5}))
    assert.Equal(true, IsSorted([]int{1, 2, 3, 4, 5, 6}))
    assert.Equal(true, IsSorted([]int{1, 2, 3, 4, 5, 6, 7}))
    assert.Equal(false, IsSorted([]int{1, 3, 2, 4, 5, 6, 7}))
    assert.Equal(false, IsSorted([]int{1, 2, 2, 2, 3, 4}))
    assert.Equal(true, IsSorted([]int{1, 2, 2, 3, 3, 4}))
}


Prompt:
// You are given two intervals,
// where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
// The given intervals are closed which means that the interval (start, end)
// includes both start and end.
// For each given interval, it is assumed that its start is less or equal its end.
// Your task is to determine whether the length of Intersection of these two
// intervals is a prime number.
// Example, the Intersection of the intervals (1, 3), (2, 4) is (2, 3)
// which its length is 1, which not a prime number.
// If the length of the Intersection is a prime number, return "YES",
// otherwise, return "NO".
// If the two intervals don't intersect, return "NO".
//
//
// [input/output] samples:
// Intersection((1, 2), (2, 3)) ==> "NO"
// Intersection((-1, 1), (0, 4)) ==> "NO"
// Intersection((-3, -1), (-5, 5)) ==> "YES"
func Intersection(interval1 [2]int, interval2 [2]int) string {

    is_prime := func(num int) bool {
        if num == 1 || num == 0 {
            return false
        }
        if num == 2 {
            return true
        }
        for i := 2;i < num;i++ {
            if num%i == 0 {
                return false
            }
        }
        return true
    }
    l := interval1[0]
    if interval2[0] > l {
        l = interval2[0]
    }
    r := interval1[1]
    if interval2[1] < r {
        r = interval2[1]
    }
    length := r - l
    if length > 0 && is_prime(length) {
        return "YES"
    }
    return "NO"
}

func TestIntersection(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("NO", Intersection([2]int{1, 2}, [2]int{2, 3}))
    assert.Equal("NO", Intersection([2]int{-1, 1}, [2]int{0, 4}))
    assert.Equal("YES", Intersection([2]int{-3, -1}, [2]int{-5, 5}))
    assert.Equal("YES", Intersection([2]int{-2, 2}, [2]int{-4, 0}))
    assert.Equal("NO", Intersection([2]int{-11, 2}, [2]int{-1, -1}))
    assert.Equal("NO", Intersection([2]int{1, 2}, [2]int{3, 5}))
    assert.Equal("NO", Intersection([2]int{1, 2}, [2]int{1, 2}))
    assert.Equal("NO", Intersection([2]int{-2, -2}, [2]int{-3, -2}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestIntersection(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("NO", Intersection([2]int{1, 2}, [2]int{2, 3}))
    assert.Equal("NO", Intersection([2]int{-1, 1}, [2]int{0, 4}))
    assert.Equal("YES", Intersection([2]int{-3, -1}, [2]int{-5, 5}))
}


Prompt:
import (
    "math"
)

// You are given an array arr of integers and you need to return
// sum of magnitudes of integers multiplied by product of all signs
// of each number in the array, represented by 1, -1 or 0.
// Note: return nil for empty arr.
//
// Example:
// >>> ProdSigns([1, 2, 2, -4]) == -9
// >>> ProdSigns([0, 1]) == 0
// >>> ProdSigns([]) == nil
func ProdSigns(arr []int) interface{} {

    if len(arr) == 0 {
        return nil
    }
    cnt := 0
    sum := 0
    for _, i := range arr {
        if i == 0 {
            return 0
        }
        if i < 0 {
            cnt++
        }
        sum += int(math.Abs(float64(i)))
    }

    prod := int(math.Pow(-1, float64(cnt)))
    return prod * sum
}

func TestProdSigns(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(-9, ProdSigns([]int{1, 2, 2, -4}))
    assert.Equal(0, ProdSigns([]int{0, 1}))
    assert.Equal(-10, ProdSigns([]int{1, 1, 1, 2, 3, -1, 1}))
    assert.Equal(nil, ProdSigns([]int{}))
    assert.Equal(20, ProdSigns([]int{2, 4,1, 2, -1, -1, 9}))
    assert.Equal(4, ProdSigns([]int{-1, 1, -1, 1}))
    assert.Equal(-4, ProdSigns([]int{-1, 1, 1, 1}))
    assert.Equal(0, ProdSigns([]int{-1, 1, 1, 0}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestProdSigns(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(-9, ProdSigns([]int{1, 2, 2, -4}))
    assert.Equal(0, ProdSigns([]int{0, 1}))
    assert.Equal(nil, ProdSigns([]int{}))
}


Prompt:
// 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:
//
// Input: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3
// Output: [1, 2, 1]
//
// Input: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1
// Output: [1]
func Minpath(grid [][]int, k int) []int {

    n := len(grid)
    val := n * n + 1
    for i:= 0;i < n; i++ {
        for j := 0;j < n;j++ {
            if grid[i][j] == 1 {
                temp := make([]int, 0)
                if i != 0 {
                    temp = append(temp, grid[i - 1][j])
                }

                if j != 0 {
                    temp = append(temp, grid[i][j - 1])
                }

                if i != n - 1 {
                    temp = append(temp, grid[i + 1][j])
                }

                if j != n - 1 {
                    temp = append(temp, grid[i][j + 1])
                }
                for _, x := range temp {
                    if x < val {
                        val = x
                    }
                }
            }
        }
    }

    ans := make([]int, 0, k)
    for i := 0;i < k;i++ {
        if i & 1 == 0 {
            ans = append(ans,  1)
        } else {
            ans = append(ans,  val)
        }
    }
    return ans
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)


Prompt:
// 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) = [1, 3, 2, 8]
func Tri(n int) []float64 {

    if n == 0 {
        return []float64{1}
    }
    my_tri := []float64{1, 3}
    for i := 2; i < n + 1; i++ {
        if i &1 == 0 {
            my_tri = append(my_tri, float64(i) / 2 + 1)
        } else {
            my_tri = append(my_tri, my_tri[i - 1] + my_tri[i - 2] + (float64(i) + 3) / 2)
        }
    }
    return my_tri
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestTri(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]float64{1, 3, 2.0, 8.0}, Tri(3))
}


Prompt:
import (
    "strconv"
)

// 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 {

    product := 1
    odd_count := 0
    for _, digit := range strconv.Itoa(n) {
        int_digit := int(digit-'0')
        if int_digit&1 == 1 {
            product= product*int_digit
            odd_count++
        }
    }
    if odd_count==0 {
        return 0
    }
    return product
}

func TestDigits(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(5, Digits(5))
    assert.Equal(5, Digits(54))
    assert.Equal(1, Digits(120))
    assert.Equal(5, Digits(5014))
    assert.Equal(315, Digits(98765))
    assert.Equal(2625, Digits(5576543))
    assert.Equal(0, Digits(2468))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestDigits(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(1, Digits(1))
    assert.Equal(0, Digits(4))
    assert.Equal(15, Digits(235))
}


Prompt:
// 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.
//
// IsNested('[[]]') ➞ true
// IsNested('[]]]]]]][[[[[]') ➞ false
// IsNested('[][]') ➞ false
// IsNested('[]') ➞ false
// IsNested('[[][]]') ➞ true
// IsNested('[[]][[') ➞ true
func IsNested(s string) bool {

    opening_bracket_index := make([]int, 0)
    closing_bracket_index := make([]int, 0)
    for i:=0;i < len(s);i++ {
        if s[i] == '[' {
            opening_bracket_index = append(opening_bracket_index, i)
        } else {
            closing_bracket_index = append(closing_bracket_index, i)
        }
    }
    for i := 0;i < len(closing_bracket_index)>>1;i++ {
        closing_bracket_index[i], closing_bracket_index[len(closing_bracket_index)-i-1] = closing_bracket_index[len(closing_bracket_index)-i-1], closing_bracket_index[i]
    }
    cnt := 0
    i := 0
    l := len(closing_bracket_index)
    for _, idx := range opening_bracket_index {
        if i < l && idx < closing_bracket_index[i] {
            cnt++
            i++
        }
    }
    return cnt >= 2
}

func TestIsNested(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, IsNested("[[]]"))
    assert.Equal(false, IsNested("[]]]]]]][[[[[]"))
    assert.Equal(false, IsNested("[][]"))
    assert.Equal(false, IsNested("'[]'"))
    assert.Equal(true, IsNested("[[[[]]]]"))
    assert.Equal(false, IsNested("[]]]]]]]]]]"))
    assert.Equal(true, IsNested("[][][[]]"))
    assert.Equal(false, IsNested("[[]"))
    assert.Equal(false, IsNested("[]]"))
    assert.Equal(true, IsNested("[[]][["))
    assert.Equal(true, IsNested("[[][]]"))
    assert.Equal(false, IsNested(""))
    assert.Equal(false, IsNested("[[[[[[[["))
    assert.Equal(false, IsNested("]]]]]]]]"))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestIsNested(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, IsNested("[[]]"))
    assert.Equal(false, IsNested("[]]]]]]][[[[[]"))
    assert.Equal(false, IsNested("[][]"))
    assert.Equal(false, IsNested("'[]'"))
    assert.Equal(true, IsNested("[[]][["))
    assert.Equal(true, IsNested("[[][]]"))
}


Prompt:
import (
    "math"
)

// You are given a list of numbers.
// You need to return the sum of squared numbers in the given list,
// round each element in the list to the upper int(Ceiling) first.
// Examples:
// For lst = [1,2,3] the output should be 14
// For lst = [1,4,9] the output should be 98
// For lst = [1,3,5,7] the output should be 84
// For lst = [1.4,4.2,0] the output should be 29
// For lst = [-2.4,1,1] the output should be 6
func SumSquares(lst []float64) int {

    squared := 0
    for _, i := range lst {
        squared += int(math.Pow(math.Ceil(i), 2))
    }
    return squared
}

func TestSumSquares(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(14, SumSquares([]float64{1,2,3}))
    assert.Equal(14, SumSquares([]float64{1.0,2,3}))
    assert.Equal(84, SumSquares([]float64{1,3,5,7}))
    assert.Equal(29, SumSquares([]float64{1.4,4.2,0}))
    assert.Equal(6, SumSquares([]float64{-2.4,1,1}))
    assert.Equal(10230, SumSquares([]float64{100,1,15,2}))
    assert.Equal(200000000, SumSquares([]float64{10000,10000}))
    assert.Equal(75, SumSquares([]float64{-1.4,4.6,6.3}))
    assert.Equal(1086, SumSquares([]float64{-1.4,17.9,18.9,19.9}))
    assert.Equal(0, SumSquares([]float64{0}))
    assert.Equal(1, SumSquares([]float64{-1}))
    assert.Equal(2, SumSquares([]float64{-1,1,0}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestSumSquares(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(14, SumSquares([]float64{1,2,3}))
    assert.Equal(98, SumSquares([]float64{1,4,9}))
    assert.Equal(84, SumSquares([]float64{1,3,5,7}))
    assert.Equal(29, SumSquares([]float64{1.4,4.2,0}))
    assert.Equal(6, SumSquares([]float64{-2.4,1,1}))
}


Prompt:
import (
    "strings"
)

// Create a function that returns true if the last character
// of a given string is an alphabetical character and is not
// a part of a word, and false otherwise.
// Note: "word" is a group of characters separated by space.
//
// Examples:
// CheckIfLastCharIsALetter("apple pie") ➞ false
// CheckIfLastCharIsALetter("apple pi e") ➞ true
// CheckIfLastCharIsALetter("apple pi e ") ➞ false
// CheckIfLastCharIsALetter("") ➞ false
func CheckIfLastCharIsALetter(txt string) bool {

    split := strings.Split(txt, " ")
    check := strings.ToLower(split[len(split)-1])
    if len(check) == 1 && 'a' <= check[0] && check[0] <= 'z' {
        return true
    }
    return false
}

func TestCheckIfLastCharIsALetter(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(false, CheckIfLastCharIsALetter("apple"))
    assert.Equal(true, CheckIfLastCharIsALetter("apple pi e"))
    assert.Equal(false, CheckIfLastCharIsALetter("eeeee"))
    assert.Equal(true, CheckIfLastCharIsALetter("A"))
    assert.Equal(false, CheckIfLastCharIsALetter("Pumpkin pie "))
    assert.Equal(false, CheckIfLastCharIsALetter("Pumpkin pie 1"))
    assert.Equal(false, CheckIfLastCharIsALetter(""))
    assert.Equal(false, CheckIfLastCharIsALetter("eeeee e "))
    assert.Equal(false, CheckIfLastCharIsALetter("apple pie"))
    assert.Equal(false, CheckIfLastCharIsALetter("apple pi e "))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestCheckIfLastCharIsALetter(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, CheckIfLastCharIsALetter("apple pi e"))
    assert.Equal(false, CheckIfLastCharIsALetter(""))
    assert.Equal(false, CheckIfLastCharIsALetter("apple pie"))
    assert.Equal(false, CheckIfLastCharIsALetter("apple pi e "))
}


Prompt:
// Create a function which returns the largest index of an element which
// is not greater than or equal to the element immediately preceding it. If
// no such element exists then return -1. The given array will not contain
// duplicate values.
//
// Examples:
// CanArrange([1,2,4,3,5]) = 3
// CanArrange([1,2,3]) = -1
func CanArrange(arr []int) int {

    ind:=-1
    i:=1
    for i<len(arr) {
      if arr[i]<arr[i-1] {
        ind=i
      }
      i++
    }
    return ind
}

func TestCanArrange(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(3, CanArrange([]int{1,2,4,3,5}))
    assert.Equal(-1, CanArrange([]int{1,2,4,5}))
    assert.Equal(2, CanArrange([]int{1,4,2,5,6,7,8,9,10}))
    assert.Equal(4, CanArrange([]int{4,8,5,7,3}))
    assert.Equal(-1, CanArrange([]int{}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestCanArrange(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(3, CanArrange([]int{1,2,4,3,5}))
    assert.Equal(-1, CanArrange([]int{1,2,3}))
}


Prompt:
// Create a function that returns a tuple (a, b), where 'a' is
// the largest of negative integers, and 'b' is the smallest
// of positive integers in a list.
// If there is no negative or positive integers, return them as nil.
//
// Examples:
// LargestSmallestIntegers([2, 4, 1, 3, 5, 7]) == (nil, 1)
// LargestSmallestIntegers([]) == (nil, nil)
// LargestSmallestIntegers([0]) == (nil, nil)
func LargestSmallestIntegers(lst []int) [2]interface{}{

    smallest := make([]int, 0)
    largest := make([]int, 0)
    for _, x := range lst {
        if x < 0 {
            smallest = append(smallest, x)
        } else if x > 0 {
            largest = append(largest, x)
        }
    }
    var result [2]interface{}
    if len(smallest) == 0 {
        result[0] = nil
    } else {
        max := smallest[0]
        for i := 1;i < len(smallest);i++ {
            if smallest[i] > max {
                max = smallest[i]
            }
        }
        result[0] = max
    }
    if len(largest) == 0 {
        result[1] = nil
    } else {
        min := largest[0]
        for i := 1;i < len(largest);i++ {
            if largest[i] < min {
                min = largest[i]
            }
        }
        result[1] = min
    }
    return result
}

func TestLargestSmallestIntegers(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([2]interface{}{nil, 1}, LargestSmallestIntegers([]int{2, 4, 1, 3, 5, 7}))
    assert.Equal([2]interface{}{nil, 1}, LargestSmallestIntegers([]int{2, 4, 1, 3, 5, 7, 0}))
    assert.Equal([2]interface{}{-2, 1}, LargestSmallestIntegers([]int{1, 3, 2, 4, 5, 6, -2}))
    assert.Equal([2]interface{}{-7, 2}, LargestSmallestIntegers([]int{4, 5, 3, 6, 2, 7, -7}))
    assert.Equal([2]interface{}{-9, 2}, LargestSmallestIntegers([]int{7, 3, 8, 4, 9, 2, 5, -9}))
    assert.Equal([2]interface{}{nil, nil}, LargestSmallestIntegers([]int{}))
    assert.Equal([2]interface{}{nil, nil}, LargestSmallestIntegers([]int{0}))
    assert.Equal([2]interface{}{-1, nil}, LargestSmallestIntegers([]int{-1, -3, -5, -6}))
    assert.Equal([2]interface{}{-1, nil}, LargestSmallestIntegers([]int{-1, -3, -5, -6, 0}))
    assert.Equal([2]interface{}{-3, 1}, LargestSmallestIntegers([]int{-6, -4, -4, -3, 1}))
    assert.Equal([2]interface{}{-3, 1}, LargestSmallestIntegers([]int{-6, -4, -4, -3, -100, 1}))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestLargestSmallestIntegers(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([2]interface{}{nil, 1}, LargestSmallestIntegers([]int{2, 4, 1, 3, 5, 7}))
    assert.Equal([2]interface{}{nil, nil}, LargestSmallestIntegers([]int{}))
    assert.Equal([2]interface{}{nil, nil}, LargestSmallestIntegers([]int{0}))
}


Prompt:
import (
    "fmt"
    "strconv"
    "strings"
)

// Create a function that takes integers, floats, or strings representing
// real numbers, and returns the larger variable in its given variable type.
// Return nil if the values are equal.
// Note: If a real number is represented as a string, the floating point might be . or ,
//
// CompareOne(1, 2.5) ➞ 2.5
// CompareOne(1, "2,3") ➞ "2,3"
// CompareOne("5,1", "6") ➞ "6"
// CompareOne("1", 1) ➞ nil
func CompareOne(a, b interface{}) interface{} {

import (
    "fmt"
    "strconv"
    "strings"
)

    temp_a := fmt.Sprintf("%v", a)
    temp_b := fmt.Sprintf("%v", b)
    temp_a = strings.ReplaceAll(temp_a, ",", ".")
    temp_b = strings.ReplaceAll(temp_b, ",", ".")
    fa, _ := strconv.ParseFloat(temp_a, 64)
    fb, _ := strconv.ParseFloat(temp_b, 64)

    if fa == fb {
        return nil
    }
    if fa > fb {
        return a
    } else {
        return b
    }
}

func TestCompareOne(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(2, CompareOne(1, 2))
    assert.Equal(2.5, CompareOne(1, 2.5))
    assert.Equal(3, CompareOne(2, 3))
    assert.Equal(6, CompareOne(5, 6))
    assert.Equal("2,3", CompareOne(1, "2,3"))
    assert.Equal("6", CompareOne("5,1", "6"))
    assert.Equal("2", CompareOne("1", "2"))
    assert.Equal(nil, CompareOne("1", 1))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestCompareOne(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(2.5, CompareOne(1, 2.5))
    assert.Equal("2,3", CompareOne(1, "2,3"))
    assert.Equal("6", CompareOne("5,1", "6"))
    assert.Equal(nil, CompareOne("1", 1))
}


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

func TestIsEqualToSumEven(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(false, IsEqualToSumEven(4))
    assert.Equal(false, IsEqualToSumEven(6))
    assert.Equal(true, IsEqualToSumEven(8))
    assert.Equal(true, IsEqualToSumEven(10))
    assert.Equal(false, IsEqualToSumEven(11))
    assert.Equal(true, IsEqualToSumEven(12))
    assert.Equal(false, IsEqualToSumEven(13))
    assert.Equal(true, IsEqualToSumEven(16))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestIsEqualToSumEven(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(false, IsEqualToSumEven(4))
    assert.Equal(false, IsEqualToSumEven(6))
    assert.Equal(true, IsEqualToSumEven(8))
}


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

    fact_i := 1
    special_fact := 1
    for i := 1; i <= n; i++ {
        fact_i *= i
        special_fact *= fact_i
    }
    return special_fact
}

func TestSpecialFactorial(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(288, SpecialFactorial(4))
    assert.Equal(34560, SpecialFactorial(5))
    assert.Equal(125411328000, SpecialFactorial(7))
    assert.Equal(1, SpecialFactorial(1))
}

package main

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestSpecialFactorial(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(288, SpecialFactorial(4))
}