1. Member
Join Date
Sep 2011
Posts
2
Rep Power
0

## Fibonacci L-System

Recently having problem on solving this java asgnmnt and I am lost on this question :

In a Java class called Rewrite write a recursive instance method called lindenmeyer that
takes in a String: start and an integer iters and applies the following set of rules:
A -> AB
B -> BC
C -> D
D -> A
and applies them to the String start simultaneously iter times in succession returning
the new String. By simultaneously we mean that produce a result that looks as if each
rule is applied to input string at the same time. So, for example the call:
lindenmeyer("A",1)
returns the string “AB” and the call:
lindenmeyer("A",2)
returns the string “ABBC” and, finally, the call:
lindenmeyer("A",3)
returns the string “ABBCBCD”.
Hint: parallel rewriting of a string like this is harder than it looks (especially if it is done
in situ) because we have to avoid rules we apply later picking up on changes made by
rules we applied earlier. A simple trick is to make the rules match uppercase letters but
produce lowercase letters. Once all the rewrites are applied you can then convert the
whole string back to upper case.

*any advise would be much appreciated...

2. ## Re: Fibonacci L-System

What part are you confused about? What have you tried? Where are you stuck?

3. Member
Join Date
Sep 2011
Posts
2
Rep Power
0

## Re: Fibonacci L-System

i don't know how to start from scratch...thanks

4. ## Re: Fibonacci L-System

Break the problem up into smaller pieces. How would you solve this without a computer, with just a piece of paper and a pencil? Pretend you have a really dumb friend who has no idea how to do it. Write out instructions, in English, that he could follow to accomplish the task. When you have that done, you'll have an algorithm that should be pretty easily translated into code.

But always focus on one small piece at a time. For example, part of your program takes in a String. Write a program that does ONLY that. Test that out and have it working perfectly before you move onto the next, most smallest step. That will also make it easier to post an SSCCE here when you get stuck.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•