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

    new_text := make([]byte, 0)
    i := 0
    start, end := 0, 0
    for i < len(text) {
        if text[i] == ' ' {
            end++
        } else {
            switch {
            case end - start > 2:
                new_text = append(new_text, '-')
            case end - start > 0:
                for n := 0;n < end-start;n++ {
                    new_text = append(new_text, '_')
                }
            }
            new_text = append(new_text, text[i])
            start, end = i+1, i+1
        }
        i+=1
    }
    if end - start > 2 {
        new_text = append(new_text, '-')
    } else if end - start > 0 {
        new_text = append(new_text, '_')
    }
    return string(new_text)
}

func TestFixSpaces(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("Example", FixSpaces("Example"))
    assert.Equal("Mudasir_Hanif_", FixSpaces("Mudasir Hanif "))
    assert.Equal("Yellow_Yellow__Dirty__Fellow", FixSpaces("Yellow Yellow  Dirty  Fellow"))
    assert.Equal("Exa-mple", FixSpaces("Exa   mple"))
    assert.Equal("-Exa_1_2_2_mple", FixSpaces("   Exa 1 2 2 mple"))
}

package main

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

func TestFixSpaces(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("Example", FixSpaces("Example"))
    assert.Equal("Example_1", FixSpaces("Example 1"))
    assert.Equal("_Example_2", FixSpaces(" Example 2"))
    assert.Equal("_Example-3", FixSpaces(" Example   3"))
}


Prompt:
import (
    "strings"
)

// Create a function which takes a string representing a file's name, and returns
// 'Yes' if the the file's name is valid, and returns 'No' otherwise.
// A file's name is considered to be valid if and only if all the following conditions
// are met:
// - There should not be more than three digits ('0'-'9') in the file's name.
// - The file's name contains exactly one dot '.'
// - The substring before the dot should not be empty, and it starts with a letter from
// the latin alphapet ('a'-'z' and 'A'-'Z').
// - The substring after the dot should be one of these: ['txt', 'exe', 'dll']
// Examples:
// FileNameCheck("example.txt") # => 'Yes'
// FileNameCheck("1example.dll") # => 'No' (the name should start with a latin alphapet letter)
func FileNameCheck(file_name string) string {

    suf := []string{"txt", "exe", "dll"}
    lst := strings.Split(file_name, ".")
    isInArray := func (arr []string, x string) bool {
        for _, y := range arr {
            if x == y {
                return true
            }
        }
        return false
    }
    switch {
    case len(lst) != 2:
        return "No"
    case !isInArray(suf, lst[1]):
        return "No"
    case len(lst[0]) == 0:
        return "No"
    case 'a' > strings.ToLower(lst[0])[0] || strings.ToLower(lst[0])[0] > 'z':
        return "No"
    }
    t := 0
    for _, c := range lst[0] {
        if '0' <= c && c <= '9' {
            t++
        }
    }
    if t > 3 {
        return "No"
    }
    return "Yes"
}

func TestFileNameCheck(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("Yes", FileNameCheck("example.txt"))
    assert.Equal("No", FileNameCheck("1example.dll"))
    assert.Equal("No", FileNameCheck("s1sdf3.asd"))
    assert.Equal("Yes", FileNameCheck("K.dll"))
    assert.Equal("Yes", FileNameCheck("MY16FILE3.exe"))
    assert.Equal("No", FileNameCheck("His12FILE94.exe"))
    assert.Equal("No", FileNameCheck("_Y.txt"))
    assert.Equal("No", FileNameCheck("?aREYA.exe"))
    assert.Equal("No", FileNameCheck("/this_is_valid.dll"))
    assert.Equal("No", FileNameCheck("this_is_valid.wow"))
    assert.Equal("Yes", FileNameCheck("this_is_valid.txt"))
    assert.Equal("No", FileNameCheck("this_is_valid.txtexe"))
    assert.Equal("No", FileNameCheck("#this2_i4s_5valid.ten"))
    assert.Equal("No", FileNameCheck("@this1_is6_valid.exe"))
    assert.Equal("No", FileNameCheck("this_is_12valid.6exe4.txt"))
    assert.Equal("No", FileNameCheck("all.exe.txt"))
    assert.Equal("Yes", FileNameCheck("I563_No.exe"))
    assert.Equal("Yes", FileNameCheck("Is3youfault.txt"))
    assert.Equal("Yes", FileNameCheck("no_one#knows.dll"))
    assert.Equal("No", FileNameCheck("1I563_Yes3.exe"))
    assert.Equal("No", FileNameCheck("I563_Yes3.txtt"))
    assert.Equal("No", FileNameCheck("final..txt"))
    assert.Equal("No", FileNameCheck("final132"))
    assert.Equal("No", FileNameCheck("_f4indsartal132."))
    assert.Equal("No", FileNameCheck(".txt"))
    assert.Equal("No", FileNameCheck("s."))
}

package main

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

func TestFileNameCheck(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("Yes", FileNameCheck("example.txt"))
    assert.Equal("No", FileNameCheck("1example.dll"))
}


Prompt:
import (
    "math"
)

// This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a
// multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not
// change the entries in the list whose indexes are not a multiple of 3 or 4. The function shall then return the sum of all entries.
//
// Examples:
// For lst = [1,2,3] the output should be 6
// For lst = []  the output should be 0
// For lst = [-1,-5,2,-1,-5]  the output should be -126
func SumSquares(lst []int) int {

    result := make([]int, 0)
    for i := 0;i < len(lst);i++ {
        switch {
        case i %3 == 0:
            result = append(result, int(math.Pow(float64(lst[i]), 2)))
        case i % 4 == 0 && i%3 != 0:
            result = append(result, int(math.Pow(float64(lst[i]), 3)))
        default:
            result = append(result, lst[i])
        }
    }
    sum := 0
    for _, x := range result {
        sum += x
    }
    return sum
}

package main

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

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


Prompt:
import (
    "strings"
)

// You are given a string representing a sentence,
// the sentence contains some words separated by a space,
// and you have to return a string that contains the words from the original sentence,
// whose lengths are prime numbers,
// the order of the words in the new string should be the same as the original one.
//
// Example 1:
// Input: sentence = "This is a test"
// Output: "is"
//
// Example 2:
// Input: sentence = "lets go for swimming"
// Output: "go for"
//
// Constraints:
// * 1 <= len(sentence) <= 100
// * sentence contains only letters
func WordsInSentence(sentence string) string {

    new_lst := make([]string, 0)
    for _, word := range strings.Fields(sentence) {
        flg := 0
        if len(word) == 1 {
            flg = 1
        }
        for i := 2;i < len(word);i++ {
            if len(word)%i == 0 {
                flg = 1
            }
        }
        if flg == 0 || len(word) == 2 {
            new_lst = append(new_lst, word)
        }
    }
    return strings.Join(new_lst, " ")
}

func TestWordsInSentence(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("is", WordsInSentence("This is a test"))
    assert.Equal("go for", WordsInSentence("lets go for swimming"))
    assert.Equal("there is no place", WordsInSentence("there is no place available here"))
    assert.Equal("Hi am Hussein", WordsInSentence("Hi I am Hussein"))
    assert.Equal("go for it", WordsInSentence("go for it"))
    assert.Equal("", WordsInSentence("here"))
    assert.Equal("is", WordsInSentence("here is"))
}

package main

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

func TestWordsInSentence(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("is", WordsInSentence("This is a test"))
    assert.Equal("go for", WordsInSentence("lets go for swimming"))
}


Prompt:
import (
    "strconv"
    "strings"
)

// Your task is to implement a function that will Simplify the expression
// x * n. The function returns true if x * n evaluates to a whole number and false
// otherwise. Both x and n, are string representation of a fraction, and have the following format,
// <numerator>/<denominator> where both numerator and denominator are positive whole numbers.
//
// You can assume that x, and n are valid fractions, and do not have zero as denominator.
//
// Simplify("1/5", "5/1") = true
// Simplify("1/6", "2/1") = false
// Simplify("7/10", "10/2") = false
func Simplify(x, n string) bool {

    xx := strings.Split(x, "/")
    nn := strings.Split(n, "/")
    a, _ := strconv.Atoi(xx[0])
    b, _ := strconv.Atoi(xx[1])
    c, _ := strconv.Atoi(nn[0])
    d, _ := strconv.Atoi(nn[1])
    numerator := float64(a*c)
    denom := float64(b*d)
    return numerator/denom == float64(int(numerator/denom))
}

func TestSimplify(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, Simplify("1/5", "5/1"))
    assert.Equal(false, Simplify("1/6", "2/1"))
    assert.Equal(true, Simplify("5/1", "3/1"))
    assert.Equal(false, Simplify("7/10", "10/2"))
    assert.Equal(true, Simplify("2/10", "50/10"))
    assert.Equal(true, Simplify("7/2", "4/2"))
    assert.Equal(true, Simplify("11/6", "6/1"))
    assert.Equal(false, Simplify("2/3", "5/2"))
    assert.Equal(false, Simplify("5/2", "3/5"))
    assert.Equal(true, Simplify("2/4", "8/4"))
    assert.Equal(true, Simplify("2/4", "4/2"))
    assert.Equal(true, Simplify("1/5", "5/1"))
    assert.Equal(false, Simplify("1/5", "1/5"))
}

package main

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

func TestSimplify(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, Simplify("1/5", "5/1"))
    assert.Equal(false, Simplify("1/6", "2/1"))
    assert.Equal(false, Simplify("7/10", "10/2"))
}


Prompt:
import (
    "sort"
    "strconv"
)

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

    digits_sum := func (n int) int {
        neg := 1
        if n < 0 {
            n, neg = -1 * n, -1
        }
        sum := 0
        for i, c := range strconv.Itoa(n) {
            if i == 0 {
                sum += int(c-'0')*neg
            } else {
                sum += int(c-'0')
            }
        }
        return sum
    }
    sort.SliceStable(nums, func(i, j int) bool {
        return digits_sum(nums[i]) < digits_sum(nums[j])
    })
    return nums
}

package main

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

func TestOrderByPoints(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{-1, -11, 1, -12, 11}, OrderByPoints([]int{1, 11, -1, -11, -12}))
    assert.Equal([]int{}, OrderByPoints([]int{}))
}


Prompt:
import (
    "strconv"
)

// Write a function that takes an array of numbers as input and returns
// the number of elements in the array that are greater than 10 and both
// first and last digits of a number are odd (1, 3, 5, 7, 9).
// For example:
// Specialfilter([15, -73, 14, -15]) => 1
// Specialfilter([33, -2, -3, 45, 21, 109]) => 2
func Specialfilter(nums []int) int {

    count := 0
    for _, num := range nums {
        if num > 10 {
            number_as_string := strconv.Itoa(num)
            if number_as_string[0]&1==1 && number_as_string[len(number_as_string)-1]&1==1 {
                count++
            }
        }
    }
    return count
}

func TestSpecialFilter(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(0, Specialfilter([]int{5, -2, 1, -5}))
    assert.Equal(1, Specialfilter([]int{15, -73, 14, -15}))
    assert.Equal(2, Specialfilter([]int{33, -2, -3, 45, 21, 109}))
    assert.Equal(4, Specialfilter([]int{43, -12, 93, 125, 121, 109}))
    assert.Equal(3, Specialfilter([]int{71, -2, -33, 75, 21, 19}))
    assert.Equal(0, Specialfilter([]int{1}))
    assert.Equal(0, Specialfilter([]int{}))
}

package main

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

func TestSpecialFilter(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(1, Specialfilter([]int{15, -73, 14, -15}))
    assert.Equal(2, Specialfilter([]int{33, -2, -3, 45, 21, 109}))
}


Prompt:
// You are given a positive integer n. You have to create an integer array a of length n.
// For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
// Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
// and a[i] + a[j] + a[k] is a multiple of 3.
//
// Example :
// Input: n = 5
// Output: 1
// Explanation:
// a = [1, 3, 7, 13, 21]
// The only valid triple is (1, 7, 13).
func GetMaxTriples(n int) int {

func TestGetMaxTriples(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(1, GetMaxTriples(5))
    assert.Equal(4, GetMaxTriples(6))
    assert.Equal(36, GetMaxTriples(10))
    assert.Equal(53361, GetMaxTriples(100))
}

package main

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

func TestGetMaxTriples(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(1, GetMaxTriples(5))
}


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

    planet_names := []string{"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"}
    pos1 := -1
    pos2 := -1
    for i, x := range planet_names {
        if planet1 == x {
            pos1 = i
        }
        if planet2 == x {
            pos2 = i
        }
    }
    if pos1 == -1 || pos2 == -1 || pos1 == pos2 {
        return []string{}
    }
    if pos1 < pos2 {
        return planet_names[pos1 + 1: pos2]
    }
    return planet_names[pos2 + 1 : pos1]
}

func TestBf(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"Saturn", "Uranus"}, Bf("Jupiter", "Neptune"))
    assert.Equal([]string{"Venus"}, Bf("Earth", "Mercury"))
    assert.Equal([]string{"Venus", "Earth", "Mars", "Jupiter", "Saturn"}, Bf("Mercury", "Uranus"))
    assert.Equal([]string{"Earth", "Mars", "Jupiter", "Saturn", "Uranus"}, Bf("Neptune", "Venus"))
    assert.Equal([]string{}, Bf("Earth", "Earth"))
    assert.Equal([]string{}, Bf("Mars", "Earth"))
    assert.Equal([]string{}, Bf("Jupiter", "Makemake"))
}

package main

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


Prompt:
import (
    "sort"
)

// Write a function that accepts a list of strings as a parameter,
// deletes the strings that have odd lengths from it,
// and returns the resulted list with a sorted order,
// The list is always a list of strings and never an array of numbers,
// and it may contain duplicates.
// The order of the list should be ascending by length of each word, and you
// should return the list sorted by that rule.
// If two words have the same length, sort the list alphabetically.
// The function should return a list of strings in sorted order.
// You may assume that all words will have the same length.
// For example:
// assert list_sort(["aa", "a", "aaa"]) => ["aa"]
// assert list_sort(["ab", "a", "aaa", "cd"]) => ["ab", "cd"]
func SortedListSum(lst []string) []string {

    sort.SliceStable(lst, func(i, j int) bool {
        return lst[i] < lst[j]
    })
    new_lst := make([]string, 0)
    for _, i := range lst {
        if len(i)&1==0 {
            new_lst = append(new_lst, i)
        }
    }
    sort.SliceStable(new_lst, func(i, j int) bool {
        return len(new_lst[i]) < len(new_lst[j])
    })
    return new_lst
}

func TestSortedListSum(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"aa"}, SortedListSum([]string{"aa", "a", "aaa"}))
    assert.Equal([]string{"AI", "asdf", "school"}, SortedListSum([]string{"school", "AI", "asdf", "b"}))
    assert.Equal([]string{}, SortedListSum([]string{"d", "b", "c", "a"}))
    assert.Equal([]string{"abcd", "dcba"}, SortedListSum([]string{"d", "dcba", "abcd", "a"}))
    assert.Equal([]string{"AI", "ai", "au"}, SortedListSum([]string{"AI", "ai", "au"}))
    assert.Equal([]string{}, SortedListSum([]string{"a", "b", "b", "c", "c", "a"}))
    assert.Equal([]string{"cc", "dd", "aaaa", "bbbb"}, SortedListSum([]string{"aaaa", "bbbb", "dd", "cc"}))
}

package main

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

func TestSortedListSum(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]string{"aa"}, SortedListSum([]string{"aa", "a", "aaa"}))
    assert.Equal([]string{"ab", "cd"}, SortedListSum([]string{"ab", "a", "aaa", "cd"}))
}


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

    if n == 1 {
        return y
    }
    for i := 2;i < n;i++ {
        if n % i == 0 {
            return y
        }
    }
    return x
}

func TestXOrY(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(34, XOrY(7, 34, 12))
    assert.Equal(5, XOrY(15, 8, 5))
    assert.Equal(33, XOrY(3, 33, 5212))
    assert.Equal(3, XOrY(1259, 3, 52))
    assert.Equal(-1, XOrY(7919, -1, 12))
    assert.Equal(583, XOrY(3609, 1245, 583))
    assert.Equal(129, XOrY(91, 56, 129))
    assert.Equal(1234, XOrY(6, 34, 1234))
    assert.Equal(0, XOrY(1, 2, 0))
    assert.Equal(2, XOrY(2, 2, 0))
}

package main

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

func TestXOrY(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(34, XOrY(7, 34, 12))
    assert.Equal(5, XOrY(15, 8, 5))
}


Prompt:
import (
    "math"
)

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

    sum := 0
    for _, i := range lst {
        if i > 0 && math.Mod(i, 2) != 0 && i == float64(int(i)) {
            sum += int(math.Pow(i, 2))
        }
    }
    return sum
}

func TestDoubleTheDifference(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(0, DoubleTheDifference([]float64{}))
    assert.Equal(25, DoubleTheDifference([]float64{5, 4}))
    assert.Equal(0, DoubleTheDifference([]float64{0.1, 0.2, 0.3}))
    assert.Equal(0, DoubleTheDifference([]float64{-10, -20, -30}))
    assert.Equal(0, DoubleTheDifference([]float64{-1, -2, 8}))
    assert.Equal(34, DoubleTheDifference([]float64{0.2, 3, 5}))
    lst := make([]float64, 0)
    odd_sum := 0
    var i float64
    for i = -99; i < 100; i+= 2 {
        lst = append(lst, float64(i))
        if math.Mod(i, 2) != 0 && i > 0 {
            odd_sum +=int(math.Pow(i, 2))
        }
    }
    assert.Equal(odd_sum, DoubleTheDifference(lst))
}

package main

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

func TestDoubleTheDifference(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(10, DoubleTheDifference([]float64{1,3,2,0}))
    assert.Equal(0, DoubleTheDifference([]float64{-1,-2,0}))
    assert.Equal(81, DoubleTheDifference([]float64{9,-2}))
    assert.Equal(0, DoubleTheDifference([]float64{0}))
}


Prompt:
import (
    "math"
)

// I think we all remember that feeling when the result of some long-awaited
// event is finally known. The feelings and thoughts you have at that moment are
// definitely worth noting down and comparing.
// Your task is to determine if a person correctly guessed the results of a number of matches.
// You are given two arrays of scores and guesses of equal length, where each index shows a match.
// Return an array of the same length denoting how far off each guess was. If they have guessed correctly,
// the value is 0, and if not, the value is the absolute difference between the guess and the score.
//
//
// example:
//
// Compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3]
// Compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6]
func Compare(game,guess []int) []int {

    ans := make([]int, 0, len(game))
    for i := range game {
        ans = append(ans, int(math.Abs(float64(game[i]-guess[i]))))
    }
    return ans
}

package main

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


Prompt:
import (
    "math"
)

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

    strong := extensions[0]

    my_val := math.MinInt
    for _, s := range extensions {
        cnt0, cnt1 := 0, 0
        for _, c := range s {
            switch {
            case 'A' <= c && c <= 'Z':
                cnt0++
            case 'a' <= c && c <= 'z':
                cnt1++
            }
        }
        val := cnt0-cnt1
        if val > my_val {
            strong = s
            my_val = val
        }
    }
    return class_name + "." + strong
}

func TestStrongestExtension(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("Watashi.eIGHt8OKe", StrongestExtension("Watashi", []string{"tEN", "niNE", "eIGHt8OKe"}))
    assert.Equal("Boku123.YEs.WeCaNe", StrongestExtension("Boku123", []string{"nani", "NazeDa", "YEs.WeCaNe", "32145tggg"}))
    assert.Equal("__YESIMHERE.NuLl__", StrongestExtension("__YESIMHERE", []string{"t", "eMptY", "nothing", "zeR00", "NuLl__", "123NoooneB321"}))
    assert.Equal("K.TAR", StrongestExtension("K", []string{"Ta", "TAR", "t234An", "cosSo"}))
    assert.Equal("__HAHA.123", StrongestExtension("__HAHA", []string{"Tab", "123", "781345", "-_-"}))
    assert.Equal("YameRore.okIWILL123", StrongestExtension("YameRore", []string{"HhAas", "okIWILL123", "WorkOut", "Fails", "-_-"}))
    assert.Equal("finNNalLLly.WoW", StrongestExtension("finNNalLLly", []string{"Die", "NowW", "Wow", "WoW"}))
    assert.Equal("_.Bb", StrongestExtension("_", []string{"Bb", "91245"}))
    assert.Equal("Sp.671235", StrongestExtension("Sp", []string{"671235", "Bb"}))
}

package main

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

func TestStrongestExtension(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("my_class.AA", StrongestExtension("my_class", []string{"AA", "Be", "CC"}))
}


Prompt:
// You are given 2 words. You need to return true if the second word or any of its rotations is a substring in the first word
// CycpatternCheck("abcd","abd") => false
// CycpatternCheck("hello","ell") => true
// CycpatternCheck("whassup","psus") => false
// CycpatternCheck("abab","baa") => true
// CycpatternCheck("efef","eeff") => false
// CycpatternCheck("himenss","simen") => true
func CycpatternCheck(a , b string) bool {

    l := len(b)
    pat := b + b
    for i := 0;i < len(a) - l + 1; i++ {
        for j := 0;j<l + 1;j++ {
            if a[i:i+l] == pat[j:j+l] {
                return true
            }
        }
    }
    return false
}

