Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Cantor-set/Python/cantor-set-1.py
Normal file
24
Task/Cantor-set/Python/cantor-set-1.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
WIDTH = 81
|
||||
HEIGHT = 5
|
||||
|
||||
lines=[]
|
||||
def cantor(start, len, index):
|
||||
seg = len / 3
|
||||
if seg == 0:
|
||||
return None
|
||||
for it in xrange(HEIGHT-index):
|
||||
i = index + it
|
||||
for jt in xrange(seg):
|
||||
j = start + seg + jt
|
||||
pos = i * WIDTH + j
|
||||
lines[pos] = ' '
|
||||
cantor(start, seg, index + 1)
|
||||
cantor(start + seg * 2, seg, index + 1)
|
||||
return None
|
||||
|
||||
lines = ['*'] * (WIDTH*HEIGHT)
|
||||
cantor(0, WIDTH, 1)
|
||||
|
||||
for i in xrange(HEIGHT):
|
||||
beg = WIDTH * i
|
||||
print ''.join(lines[beg : beg+WIDTH])
|
||||
Loading…
Add table
Add a link
Reference in a new issue