Skip to content

Instantly share code, notes, and snippets.

@ratatosk
ratatosk / gist:5427242
Last active December 16, 2015 11:28
histogram water volume under waterfall
module Main where
-- for each histogram column find maximum height to the left
maxima :: [Int] -> [Int]
maxima = scanl1 max
-- fill with water. level at every column is minimum of
-- right and left maximum heights
fill :: [Int] -> [Int]
fill l = zipWith min (maxima l) (reverse $ maxima $ reverse l)
#include <stdexcept>
#include <iostream>
#include <string>
#include <boost/thread.hpp>
#include <boost/asio.hpp>
#include <boost/chrono.hpp>
using boost::asio::ip::tcp;
boost::asio::io_service io;
#include <iostream>
#include <string>
#include <boost/thread.hpp>
#include <boost/asio.hpp>
#include <boost/chrono.hpp>
using boost::asio::ip::tcp;
boost::asio::io_service io;
tcp::socket sock(io);