Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shravan-shandilya/8eea84fec6d5f18b70e6285cca2c6739 to your computer and use it in GitHub Desktop.
Save shravan-shandilya/8eea84fec6d5f18b70e6285cca2c6739 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"strconv"
"strings"
"bufio"
"os"
)
func cleanString(stream,seperator string) []int{
trimmed_stream := strings.TrimSpace(stream)
split_arr := strings.Split(trimmed_stream, seperator)
clean_arr := make([]int, len(split_arr))
for index,val := range split_arr{
clean_arr[index], _ = strconv.Atoi(val)
}
return clean_arr
}
func main() {
reader := bufio.NewReader(os.Stdin)
stream,_ := reader.ReadString('\n')
N := cleanString(stream," ")[0]
stream,_ = reader.ReadString('\n')
array := cleanString(stream," ")
sum := 0
for i:=0;i<N;i++{
sum += array[i]
}
fmt.Println(sum)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment