Skip to content

Commit

Permalink
gcd recursive correction
Browse files Browse the repository at this point in the history
  • Loading branch information
quapka committed Jun 24, 2014
1 parent b7fb1a8 commit 612d500
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
18 changes: 9 additions & 9 deletions KvagrsWork/10_task/mazelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@


COLORS = {'W':'rgb(255,255,255)',
'R':'rgb(255,10,10)',
'Y':'rgb(255,255,10)',
'B':'rgb(10,10,255)',
'K':'rgb(0,0,0)',
'O':'rgb(255,133,10)',
'P':'rgb(133,10,255)',
'N':'rgb(51,26,0)',
'G':'rgb(0,153,0)',
'A':'rgb(255,255,255)'}
'R':'rgb(255,10,10)',
'Y':'rgb(255,255,10)',
'B':'rgb(10,10,255)',
'K':'rgb(0,0,0)',
'O':'rgb(255,133,10)',
'P':'rgb(133,10,255)',
'N':'rgb(51,26,0)',
'G':'rgb(0,153,0)',
'A':'rgb(255,255,255)'}

def load_num_maze(filename, separator=''):

Expand Down
6 changes: 2 additions & 4 deletions KvagrsWork/1_task/gcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ def gcd_recursive_modulo(a, b):

if b == 0:
return a
if a % b == 0:
return a
else:
#print b, a % b
return gcd_modulo( b, a % b )
return gcd_recursive_modulo( b, a % b )


def gcd_modulo(a, b):
Expand Down Expand Up @@ -95,6 +92,7 @@ def plot_fixed_par_gcd(fixed=7, method=gcd_modulo, n=100, filename=''):

if __name__ == '__main__':


plot_gcd_algorithm(gcd_substraction, n=200, m=200, filename='gcd_substraction')
plot_gcd_algorithm(gcd_modulo, n=200, m=200, filename='gcd_modulo')
plot_gcd_algorithm(gcd_recursive_modulo, n=200, m=200, filename='gcd_recursive_modulo')
Expand Down
17 changes: 13 additions & 4 deletions KvagrsWork/7_task/complex_fractals.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def mandelbrot_set(C=-0.13 + 0.75j, pol=[1,0,0], filename='', julia=False, frame
#weight -= 0.05

elif coloring == 1:
# + 15 for nicer color set
col = colors[(15 + steps) % 30]

elif coloring == 2:
Expand Down Expand Up @@ -145,9 +146,9 @@ def mandelbrot_set(C=-0.13 + 0.75j, pol=[1,0,0], filename='', julia=False, frame
# [-2,-0.5, .5],
# [-2,-0.5, .1],
# [-2,-0.5, .01]]
mandelbrot_set(filename='mandelbrot_set_col0',coloring=0)
mandelbrot_set(filename='mandelbrot_set_col1',coloring=1)
mandelbrot_set(filename='mandelbrot_set_col2',coloring=2)
#mandelbrot_set(filename='mandelbrot_set_col0', coloring=0)
#mandelbrot_set(filename='mandelbrot_set_col1', coloring=1)
#mandelbrot_set(filename='mandelbrot_set_col2', coloring=2)
#for frame in frames:
# filename = 'mandelbrot_set'
# filename += '_'.join([str(x) for x in frame])
Expand All @@ -162,4 +163,12 @@ def mandelbrot_set(C=-0.13 + 0.75j, pol=[1,0,0], filename='', julia=False, frame
# #mandelbrot_set(C=C, filename=filename, julia=True,frame=[-2,-2,4], coloring=1)
# k += 1
#
# mandelbrot_set(C=C, filename=filename,julia=True, frame=[-2,-2,4], coloring=0)
# mandelbrot_set(C=C, filename=filename,julia=True, frame=[-2,-2,4], coloring=0)
for i in xrange(200):
index = str(i + 1).zfill( 3 )
#b = -1.5 + 0.007 * 200
b = -1.5 + 0.007 * i
frame = [-2, b, abs(2*b)]
filename = 'zoom_mandelbrot_set_'+ index
print "+++ img/{}".format( filename )
mandelbrot_set(filename='zoom_mandelbrot_set_'+ index,coloring=1, frame=frame)

0 comments on commit 612d500

Please sign in to comment.