Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
E

el_vez

@el_vez
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • IQ / Programming Quiz (Cannon-Ball Stacks)
    E el_vez

    Haskell answer:

    layers = scanl1 (+) [1..]
    sizes = scanl1 (+) layers
    combinedSizes = [(s1, s2, s1 + s2) | s1 <- sizes, s2 <- takeWhile (< s1) sizes]
    newPyramids = filter combinesToPyramid combinedSizes
    where combinesToPyramid (s1, s2, sum) = sum `elem` (takeWhile (sum >=) sizes)

    answer = head newPyramids

    -------- SPOILER ------------ this gives the answer as "(560, 120, 680)", (if you load it up in GHCI and type "answer"). If you want the n first solutions, just type "take n newPyramids":

    take 3 newPyramids
    [(560,120,680),(27720,1540,29260),(29260,4960,34220)]

    The Lounge help com question learning
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups