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: Anonymous 2010-01-06 14:46

Cool homework bro.

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).

Name: Anonymous 2010-01-06 15:12

solve the tower of hanoi problem for 3 slots
There is no reason to arbitrarily limit the number of slots.

Name: Anonymous 2010-01-06 15:33

>>4
There is no reason to arbitrarily limit the number of sluts.
Sure sounds like a party I'd go to, brah.

Name: dasuraga !8GgBtN/zr. 2010-01-06 15:40

>>4
solving it for n slots becomes somewhat pointless (you'd probably have to cycle through them wierdly to do it "efficiently"). You can solve an arbitrary height with 3 slots: the point is to see if they can write it out relatively fast.

Name: Anonymous 2010-01-06 15:44

What do you guys think are some problems that I memorized from a CS class but couldn't solve myself
ftfy

Name: Anonymous 2010-01-06 15:47

>>6
It's no more pointless than the problem was to begin with. You are supposed to be a programmer, if you can do something once, you can do it n times.

Name: Anonymous 2010-01-06 16:00

>>8
You can't kill yourself n times. Ergo your wrong bitch.

Name: Anonymous 2010-01-06 16:06

>>9
You can, except it's idempotent.

Name: Anonymous 2010-01-06 16:08

>>9
You could certainly write a kill_human procedure, which could be generalised to kill_humans and possibly a kill_all_humans procedure.
I am not a doctor, but I believe that there are several definitions of dead (brain-dead, etc) and it may be possible that you met one of the definitions, and survived. This would allow you to die multiple times.

Name: Anonymous 2010-01-06 16:08

>>9
Leave my wrong bitch out of this, pal.

Name: Anonymous 2010-01-06 16:38

I couldn't write it in five minutes because I never actually bothered to remember the solution. However, I'm still a better programmer than you, >>1.

Name: Anonymous 2010-01-06 17:11

>>12
I'm not you're pal, ntsc.

Name: Anonymous 2010-01-06 17:11

>>3
Can you explain how this executes?  It's not that I' don't know how a Tower of Hanoi problem resolves, but I think I may need your initial parameter values to understand your algorithm better.

Name: dasuraga !8GgBtN/zr. 2010-01-06 17:12

>>13
the point is you shouldn't need to memorise the solution, you should be able to find it in a minute or so(less if you know it's recursive). That's like complaining you couldn't find fizzbuzz in 5 minutes.

Name: Anonymous 2010-01-06 17:16

>>10
Have you read your RFC2616 today?

Name: Anonymous 2010-01-06 21:33

hello world

Name: Anonymous 2010-01-06 22:59

What is this [sup]\\ [\sup]Tower of Hanoi// and why should I know how to solve it

Name: Anonymous 2010-01-06 22:59

What is this \\ Tower of BBCode// and why should I know how to fail it

Name: Anonymous 2010-01-06 23:02

EXPERT FIZZ-BUZZ SOLUTIONS

Name: Anonymous 2010-01-07 5:57

>>3

Understanding (i.e. memorizing) algorithms, but not too sure about them C/C++ strings and the basics of how characters are encoded for use in a string...

well, you're fucked.

Name: dasuraga !8GgBtN/zr. 2010-01-07 6:49

>>22
I understand how a C string works(null terminated char array), it's just I make indexing errors all the time. C++ strings I don't manipulate enough to know the class functions well(I use perl regex if I want to do anything string-y)

Name: Anonymous 2010-01-07 7:26

I use perl
And now you have two problems

Name: Anonymous 2010-01-07 18:47

What do you guys think are some problems that most all programmers should be able to write in under 5 minutes?
fib, of course

Name: Anonymous 2010-01-14 8:48

How about doing hanoi without recursion? Anyone up for the task? Or are you not MAN ENOUGH.

Name: Anonymous 2010-01-14 8:51

>>26
Are you crazy? Hanoi can't be done without recursion!

Name: Anonymous 2010-01-14 9:01

>>27
2/10

Name: Anonymous 2010-01-14 9:57

>>27
bah humbug.
if you can unroll loops, you can unroll recursions.
it's possible without using recursion and without using loops, AND without using if statements.

Name: Anonymous 2010-01-14 10:11

>>29
Let me guess. You think being a human compiler is super cool. Am I right or am I right?

Name: Anonymous 2010-01-14 10:32

>>30
How else could he have completed his ANSI C compiler in ANSI C when he was 12?

Name: Anonymous 2011-01-31 20:47

<-- check em dubz

Name: Anonymous 2011-02-02 22:32

<

Name: Anonymous 2011-02-04 16:21


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