Coder Social home page Coder Social logo

stringcalculatorkata's Introduction

String Calculator Kata

Credit

This exercise is based off the work of Roy Osherove

Before you start

  • Do not read ahead
  • Do one task at a time
  • Refactor as necessary
  • Do not handle invalid inputs
  • Check in often
  • Tests are your friends

Getting Started

Clone the branch from here

Create and push a branch under attempts/ now. Ideally you can call it <first name>_<last name> (eg. attempts/philippe_castonguay)

You will be building a String Calculator. The initial branch contains the following projects:

  • Product - The String Calculator you will be developing, with the initial function stub
  • Product.Tests - An XUnit test file with one failing test
  • Product.CLI - A simple console application that will run the calculator and show the results

Only expand the details once you have completed the previous step, to avoid looking ahead

0. Base case Start with the base case.
Eg. 
"" → 0
1. Loneliest When one number is passed, return that number for the sum
Eg. 
"1" → 1
"10" → 10
2. Basics When two numbers are passed, separated by a plus '+', return their sum
Eg.
"1+1" → 2
"12+34" → 36
3. N Allow any number of numbers to be passed, and add ',' as a delimiter
Eg.
"1,2,3" → 6
"1,1,1,1,1" → 5
4. NL Allow the new line character (\n) to be used as a delimiter as well
Eg.
"1\n2" → 3
5. Custom Allow optional custom delimiters, in the format of "//{delimiter}{numbers}" (It should continue to work without the delimiters)
Eg.
"//;1;2" → 3
6. Negative When a negative is passed, throw an Exception with the message "Negatives not allowed ({number})", where number is the first negative number that was encountered
Eg.
"-1" → "Negatives not allowed (-1)"
7. Numerous When multiple negatives are passed, return the comma-separated list of all the negatives in the order they were presented, instead of just the first one
Eg.
"-1,-2" → "Negatives not allowed (-1,-2)"
8. Mille Ignore numbers greater than 1000
Eg.
"1,1005" → 1
9. Delimited Allow for delimiters of any length, using the format "//[{delimiter}]{numbers}". (The previous delimiter method should continue to work)
Eg.
"//[***]1***2***3" → 6
10. Unlimiated Allow for multiple long delimiters, using the format "//[{delimiter1}][{delimiter2}][{...}]{numbers}".
Eg.
"//[*][%]1*2%3" → 6
11. Revision Ensure that you can use multiple and long delimiters
Eg.
"//[***][%%%]1***2%%%3" → 6
12. Conclusion Woohoo! You're done! Check it in and reflect.

stringcalculatorkata's People

Contributors

joshcampbell191 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.