Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

essential problems?

Name: dasuraga !8GgBtN/zr. 2010-01-06 14:43

What do you guys think are some problems that most all programmers should be able to write in under 5 minutes? For me, I'd guess Hanoi should be an essential one: writing a function Hanoi(char* letters,int number,int to,int from,int temp) to solve the tower of hanoi problem for 3 slots(the letters array has the disc identifiers in decreasing order) You are supplied with the function move_single(char id,int to,int from) that moves the top disc on the to slot to the from slot(assumes it to be possible).

Name: dasuraga !8GgBtN/zr. 2010-01-06 14:59

>>2
It's not my homework, retard, I know how to solve this:

void Hanoi(char* letters,int number,int to,int from,int temp){
     if(number==0) return;
     Hanoi(letters+1,number-1,temp,from,to);
     move_single(&letters,to,from);
     Hanoi(letters+1,number-1,to,temp,from);
}

(granted, I am not  too sure about my character strings stuff, I have never figured out C strings properly, or C++ strings for that matter: or any strings really)

Anyways, I was just wondering about any other fizzbuzz-y kind of questions, since those are the ones where it's the easiest to make subtle mistakes ( be them inefficiencies or actual mistakes).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List