Skip to content

Instantly share code, notes, and snippets.

@quilime
Created April 18, 2013 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quilime/5409921 to your computer and use it in GitHub Desktop.
Save quilime/5409921 to your computer and use it in GitHub Desktop.
random stars in the console
#!/usr/bin/python
import random
rows = 20
cols = 80
num_stars = 100
rand_stars = []
while (len(rand_stars) < num_stars):
rand = random.randint(0, rows * cols)
if rand not in rand_stars:
rand_stars.append(rand)
count = 0
out = ''
for r in range(rows):
for c in range(cols):
if count in rand_stars:
out += '*'
else:
out += ' '
count = count + 1
out += "\n"
print out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment