Skip to content

Instantly share code, notes, and snippets.

@shuntksh
Last active December 27, 2017 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shuntksh/7cc179ed383ffd7d153ef38aad1933c8 to your computer and use it in GitHub Desktop.
Save shuntksh/7cc179ed383ffd7d153ef38aad1933c8 to your computer and use it in GitHub Desktop.
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