package main import "strings" import "bufio" import "strconv" import "fmt" import "os" func isPossibleTriangle(sides [3]int) bool { sum := 0 for _, i := range(sides) { sum += i } for _, i := range(sides) { if (sum -i <= i) { return false } } return true } func lineToIntArr(line string) [3]int { words := strings.Fields(line) if len(words) == 3 { var wints [3]int i := 0 for _, wstr := range(words) { wints[i], _ = strconv.Atoi(wstr) i++ } return wints } return [3]int { 0, 0, 0 } } func isPossible(line string) bool { wints := lineToIntArr(line) return isPossibleTriangle(wints) } func byLine() int { reader := bufio.NewReader(os.Stdin) result := 0 for true { read, _, err := reader.ReadLine() if isPossible(string(read)) { result++ } if (err != nil) { break } } return result } func byCol() int { result := 0 reader := bufio.NewReader(os.Stdin) i := 0 var triangles [3][3]int for true { read, _, err := reader.ReadLine() currentLine := lineToIntArr(string(read)) triangles[0][i] = currentLine[0] triangles[1][i] = currentLine[1] triangles[2][i] = currentLine[2] if (i == 2) { for _, triangle := range(triangles) { if isPossibleTriangle(triangle) { result++ } } i = 0 } else { i++ } if (err != nil) { break } } return result } func main() { result := byCol() fmt.Println("result is ", result) }