Skip to content

Instantly share code, notes, and snippets.

@qi7chen
Created August 26, 2015 07:51
Show Gist options
  • Save qi7chen/501e4029a306b1516028 to your computer and use it in GitHub Desktop.
Save qi7chen/501e4029a306b1516028 to your computer and use it in GitHub Desktop.
print big digit
package main
import (
"fmt"
"os"
"path/filepath"
)
var print = fmt.Println
func main() {
progname := filepath.Base(os.Args[0])
if len(os.Args) < 2 {
print("Usage: %s <whole-number", progname)
os.Exit(1)
}
number := os.Args[1]
for row := 0; row < len(bigDigits[0]); row++ {
line := ""
for _, ch := range number {
digit := ch - '0'
if digit >= 0 && digit <= 9 {
line += bigDigits[digit][row]
}
}
print(line)
}
}
var bigDigits = [][]string{
{" 000 ",
" 0 0 ",
"0 0",
"0 0",
"0 0",
" 0 0 ",
" 000 "},
{" 1 ", "11 ", " 1 ", " 1 ", " 1 ", " 1 ", "111"},
{" 222 ", "2 2", " 2 ", " 2 ", " 2 ", "2 ", "22222"},
{" 333 ", "3 3", " 3", " 33 ", " 3", "3 3", " 333 "},
{" 4 ", " 44 ", " 4 4 ", "4 4 ", "444444", " 4 ",
" 4 "},
{"55555", "5 ", "5 ", " 555 ", " 5", "5 5", " 555 "},
{" 666 ", "6 ", "6 ", "6666 ", "6 6", "6 6", " 666 "},
{"77777", " 7", " 7 ", " 7 ", " 7 ", "7 ", "7 "},
{" 888 ", "8 8", "8 8", " 888 ", "8 8", "8 8", " 888 "},
{" 9999", "9 9", "9 9", " 9999", " 9", " 9", " 9"},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment