Skip to content

Instantly share code, notes, and snippets.

@jon-acker
Last active September 15, 2019 15:17
Show Gist options
  • Save jon-acker/56a8431b18085a1710f056302a540fa9 to your computer and use it in GitHub Desktop.
Save jon-acker/56a8431b18085a1710f056302a540fa9 to your computer and use it in GitHub Desktop.
String Calculator Kata

String Caluclator Kata

E.g., create a class a method called calc, which does the following:

It returns 0 for empty string It returns the bare number for a single number (e.g. '2' -> 2) It returns the sum of space-separated numbers (e.g. '1 2' -> 3) It returns the sum of any whitespace-separated numbers (e.g. "1 2\t3\n4" -> 10) It returns the sum of numbers separated by custom separator given as first char (e.g. '12' -> 3)

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