Created
June 15, 2017 10:34
-
-
Save shravan-shandilya/8eea84fec6d5f18b70e6285cca2c6739 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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