func fizzBuzz(i int) string { switch true { case i%3 == 0 && i%5 == 0: return "fizzbuzz" case i%3 == 0: return "fizz" case i%5 == 0: return "buzz" default: return strconv.Itoa(i) } }
func arrayChunk(arr []int, size int) [][]int { if len(arr) <= 0 { return nil } var tmp []int var chunkedArr [][]int for i, item := range arr { tmp = append(tmp, item) isFinal := len(arr)-1 == i if i%size == size-1 || isFinal { fmt.Printf("%v", tmp) chunkedArr = append(chunkedArr, tmp) tmp = nil } } return chunkedArr }
package main // return whether it is a palindrome or not func main() { return } // String converts string struct expecting palindromes type String struct { str string } func newPalindrome(s string) String { return String{s} } func (s String) isPalindrome() bool { r := []rune(s.str) for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 { if r[i] != r[j] { return false } } return true }