40 lines
503 B
Go
40 lines
503 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"bufio"
|
||
|
"fmt"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
//const entryBits = 12
|
||
|
//const entryBits = 5
|
||
|
|
||
|
func main() {
|
||
|
zeroes := [entryBits]int{}
|
||
|
ones := [entryBits]int{}
|
||
|
|
||
|
s := bufio.NewScanner(os.Stdin)
|
||
|
for s.Scan() {
|
||
|
for i, v := range s.Bytes() {
|
||
|
if v == '0' {
|
||
|
zeroes[i]++
|
||
|
} else {
|
||
|
ones[i]++
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
gamma := 0
|
||
|
|
||
|
for i := range zeroes {
|
||
|
if ones[i] > zeroes[i] {
|
||
|
gamma |= 1 << (entryBits - i - 1)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
epsilon := gamma ^ ((1 << entryBits) - 1)
|
||
|
|
||
|
fmt.Println(gamma * epsilon)
|
||
|
}
|