Psuedo Code; Excercise 1.

I have enrolled in the Viking Code School and I am currently doing the prep work.

Our first assignment is to use PsuedoCode; simple language used to describe a process or solution in code.  The first assignment is to describe the process of making a grilled cheese sandwich.

I found this assignment interesting if not slightly daunting. I realized I had a fatal flaw inside my PsuedoCode when I was 3/4 finished but I decided to leave it in as a teaching point.  By running programs like GroceryShopping and WASHDISHES multiple times throughout the code I left myself room for serious error.

It is not efficient to search for items seperately at every step of the recipe.

What would be more efficient is to do what Jonathan Popenuck did in his solution.

By searching for all the items needed for the sandwich at the beginning and perhaps seperating them by items that would be under the control of GroceryShopping and items that would be WashDishes you could execute those codes once and save yourself from say, washing the spatula while the sandwich burns on the stove. Or from going to the grocery store 4 seperate times.

What I found most interesting about this assignment was how it forced me to take a seemingly basic task, find all of the essential elements to that task, and try to execute it. I have zero coding experience and no engineering background so this was a fun icebreaker to the theory behind coding.

I found myself thinking of efficent ways to create and link the programs, and even trying to create parent and child code with parameters like INSPECT.

I then began to think of ways to make the program GroceryShopping more streamlined.

I believe however that is our next assignment so I will leave you with this;

Alex´s Grilled Cheese Sandwich- PsuedoCode

    1. PROGRAM GrilledCheeseSandwich

    Search; Bread.

    If FOUND then proceed.

    If NOT FOUND then RUNPROGRAM; GroceryShopping

    Proceed;

    INSPECT; Bread. If Bread is; Moldy and or Hard. RUNPROGRAM; GroceryShopping

    If Bread is Ok, Proceed.

    Search; Cheese.

    INSPECT; (Same parameters as Bread)

    If Cheese is OK-Proceed;

    Take (2) pieces of Bread and place beside eachother.

    Search; Butter

    If FOUND then proceed.

    If NOT FOUND then RUNPROGRAM; GroceryShopping

    Inspect

    If Ok -Proceed

    Search; Knife.

    If Dirty THEN run program WASHDISHES

    If Clean Then Proceed.

    Take Knife and CUT-SmallPiece of Butter.

    Spread Butter on Bread 1.

    Spread Butter on Bread 2

    Turn over Bread 1.

    Place Cheese on Bread 1.

    Pick Up Bread 2

    Place Bread 2 on TOP of Cheese and Bread 1

    Bread 2-Butter UP.

    Search; FryingPan.

    If Dirty THEN run program WASHDISHES

    If Clean Then Proceed.

    Turn ON Burner1 to 75%.

    Place FryingPan on Burner1.

    Wait 5 Minutes for Preheat.

    Add Bread to Frying Pan.

    Wait 2 Minutes.

    Search; Spatula.

    If Dirty THEN run program WASHDISHES

    If Clean Then Proceed.

Flip Grilled Cheese with Spatula- Bread1 is now TOP.

Lower Temperature on Burner1 to 50%

Wait 5 Minutes.

Check if Bread is Brown.

If Bread is NOT Brown Wait (1) Minutes.

Repeat as necessary.

If Bread is OK

Remove GrilledCheese from FryingPan with Spatula.

Place on Plate.

Turn OFF Burner1

Place FryingPan in SINK.

Enjoy.

End.

 

 

 

Advertisements