Function with Rules

Hi, welcome!

Please have a look to our homework policy, homework inspired questions are welcome but they should not include verbatim instructions from your course.

Also, it would be easier to help you if you make your question in the form of a REPRoducible EXample (reprex) showing what you have made so far.