Open evantianx opened 5 years ago
You will be given a number and you will need to return it as a string in Expanded Form. For example:
expandedForm 12 -- Should return '10 + 2' expandedForm 42 -- Should return '40 + 2' expandedForm 70304 -- Should return '70000 + 300 + 4'
NOTE: All numbers will be whole numbers greater than 0.
import Data.List(intercalate) expandedForm :: Int -> String expandedForm = intercalate " + " . map(\(n, c) -> c : replicate n '0') . reverse . filter((/='0') . snd) . zip [0..] . reverse . show
You will be given a number and you will need to return it as a string in Expanded Form. For example:
NOTE: All numbers will be whole numbers greater than 0.