## Search found 6 matches

Wed Aug 25, 2010 6:50 am UTC
Forum: Computer Science
Topic: Ackermann Function
Replies: 7
Views: 2810

### Re: Ackermann Function

C++, and noticeably faster then the naive implementation. Dynamic programming FTW! (defn ack [x y] (cond (= x 0) (inc y) (= y 0) (ack (dec x) 1) :else (ack (dec x) (ack x (dec y))))) Clojure: a little less verbose than C++. And if you want to cache results, just: (def ack* (memoize ack)) edit: spac...
Wed Jun 02, 2010 6:50 pm UTC
Forum: Coding
Topic: Manufactoria - Make Turing Machines with Conveyor Belts
Replies: 350
Views: 119247

### Re: Manufactoria - Make Turing Machines with Conveyor Belts

That works only if the three blues are all in a row; your solution rejects [BBRB]. If it were as simple as your 5-part solution, you wouldn't be the first to notice.
Wed May 26, 2010 3:06 pm UTC
Forum: Coding
Topic: Manufactoria - Make Turing Machines with Conveyor Belts
Replies: 350
Views: 119247

### Re: Manufactoria - Make Turing Machines with Conveyor Belts

My robo-children answer is n 2 too, and with a slightly larger constant factor than yours. As Berengal demonstrated, though, it doesn't have to be - his looks n*log(n) to me, with a pretty small constant factor? Most of the time it's O(n), even, but for pathological inputs like RRRRRRRRRRRRBBBBBBBBB...
Tue May 25, 2010 10:34 pm UTC
Forum: Coding
Topic: Manufactoria - Make Turing Machines with Conveyor Belts
Replies: 350
Views: 119247

### Re: Manufactoria - Make Turing Machines with Conveyor Belts

I'm surprised everyone is having so much trouble with Rocket Planes - that wasn't the one that tripped me up. The general approach I used was Rather than move blues to the front, move reds to the back A more detailed (still pseudo-code) algorithm: ⋅ Copy/skip any number of blues ⋅&nbs...
Fri Feb 29, 2008 11:17 pm UTC
Forum: Coding
Topic: Using regexec in C/C++
Replies: 5
Views: 3864

### Re: Using regexec in C/C++

int regexec(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags) from reading the docs on regex.h, this is what i gather: i believe nmatch is the number of matches you want and pmatch is an array that needs to be of size nmatch. after running regexec, pmatch will...
Fri Dec 15, 2006 9:30 am UTC