Print strings from "a" to "zzzzz" without using any loop or conditional statements. Don't just write all 1000 permutations out by hand. The output should look like this: a
b
c
...
aa
ab
ac
...
zzzzx
zzzzy
zzzzz
inb4 lipthfags and dead dogs using some obscure functionality of their obscure languages.
Name:
172011-05-03 7:54
This runs for me without any stack overflows on my machine.
#include <iostream>
#include <cstdlib>
template<typename T>
struct true_define
{
typedef T (*is_true)(T);
};
template<typename T>
T is_true1(T x)
{
return x;
}
template<typename T>
T is_true2(T x)
{
return 1;
}
template<typename T, int I>
struct check_bits
{
static T check(T x, T cur, typename true_define<T>::is_true tests[2])
{
cur = tests[cur]((x >> I) & 1);
return check_bits<T, I-1>::check(x, cur, tests);
}
};
template<typename T>
struct check_bits<T, 0>
{
static T check(T x, T cur, typename true_define<T>::is_true tests[2])
{
cur = tests[cur](x & 1);
return cur;
}
};
void recursive_increment(char* p)
{
incrementer inc(p+4, 5);
inc.if_(p[4] / 'z');
print_string(p);
__asm {
pop eax;
pop eax;
pop eax;
pop eax;
pop eax;
pop eax;
pop eax;
pop eax;
}
recursive_increment(p);
}