English subtitles

← 09ps-08 Satisfied Solution

Get Embed Code
1 Language

Showing Revision 1 created 10/24/2012 by Amara Bot.

  1. So this is my solution to the problem, so let's just go ahead and run through it.
  2. Since clauses is a list of lists,
  3. we're just going to run through each inner list of for clause and clauses.
  4. We're going to set a variable called clause satisfied to false to begin with,
  5. then for each variable in the clause, if it is positive,
  6. that is if it is not negated than if the assignment to the variable is true,
  7. then we switch clause satisfied to true and break
  8. and go to the next variable in the clause.
  9. Else, we go ahead and recognize that the variable is negated
  10. and we check that the assignment is false,
  11. and if that is the case, then we set
  12. the clause satisfied to true and break.
  13. Finally, once we are done looping through all the
  14. variables in the clause we check if clause satisfied is false,
  15. and it is still false,
  16. then we immediately return false
  17. because there is a clause that is not satisfied.
  18. This is simply a shortcut to make the
  19. algorithm run a little bit faster.
  20. And once we're done with that,
  21. we simply loop back to the next clause and start all over.
  22. And if we fall through all of those,
  23. then we return true and say, yes,
  24. the entire Boolean formula is in fact satisfied by the given assignment.