Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "log"
- "os"
- "strings"
- )
- func main() {
- if len(os.Args) != 2 {
- log.Fatal("Wrong number of arguments. Correct use: 'go run main.go <your input>'")
- }
- if os.Args[1] == "" {
- return
- }
- // Create an array of lines from ascii art input file
- fileBytes, err := os.ReadFile("standard.txt")
- if err != nil {
- log.Fatal(err)
- }
- fileString := string(fileBytes)
- artArray := strings.Split(fileString, "\n")
- // Take written input from terminal and cut it into an array at "\n"
- inputArray := strings.Split(os.Args[1], "\\n")
- // Print lines from artArray based on input string
- for i := range inputArray {
- if inputArray[i] == "" {
- fmt.Println()
- } else {
- for charLine := 0; charLine < 8; charLine++ { // all ascii characters are 8 lines high
- for j := range inputArray[i] {
- pos := 1 + (int(inputArray[i][j])-32)*9 + charLine
- fmt.Print(artArray[pos])
- }
- fmt.Println()
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement