Created
May 13, 2017 14:05
-
-
Save gerep/fc8ae0a9504f90d573ecb662ebf8b95a 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 ( | |
"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