Skip to content

Instantly share code, notes, and snippets.

@Arnauld
Last active June 18, 2016 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arnauld/b429193fe041de876acedc119a88a2b6 to your computer and use it in GitHub Desktop.
Save Arnauld/b429193fe041de876acedc119a88a2b6 to your computer and use it in GitHub Desktop.
Unit converter kata

Use case

1 cp of Paracetamol 500mg

Paracetamol density 1,26 g/cm³

Are (5 lyoc) equivalent to (50 ml)?

50ml * 1,26g/cm³ = 63 g * ml/cm³ = 63g

Rule

Conversion table:

  • 1 lyoc = 1 cp
  • 1l = 1dm³
  • 1cc (teaspoon) = 0.005dm³
  • 1cup = 0.250dm³

When x is m, g or l ...

  • 1x = 10 dx
  • 1x = 100 cx
  • 1x = 1000 mx
  • 1x = 0.001 kx

which should lead to:

  • 1cm³ = 1ml
  • 1m³ = 1000dm³

See also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment