[ create a new paste ] login | about

Link: http://codepad.org/D1Sesi4Q    [ raw code | output | fork ]

C, pasted on Feb 7:
#include <stdio.h>
#define RN 7
#define BK 1
#define USE 2
#define recurse(x) { s[p]=(x); count += times * find(p + 1, s); }

typedef unsigned int uint;

uint find(uint p, uint* s)
{
  uint count = 0;
  if (p == RN) return 1; 
  uint times = 1;
  recurse(USE);
  recurse(0);
  if (p > 0 && p % 2 == 0)
  {
    times = (uint)(s[p - 2] == USE && !s[p - 1]) + (uint)(s[p - 1] == USE);
    if (times) recurse(BK);
  }
  return count;
}

int main(int argc, char** argv)
{
  uint s[RN] = {0, 0, 0, 0, 0, 0, 0};
  uint count = find(0, s);
  printf("%d\n", count - 1);
  return 0;
}


Output:
1
316


Create a new paste based on this one


Comments: