JMU
Arithmetic on a Circle
A Programming Pattern


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu


Motivation
Review

Addition on the Line

images/NumberLine_Addition.svg

Subtraction on the Line

images/NumberLine_Subtraction.svg
Thinking About the Problem

Addition on the Circle

images/NumberCircle_Addition.svg

Subtraction on the Circle

images/NumberCircle_Subtraction.svg
The Pattern
The Example of Military Time
Other Time/Date Examples
Other Examples: Weights and Distances
Other Examples: Even/Odd Numbers
Other Examples: Cycling through a Set
Humor
http://imgs.xkcd.com/comics/snacktime_rules.png
(Courtesy of xkcd)