Python Forum
Increasing depth in python
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Increasing depth in python
#18
I think i came up with something. I basicly just repeated the steps from previous task. the apply(left, right, state)

def step(rules, state):
  result=[]
  for x in state:
     if x==rules:
        result.append(state)
     else:
        result.append(x)

[inner for outer in result for inner in outer]

print(result)

#This funktion is not made yet. Dont think about it!!!
def compute(depth, rules, start):
  print()

step("F",["F","L","F","R","F","L","F"])   
Now i just need to flatten it but it didn't seem to work as planned.

Update!!!

I found out how to remove the brackets but still haven't removed 2 outer ones. any ideer?
I did this:

def step(rules, state):
   result=[]
   for x in state:
       if x==rules:
           result.append(state)
       else:
           result.append(x)
   
   flatten = [inner for outer in result for inner in outer]
   print(flatten)

#This funktion is not made yet. Dont think about it!!!
def compute(depth, rules, start):
   print()
   
step("F",["F","L","F","R","F","L","F"])
and got this

Output:
['F', 'L', 'F', 'R', 'F', 'L', 'F', 'L', 'F', 'L', 'F', 'R', 'F', 'L', 'F', 'R', 'F', 'L', 'F', 'R', 'F', 'L', 'F', 'L', 'F', 'L', 'F', 'R', 'F', 'L', 'F']
But as you see i still need to remove the last 2 at each side.
Reply


Messages In This Thread
Fractals in python using fdl - by malling - Oct-20-2016, 11:06 AM
RE: Increasing depth in python - by malling - Oct-20-2016, 06:44 PM
RE: Increasing depth in python - by nilamo - Oct-20-2016, 06:48 PM
RE: Increasing depth in python - by malling - Oct-20-2016, 07:30 PM
RE: Increasing depth in python - by nilamo - Oct-20-2016, 07:48 PM
RE: Increasing depth in python - by malling - Oct-20-2016, 07:51 PM
RE: Increasing depth in python - by sparkz_alot - Oct-20-2016, 08:01 PM
RE: Increasing depth in python - by nilamo - Oct-20-2016, 08:01 PM
RE: Increasing depth in python - by malling - Oct-20-2016, 08:08 PM
RE: Increasing depth in python - by nilamo - Oct-20-2016, 08:48 PM
RE: Increasing depth in python - by malling - Oct-20-2016, 08:53 PM
RE: Increasing depth in python - by nilamo - Oct-20-2016, 09:50 PM
RE: Increasing depth in python - by malling - Oct-20-2016, 10:43 PM
RE: Fractals in python using fdl - by Yoriz - Oct-20-2016, 12:27 PM
RE: Fractals in python using fdl - by malling - Oct-20-2016, 04:10 PM
Increasing depth in python - by malling - Oct-20-2016, 04:21 PM
RE: Increasing depth in python - by nilamo - Oct-20-2016, 04:45 PM
RE: Increasing depth in python - by malling - Oct-20-2016, 05:24 PM
RE: Increasing depth in python - by nilamo - Oct-20-2016, 05:38 PM
RE: Fractals in python using fdl - by metulburr - Oct-20-2016, 05:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  "RecursionError: maximum recursion depth exceeded in comparison" hhydration 1 2,661 Sep-26-2020, 03:07 PM
Last Post: deanhystad
  Digits increasing meknowsnothing 6 5,886 Feb-17-2019, 11:22 AM
Last Post: scidam
  Increasing difficulty of a maths game Maxxy_Gray 1 4,153 Apr-04-2018, 03:00 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020