thoughts about tech

Taxation Challenge

My daily programmer solution for reddit’s daily programmer

#!/bin/env python3

import math

"""tax(0) => 0
tax(10000) => 0
tax(10009) => 0
tax(10010) => 1
tax(12000) => 200
tax(56789) => 8697
tax(1234567) => 473326
"""


def taxation(totalIncome) -> int:
    incomeBracket = [0, 10000, 30000, 100000]
    incomePercent = [0, 0.10, 0.25, 0.40]

    taxOwed = 0
    if totalIncome > 10000 and totalIncome <= 30000:
        x1 = totalIncome - 10000
        taxOwed += math.floor(x1 * incomePercent[1])
    if totalIncome > 30000 and totalIncome <= 100000:
        x2 = totalIncome - 30000
        taxOwed += 2000
        taxOwed += math.floor(x2 * incomePercent[2])
    if totalIncome > 100000:
        x3 = totalIncome - 100000
        taxOwed += 17500 + 2000
        taxOwed += math.floor(x3 * incomePercent[3])

    return taxOwed


if __name__ == "__main__":
    print(taxation(10010))
    print(taxation(12000))
    print(taxation(56789))
    print(taxation(1234567))