GithubHelp home page GithubHelp logo

quadratic-equation's Introduction

Quadratic equation

Recall school math!

Task

Your task is to implement solveEquation function, wihch solves Quadratic equation. Each equality has exact 2 integer solutions. Return those numbers as ordered array.

Example:

  const solutions = solveEquation('2 * x^2 - 10 * x + 12');
  console.log(solutions); // [2, 3]

Write your code in `src/index.js. Be sure, that all tests are positive. That means you cannot catch any error in tests.

Prepare and test

  • Install Node.js
  • Clone this repository: git clone https://github.com/yankouskia/quadratic-equation.git
  • Go to folder quadratic-equation
  • Run npm install in command line
  • Run npm test in command line
  • You will see the number of passing and failing tests

quadratic-equation's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

quadratic-equation's Issues

Tests should not check the order of roots

Tests can be improved.

Now they check that result array is completely equal to expected. But in quadratic equation the order of roots does not matter. So it's better to check length of result array and that it includes first and second roots.

Because I got such failing tests:

AssertionError [ERR_ASSERTION]: [ 4647489, 62156 ] deepEqual [ 62156, 4647489 ]
      + expected - actual
       [
      +  62156
         4647489
      -  62156
       ]

It's not an equation.

An equation is written as two expressions, connected by an equals sign ("=")
2 * x^2 - 10 * x + 12 -- is expression
2 * x^2 - 10 * x + 12 = 0 -- is equation

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.