• 0

Need help coming up with an efficient algorithm pseudocode.


 Share

Question

I need help coming up with an efficient algorithm for the below.  The automation software i am using has a very limited syntax, can use for loops and if else statements and all the math functions.  

 

I have several variables.

Boolean Variable S = Start Step Sequence - True/False

Integer Variable R = Total Number of Recipes - Constant of 50

Integer Variable X = Number of Recipe Steps - Can be 1 to (Variable R)

Integer Variable Y = Starting Recipe Step - Can be 1 to (Variable R)

Integer Variable Z = Ending Recipe Step - Can be 1 to (Variable R)

Integer Variable C = Current Recipe Step - Can be 1 to (Variable R)

Integer Variable T = Time Duration - Constant 60 seconds

Boolean Variable D = Steps Done - True/False

 

So I am working on a problem where the end user can Change Variable X and Y.

 

At minimum i need an algorithm that can look at the Number of steps (Variable X) and then take the input of the starting Step (Variable Y) and then Calculate the Ending Step (Variable Z). If the steps cause Variable Z to go past 50 (Variable R) then is starts back at 1 and increments the value up accordingly.

Once Start Step Sequence (Variable S) is set to True then the algorithm will need to start at Variable Y and assign this to the Current Recipe Step (Variable C) then every Time Duration (Variable T) it needs to increment Variable C up by 1 to the next step. If the Ending Step (Variable Z) is such that it is less than the starting step (Variable Y) due to the to the number of steps causing the value to roll over then the same thing would need to happen with variable C and once at a value of 50 (Variable R) and more increments are required it would roll over to 1 and keep incrementing up until the number of steps is completed meaning Variable C is equal to Variable Z and the duration of the final step has expired. THen once the final step duration has completed flag Steps Done (Variable D) to True and set Variable S to false.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.