Imagine if there were no order of operations. Instead, you would do the problem from left to right. For example, the equation `$a +b  *c /d$` would become `$(((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](https://en.wikipedia.org/wiki/Order_of_operations#:~:text=In%20the%20United%20States%2C%20the,Excuse%20My%20Dear%20Aunt%20Sally%22.)

### Key:

- `^` represents `**`

```if:python
- `/` represents `//` or `math.floor` because the result will always be an integer
```

```if:javascript
- `/` should always be rounded down(`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
```

Difficulty: introductory

Starter code:

def no_order(equation):
	

Solutions:
def no_order(equation):
    equation = equation.replace(' ', '')
    equation = equation.replace('+', ')+')
    equation = equation.replace('-', ')-')
    equation = equation.replace('*', ')*')
    equation = equation.replace('/', ')//')
    equation = equation.replace('%', ')%')
    equation = equation.replace('^', ')**')
    equation = '('*equation.count(')') + equation
    try : return eval(equation)
    except : pass

import re

def no_order(s):
    try:
        nums= [int(i.replace(' ', '')) for i in re.split('\+|\-|\*|\/|\^|\%', s)]
        ops = [a for a in s if not a in nums and not a in ' 1234567890']
        ans = nums[0]
        for n in range(1, len(nums)):
            op  = ops[n-1]
            num = nums[n]
            if op == '+': ans += num
            if op == '-': ans -= num
            if op == '*': ans *= num
            if op == '/': ans  = ans // num
            if op == '^': ans  = ans ** num
            if op == '%': ans  = ans  % num
        return ans
    except:
        return None


op_table = {
    "+": lambda a,b: a+b,
    "-": lambda a,b: a-b,
    "*": lambda a,b: a*b,
    "/": lambda a,b: a//b,
    "^": lambda a,b: a**b,
    "%": lambda a,b: a%b,
}

def no_order(equation):
    result = op2 = 0
    func_name = "+"
    
    # dummy add to force prior operation to be run
    formula = equation.replace(" ", "") + "+"
    for ch in formula:
        if ch.isdigit():
            op2 *= 10
            op2 += int(ch)
        elif ch not in op_table:
            return None
        else:
            try:
                result = op_table[func_name](result, op2)
            except ZeroDivisionError:
                return None
            func_name = ch
            op2 = 0

    return result


def no_order(e):
    e = e.replace(' ', '').replace('+', ')+').replace('-', ')-').replace('*', ')*').replace('/', ')//').replace('%', ')%').replace('^', ')**')
    try: 
        return eval(f"{'(' * e.count(')')}{e}")
    except: 
        pass

import re

def no_order(equation):
    ops = {
        '+' : lambda l, r : l + r,
        '-' : lambda l, r : l - r,
        '*' : lambda l, r : l * r,
        '/' : lambda l, r : l // r if r != 0 else None,
        '^' : lambda l, r : l ** r,
        '%' : lambda l, r : l % r if r != 0 else None
    }
        
    expr = re.sub(r'[\s\t]+', '', equation.strip())
    expr = re.sub(r'(?<=\W)(?=[\d\s])|(?<=[\d\s])(?=\W)', '\f', expr).split('\f')
    
    temp = expr[0]
    for i in range(1, len(expr), 2):
        temp = ops[expr[i]](int(temp), int(expr[i+1]))
        if temp is None:
            break
    
    if temp is not None:
        return int(temp)
    return temp
    


import re

def no_order(equation):
    operators = {
        "+" : lambda x,y : x + y,
        "-" : lambda x,y : x-y,
        "*" : lambda x,y : x*y,
        "/" : lambda x,y : x//y,
        '^' : lambda x,y : x**y,
        '%' : lambda x,y : x%y}

    equation = equation.replace(" ","")
    list_eq = re.split(r"(\D)", equation)
    
    while len(list_eq) != 1 :
        x = list_eq.pop(0)
        op = list_eq.pop(0)
        y = list_eq.pop(0)
        try : 
            result = operators[op](int(x),int(y))
        except ZeroDivisionError : #for handling %0 and /0
            return None
        list_eq.insert(0,result)
        
    return int(list_eq[0])

import re
from operator import add, sub, floordiv, mul, pow, mod

OPS = {
    '+': add,
    '-': sub,
    '*': mul,
    '/': floordiv,
    '^': pow,
    '%': mod,
}

def no_order(equation):
    equation = equation.replace(' ', '')
    if not equation:
        return None
    it = iter(re.findall(r'\d+|\D+', equation))
    x = int(next(it))
    for op, y in zip(it, it):
        try:
            x = OPS[op](x, int(y))
        except ZeroDivisionError:
            return None
    return x

from re import compile
from functools import reduce
from operator import add, sub, mul, floordiv as div, pow, mod

REGEX = compile(r"^\d+|[^\d]\d+").findall
D = {'+':add, '-':sub, '*':mul, '/':div, '^':pow, '%':mod}

def no_order(equation):
    L = REGEX(equation.replace(" ", ""))
    try:
        return reduce(lambda x,y: D[y[0]](x, int(y[1:])), L[1:], int(L[0]))
    except:
        return None

import re
def no_order(equation):        
    # Delete blank spaces
    equation = equation.replace(' ', '')
    
    # Check null cases
    if '%0' in equation or '/0' in equation: 
        return None
    
    # Extract numbers and operators
    n = re.findall(r'\d+', equation)
    op = re.findall('[+\\-*/%^]', equation)
    
    #Define operators
    operators={
        "+": lambda x, y: x + y,
        "-": lambda x, y: x - y,
        "*": lambda x, y: x * y,
        "/": lambda x, y: x // y,
        "^": lambda x, y: x ** y,
        "%": lambda x, y: x % y}

    result = int(n[0])
    for i in range(1, len(n)):
        result = operators[op[i-1]](result, int(n[i]))
    return result

def is_digit(p):
    return p >= '0' and p <= '9'
    
def is_sign(p):
    return p in '+-*/^%'

def calc(sign, a, b):
    try:
        if sign == '+':
            return a+b
        elif sign == '-':
            return a-b
        elif sign == '*':
            return a*b
        elif sign == '/':
            return a//b
        elif sign == '^':
            return a**b
        else:
            return a%b
    except:
        return None

def no_order(equation):
    left, right = 0, ""
    sign = '+'
    for e in equation:
        if is_sign(e):
            left = calc(sign, left, int(right))
            right = ""
            if left == None:
                return None
            sign = e
        elif is_digit(e):
            right += e
        elif e != ' ':
            return None
    return calc(sign, left, int(right))