Created
June 20, 2014 02:12
-
-
Save tos-kamiya/f2c5f10f978f9ba24d59 to your computer and use it in GitHub Desktop.
Amida-kuji (ladder lottery)
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
#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