Skip to content

Instantly share code, notes, and snippets.

View abigagli's full-sized avatar

Andrea Bigagli abigagli

  • Florence - Italy
View GitHub Profile
@abigagli
abigagli / num_ways_to_make_change.cpp
Last active February 18, 2019 14:17
Brute force solution for number of ways to make a change in C++
#include <vector>
#include <set>
//Just a brute force recursive solution, to be used as a first step in finding the optimal solution, i.e. by adding memoization
//and then possibly flipping into a table-based bottom-up solution
namespace with_multiset
{
void make_change (int amount, std::vector<int> const &coins, std::set<std::multiset<int>> &changes, std::multiset<int> partial = {})
{
if (amount == 0)
@abigagli
abigagli / main.cpp
Created March 27, 2017 12:51 — forked from Starl1ght/main.cpp
Console
#include <vector>
#include <sstream>
#include <iostream>
#include <iterator>
#include <tuple>
template <typename T>
std::vector<std::string> Split(T&& input) {
std::stringstream ss{ std::forward<T>(input) };
return std::vector<std::string> {std::istream_iterator<std::string>(ss), std::istream_iterator<std::string>{} };