Skip to content

Instantly share code, notes, and snippets.

@mrkloan
Last active January 9, 2020 18:32
Show Gist options
  • Save mrkloan/2f7db0874a64fa571e423262b511353b to your computer and use it in GitHub Desktop.
Save mrkloan/2f7db0874a64fa571e423262b511353b to your computer and use it in GitHub Desktop.

Kata Fraction

Write a simple Fraction calculator. Simplification is not required.

Examples

Addition

  • 1/2 + 3/4
  • = ((1*4) + (3*2)) / (2*4)
  • = 10/8

Subtraction

  • 1/2 - 3/4
  • = ((1*4) - (3*2)) / (2*4)
  • = -2/8

Multiplication

  • 1/2 * 3/4
  • = (1*3) / (2*4)
  • = 3/8

Division

  • 1/2 / 3/4
  • = (1*4) / (2*3)
  • = 4/6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment