Exception or error: I want remove spaces in String value, for example: “I d skd a efju N” to “IdskdaefjuN” and it’s not working… I tried using: stringValue = strings.Replace(stringValue, ” “, “”, -1) package main import ( “fmt” “strings” ) func main() { //var String var stringValue string var originalValue string fmt.Printf(“please, type some …

# Tag: algorithmalgorithm

## algorithm – How to split a large csv file into multiple files in GO lang?-ThrowExceptions

Exception or error: I am a novice Go lang programmer,trying to learn Go lang features.I wanted to split a large csv file into multiple files in GO lang, each file containing the header.How do i do this? I have searched everywhere but couldnt get the right solution.Any help in this regard will be greatly appreciated. …

## Go channels in recursive algorithm results in duplicate values-ThrowExceptions

Exception or error: Starting point I have an implementation of Heap’s algorithm to create all permutations of a set in Go: package main import “fmt” func main() { set := []string{“a”, “b”, “c”} Permutation(set, len(set)) } func Permutation(a []string, k int) { if k == 1 { fmt.Println(a) } for i := 0; i < …

## algorithm – Finding pair arrangement in Go-ThrowExceptions

Exception or error: Here I’m trying to form an arrangement that contains pairs of numbers that each pair of m’s are separated by m elements. for example: for [0,2], the pair arrangement is [2,0, 0,2] such that m=2, hence the number 2 is separated by 2 elements. for [0,1] = there is no valid arrangement …

## algorithm – Understanding recursion-ThrowExceptions

Exception or error: As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the …

## algorithm – GoLang Heap and Heapsort-ThrowExceptions

Exception or error: So I’m trying to implement a max heap for practice so I can get familiar with Go. type MaxHeap struct { slice []int heapSize int } func BuildMaxHeap(slice []int) MaxHeap{ h := MaxHeap{slice: slice, heapSize: len(slice)} for i := len(slice)/2; i >= 0; i– { h.MaxHeapify(i) } return h } func (h …

## algorithm – problem: get coin or energy in numerous house-ThrowExceptions

Exception or error: I face the one interview question, I cant able to solve it and google it but no use, Here the question is (Which algorithm is suitable for given below question) There are numerous houses in the line,numbered from 0, Which User can visit. Each house its own amount of energy supply and …

## algorithm – Generate all permutations in go-ThrowExceptions

Exception or error: I am looking for a way to generate all possible permutations of a list of elements. Something similar to python’s itertools.permutations(arr) permutations ([]) [] permutations ([1]) [1] permutations ([1,2]) [1, 2] [2, 1] permutations ([1,2,3]) [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 1, 2] [3, 2, …