commit 20c0a2b73171d5c7e3431feb0918946d72b1592f Author: Jacob Date: Mon Nov 1 18:24:18 2021 +0200 works diff --git a/main.go b/main.go new file mode 100644 index 0000000..5f06b38 --- /dev/null +++ b/main.go @@ -0,0 +1,52 @@ +package main + +import ( + "fmt" + "io" + "net/http" + "os" + "strings" +) + +func main() { + banner := "shadow" + ascii, err := http.Get("https://git.01.kood.tech/root/public/raw/branch/master/subjects/ascii-art/" + banner + ".txt") + + asciiBody, err := io.ReadAll(ascii.Body) + if err != nil { + return + } + args := os.Args[1] + loopCount := 0 + var newlinePos []int + var hasNewLine bool + asciiSplit := strings.Split(string(asciiBody), "\n") + for i := 0; i < 8; i++ { + for j := 0; j < len(args); j++ { + hasNewLine = false + if args[j] == '\\' && args[j+1] == 'n' { + // fmt.Println() + newlinePos = append(newlinePos, j) + + hasNewLine = true + fmt.Println() + break + } + fmt.Printf(string(asciiSplit[(int(args[j])-32)*8+(int(args[j])-32)+i+1])) + + if j == len(args)-1 { + fmt.Println() + } + } + // fmt.Println() + if i == 7 { + if hasNewLine == true { + fmt.Println() + i = 0 + hasNewLine = false + args = args[newlinePos[loopCount*8]+2:] + loopCount++ + } + } + } +}