🚧 Add Defrag function

This commit is contained in:
Dan Jones 2024-12-09 12:30:41 -06:00
commit 932e8e2f11
7 changed files with 136 additions and 1 deletions

36
cmd/defrag/main.go Normal file
View 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)
}