Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gerep
Created May 13, 2017 14:05
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 gerep/fc8ae0a9504f90d573ecb662ebf8b95a to your computer and use it in GitHub Desktop.
Save gerep/fc8ae0a9504f90d573ecb662ebf8b95a to your computer and use it in GitHub Desktop.
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
var lines [2]string
var count int
for scanner.Scan() {
lines[count] = scanner.Text()
count++
}
if err := scanner.Err(); err != nil {
log.Fatal(err)
}
alice := strings.Split(lines[0], " ")
bob := strings.Split(lines[1], " ")
ap := 0
bp := 0
if len(alice) != len(bob) {
log.Fatal("Different array sizes")
}
for x := 0; x < len(alice); x++ {
aliceInt, err := strconv.Atoi(alice[x])
if err != nil {
panic(err)
}
bobInt, err := strconv.Atoi(bob[x])
if err != nil {
panic(err)
}
if aliceInt > bobInt {
ap++
} else if aliceInt < bobInt {
bp++
}
}
fmt.Println(ap, bp)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment