package main import ( "bufio" "fmt" "io" "log" "os" "strconv" "strings" ) func Run(in io.Reader, out io.Writer) error { sc := bufio.NewScanner(in) sc.Scan() lineText := sc.Text() lines := strings.Split(lineText, " ") targetHeightText := lines[0] targetHeight, err := strconv.ParseInt(targetHeightText, 0, 64) if err != nil { return err } order := 1 for sc.Scan() { heightText := sc.Text() height, parseErr := strconv.ParseInt(heightText, 0, 64) if parseErr != nil { return parseErr } if height > targetHeight { order++ } } if order == 1 { fmt.Fprint(out, "1st\n") } else if order == 2 { fmt.Fprint(out, "2nd\n") } else if order == 3 { fmt.Fprint(out, "3rd\n") } else { fmt.Fprintf(out, "%dth\n", order) } return nil } func main() { err := Run(os.Stdin, os.Stdout) if err != nil { log.Fatal(err) } }