added src files

Range for. Also, I wonder can you use one of the std algorithms here (maybe std::accumulate with a lamba)