Git Product home page Git Product logo

incubyte-assesment's Introduction

String Calculator TDD Kata

Overview

This is a TDD (Test-Driven Development) exercise to create a simple String calculator with the following requirements:

  1. An empty string should return 0.
  2. A single number should return the value of that number.
  3. Two numbers separated by a comma should return their sum.
  4. The calculator should handle any amount of numbers.
  5. The calculator should handle new lines as delimiters (e.g., "1\n2,3" should return 6).
  6. The calculator should support custom delimiters specified at the beginning of the string (e.g., "//;\n1;2" where the delimiter is ";" should return 3).
  7. The calculator should throw an exception if a negative number is provided (e.g., "negative numbers not allowed -1").
  8. Numbers bigger than 1000 should be ignored, so adding 2 + 1001 = 2.
  9. Delimiters can be of any length with the following format: "//[delimiter]\n" for example: "//[]\n12***3" should return 6.

Examples

  • Input: "", Output: 0
  • Input: "1", Output: 1
  • Input: "1,5", Output: 6
  • Input: "1\n2,3", Output: 6
  • Input: "//;\n1;2", Output: 3
  • Input: "-1,2", Output: "negative numbers not allowed -1"
  • Input: "2,1001", Output: 2
  • Input: "//[]\n12***3", Output: 6

incubyte-assesment's People

Contributors

bhaskar8074 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.