Advertisement
JoelSjogren

Untitled

Nov 25th, 2020
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. box% ghci
  2. GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
  3. Prelude> terms = let digs = [1..5] in [a*1000 + b*100 + c*10 + d*1 | a <- digs, b <- digs, c <- digs, d <- digs, a/=b, a/=c, a/=d, b/=c, b/=d, c/=d]
  4. Prelude> terms
  5. [1234,1235,1243,1245,1253,1254,1324,1325,1342,1345,1352,1354,1423,1425,1432,1435,1452,1453,1523,1524,1532,1534,1542,1543,2134,2135,2143,2145,2153,2154,2314,2315,2341,2345,2351,2354,2413,2415,2431,2435,2451,2453,2513,2514,2531,2534,2541,2543,3124,3125,3142,3145,3152,3154,3214,3215,3241,3245,3251,3254,3412,3415,3421,3425,3451,3452,3512,3514,3521,3524,3541,3542,4123,4125,4132,4135,4152,4153,4213,4215,4231,4235,4251,4253,4312,4315,4321,4325,4351,4352,4512,4513,4521,4523,4531,4532,5123,5124,5132,5134,5142,5143,5213,5214,5231,5234,5241,5243,5312,5314,5321,5324,5341,5342,5412,5413,5421,5423,5431,5432]
  6. Prelude> length terms
  7. 120
  8. Prelude> sum terms
  9. 399960
  10. Prelude>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement