Skip to content

Instantly share code, notes, and snippets.

View willkill07's full-sized avatar
🏠
Working from home

Will Killian willkill07

🏠
Working from home
View GitHub Profile
#include <iostream>
#include <string>
#include <array>
#include <map>
#include <set>
using Point = std::array<int, 2>;
inline Point operator+(const Point& p1, const Point& p2) {
return {{std::get<0>(p1) + std::get<0>(p2), std::get<1>(p1) + std::get<1>(p2)}};
@willkill07
willkill07 / Day11.cpp
Created December 13, 2016 23:58
Day11 AOC2016 Askalski Improved
// compile with -O3 -march=native -std=c++14
#include <array>
#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <map>
#include <regex>
#include <string>
#include <unordered_map>
@willkill07
willkill07 / Day13.cpp
Last active December 14, 2016 00:28
Advent of Code Day 13 C++14
#include <iostream>
#include <string>
#include <array>
#include <map>
#include <set>
// A point is just an array of two elements
using Point = std::array<int, 2>;
// We need to add two points to make a new point, so let's write operator+
@willkill07
willkill07 / day16.cpp
Created December 16, 2016 21:29
Day16.cpp
#include <chrono>
#include <iostream>
#include <string>
int main(int argc, char**) {
auto start = std::chrono::high_resolution_clock::now();
uint LIM{argc > 1 ? 35651584U : 272U};
std::string in;
in.reserve(LIM << 1); // big buffer
std::cin >> in;
@willkill07
willkill07 / .clang-format
Last active September 21, 2017 12:29
Zoppetti-like .clang-format
BasedOnStyle: Mozilla
AlignAfterOpenBracket: Align
AlignEscapedNewlinesLeft: 'true'
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: 'false'
// Expressive Pi
// -------------
//
// Fluent C++ Blog Post: The Pi Day Challenge for Expressive Code
// http://www.fluentcpp.com/2017/03/02/the-pi-day-challenge-for-expressive-code-in-c/
//
// Author: William Killian
// Email: [email protected]
// Github: http://www.github.com/willkill07
// Website: https://www.eecis.udel.edu/~wkillian
@willkill07
willkill07 / ReduceRedux.cpp
Last active May 4, 2017 03:50
RAJA Reduce Redux
// use C++11 to compile
#include <array>
#include <limits>
#include <numeric>
#include <type_traits>
#ifdef _OPENMP
#include <omp.h>
#endif
@willkill07
willkill07 / StrongType.hpp
Last active May 9, 2017 19:43
Strong Typing in C++11
#include <type_traits>
template <typename T, typename Tag>
struct StrongType {
T value;
explicit StrongType(T v) : value(v) {}
StrongType() = default;
StrongType(StrongType const &) = default;
StrongType(StrongType &&) = default;
@willkill07
willkill07 / concat.hpp
Last active May 15, 2017 20:12
tinymeta
namespace impl {
template <template <class ...> class L, class = L<>, class = L<>, class ...>
struct concat_ {
using type = L<>;
};
template <template <class ...> class L,
template <class ...> class L1, class ... T1>
struct concat_<L, L1<T1...>> {
using type = L<T1...>;
@willkill07
willkill07 / StrongTyping.hpp
Last active May 17, 2017 02:45
Strong Typing in C++14
#include <type_traits>
#include <utility>
namespace detail {
template <typename Seq, std::size_t Idx, typename T, T Val, T DefaultVal>
struct make_list_with_index_value;
template <std::size_t Idx, typename T, T Val, T DefaultVal, std::size_t ... Ids>
struct make_list_with_index_value<std::index_sequence<Ids...>, Idx, T, Val, DefaultVal> {
using type = std::integer_sequence<T, ((Idx == Ids) ? Val : DefaultVal)...>;
};