2023-11-15 13:28:22 +01:00
|
|
|
package main
|
|
|
|
|
2023-11-15 18:34:41 +01:00
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
2023-11-15 13:28:22 +01:00
|
|
|
|
2023-11-15 18:34:41 +01:00
|
|
|
func GetData(s string) []string {
|
|
|
|
var result []string
|
|
|
|
fileReader, err := os.Open(s)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
lines := bufio.NewScanner(fileReader)
|
|
|
|
lines.Split(bufio.ScanLines)
|
|
|
|
for lines.Scan() {
|
|
|
|
result = append(result, lines.Text())
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
2023-11-15 13:28:22 +01:00
|
|
|
func main() {
|
|
|
|
fmt.Println("GoFast!")
|
2023-11-15 18:34:41 +01:00
|
|
|
|
2023-11-15 13:28:22 +01:00
|
|
|
}
|
|
|
|
|
2023-11-15 18:34:41 +01:00
|
|
|
func Part1(s []string) int {
|
|
|
|
var store []rune
|
|
|
|
var result []string
|
|
|
|
resultLen := len([]rune(s[0]))
|
2023-11-18 10:34:18 +01:00
|
|
|
|
2023-11-15 18:34:41 +01:00
|
|
|
for x := 0; x < resultLen; x++ {
|
2023-11-18 10:34:18 +01:00
|
|
|
zero, one := 0, 0
|
2023-11-15 18:34:41 +01:00
|
|
|
for _, report := range s {
|
|
|
|
chars := []rune(report)
|
|
|
|
store = append(store, chars[x])
|
|
|
|
}
|
|
|
|
for _, data := range store {
|
|
|
|
switch data {
|
|
|
|
case '0':
|
2023-11-18 10:34:18 +01:00
|
|
|
zero += 1
|
2023-11-15 18:34:41 +01:00
|
|
|
case '1':
|
2023-11-18 10:34:18 +01:00
|
|
|
one += 1
|
2023-11-15 18:34:41 +01:00
|
|
|
}
|
|
|
|
}
|
2023-11-18 10:34:18 +01:00
|
|
|
|
2023-11-15 18:34:41 +01:00
|
|
|
fmt.Println(zero, one)
|
|
|
|
if zero < one {
|
|
|
|
result = append(result, "1")
|
|
|
|
} else {
|
|
|
|
result = append(result, "0")
|
|
|
|
}
|
|
|
|
zero, one = 0, 0
|
|
|
|
}
|
|
|
|
fmt.Println(result)
|
2023-11-15 13:28:22 +01:00
|
|
|
return 0
|
|
|
|
}
|