Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/09/2010, 12:52
e10erick
 
Fecha de Ingreso: septiembre-2010
Mensajes: 2
Antigüedad: 13 años, 7 meses
Puntos: 0
Busqueda python recursivo

compñeros de foros del web nesito ayuda alguno sabe como cambiar este codigo a recursivo esta escrito en python 3.1

from turtle import *
import turtle as t

import math

def drawsquare(t, start, length):
t.penup()
t.speed(0)
t.goto(start)
t.pendown()
color('dark blue')

#no se puede usar for o cualquier otro bucle ayud gracis
for i in range(4):
t.forward(length)
t.right(90)

def carpet(t, p1, length, depth):
color('dark green')
if depth == 0:
drawsquare(t, p1, length)

else:
carpet(t, p1, length//3, depth - 1)
carpet(t, (p1[0], p1[1] - length//3), length//3, depth - 1)
carpet(t, (p1[0], p1[1] - (length//3) * 2), length//3, depth - 1)
carpet(t, (p1[0] + length//3, p1[1]), length//3, depth - 1)
carpet(t, (p1[0] + length//3, p1[1] - (length//3) * 2), length//3, depth - 1)
carpet(t, (p1[0] + (length//3) * 2, p1[1]), length//3, depth - 1)
carpet(t, (p1[0] + (length//3) * 2, p1[1] - length//3), length//3, depth - 1)
carpet(t, (p1[0] + (length//3) * 2, p1[1] - (length//3) * 2), length//3, depth - 1)
exitonclick

carpet(t,(-250,250), 500, 4)