package main import ( "fmt" "os" ) func main() { args := os.Args[1:] input := args[0] fmt.Println(input) row, column := getRow(input) fmt.Printf("|%d|%d|\n", row, column) } func getRow(boardingPass string) (int, int) { rowP1 := 0 rowP2 := 127 for _,char := range boardingPass[:7] { if char == 'F' { rowP2 = rowP2 - (rowP2-rowP1)/2 - 1 } if char == 'B' { rowP1 = rowP1 + (rowP2-rowP1)/2 + 1 } } columnP1 := 0 columnP2 := 7 for _,char := range boardingPass[7:] { if char == 'L' { columnP2 = columnP2 - (columnP2-columnP1)/2 - 1 } if char == 'R' { columnP1 = columnP1 + (columnP2-columnP1)/2 + 1 } } return rowP1, columnP1 }