Skip to content

Instantly share code, notes, and snippets.

@Tyralion
Last active March 18, 2016 03:07
Show Gist options
  • Select an option

  • Save Tyralion/a90da5489f6c25995a28 to your computer and use it in GitHub Desktop.

Select an option

Save Tyralion/a90da5489f6c25995a28 to your computer and use it in GitHub Desktop.
import Data.List
change :: (Ord a, Num a) => a -> [[a]]
change a = let
coins = [2,3,7]
unique = reverse . nub . reverse
helper a = [ filter (/=0) [x, y, z] | x <- 0 : coins, y <- 0 : coins, z <- 0 : coins, x + y + z == a ]
in unique $ helper a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment