Last active
December 27, 2017 01:52
-
-
Save shuntksh/7cc179ed383ffd7d153ef38aad1933c8 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" | |
"strings" | |
"bufio" | |
"bytes" | |
"strconv" | |
"io" | |
"os" | |
) | |
var lines []string | |
func lineToIntArray(line string) []int { | |
arr := strings.Split(line, " ") | |
ret := make([]int, len(arr)) | |
for i, el := range arr { | |
n, err := strconv.Atoi(el) | |
if err != nil { | |
panic(fmt.Sprintf("Failed to convert %v to int: %v", el, err)) | |
} | |
ret[i] = n | |
} | |
return ret | |
} | |
func init() { | |
reader := bufio.NewReader(os.Stdin) | |
buf := bytes.NewBuffer(nil) | |
io.Copy(buf, reader) | |
lines = strings.Split(fmt.Sprint(buf), "\n") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment