Skip to main content
added 1 character in body
Source Link
mbomb007
  • 23.5k
  • 7
  • 63
  • 135

C++11 metaprogramming, 348bytes348 bytes

#include<iostream>
#define D static const unsigned long long v=
template<int L>struct F{D F<L-1>::v+F<L-2>::v;};template<>struct F<2>{D 1;};template<>struct F<1>{D 1;};template<int Z>struct S:S<Z-1>{S(){auto&s=std::cout;auto l=F<Z>::v;s<<(l%2?"":"Fibo")<<(l%3?"":"Nacci");(l%2&&l%3?s<<l:s)<<"\n";}};template<>struct S<0>{S(){}};int main(){S<100>s;}

Because, why not. It compiles with warning C4307: '+': integral constant overflow, runs fine, but 93+ th Fibonacci numbers are not shown correctly (due to overflow), so this is invalid entry (but I could not win it with that much of bytes though)

Ungolfed

#include <iostream>
#define D static const unsigned long long v = 
template<int L>struct F { D F<L - 1>::v + F<L - 2>::v; };
template<>struct F<2> { D 1; };
template<>struct F<1> { D 1; };

template<int Z>struct S : S<Z - 1>
{
    S()
    {
        auto&s = std::cout;
        auto l = F<Z>::v;
        s << (l % 2 ? "" : "Fibo")
          << (l % 3 ? "" : "Nacci");
        (l % 2 && l % 3 ? s << l : s) << "\n";
    }
};

template<>struct S<0>
{
    S() { }
};

int main()
{
    S<100>s;
}

C++11 metaprogramming, 348bytes

#include<iostream>
#define D static const unsigned long long v=
template<int L>struct F{D F<L-1>::v+F<L-2>::v;};template<>struct F<2>{D 1;};template<>struct F<1>{D 1;};template<int Z>struct S:S<Z-1>{S(){auto&s=std::cout;auto l=F<Z>::v;s<<(l%2?"":"Fibo")<<(l%3?"":"Nacci");(l%2&&l%3?s<<l:s)<<"\n";}};template<>struct S<0>{S(){}};int main(){S<100>s;}

Because, why not. It compiles with warning C4307: '+': integral constant overflow, runs fine, but 93+ th Fibonacci numbers are not shown correctly (due to overflow), so this is invalid entry (but I could not win it with that much of bytes though)

Ungolfed

#include <iostream>
#define D static const unsigned long long v = 
template<int L>struct F { D F<L - 1>::v + F<L - 2>::v; };
template<>struct F<2> { D 1; };
template<>struct F<1> { D 1; };

template<int Z>struct S : S<Z - 1>
{
    S()
    {
        auto&s = std::cout;
        auto l = F<Z>::v;
        s << (l % 2 ? "" : "Fibo")
          << (l % 3 ? "" : "Nacci");
        (l % 2 && l % 3 ? s << l : s) << "\n";
    }
};

template<>struct S<0>
{
    S() { }
};

int main()
{
    S<100>s;
}

C++11 metaprogramming, 348 bytes

#include<iostream>
#define D static const unsigned long long v=
template<int L>struct F{D F<L-1>::v+F<L-2>::v;};template<>struct F<2>{D 1;};template<>struct F<1>{D 1;};template<int Z>struct S:S<Z-1>{S(){auto&s=std::cout;auto l=F<Z>::v;s<<(l%2?"":"Fibo")<<(l%3?"":"Nacci");(l%2&&l%3?s<<l:s)<<"\n";}};template<>struct S<0>{S(){}};int main(){S<100>s;}

Because, why not. It compiles with warning C4307: '+': integral constant overflow, runs fine, but 93+ th Fibonacci numbers are not shown correctly (due to overflow), so this is invalid entry (but I could not win it with that much of bytes though)

Ungolfed

#include <iostream>
#define D static const unsigned long long v = 
template<int L>struct F { D F<L - 1>::v + F<L - 2>::v; };
template<>struct F<2> { D 1; };
template<>struct F<1> { D 1; };

template<int Z>struct S : S<Z - 1>
{
    S()
    {
        auto&s = std::cout;
        auto l = F<Z>::v;
        s << (l % 2 ? "" : "Fibo")
          << (l % 3 ? "" : "Nacci");
        (l % 2 && l % 3 ? s << l : s) << "\n";
    }
};

template<>struct S<0>
{
    S() { }
};

int main()
{
    S<100>s;
}
added 1 character in body
Source Link
Zereges
  • 1.2k
  • 10
  • 22

C++11 metaprogramming, 348bytes

#include<iostream>
#define D static const unsigned long long v=
template<int L>struct F{D F<L-1>::v+F<L-2>::v;};template<>struct F<2>{D 1;};template<>struct F<1>{D 1;};template<int Z>struct S:S<Z-1>{S(){auto&s=std::cout;auto l=F<Z>::v;s<<(l%2?"":"Fibo")<<(l%3?"":"Nacci");(l%2&&l%3?s<<l:s)<<"\n";}};template<>struct S<0>{S(){}};int main(){S<100>s;}

Because, why not. It compiles with warning C4307: '+': integral constant overflow, runs fine, but 93+ th Fibonacci numbers are not shown correctly (due to overflow), so this is invalid entry (but I could not win it with that much of bytes though)

Ungolfed

#include <iostream>
#define D static const unsigned long long v = 
template<int L>struct F { D F<L - 1>::v + F<L - 2>::v; };
template<>struct F<2> { D 1; };
template<>struct F<1> { D 1; };

template<int Z>struct S : S<Z - 1>
{
    S()
    {
        auto&s = std::cout;
        auto l = F<Z>::v;
        s << (l % 2 ? "" : "Fibo")
          << (l % 3 ? "" : "Nacci");
        (l % 2 && l % 3 ? s << l : s) << "\n";
    }
};

template<>struct S<0>
{
    S() { }
};

int main()
{
    S<15>s;S<100>s;
}

C++11 metaprogramming, 348bytes

#include<iostream>
#define D static const unsigned long long v=
template<int L>struct F{D F<L-1>::v+F<L-2>::v;};template<>struct F<2>{D 1;};template<>struct F<1>{D 1;};template<int Z>struct S:S<Z-1>{S(){auto&s=std::cout;auto l=F<Z>::v;s<<(l%2?"":"Fibo")<<(l%3?"":"Nacci");(l%2&&l%3?s<<l:s)<<"\n";}};template<>struct S<0>{S(){}};int main(){S<100>s;}

Because, why not. It compiles with warning C4307: '+': integral constant overflow, runs fine, but 93+ th Fibonacci numbers are not shown correctly (due to overflow), so this is invalid entry (but I could not win it with that much of bytes though)

Ungolfed

#include <iostream>
#define D static const unsigned long long v = 
template<int L>struct F { D F<L - 1>::v + F<L - 2>::v; };
template<>struct F<2> { D 1; };
template<>struct F<1> { D 1; };

template<int Z>struct S : S<Z - 1>
{
    S()
    {
        auto&s = std::cout;
        auto l = F<Z>::v;
        s << (l % 2 ? "" : "Fibo")
          << (l % 3 ? "" : "Nacci");
        (l % 2 && l % 3 ? s << l : s) << "\n";
    }
};

template<>struct S<0>
{
    S() { }
};

int main()
{
    S<15>s;
}

C++11 metaprogramming, 348bytes

#include<iostream>
#define D static const unsigned long long v=
template<int L>struct F{D F<L-1>::v+F<L-2>::v;};template<>struct F<2>{D 1;};template<>struct F<1>{D 1;};template<int Z>struct S:S<Z-1>{S(){auto&s=std::cout;auto l=F<Z>::v;s<<(l%2?"":"Fibo")<<(l%3?"":"Nacci");(l%2&&l%3?s<<l:s)<<"\n";}};template<>struct S<0>{S(){}};int main(){S<100>s;}

Because, why not. It compiles with warning C4307: '+': integral constant overflow, runs fine, but 93+ th Fibonacci numbers are not shown correctly (due to overflow), so this is invalid entry (but I could not win it with that much of bytes though)

Ungolfed

#include <iostream>
#define D static const unsigned long long v = 
template<int L>struct F { D F<L - 1>::v + F<L - 2>::v; };
template<>struct F<2> { D 1; };
template<>struct F<1> { D 1; };

template<int Z>struct S : S<Z - 1>
{
    S()
    {
        auto&s = std::cout;
        auto l = F<Z>::v;
        s << (l % 2 ? "" : "Fibo")
          << (l % 3 ? "" : "Nacci");
        (l % 2 && l % 3 ? s << l : s) << "\n";
    }
};

template<>struct S<0>
{
    S() { }
};

int main()
{
    S<100>s;
}
Source Link
Zereges
  • 1.2k
  • 10
  • 22

C++11 metaprogramming, 348bytes

#include<iostream>
#define D static const unsigned long long v=
template<int L>struct F{D F<L-1>::v+F<L-2>::v;};template<>struct F<2>{D 1;};template<>struct F<1>{D 1;};template<int Z>struct S:S<Z-1>{S(){auto&s=std::cout;auto l=F<Z>::v;s<<(l%2?"":"Fibo")<<(l%3?"":"Nacci");(l%2&&l%3?s<<l:s)<<"\n";}};template<>struct S<0>{S(){}};int main(){S<100>s;}

Because, why not. It compiles with warning C4307: '+': integral constant overflow, runs fine, but 93+ th Fibonacci numbers are not shown correctly (due to overflow), so this is invalid entry (but I could not win it with that much of bytes though)

Ungolfed

#include <iostream>
#define D static const unsigned long long v = 
template<int L>struct F { D F<L - 1>::v + F<L - 2>::v; };
template<>struct F<2> { D 1; };
template<>struct F<1> { D 1; };

template<int Z>struct S : S<Z - 1>
{
    S()
    {
        auto&s = std::cout;
        auto l = F<Z>::v;
        s << (l % 2 ? "" : "Fibo")
          << (l % 3 ? "" : "Nacci");
        (l % 2 && l % 3 ? s << l : s) << "\n";
    }
};

template<>struct S<0>
{
    S() { }
};

int main()
{
    S<15>s;
}