# Solution of Death by Taxes

O prima solutie implica multe ifuri, dar se poate gasi una mai scurta:
```    1 #!/usr/bin/perl -w
2 use v5.14;
3
4 my @taxes = (10, 15, 25, 28, 33, 35, 39.6);
5
6 my %types; # Hash de la tipuri de persoane la punctele unde se schimba taxa
7            # Daca valoarea e mai mica decat \$types{\$type}[\$i], taxa e \$taxes[\$i] / 100.
8 \$types{Single}                      = [9075,  36900, 89350,  186350, 405100, 406750, 500000];
9 \$types{'Married joint filer'}       = [18150, 73800, 148850, 226850, 405100, 457600, 500000];
10 \$types{'Head of household'}         = [12950, 49400, 127550, 206600, 405100, 432200, 500000];
11 \$types{'Married filing separately'} = [9075,  36900, 74425,  113425, 202550, 228800, 500000];
12 \$types{'Surviving spouse'}          = \$types{'Married joint filer'};
13
14 my (\$type, \$amount) = <>;                     # Citim tipul de persoana si valoarea taxabila
15 chomp \$type;                                  # Stergem newline-ul din \$type
16
17 for my \$i (0 .. \$#taxes) {                    # Luam pe rand tax bracket-urile
18     if (\$types{\$type}[\$i] > \$amount) {        # Daca valoarea se incadreaza in acest bracket...
19         say int (\$amount * \$taxes[\$i] / 100); # ... scriem raspunsul
20         exit                                  # ... si ne oprim
21     }
22 }
```
Questions?