How to conver code to an algorithm?

Discussion in 'Computer Games and General Discussion' started by kevan, Mar 4, 2012.

Mar 4, 2012
  1. kevan
    OP

    Member kevan Imagination rules the world

    Joined:
    Dec 4, 2009
    Messages:
    1,378
    Location:
    Place
    Country:
    Australia
    This is the code I have and I'm curious on how I would convert it back to an Algorithm? Also the question I have there in the quote. Any help with that please! :)
     
  2. kirlac

    Newcomer kirlac Member

    Joined:
    May 17, 2009
    Messages:
    49
    Country:
    New Zealand
    Since an algorithm is just the step by step of what needs to happen you just read the code and write what each part is doing eg.
    In a loop
    Take in input to determine user is not a bot
    Check if input is less than 5
    etc.

    As for the question, perhaps use some while loops eg.
    create variable repeating set to true
    while repeating
    enter login
    ask question
    while answer is not yes or no
    ask question again
    if answer is yes
    do yes scenario
    set repeating to false
    else set repeating to true
    end loop
    end loop

    EDIT: Forgot to create repeating variable (initialized as true) and set it to false when doing the yes sceneario to prevent infinite loop.
     

Share This Page