func TestCycpatternCheck(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(false, CycpatternCheck("xyzw", "xyw"))
    assert.Equal(true, CycpatternCheck("yello", "ell"))
    assert.Equal(false, CycpatternCheck("whattup", "ptut"))
    assert.Equal(true, CycpatternCheck("efef", "fee"))
    assert.Equal(false, CycpatternCheck("abab", "aabb"))
    assert.Equal(true, CycpatternCheck("winemtt", "tinem"))
}

package main

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

func TestCycpatternCheck(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(false, CycpatternCheck("abcd", "abd"))
    assert.Equal(true, CycpatternCheck("hello", "ell"))
    assert.Equal(false, CycpatternCheck("whasup", "psus"))
    assert.Equal(true, CycpatternCheck("abab", "baa"))
    assert.Equal(false, CycpatternCheck("efef", "eeff"))
    assert.Equal(true, CycpatternCheck("himenss", "simen"))
}


Prompt:
import (
    "strconv"
)

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

    even_count := 0
    odd_count := 0
    if num < 0 {
        num = -num
    }
    for _, r := range strconv.Itoa(num) {
        if r&1==0 {
            even_count++
        } else {
            odd_count++
        }
    }
    return [2]int{even_count, odd_count}
}

func TestEvenOddCount(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([2]int{0, 1}, EvenOddCount(7))
    assert.Equal([2]int{1, 1}, EvenOddCount(-78))
    assert.Equal([2]int{2, 2}, EvenOddCount(3452))
    assert.Equal([2]int{3, 3}, EvenOddCount(346211))
    assert.Equal([2]int{3, 3}, EvenOddCount(-345821))
    assert.Equal([2]int{1, 0}, EvenOddCount(-2))
    assert.Equal([2]int{2, 3}, EvenOddCount(-45347))
    assert.Equal([2]int{1, 0}, EvenOddCount(0))
}

package main

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

func TestEvenOddCount(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([2]int{1, 1}, EvenOddCount(-12))
    assert.Equal([2]int{1, 2}, EvenOddCount(123))
}


Prompt:
import (
    "strings"
)

// Given a positive integer, obtain its roman numeral equivalent as a string,
// and return it in lowercase.
// Restrictions: 1 <= num <= 1000
//
// Examples:
// >>> IntToMiniRoman(19) == 'xix'
// >>> IntToMiniRoman(152) == 'clii'
// >>> IntToMiniRoman(426) == 'cdxxvi'
func IntToMiniRoman(number int) string {

func TestIntToMiniRoman(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("xix", IntToMiniRoman(19))
    assert.Equal("clii", IntToMiniRoman(152))
    assert.Equal("ccli", IntToMiniRoman(251))
    assert.Equal("cdxxvi", IntToMiniRoman(426))
    assert.Equal("d", IntToMiniRoman(500))
    assert.Equal("i", IntToMiniRoman(1))
    assert.Equal("iv", IntToMiniRoman(4))
    assert.Equal("xliii", IntToMiniRoman(43))
    assert.Equal("xc", IntToMiniRoman(90))
    assert.Equal("xciv", IntToMiniRoman(94))
    assert.Equal("dxxxii", IntToMiniRoman(532))
    assert.Equal("cm", IntToMiniRoman(900))
    assert.Equal("cmxciv", IntToMiniRoman(994))
    assert.Equal("m", IntToMiniRoman(1000))
}

package main

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

func TestIntToMiniRoman(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("xix", IntToMiniRoman(19))
    assert.Equal("clii", IntToMiniRoman(152))
    assert.Equal("cdxxvi", IntToMiniRoman(426))
}


Prompt:
// Given the lengths of the three sides of a triangle. Return true if the three
// sides form a right-angled triangle, false otherwise.
// A right-angled triangle is a triangle in which one angle is right angle or
// 90 degree.
// Example:
// RightAngleTriangle(3, 4, 5) == true
// RightAngleTriangle(1, 2, 3) == false
func RightAngleTriangle(a, b, c int) bool {

    return a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b
}

func TestRightAngleTriangle(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, RightAngleTriangle(3, 4, 5))
    assert.Equal(false, RightAngleTriangle(1, 2, 3))
    assert.Equal(true, RightAngleTriangle(10, 6, 8))
    assert.Equal(false, RightAngleTriangle(2, 2, 2))
    assert.Equal(true, RightAngleTriangle(7, 24, 25))
    assert.Equal(false, RightAngleTriangle(10, 5, 7))
    assert.Equal(true, RightAngleTriangle(5, 12, 13))
    assert.Equal(true, RightAngleTriangle(15, 8, 17))
    assert.Equal(true, RightAngleTriangle(48, 55, 73))
    assert.Equal(false, RightAngleTriangle(1, 1, 1))
    assert.Equal(false, RightAngleTriangle(2, 2, 10))
}

