Skip to content

Instantly share code, notes, and snippets.

@gizmomogwai
Last active April 14, 2018 13:57
Show Gist options
  • Save gizmomogwai/d55ecbd1019ff49f2925e28af28dda3d to your computer and use it in GitHub Desktop.
Save gizmomogwai/d55ecbd1019ff49f2925e28af28dda3d to your computer and use it in GitHub Desktop.
The Kitchen, dish, dishwasher algorithm
@startuml
start
note right: Agent enters the kitchen to bring back a dish (e.g. glass, cup, mug, plate, ...)
if (Dishwasher running?) then (yes)
:Put dish into sink;
stop
else (no)
if (Dishwasher full?) then (yes)
if (Dishes in dishwasher clean?) then (yes)
:Put clean dishes back;
note left: Longest running operation
:Put as much dishes from sink into dishwasher as possible;
if (Dishwasher full?) then (yes)
:Start dishwasher;
:Put your dish into the sink;
stop
else (no)
:Put your dish into dishwasher;
if (Dishwasher full?) then (yes)
:Start dishwasher;
stop
note left: Worst case
else (no)
stop
endif
endif
else (no)
:Put dish into sink;
:Start dishwasher;
stop
endif
else (no)
:Put dish into dishwasher;
if (Dishwasher full?) then (yes)
:Start dishwasher;
stop
else
stop
endif
endif
endif
@enduml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment