Giter Site home page Giter Site logo

digit-operations's Introduction

digit-operations

Assuming you are given the list of all digits going from 1 to 9, 1 2 3 4 5 6 7 8 9. How many ways can we intercalate the operations multiplication (*) and addition (+) between the digits in such a way that the value of the arithmetic expression we get equals X (set X = 50 for example) ? Note that the order of the digits 1 to 9 has to be ordered from smallest to the greatest one.

Here’s one solution for X=50:   1+2+3*4+5+6+7+8+9 è 50

Here’s one solution for X=100: 12+34+5+67+8+9   è 100 [1]

As you can see in [1], 34 is also used as we didn’t put any operator between 3 and 4. So note that not putting any operation between digits is a valid choice as well.

I usually make up for combinations of this concept by asking the candidate to write code to print out all the solutions, or just print how many possible solutions we do have.

Next step is usually discussing the complexity of the provided solution by the candidate, but it’s not very important I believe (anyone knows why ?).

Happy coding !

=================

digit-operations's People

Contributors

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