Results 1 to 4 of 4
  1. #1
    sctong147 is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default 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. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,691
    Rep Power
    8

    Default Re: Fibonacci L-System

    What part are you confused about? What have you tried? Where are you stuck?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    sctong147 is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default Re: Fibonacci L-System

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

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,691
    Rep Power
    8

    Default 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.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Need Help - StackOverflowError - Fibonacci
    By ausglanville in forum New To Java
    Replies: 3
    Last Post: 04-13-2011, 03:43 AM
  2. Fibonacci Help
    By zit1343 in forum New To Java
    Replies: 16
    Last Post: 01-24-2011, 01:09 AM
  3. Fibonacci sequece
    By Bgreen7887 in forum New To Java
    Replies: 10
    Last Post: 12-03-2010, 07:27 PM
  4. Fibonacci sequence
    By ŖàΫ ỏƒ Ңόρę in forum New To Java
    Replies: 6
    Last Post: 03-25-2010, 06:59 AM
  5. help with fibonacci
    By likemine in forum New To Java
    Replies: 8
    Last Post: 01-07-2010, 02:32 AM

Posting Permissions

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