Commit 2f73fe79 authored by epsi sayidina's avatar epsi sayidina

PPh ps 17: Tarif Progresif

parent 693638c7
......@@ -7,13 +7,13 @@ pph :: Int -> Int
pph pkp = round $ pph_recursive $ fromIntegral pkp
where
-- [(tingkat, persentase)]
reff = [(0, 5), (50, 15), (250, 25), (500, 30)]
reff2 = [ (t*(10^6), (p/100)) | (t, p) <- reff]
reff = [(0, 5), (50, 15), (250, 25), (500, 30)]
tarrifs = [ (t*(10^6), (p/100)) | (t, p) <- reff]
pph_recursive 0 = 0
pph_recursive pkp_real =
(\(t, p) -> (pkp_real - t) * p + pph_recursive(t)) tariff
where
indices = [ i | (i, (t, p)) <- zip [0..] reff2, pkp_real > t]
tariff = reff2 !! last indices
indices = [ i | (i, (t, p)) <- zip [0..] tarrifs, pkp_real > t]
tariff = tarrifs !! last indices
main = mapM_ (print . pph) pkps
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment