Posts

Showing posts from August, 2013

The beauty of Haskell

Ah, the beauty of Haskell, solving the graceful labeling node generation (brute force mind you, but still...) vonKoch edges = do let n = length edges + 1 nodes <- permutations [ 1 .. n ] let nodeArray = listArray ( 1 , n ) nodes let dists = sort $ map ( \ ( x , y ) -> abs ( nodeArray ! x - nodeArray ! y ) ) edges guard $ and $ zipWith ( /= ) dists ( tail dists ) return nodes (solution found here: http://www.haskell.org/haskellwiki/99_questions/Solutions/92 )