Skip to content

Instantly share code, notes, and snippets.

@tos-kamiya
Created June 20, 2014 02:12
Show Gist options
  • Save tos-kamiya/f2c5f10f978f9ba24d59 to your computer and use it in GitHub Desktop.
Save tos-kamiya/f2c5f10f978f9ba24d59 to your computer and use it in GitHub Desktop.
Amida-kuji (ladder lottery)
#coding: utf-8
import os
import random
def write_u(u):
os.sys.stdout.write(u.encode("utf-8"))
no_beam = u"\u2502"
beam_right = u"\u251C"
beam_left = u"\u2524"
width = 15
height = 10
for y in range(height):
prev_pillar_having_beam = False
for x in range(width):
if prev_pillar_having_beam:
write_u(beam_left)
prev_pillar_having_beam = False
else:
if x < width - 1 and random.choice((True, False)):
write_u(beam_right)
prev_pillar_having_beam = True
else:
write_u(no_beam)
prev_pillar_having_beam = False
write_u("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment