34 lines
416 B
Go
34 lines
416 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"math"
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func main() {
|
|
var sum int
|
|
in := bufio.NewScanner(os.Stdin)
|
|
for in.Scan() {
|
|
sum += diff(in.Text())
|
|
}
|
|
fmt.Println(sum)
|
|
}
|
|
|
|
func diff(l string) int {
|
|
min, max := math.MaxInt64, 0
|
|
for _, s := range strings.Split(l, "\t") {
|
|
i, _ := strconv.Atoi(s)
|
|
if min >= i {
|
|
min = i
|
|
}
|
|
if max <= i {
|
|
max = i
|
|
}
|
|
}
|
|
return max - min
|
|
}
|