• Member for 7 years, 7 months
  • Last seen more than a month ago
  • Canada
Write a piece of code to output the line number of the print / output statement itself (in the form "Hello World, from line X!")
27 votes

C++ #include <iostream> #include <utility> #include <type_traits> #define __(A,B,C,...) B##C##A #define _(A,...) __(__VA_ARGS__, A) template<unsigned...Is> struct v; template&...

View answer
Magic the Gathering: Friends or Foes?
16 votes

C++ template metaprogramming, 85 bytes template<int A,int B,int=(A-B)%9%5%3>struct f;template<int A,int B>struct f<A,B,0>{}; less golfed: template<int A, int B,int Unused=(((A-B)%...

View answer
Is this number a prime?
15 votes

C++ template metaprogramming. 166 131 119 bytes. Code compiles if the constant is a prime, and does not compile if composite or 1. template<int a,int b=a>struct t{enum{x=t<a,~-b>::x+!(a%b)...

View answer
A Numpad's Knight Numbers
6 votes

grep 58 bytes grep "^((?=18|16|29|27|34|38|49|43|61|67|72|76|81|83|94|92).)*.$" Because really, if you cannot beat grep...

View answer
You are the Weakest Link, Goodbye
4 votes

MedianPlayer This player attempt to be the meanest (well, medianness) one left. It votes to eliminate the smartest and dumbest opponents (with a slight bias towards voting off the smartest), depending ...

View answer
Produce different behaviour in all versions of your language
3 votes

This C++03 C++11 and C++14 program prints old, medium or new: (C++03 is a set of technical corrections to C++98: compilers consider the two to be synonymous) #define M(x, ...) __VA_ARGS__ int a[] = {...

View answer
Addition in base -1+i
2 votes

C++ 416 bytes, plus #include <vector>\n#include <algorithm>\n (another 40) using I=int;using v=std::vector<I>;void r(v&x){v r{rbegin(x),rend(x)};x=r;}v a(v L,v R){r(L);r(R);L....

View answer
Write a program that makes 2 + 2 = 5
0 votes

template metaprogramming #include <iostream> #include <utility> #include <type_traits> enum class values { zero = 7, one = 3, two = 1, three = -7, four = 2, five = 4, };...

View answer