Created
March 26, 2018 08:02
-
-
Save danrl/82ad4a53eb783051d13e2230440e5c24 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" | |
"log" | |
"os" | |
"strconv" | |
"strings" | |
) | |
func main() { | |
scanner := bufio.NewScanner(os.Stdin) | |
lastID := -1 | |
for scanner.Scan() { | |
columns := strings.Split(scanner.Text(), ",") | |
id, err := strconv.Atoi(columns[0]) | |
if err != nil { | |
log.Fatalf("ParseInt: %v", err) | |
} | |
if id <= lastID { | |
log.Fatal("😭") | |
} | |
lastID = id | |
} | |
if err := scanner.Err(); err != nil { | |
log.Fatal("scanner: %v", err) | |
} | |
log.Println("👍") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment