Created
May 11, 2015 20:06
-
-
Save spedru/2a38e354b8ed28a3cca0 to your computer and use it in GitHub Desktop.
absolutely stupid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"strings" | |
"time" | |
"unicode/utf8" | |
) | |
func main() { | |
if len(os.Args) < 2 { | |
fmt.Fprintf(os.Stderr, | |
"%s: you must supply at least one argument\n", | |
os.Args[0]) | |
os.Exit(1) | |
} | |
str := strings.Join(os.Args[1:], " ") | |
cnt := utf8.RuneCountInString(str) | |
bubble := []int{2, 3, 3, 4, 5, 4, 3, 3, 2} | |
rail := make([]int, cnt * 2 + len(bubble)) | |
copy(rail[cnt:], bubble) | |
width := cnt * 2 | |
for _, n := range bubble { | |
width += n | |
} | |
for j := len(rail) - cnt; j >= 0; j-- { | |
fmt.Printf("\r%*s\r", width , "") | |
i := 0 | |
for _, r := range str { | |
fmt.Printf("%*c", rail[j+i], r) | |
i++ | |
} | |
time.Sleep(70 * time.Millisecond) | |
} | |
fmt.Print("\n") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment