Created
June 2, 2012 16:31
-
-
Save muddydixon/2859068 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env node | |
var num = process.argv[2] || 5 | |
, maxLen = 20 | |
, ratio = 0.5 | |
, hasNext = false | |
, l = 0 | |
, u = 0; | |
var stdout = process.stdout; | |
while(++l < maxLen){ | |
u = 0, hasNext = false; | |
while(++u < num){ | |
if(!hasNext && Math.random() < ratio){ | |
stdout.write('|---'); | |
hasNext = true; | |
}else{ | |
stdout.write('| '); | |
hasNext = false; | |
} | |
} | |
stdout.write('|\n'); | |
} | |
var hit = 0|Math.random() * num; | |
u = 0; | |
while(u++ < hit){ | |
stdout.write(' '); | |
} | |
stdout.write('!\n'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
横線がもっとあったほうがいいかなぁとおもた