-
Notifications
You must be signed in to change notification settings - Fork 17
/
arrow.go
44 lines (40 loc) · 941 Bytes
/
arrow.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"os"
"strconv"
"strings"
)
func getArrowString(arrowSize int) string {
arrow := ""
for line := 0; line < arrowSize; line++ {
arrow += strings.Repeat(" ", arrowSize-line)
arrow += "*"
if line != 0 {
arrow += strings.Repeat(" ", 1+(line-1)*2)
arrow += "*"
}
arrow += "\n"
}
arrow += strings.Repeat("*", arrowSize*2+1)
arrow += "\n"
tailLine := strings.Repeat(" ", arrowSize) + "*" + strings.Repeat(" ", arrowSize) + "\n"
arrow += strings.Repeat(tailLine, arrowSize)
return arrow
}
func main() {
if len(os.Args) < 2 {
fmt.Println("[" + os.Args[0] + "] Please enter one argument")
return
} else if len(os.Args) != 2 {
fmt.Println("[" + os.Args[0] + "] Please enter ONLY one argument")
return
}
arrowSize, err := strconv.Atoi(os.Args[1])
if err != nil {
fmt.Println("First argument must be an integer")
return
}
arrow := getArrowString(arrowSize)
fmt.Print(arrow)
}