33 lines
643 B
Go
33 lines
643 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"internal/util"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
ids := util.ReadInput()
|
||
|
|
||
|
for _, box1 := range ids {
|
||
|
for _, box2 := range ids {
|
||
|
diffIndex := -1 // diffIndex doubles as the letter to remove and a 'found' flag
|
||
|
for i := range box1 {
|
||
|
if box1[i] != box2[i] {
|
||
|
if diffIndex != -1 {
|
||
|
// If we reach here, we've detected more than one error, so we set
|
||
|
// diffIndex back to -1 here to avoid the conditional below this loop.
|
||
|
diffIndex = -1
|
||
|
break
|
||
|
}
|
||
|
diffIndex = i
|
||
|
}
|
||
|
}
|
||
|
if diffIndex != -1 {
|
||
|
fmt.Printf("%s%s\n", box1[0:diffIndex], box1[diffIndex+1:])
|
||
|
return
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|