Compare commits
3 Commits
77a352aa2e
...
ea037debed
| Author | SHA1 | Date | |
|---|---|---|---|
| ea037debed | |||
| a0a0c43690 | |||
| bce49d51f7 |
@@ -45,11 +45,11 @@ func TestPartTwo(t *testing.T) {
|
|||||||
|
|
||||||
PartTwo(input)
|
PartTwo(input)
|
||||||
|
|
||||||
w.Close()
|
_ = w.Close()
|
||||||
os.Stdout = oldStdout
|
os.Stdout = oldStdout
|
||||||
|
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
buffer.ReadFrom(r)
|
_, _ = buffer.ReadFrom(r)
|
||||||
got := strings.TrimSpace(buffer.String())
|
got := strings.TrimSpace(buffer.String())
|
||||||
|
|
||||||
if got != expected {
|
if got != expected {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ func PartTwo(data []string) int {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, c := range value[1:] {
|
for _, c := range value[1:] {
|
||||||
if !((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) {
|
if (c < '0' || c > '9') && (c < 'a' || c > 'f') {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,8 @@ func init() {
|
|||||||
func ParseInput(filepath string) []string {
|
func ParseInput(filepath string) []string {
|
||||||
content, _ := os.ReadFile(filepath)
|
content, _ := os.ReadFile(filepath)
|
||||||
lines := strings.Split(string(content), "\n")
|
lines := strings.Split(string(content), "\n")
|
||||||
var data []string
|
data := make([]string, 0, len(lines))
|
||||||
for _, line := range lines {
|
return append(data, lines...)
|
||||||
data = append(data, line)
|
|
||||||
}
|
|
||||||
return data
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func PartOne(data []string) int {
|
func PartOne(data []string) int {
|
||||||
|
|||||||
Reference in New Issue
Block a user