Git Product home page Git Product logo

swe_take_home_exercise's Introduction

Prefix & Infix Calculator

Part One

You are to write a program that accepts numerical calculations in prefix notation, such as + 5 7 or - 12 * 2 6.

You can make the following assumptions:

  • The system should support the operators {+, -, *, /} which all take exactly two args.
  • The input literals are positive integers
  • Calculations can be done in the floating-point or integer domain
  • Handling division by zero is unimportant; program can crash or do anything if that arises.
  • You don't need to consider operator presidence
  • You are free to use any programming language of choice but please provide any requirements to run the code EG: Python version or Pip dependencies

Sample input (caret prompt for clarity only):

> 3
3
> + 1 2
3
> + 1 * 2 3
7
> + * 1 2 3
5
> - / 10 + 1 1 * 1 2
3
> - 0 3
-3
> / 3 2
1 (or 1.5)

All assumptions from the previous task hold for this one.

Part Two

Implement your calculator in infix notation with support for full-parenthesized operands. It's OK to assume that all the tokens are space-separated, including the parenethesis tokens

Sample input (caret prompt for clarity only):

> ( 1 + 2 )
3
> ( 1 + ( 2 * 3 ) )
7
> ( ( 1 * 2 ) + 3 )
5
> ( ( ( 1 + 1 ) / 10 ) - ( 1 * 2 ) )
-1 (or -1.8)

Additional Bonus

Create a web-based version of your calculator, as in a service with a RESTful interface. The goal would be to be able to interact with your calculator over the internet vs a standalone desktop based application.

Deliverables:

A GitHub repo with your working code for the prefix and infix versions along with accompanying test cases

swe_take_home_exercise's People

Contributors

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