🚧 Add Defrag function
This commit is contained in:
parent
2f165369cc
commit
932e8e2f11
7 changed files with 136 additions and 1 deletions
36
cmd/defrag/main.go
Normal file
36
cmd/defrag/main.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"bytes"
|
||||
|
||||
"codeberg.org/danjones000/advent-of-code/2024-09/defrag"
|
||||
)
|
||||
|
||||
func handleErr(err error) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
name := os.Args[0]
|
||||
|
||||
input, err := io.ReadAll(os.Stdin)
|
||||
handleErr(err)
|
||||
|
||||
fmt.Fprintln(os.Stderr, "Welcome to ", name)
|
||||
input = bytes.TrimSpace(input)
|
||||
|
||||
blocks, err := defrag.Blocks(input)
|
||||
handleErr(err)
|
||||
|
||||
fmt.Println("@TODO")
|
||||
fmt.Println("Got this")
|
||||
fmt.Printf("%s\n", blocks)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue