diff --git a/cpp/grains/grains.cpp b/cpp/grains/grains.cpp new file mode 100644 index 0000000..d213d8f --- /dev/null +++ b/cpp/grains/grains.cpp @@ -0,0 +1,18 @@ +#include "grains.h" + +namespace grains { + +static const index_t number_of_squares = 64; + + +ulong_t square(index_t index) +{ + return 1ULL << (index - 1); +} + +ulong_t total() +{ + return (1ULL << number_of_squares) - 1; +} + +} diff --git a/cpp/grains/grains.h b/cpp/grains/grains.h new file mode 100644 index 0000000..5afadd5 --- /dev/null +++ b/cpp/grains/grains.h @@ -0,0 +1,14 @@ +#pragma once + +#define EXERCISM_RUN_ALL_TESTS + + +namespace grains { + +typedef unsigned long long ulong_t; +typedef unsigned int index_t; + +ulong_t square(index_t index); +ulong_t total(); + +}