For the next problem, consider a household with four members: Jon, Dustin, Joe, and Phil. There are five jobs that need to be done every week. These are (0) cleaning the kitchen, (1) cleaning the bathroom, (2) shopping for groceries, (3) vacuuming, and (4) emptying the trash. Due to an allergic reaction, Joe cannot clean the bathroom. Phil cannot shop for groceries because he has no car.

Devise a way so that the chores get distributed as evenly as possible but still rotated every week. You may write a program in LISP to help you.


(defun show-chores (weekStart weekDone)
  "Output the chores and who does them from the span of one week to another" 

  (setq week weekStart)

  (while (<= week weekDone)
    (insert-string "

For week " week ":
")

    (num-to-name 0 (% week 3) week)
    (insert "
Kitchen: " who)
    (num-to-name 1 (% week 3) week)
    (insert "
Shopping: " who)
    (num-to-name 2 (% week 3) week)
    (insert "
Bathroom: " who)
    (num-to-name 3 (% week 3) week)
    (insert "
Vacuum: " who)
    (num-to-name 4 (% week 3) week)
    (insert "
Trash: " who)

    (setq week (+ 1 week))
   )
)

(defun num-to-name (job cycle week)
  "Translate the cycle based on the job"
  (if (equal job 0)      (if (equal cycle 0) (setq who "Phil")))
  (if (equal job 0)      (if (equal cycle 1) (setq who "Joe")))
  (if (equal job 0)      (if (equal cycle 2) (if(eq 1 (% week 2)) (setq who "Dustin") (setq who "Jon"))))

  (if (equal job 1)      (if (equal cycle 0) (setq who "Jon")))
  (if (equal job 1)      (if (equal cycle 1) (setq who "Dustin")))
  (if (equal job 1)      (if (equal cycle 2) (setq who "Joe")))

  (if (equal job 2)      (if (equal cycle 0) (setq who "Dustin")))
  (if (equal job 2)      (if (equal cycle 1) (setq who "Jon")))
  (if (equal job 2)      (if (equal cycle 2) (setq who "Phil")))

  (if (equal job 3)      (if (equal cycle 0) (setq who "Joe")))
  (if (equal job 3)      (if (equal cycle 1) (if(eq 1 (% week 2)) (setq who "Dustin") (setq who "Jon"))))
  (if (equal job 3)      (if (equal cycle 2) (setq who "Phil")))

  (if (equal job 4)      (if (equal cycle 0) (if(eq 1 (% week 2)) (setq who "Dustin") (setq who "Jon"))))
  (if (equal job 4)      (if (equal cycle 1) (setq who "Phil")))
  (if (equal job 4)      (if (equal cycle 2) (setq who "Joe")))

)

(show-chores 0 10)

Well, if it isn’t my first LISP program!