package main

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

func TestRightAngleTriangle(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(true, RightAngleTriangle(3, 4, 5))
    assert.Equal(false, RightAngleTriangle(1, 2, 3))
}


Prompt:
import (
    "sort"
)

// Write a function that accepts a list of strings.
// The list contains different words. Return the word with maximum number
// of unique characters. If multiple strings have maximum number of unique
// characters, return the one which comes first in lexicographical order.
//
// FindMax(["name", "of", "string"]) == "string"
// FindMax(["name", "enam", "game"]) == "enam"
// FindMax(["aaaaaaa", "bb" ,"cc"]) == ""aaaaaaa"
func FindMax(words []string) string {

    key := func (word string) (int, string) {
        set := make(map[rune]struct{})
        for _, r := range word {
            set[r] = struct{}{}
        }
        return -len(set), word
    }
    sort.SliceStable(words, func(i, j int) bool {
        ia, ib := key(words[i])
        ja, jb := key(words[j])
        if ia == ja {
            return ib < jb
        }
        return ia < ja
    })
    return words[0]
}

func TestFindMax(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("string", FindMax([]string{"name", "of", "string"}))
    assert.Equal("enam", FindMax([]string{"name", "enam", "game"}))
    assert.Equal("aaaaaaa", FindMax([]string{"aaaaaaa", "bb", "cc"}))
    assert.Equal("abc", FindMax([]string{"abc", "cba"}))
    assert.Equal("footbott", FindMax([]string{"play", "this", "game", "of", "footbott"}))
    assert.Equal("gonna", FindMax([]string{"we", "are", "gonna", "rock"}))
    assert.Equal("nation", FindMax([]string{"we", "are", "a", "mad", "nation"}))
    assert.Equal("this", FindMax([]string{"this", "is", "a", "prrk"}))
}

package main

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

func TestFindMax(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("string", FindMax([]string{"name", "of", "string"}))
    assert.Equal("enam", FindMax([]string{"name", "enam", "game"}))
    assert.Equal("aaaaaaa", FindMax([]string{"aaaaaaa", "bb", "cc"}))
}


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

    if(need <= remaining) {
        return []int{ number + need , remaining-need }
    }
    return []int{ number + remaining , 0}
}

func TestEat(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{11, 4}, Eat(5, 6, 10))
    assert.Equal([]int{12, 1}, Eat(4, 8, 9))
    assert.Equal([]int{11, 0}, Eat(1, 10, 10))
    assert.Equal([]int{7, 0}, Eat(2, 11, 5))
    assert.Equal([]int{9, 2}, Eat(4, 5, 7))
    assert.Equal([]int{5, 0}, Eat(4, 5, 1))
}

package main

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

func TestEat(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{11, 4}, Eat(5, 6, 10))
    assert.Equal([]int{12, 1}, Eat(4, 8, 9))
    assert.Equal([]int{11, 0}, Eat(1, 10, 10))
    assert.Equal([]int{7, 0}, Eat(2, 11, 5))
}


Prompt:
import (
    "math"
)

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

    higher := func(a, b string) bool {
        if b == "*" || b == "//" || b == "**" {
            return false
        }
        if a == "*" || a == "//" || a == "**" {
            return true
        }
        return false
    }
    for len(operand) > 1 {
        pos := 0
        sign := operator[0]
        for i, str := range operator {
            if higher(str, sign) {
                sign = str
                pos = i
            }
        }
        switch sign {
        case "+":
            operand[pos] += operand[pos+1]
        case "-":
            operand[pos] -= operand[pos+1]
        case "*":
            operand[pos] *= operand[pos+1]
        case "//":
            operand[pos] /= operand[pos+1]
        case "**":
            operand[pos] = int(math.Pow(float64(operand[pos]), float64(operand[pos+1])))
        }
        operator = append(operator[:pos], operator[pos+1:]...)
        operand = append(operand[:pos+1], operand[pos+2:]...)
    }
    return operand [0]
}

func TestDoAlgebra(t *testing.T) {
    assert := assert.New(t)
    assert.Equal(37, DoAlgebra([]string{"**", "*", "+"}, []int{2, 3, 4, 5}))
    assert.Equal(9, DoAlgebra([]string{"+", "*", "-"}, []int{2, 3, 4, 5}))
    assert.Equal(8, DoAlgebra([]string{"//", "*"}, []int{7, 3, 4}))
}

package main

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


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

    flg := 0
    new_str := []rune(s)
    for i, r := range new_str {
        if ('a' <= r && r <= 'z') || ('A' <= r && r <= 'Z') {
            if 'a' <= r && r <= 'z' {
                new_str[i] = r - 'a' + 'A'
            } else {
                new_str[i] = r - 'A' + 'a'
            }
            flg = 1
        }
    }
    if flg == 0 {
        for i := 0;i < len(new_str)>>1;i++ {
            new_str[i], new_str[len(new_str)-i-1] = new_str[len(new_str)-i-1], new_str[i]
        }
    }
    return string(new_str)
}

func TestSolve(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("aSdF", Solve("AsDf"))
    assert.Equal("4321", Solve("1234"))
    assert.Equal("AB", Solve("ab"))
    assert.Equal("#A@c", Solve("#a@C"))
    assert.Equal("#aSDFw^45", Solve("#AsdfW^45"))
    assert.Equal("2@6#", Solve("#6@2"))
    assert.Equal("#$A^d", Solve("#$a^D"))
    assert.Equal("#CCC", Solve("#ccc"))
}

package main

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

func TestSolve(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("4321", Solve("1234"))
    assert.Equal("AB", Solve("ab"))
    assert.Equal("#A@c", Solve("#a@C"))
}


Prompt:
import (
    "crypto/md5"
    "fmt"
)

// Given a string 'text', return its md5 hash equivalent string.
// If 'text' is an empty string, return nil.
//
// >>> StringToMd5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
func StringToMd5(text string) interface{} {

    if text == "" {
        return nil
    }
    return fmt.Sprintf("%x", md5.Sum([]byte(text)))
}

func TestStringToMd5(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("3e25960a79dbc69b674cd4ec67a72c62", StringToMd5("Hello world"))
    assert.Equal(nil, StringToMd5(""))
    assert.Equal("0ef78513b0cb8cef12743f5aeb35f888", StringToMd5("A B C"))
    assert.Equal("5f4dcc3b5aa765d61d8327deb882cf99", StringToMd5("password"))
}

package main

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

func TestStringToMd5(t *testing.T) {
    assert := assert.New(t)
    assert.Equal("3e25960a79dbc69b674cd4ec67a72c62", StringToMd5("Hello world"))
}


Prompt:
// Given two positive integers a and b, return the even digits between a
// and b, in ascending order.
//
// For example:
// GenerateIntegers(2, 8) => [2, 4, 6, 8]
// GenerateIntegers(8, 2) => [2, 4, 6, 8]
// GenerateIntegers(10, 14) => []
func GenerateIntegers(a, b int) []int {

    min := func (a, b int) int {
        if a > b {
            return b
        }
        return a
    }
    max := func (a, b int) int {
        if a > b {
            return a
        }
        return b
    }
    lower := max(2, min(a, b))
    upper := min(8, max(a, b))
    ans := make([]int, 0)
    for i := lower;i <= upper;i++ {
        if i&1==0 {
            ans = append(ans, i)
        }
    }
    return ans
}

func TestGenerateIntegers(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{2, 4, 6, 8}, GenerateIntegers(2, 10))
    assert.Equal([]int{2, 4, 6, 8}, GenerateIntegers(10, 2))
    assert.Equal([]int{2, 4, 6, 8}, GenerateIntegers(132, 2))
    assert.Equal([]int{}, GenerateIntegers(17, 89))
}

package main

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

func TestGenerateIntegers(t *testing.T) {
    assert := assert.New(t)
    assert.Equal([]int{2, 4, 6, 8}, GenerateIntegers(2, 8))
    assert.Equal([]int{2, 4, 6, 8}, GenerateIntegers(8, 2))
    assert.Equal([]int{}, GenerateIntegers(10, 14))
}