Retired

Calculator (retired)

1,402 of 11,547obrok

Description:

Create a simple calculator that given a string of operators (), +, -, *, / and numbers separated by spaces returns the value of that expression

Example:

Calculator().evaluate("2 / 2 + 3 * 4 - 6") # => 7
Calculator.new.evaluate("2 / 2 + 3 * 4 - 6") # => 7
Calculator.evaluate("2 / 2 + 3 * 4 - 6") // => 7
Calculator.evaluate "2 / 2 + 3 * 4 - 6" // => 7.0

Remember about the order of operations! Multiplications and divisions have a higher priority and should be performed left-to-right. Additions and subtractions have a lower priority and should also be performed left-to-right.

Algorithms
Parsing
Logic
Strings
Expressions
Basic Language Features
Fundamentals

Similar Kata:

Stats:

CreatedSep 15, 2013
Warriors Trained33772
Total Skips5592
Total Code Submissions154298
Total Times Completed11547
Ruby Completions1402
Python Completions4902
C# Completions924
Java Completions1315
Haskell Completions200
JavaScript Completions2966
Total Stars1372
% of votes with a positive feedback rating82% of 1782
Total "Very Satisfied" Votes1290
Total "Somewhat Satisfied" Votes347
Total "Not Satisfied" Votes145
Ad
Contributors
  • obrok Avatar
  • jhoffner Avatar
  • bisceglie Avatar
  • xoh Avatar
  • maxprilutskiy Avatar
  • docgunthrop Avatar
  • JohanWiltink Avatar
  • Blind4Basics Avatar
  • Firefly2002 Avatar
  • Axure Avatar
  • albek Avatar
  • FArekkusu Avatar
  • user9644768 Avatar
  • ___i Avatar
  • solitude Avatar
  • C.c. Avatar
Ad