Skip to main content
Notice removed Reward existing answer by lyxal
Bounty Ended with The Thonnu's answer chosen by lyxal
Notice added Reward existing answer by lyxal
Bounty Started worth 100 reputation by lyxal
edited tags
Link
The Thonnu
  • 18.3k
  • 3
  • 16
  • 74
Became Hot Network Question
Tweeted twitter.com/StackCodeGolf/status/1606983096011825152
Clarify that it is always positive
Source Link
The Thonnu
  • 18.3k
  • 3
  • 16
  • 74

Background

Here in the UK1, these are the income tax rules:

  • You get a personal allowance (untaxed) of up to £12,570:
    • If you earn less than £100,000, you get the full £12,570 as personal allowance
    • For every £2 over £100,000, your personal allowance goes down by £1
  • After the personal allowance, the next £37,700 is taxed at the "basic rate" of 20%
  • After that, the next £99,730 is taxed at the "higher rate" of 40%
  • Finally, anything above this is taxed at the "additional rate" of 45%

1: This isn't actually the case in Scotland; only England, Wales and Northern Ireland.

Your task

Using the above tax rules, take in an annual salary (as ana positive integer) and calculate the income tax.

Test cases

Input    Output
12570    0
50000    7486
80000    19432
120000   39432
200000   75588.5

Note: the final test case can be any of 75588, 75588.5, or 75589 (any is fine)

Clarifications

  • You can choose whether to make the personal allowance an integer or keep it as a float
    • e.g. if the input is £100,003, the personal allowance can be £12,569, £12,568.50, or £12,568
  • The same goes for the final output. If it ends up as a float, you can make it an integer or keep it as a float
    • (see the final test case)
  • This is , so shortest answer in bytes wins!

Background

Here in the UK1, these are the income tax rules:

  • You get a personal allowance (untaxed) of up to £12,570:
    • If you earn less than £100,000, you get the full £12,570 as personal allowance
    • For every £2 over £100,000, your personal allowance goes down by £1
  • After the personal allowance, the next £37,700 is taxed at the "basic rate" of 20%
  • After that, the next £99,730 is taxed at the "higher rate" of 40%
  • Finally, anything above this is taxed at the "additional rate" of 45%

1: This isn't actually the case in Scotland; only England, Wales and Northern Ireland.

Your task

Using the above tax rules, take in an annual salary (as an integer) and calculate the income tax.

Test cases

Input    Output
12570    0
50000    7486
80000    19432
120000   39432
200000   75588.5

Note: the final test case can be any of 75588, 75588.5, or 75589 (any is fine)

Clarifications

  • You can choose whether to make the personal allowance an integer or keep it as a float
    • e.g. if the input is £100,003, the personal allowance can be £12,569, £12,568.50, or £12,568
  • The same goes for the final output. If it ends up as a float, you can make it an integer or keep it as a float
    • (see the final test case)
  • This is , so shortest answer in bytes wins!

Background

Here in the UK1, these are the income tax rules:

  • You get a personal allowance (untaxed) of up to £12,570:
    • If you earn less than £100,000, you get the full £12,570 as personal allowance
    • For every £2 over £100,000, your personal allowance goes down by £1
  • After the personal allowance, the next £37,700 is taxed at the "basic rate" of 20%
  • After that, the next £99,730 is taxed at the "higher rate" of 40%
  • Finally, anything above this is taxed at the "additional rate" of 45%

1: This isn't actually the case in Scotland; only England, Wales and Northern Ireland.

Your task

Using the above tax rules, take in an annual salary (as a positive integer) and calculate the income tax.

Test cases

Input    Output
12570    0
50000    7486
80000    19432
120000   39432
200000   75588.5

Note: the final test case can be any of 75588, 75588.5, or 75589 (any is fine)

Clarifications

  • You can choose whether to make the personal allowance an integer or keep it as a float
    • e.g. if the input is £100,003, the personal allowance can be £12,569, £12,568.50, or £12,568
  • The same goes for the final output. If it ends up as a float, you can make it an integer or keep it as a float
    • (see the final test case)
  • This is , so shortest answer in bytes wins!
Clarified that it's not actually the same system in Scotland
Source Link
The Thonnu
  • 18.3k
  • 3
  • 16
  • 74

Background

Here in the UK1, these are the income tax rules:

  • You get a personal allowance (untaxed) of up to £12,570:
    • If you earn less than £100,000, you get the full £12,570 as personal allowance
    • For every £2 over £100,000, your personal allowance goes down by £1
  • After the personal allowance, the next £37,700 is taxed at the "basic rate" of 20%
  • After that, the next £99,730 is taxed at the "higher rate" of 40%
  • Finally, anything above this is taxed at the "additional rate" of 45%

1: This isn't actually the case in Scotland; only England, Wales and Northern Ireland.

Your task

Using the above tax rules, take in an annual salary (as an integer) and calculate the income tax.

Test cases

Input    Output
12570    0
50000    7486
80000    19432
120000   39432
200000   75588.5

Note: the final test case can be any of 75588, 75588.5, or 75589 (any is fine)

Clarifications

  • You can choose whether to make the personal allowance an integer or keep it as a float
    • e.g. if the input is £100,003, the personal allowance can be £12,569, £12,568.50, or £12,568
  • The same goes for the final output. If it ends up as a float, you can make it an integer or keep it as a float
    • (see the final test case)
  • This is , so shortest answer in bytes wins!

Background

Here in the UK, these are the income tax rules:

  • You get a personal allowance (untaxed) of up to £12,570:
    • If you earn less than £100,000, you get the full £12,570 as personal allowance
    • For every £2 over £100,000, your personal allowance goes down by £1
  • After the personal allowance, the next £37,700 is taxed at the "basic rate" of 20%
  • After that, the next £99,730 is taxed at the "higher rate" of 40%
  • Finally, anything above this is taxed at the "additional rate" of 45%

Your task

Using the above tax rules, take in an annual salary (as an integer) and calculate the income tax.

Test cases

Input    Output
12570    0
50000    7486
80000    19432
120000   39432
200000   75588.5

Note: the final test case can be any of 75588, 75588.5, or 75589 (any is fine)

Clarifications

  • You can choose whether to make the personal allowance an integer or keep it as a float
    • e.g. if the input is £100,003, the personal allowance can be £12,569, £12,568.50, or £12,568
  • The same goes for the final output. If it ends up as a float, you can make it an integer or keep it as a float
    • (see the final test case)
  • This is , so shortest answer in bytes wins!

Background

Here in the UK1, these are the income tax rules:

  • You get a personal allowance (untaxed) of up to £12,570:
    • If you earn less than £100,000, you get the full £12,570 as personal allowance
    • For every £2 over £100,000, your personal allowance goes down by £1
  • After the personal allowance, the next £37,700 is taxed at the "basic rate" of 20%
  • After that, the next £99,730 is taxed at the "higher rate" of 40%
  • Finally, anything above this is taxed at the "additional rate" of 45%

1: This isn't actually the case in Scotland; only England, Wales and Northern Ireland.

Your task

Using the above tax rules, take in an annual salary (as an integer) and calculate the income tax.

Test cases

Input    Output
12570    0
50000    7486
80000    19432
120000   39432
200000   75588.5

Note: the final test case can be any of 75588, 75588.5, or 75589 (any is fine)

Clarifications

  • You can choose whether to make the personal allowance an integer or keep it as a float
    • e.g. if the input is £100,003, the personal allowance can be £12,569, £12,568.50, or £12,568
  • The same goes for the final output. If it ends up as a float, you can make it an integer or keep it as a float
    • (see the final test case)
  • This is , so shortest answer in bytes wins!
Source Link
The Thonnu
  • 18.3k
  • 3
  • 16
  • 74
Loading