GithubHelp home page GithubHelp logo

scala-exercise-2's Introduction

Sum numbers in a string

Logical Rules

  • Given a string as input, we need to be able to sum the numbers it contains.
  • The first line of the string shall encompass the delimiters between the numbers we want to sum.

For instance:

//[delimiter]\n[numbers…]

"//;\n2;3;4;5;67;888" -> this shall return 2+3+4+5+67+888

"//x\n1x2x3x4x5x6x7x8x9x90" -> this shall return 1+2+3+4+5+6+7+8+9+90

"//[x][y]\n1x2y5x9y10 -> this shall return 1+2+5+9+10

That input shall return the sum of all the numbers separated by ;

  • The default delimiter is ,
  • We only want to sum numbers that are smaller than 1001
  • We only allow positive numbers
  • We need to be able to sum numbers even if they are in different lines. So the following string 1\n2,3 shall return 6
  • We need to be able to define more than one delimiter in the following way //[delim1][delim2]\n

Coding Rules

  • The input string shall be read from a file whose path is specified in a config

  • If the string is invalid we need to log a specific error to a file

  • Each line of code shall have a comment explaining the thought behind it

  • Tests are mandatory, as well as code coverage above 90%

scala-exercise-2's People

Contributors

deboracgs avatar

Watchers

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