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 would become (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//
ormath.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
Similar Kata:
Stats:
Created | Apr 20, 2020 |
Published | Apr 20, 2020 |
Warriors Trained | 694 |
Total Skips | 25 |
Total Code Submissions | 2424 |
Total Times Completed | 298 |
Python Completions | 197 |
JavaScript Completions | 113 |
Total Stars | 9 |
% of votes with a positive feedback rating | 89% of 120 |
Total "Very Satisfied" Votes | 98 |
Total "Somewhat Satisfied" Votes | 18 |
Total "Not Satisfied" Votes | 4 |
Total Rank Assessments | 29 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 8 kyu |