6 kyu

No Order of Operations

197 of 298tonylicoding

Description:

Imagine if there were no order of operations. Instead, you would do the problem from left to right. For example, the equation a+bc/da +b *c /d would become (((a+b)c)//d)(((a+b)*c)//d) (Math.floor(((a+b)*c)/d) in JS). Return None/null (depending on your language) if the equation is "".

Task:

Given an equation with a random amount of spaces greater than or equal to zero between each number and operation, return the result without order of operations. Note that if two numbers are spaces apart, act as if they were one number: 1 3 = 13. However, if given something % 0 or something / 0, return None/null.

More about order of operations: here

Key:

  • ^ represents **
  • / represents // or math.floor because the result will always be an integer

Operations allowed:

+, -, * , /, ^, %

Example:

no_order(2 + 3 - 4 * 1 ^ 3) returns 1

because:

  2 + 3 - 4 * 1 ^ 3
= 2 + 3 - 4 * 1 ^ 3
= 5 - 4 * 1 ^ 3
= 1 * 1 ^ 3
= 1 ^ 3
= 1
Mathematics
Algorithms

Stats:

CreatedApr 20, 2020
PublishedApr 20, 2020
Warriors Trained694
Total Skips25
Total Code Submissions2424
Total Times Completed298
Python Completions197
JavaScript Completions113
Total Stars9
% of votes with a positive feedback rating89% of 120
Total "Very Satisfied" Votes98
Total "Somewhat Satisfied" Votes18
Total "Not Satisfied" Votes4
Total Rank Assessments29
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • tonylicoding Avatar
  • kazk Avatar
  • user9644768 Avatar
  • user8436785 Avatar
Ad