manetta
5 years ago
1 changed files with 77 additions and 0 deletions
@ -0,0 +1,77 @@ |
|||||
|
from math import sqrt, log, log10 |
||||
|
|
||||
|
# Using a function to describe a circle |
||||
|
# Thanks J |
||||
|
|
||||
|
def circulair_pattern(): |
||||
|
line_width = 110 |
||||
|
line_height = 70 |
||||
|
|
||||
|
out = '' |
||||
|
count = 0 |
||||
|
|
||||
|
for x in range(100): |
||||
|
for y in range(100): |
||||
|
if count == 10: |
||||
|
count = 0 |
||||
|
z = sqrt((x ** 2) + (y ** 2)) |
||||
|
z = int(z / 50) |
||||
|
print(z) |
||||
|
out += str(count) + (' ' * z) |
||||
|
count += 1 |
||||
|
|
||||
|
page = '' |
||||
|
linenumber = 0 |
||||
|
for i, c in enumerate(out): |
||||
|
if i % line_width == 0: |
||||
|
range_start = linenumber * line_width |
||||
|
range_end = range_start + line_width |
||||
|
page += out[range_start:range_end] + '\n' |
||||
|
linenumber += 1 |
||||
|
|
||||
|
lines = page.split('\n') |
||||
|
page = '\n'.join(lines[:69]) + '\n' |
||||
|
|
||||
|
f = open('pattern.txt', 'w+') |
||||
|
f.write(page) |
||||
|
f.close() |
||||
|
return page |
||||
|
|
||||
|
circulair_pattern() |
||||
|
|
||||
|
|
||||
|
def new(): |
||||
|
line_width = 110 |
||||
|
line_height = 70 |
||||
|
|
||||
|
out = '' |
||||
|
count = 0 |
||||
|
|
||||
|
for x in range(100): |
||||
|
if count == 10: |
||||
|
count = 0 |
||||
|
z = int(log10(4 * (x + 1))) |
||||
|
print(z) |
||||
|
out += str(count) + (' ' * z) |
||||
|
count += 1 |
||||
|
|
||||
|
out = out.replace(' ', ' ') |
||||
|
|
||||
|
page = '' |
||||
|
linenumber = 0 |
||||
|
for i, c in enumerate(out): |
||||
|
if i % line_width == 0: |
||||
|
range_start = linenumber * line_width |
||||
|
range_end = range_start + line_width |
||||
|
page += out[range_start:range_end] + '\n' |
||||
|
linenumber += 1 |
||||
|
|
||||
|
lines = page.split('\n') |
||||
|
page = '\n'.join(lines[:69]) + '\n' |
||||
|
|
||||
|
f = open('pattern.txt', 'w+') |
||||
|
f.write(page) |
||||
|
f.close() |
||||
|
return page |
||||
|
|
||||
|
# new() |
Loading…
Reference in new issue