Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Brain Teasers for Coders?

Cliff posted about 9 years ago | from the excercise-for-your-mind dept.

Education 109

calvinandhobbes asks: "There are about 200 people working on different projects and most of them do programming without having an idea of what they actually do. they have little understanding of OS internals and primitive hacking skills. I want to enthuse them by providing some challenges by which they touch upon complex computing concepts, while solving the problem. Does anyone know of a set of C-based hacks or puzzles with which I can enthuse these budding programmers and testers?"

cancel ×


Sorry! There are no comments related to the filter you selected.

If they're not interested, they're not interested (3, Insightful)

DavidNWelton (142216) | about 9 years ago | (#13222069)

If you've already been exposed to programming, and haven't got the desire to carry on learning on your own, I don't know that any amount of brain teasers will give you that spark. More likely, they'll just regard it as another pain in the ass to be dealt with.

Re:If they're not interested, they're not interest (1)

liquidpele (663430) | about 9 years ago | (#13222717)

True, unless it's a game with a good prize! That has a chance of still working...
for instance, make a group project where they can work together and share the prize if they want, but the goal is to get embedded linux working on a robot that will then pamper them with doughnuts and coffee. Stupid example, but you get the idea. Make sure it's fun and that there is some kind of reward. Also make sure that they don't only work on the project and still get work done.

Re:If they're not interested, they're not interest (1, Insightful)

Shaper_pmp (825142) | about 9 years ago | (#13230853)

TBH, even then the reward is the prize, and not the programming.

There are two types of programmers in the world - hackers and code-grinders.

Hackers live for interesting problems, matching their wits and expertise against the hardest and most intracable problems they can find, and smash through complexities that would make anyone else's your brain bleed with a gleeful laugh [] . No reward you can offer them is better than a selection of interesting challenges, adequate pay and freedom from drudgery.

Code-grinders code because they have to, not because they like it - it's a job, nothing more. Nothing you can do will make them love it, or they'd be hackers, not code-grinders. You can try to improve morale with rewards, incentives and fun games, but you'll only be teaching them to work hard for extra rewards, not to love what they're doing or to do their best work.

On the upside, code-grinders don't do their jobs for fun or stimulation, so you can give them the shittiest, most boring problems and make them work under the most unnecessary, arbitrary restrictions, just as long as you also keep giving them the paycheques with the other hand. After all, that's the only reason they're there.

If you're lucky, you've got a room full of hackers, and your productivity will be enormous as long as you don't do something stupid like giving them drudge-work, putting a non-hacker manager in charge of them or needlessly forcing them to follow a non-optimal solution.

If you're unlucky (as it sounds) you've got a room full of code-grinders. You'll never motivate them to enjoy their jobs, only to tolerate them better.

Against this background I'd advise you not to bother tring to awaken their interest in programming - if they ever had one it would have sparked the second they first tried coding, and if it didn't, it ain't there.

Instead, focus on perks, pay and working conditions, to make their job more tolerable.

Ok, so I'm generalising a bit here, but I've found it broadly to be true - either you live to code, or code to live, and people don't really change that much.

Re:If they're not interested, they're not interest (0)

Anonymous Coward | about 9 years ago | (#13226299)

bah, cmon people, mod this down. he never said these people werent interested in learning.

brain teasers arent just for people who need a spark. they can be fun for pros also.

Re:If they're not interested, they're not interest (1)

Shaper_pmp (825142) | about 9 years ago | (#13232527)

I don't know if you've ever worked with real programmers before, but if you have to "motivate" them to learn something, they really don't want to learn it, and really aren't going to enjoy doing so.

In addition, what's the point of trying games to "enthuse" people who are already highly motivated to learn? You'd do better by chucking them a book or website and letting them get on with it.

The entire subtext of the question seems to indicate they aren't already interested in learning.

Aren't things like that... (1)

Hangin10 (704729) | about 9 years ago | (#13222073)

At the end of every chapter in a learn to program book? Chapter exercises and things like that. Bank account classes and the like.

Re:Aren't things like that... (2, Insightful)

EdelFactor19 (732765) | about 9 years ago | (#13223531)

that is precisely what he is NOT looking for or asking for.. which part of complex computing concepts and OS internals did you fail to grasp? a bank account program / class (if done in c++) is merely another silly and trivial program to write. Heck i've had do write one in just about every other lower level CS class i've ever taken. it doesnt involve whats really going on with the computer and it has nothing to do with a hack, OS internals, or any of that good stuff.....

chapter exercises? are you kidding me? thats like responding to "im looking for some complex math puzzles" and you say pick up your calc book and do the section reviews... 99% of the time they arent challenging, interesting or of any more value than any other mundane problem in the section of the books exercises.

next time, rtfa and then rtfa again.

Re:Aren't things like that... (1)

Hangin10 (704729) | about 9 years ago | (#13224144)

A couple minutes after hitting Submit, I realized
that. You are quite right.

Another argument against complex computing concepts
and OS internals is that the latest trend is away
from having to know such things. It started with
high level languages, then protected mode APIs, now
we have virtual machines (ala Java and it's huge

Of course there's also people who just shouldn't
be told how things work. These are the same people
who would ask what they need to import to use
while (Java class a long time ago.. was pretty
funny and sad at the same time).

Re:Aren't things like that... (0)

Anonymous Coward | about 9 years ago | (#13233125)

There's the classic write a function to swap two integers WITHOUT A TEMP variable given this shell:
void swap(int * a, int * b) { }

It's probably the most common mind-bender of a problem, but I think it's the type of thing you're looking for. The other one that I can think of off the top of my head would be re-using code for linked lists... for example, if you want a function to concatinate two linked lists and return the result... tell them they have to do it without writing code to transverse either of the lists (and don't TELL them to use the copy constructor), and things of that nature.

Try here for inspiration (1)

SimilarityEngine (892055) | about 9 years ago | (#13222113)

You might want to look at The Python Challenge [] - admittedly not C-based, but goes to show to concept works.

Make it more interesting (0)

Anonymous Coward | about 9 years ago | (#13222133)

Try googling for "Shell wargames" and look around at what you find. There is an excellent website out there, but I'm not going to post the link on slashdot since the flood of semi-interested people who would register and never contribute to the scene there would take the site down a couple notches.

consider finding this site the first challenge.

Re:Make it more interesting (1)

Anonymous Coward | about 9 years ago | (#13222683) [] [] []

semi interested people become interested people, idiot.

Re:Make it more interesting (-1, Flamebait)

Anonymous Coward | about 9 years ago | (#13223167)

Congrats, moron. is now slashdotted.

I managed to find it, what makes you think others couldn't? What makes you think that the ones who couldn't find it have any fucking BUSINESS going there?

In conclusion, thanks a lot, jackass.

Re:Make it more interesting (0)

Anonymous Coward | about 9 years ago | (#13224592)


lol caps lock is cruise control for cool idiots

Re:Make it more interesting (0, Flamebait) (780570) | about 9 years ago | (#13223233)

you son of a whore, I was attempting to save the site from slashdotting. good fucking job.

Hmm (0)

KDan (90353) | about 9 years ago | (#13222140)

Sounds like your average IT department...

Only one solution: extermination.


Re:Hmm (1)

lobsterGun (415085) | about 9 years ago | (#13222257)

Funny you should say that.

When I read the atricle, I mentally substituted
the word euthanise to enthuse. I found myself wondering, "Why give brain teasers to peopl you're going to kill anyway? This makes no sense."

Programming Challenges (3, Informative)

tcopeland (32225) | about 9 years ago | (#13222145)

Programming Challenges [] is a nifty book by Steven Skiena and Miguel Revilla. It's a selection of problems from the Online-Judge [] problem set. There's a lot of nifty stuff in there - sorting, graph theory, number theory, etc.

Best of all, when folks solve the problems, they can submit their solutions online to see if they pass muster!

Re:Programming Challenges (2, Informative)

saintp (595331) | about 9 years ago | (#13222205)

It's a selection of problems from the Online-Judge problem set.
Yes yes yes! That problem set is wonderful, and would have been my recommendation had you not cold-heartedly stolen it. The problems range from easy to friggin' impossible, most are fun, some are even funny, and, as noted, you can get the results online. There are also, IIRC, message boards somewhere if you need help with a problem. Great and extremely large problem set.

Re:Programming Challenges (1)

niskel (805204) | about 9 years ago | (#13222808)

Yes, I would also recommend this book. I had the opportunity to attend a keynote by the author regarding sports betting and mathmatical biases. Also, I often use and enjoy those programming problems from that problemset. Again, highly recommended.

Re:Programming Challenges (1)

meiao (846890) | about 9 years ago | (#13228020)

I recommend the PC site which has a judge just like uva, but it has a better interface. You send your source code and after a few seconds you get a message (OK, no, and maybe a few info on no's).

Here's a site with challenges (1)

hackwrench (573697) | about 9 years ago | (#13222172) [] I first knew of this site because of it's Borg Disassembler. I wrote a few utilites for Borg in QB and he was nice enough to put them on his site. (1)

slapout (93640) | about 9 years ago | (#13222173)

Not exactly what you're asking for, but their are some programming challenges at []

More programming challenges... (2, Informative)

SimilarityEngine (892055) | about 9 years ago | (#13222196)

Just looked on google [] and there's a ton of stuff. Quite interesting was [] 's C++ Programming Challenge, but there's loads more....

topcoder (2, Informative)

Glog (303500) | about 9 years ago | (#13222214)

TopCoder []

Re:topcoder (1)

thesnarky1 (846799) | about 9 years ago | (#13228294)

I highly recommend this competition for a number of reasons. 1 - The puzzles are fairly good, and both speed and correctness are judged. 2 - There's a challenge phase, which gives practice reading through other people's source. 3 - It *is* a competition, and money can be won. 4 - Through the same site, free-lance programming can be found for some extra cash. All in all, definatly worth checking out!

ACM Programming Competition Problems (3, Interesting)

mr_rattles (303158) | about 9 years ago | (#13222245)

The ACM puts up a lot of programming challenges and have an automatic judge system to determine if your solution is correct or not. They have hundreds of problems of varying difficulty: []

RSA (1)

RealityMogul (663835) | about 9 years ago | (#13222256)

Things I like to tinker with when I'm feeling overly geeky and bored.

* RSA Factoring Challenge - because nobody has found a "magic" formula for instant factoring.
* Physics simulations - just because its fun to draw a ball on the screen and have it bounce around in a realitic fashion.
* 3D graphics - because it looks cool

The RSA challenge I play with when I feel more like thinking than coding. The other two are nice when I want to tinker for awhile, but also want quick visual results, which in turn keep me motivated to keep going further.

Re:RSA (2, Insightful)

Paul Crowley (837) | about 9 years ago | (#13222930)

* RSA Factoring Challenge - because nobody has found a "magic" formula for instant factoring.

You're funny. It's very unlikely that a breakthrough in factoring is going to come from the tinkering of a bored coder. It's more likely to come from someone who has already mastered advanced number theory, algebraic number theory, elliptic curves and finite fields, the CFRAC method, the quadratic sieve, and the special and general number field sieves.

And no-one's ever proven that you have to factor large numbers to solve the RSA problem. Indeed, it's now believed that no such relation will ever be found.

Re:RSA (1)

LnxAddct (679316) | about 9 years ago | (#13224312)

Many advances and breakthroughs have come from people who were nothing but armchair tinkerers in their field, including mathematics. I wouldn't be surprised if it was a tinkerer who cracked RSA. Regardless, you shouldn't insult or deride people for trying, what makes you think its not easy to factor large integers other then the fact that its never been done. I have yet to see a proof and until then, RSA is only secure because of an oversight by humans as far as I'm concerned. Say what you want, but show me a proof Mr. Supreme Cryptologist who is so great that he can mock others for something he hasn't been able to do!

Re:RSA (1, Interesting)

Anonymous Coward | about 9 years ago | (#13224385)

And no-one's ever proven that you have to factor large numbers to solve the RSA problem.

??? The "RSA Factoring Challenge" [] is a challenge set by the RSA company to... factor large numbers.

This is a different proposition to breaking RSA encryption.

And yes, you do look like an ass now.

Good C line (1)

thefirelane (586885) | about 9 years ago | (#13222298)

Ask them what this line of C does


Re:Good C line (1)

Profane MuthaFucka (574406) | about 9 years ago | (#13222626)

Simple answer, it segfaults.

Re:Good C line (2, Informative)

drxenos (573895) | about 9 years ago | (#13222632)

According to the C Standard, it invokes undefined behavior. So, answer is anything the compiler wants it to do.

Re:Good C line (1)

p00ya (579445) | about 9 years ago | (#13222638)


Looks like it casts null to a pointer to a function with no parameters that returns void, and calls it. Remind me how this "touches on complex computing concepts"?

Re:Good C line (1)

pavon (30274) | about 9 years ago | (#13223554)

Well, for starters they have to figure out what, if anything, is at address 0. Does the operating system handle calling a null function pointer any different than any other address? What does the loader put at (virtual) address 0? Will there be executable code there or data? If there is executable code what does it do? Are you effectively creating infinite recursion? If so, will it continue indefinately, or will it overflow the stack? The question has certainly piqued my curiosity to learn more about how the linker, loader and process initialization works on my system.

This actually seems like a more relevent question than most of the ones posted here. The submitter was lamenting that they didn't know low-level stuff about the OS, but most of the responses so far have given high-level algorithmic puzzles.

Re:Good C line (1)

drxenos (573895) | about 9 years ago | (#13223652)

No, 0 is a null pointer which is not necessarily internally represented by all bits zero. There is no standard way in C to access address 0. The behavior is not implementation specific, so studying your linker, OS, et. al., is a waste of time. It is undefined behavior, and thus the compiler may do anything with it and that behavior does not have to be documented, nor even consistant. Studying such code is simply a waste of time since such a question is nonsense.

Re:Good C line (1)

pavon (30274) | about 9 years ago | (#13225218)

True, constant zero is defined to be an invalid address. Casting from an int would be more interesting, and is implementation dependant.

int i = 0;

Re:Good C line (0)

Anonymous Coward | about 9 years ago | (#13227153)

I don't think it's quite nonsense. On many architectures (especially embedded systems) jumping/calling address 0 is one way of performing a software reset.

Re:Good C line (1)

larry bagina (561269) | about 9 years ago | (#13228252)

some architectures/OSes/loaders have a 0 stored at address 0x00000000 as a courtesy for people that dereference a null pointer.

Re:Good C line (0)

Anonymous Coward | about 9 years ago | (#13229126)

Yeah. That's annoying, because it makes incorrect code appear to work.

For the last few months I've been writing my own kernel as a hobby exercise. I have it so that ring 0 has memory mapped 1:1 and user processes of course have their own page table. It's very annoying when I write ring 0 code that accidentally touches a NULL pointer, 'cause it usually takes me awhile to realize it.

Maybe I should unmap the first page, but then what do I do when I want to read the x86 16-bit interrupt table?

By the way, maybe that's a good exercise for the question asked: writing a kernel. It's not really that hard, and can be extremely enlightening. Some assembly required. (On x86, you'd only really need assembly for a few things: initializing GDT/IDT, interrupt service routines, task switches (which can fall in the former category), wrappers for IN/OUT instructions, updating the CR3 register, and then the system call interface for userland)

Re:Good C line (0)

Anonymous Coward | about 9 years ago | (#13230621)

Why would you want to read thereal mode interrupt vector table from protected paged mode anyway? Is it to call some of the few BIOS/VESA functions that can operate in this mode or ...? The best way to do it would be to map the physical region 0x00000000-? to some logical address range different from 0x0. If it is your kernel that needs access it should be somewhere in the address space where your other kernel structures reside (like in the top 1G or whatever). You could also copy the datastructure to somewhere else before you enter paged mode. It seems like a good idea to leave the first (logical) page not mapped to any physical page so you get a GPF if some buggy program tries to access it. I also read in some intel doc (oddly in the documentation to the 8259A interrupt controller even though that controller shouldn't have a say in the x86 memory management - I guess Intel just tried to be helpful) that the physical memory area 0x400-0x600 (right after the real mode interrupt vector table) is reserved so I would entirely refrain from storing anything in the first physical page.

Re:Good C line (1)

drxenos (573895) | about 9 years ago | (#13229570)

Yes, I have work on many such systems. How does that change the fact that 1) NULL pointers are not necessarily 0, and 2) referencing a NULL pointer in C invokes undefined behavior?

Re:Good C line (0)

Anonymous Coward | about 9 years ago | (#13222837)

Ask them what this line of C does

How'd you get my password?

Re:Good C line (2, Insightful)

dark404 (714846) | about 9 years ago | (#13223066)

And if they respond with anything other than "Anyone who writes something like that should be fired." Fire them.

Re:Good C line (1)

Reverend528 (585549) | about 9 years ago | (#13223199)

a better example is this:

for(;;) printf("\t\t\b\b\b\b\b");

Some brainteasers relevant to today (2, Funny)

Yeechang Lee (3429) | about 9 years ago | (#13222361)

1. How would you design a CVS-like system that is most effective for multiple teams of developers working simultaneously in Delhi, Mumbai, and Hyderabad, with the final customer in California?

2. How well can Visual Studio, Eclipse, and Emacs handle filenames in Hindi and Kannada?

Bonus question: How does the answer change when Bengali, Gujarati, and Urdu are also used?

3. Use Rational Rose, Visio, or another modeling tool of your choice to draw a flowchart of the proper actions a call center operator can follow to deal with a customer who wants to find out the status of his online purchase. Make sure to incorporate the high likelihood that the customer will become steadily more irate as he tries, but fails, to understand the "English" that the operator speaks, with appropriately calm and soothing responses to at least three forms of bodily threats or insults.

Re:Some brainteasers relevant to today (1)

ACORN_USER (902686) | about 9 years ago | (#13229448)

Dude. They only sounds so weird because they are forced to learn to speak in a fake American accent. I think the problem is that guys over there do actually take on really low level puzzles for research projects, as opposed to fun. Every Indian developer I've met has an excellent grasp for theoretical cs, sw engineering methodologies and the tools available to him. Just for giggles they also then to throw in some number theory to read about whilst on the toilet. Sure, there are some of us out in the west who this also describes. The downside is that majority of developers whom I have worked with are unfortunately quite the opposite. Still, this has little to do with puzzles. Ask them to write a SAT solver? I had an eastern european friend who worked on one for 'fun.' We are going to be in real trouble unless with pull our thumbs out of our .. wherever they are.

surprised noone's suggested (2, Informative)

yagu (721525) | about 9 years ago | (#13222371)

Surprised noone's suggested this [] one yet. One of my favorites. If you can solve these puzzles, you know C.

Re:surprised noone's suggested (1)

Frequency Domain (601421) | about 9 years ago | (#13226464)

From the spotlight review of the cited Amazon page:
Please note, these puzzles are not programming puzzles but follow the code and determine the output puzzles.
Maybe nobody suggested it because it's not what the submitter asked for?

Re:surprised noone's suggested (0)

Anonymous Coward | about 9 years ago | (#13229171)

Please note, these puzzles are not programming puzzles but follow the code and determine the output puzzles.
Oh God. Those are the worst kind of "puzzles." A piece of intentionally obfuscated code that exploits the ambiguities of the language to be confusing, and does nothing useful. The kind where basically, you have to step through each line and "be the computer." Well fuck. If I were a computer, I wouldn't need the machine. I'm not, so that's why I have the machine.

Over the years I had programming teachers who seemed to think this kind of exercise is valuable. In practice no one writes code that is like those exercises. If they do, then you need to get rid of it and rewrite it as something clearer, that is preferably not a do-nothing intentionally obfuscated "I'm going to do a lot of strange things; prove you can understand this" kind of thing.

When I had to do those kind of exercises in school, it was insulting. Sure, I could do them. But why should I have to?

Re:surprised noone's suggested (1)

smcdow (114828) | about 9 years ago | (#13230322)

In practice no one writes code that is like those exercises.
Except for people whose code you'll end up maintaining

If they do, then you need to get rid of it and rewrite it ....
Uh-huh. Try explaining the added expense of rewriting vs. maintaining. If if you don't have the right "colors" of money in your budget, then you can completely forget rewriting.

intentionally obfuscated "I'm going to do a lot of strange things; prove you can understand this" kind of thing.
You've obviously never worked with people who write code only with their own job security in mind. "If I write it, then I'll have to maintain it forever. Job security!"

I blame university (0)

Anonymous Coward | about 9 years ago | (#13222433)

What you have here is the typical end result of university. First, the universities recruit students like crack-whores looking for crystal meth. Then they flood the market with people whose only skills are memorizing textbooks and complaining when their grades are too low, and are only able to "work" with a clearly defined end-result (the exam) laid out months in advance.

In other words, totally incompatible with the real world. You don't get the same kind of hacker-type from the 60s anymore. Just some more cogs who have student loans to pay.

So what exactly is surprising in "it's only a job"?

Re:I blame university (1)

heinousjay (683506) | about 9 years ago | (#13224237) crack-whores looking for crystal meth.


Re:I blame university (0)

Anonymous Coward | about 9 years ago | (#13224276)

Oh, don't be dense...

Re:I blame university (0)

Anonymous Coward | about 9 years ago | (#13227336)

I don't get it either, I would think crack-whores would be looking for crack, not crystal meth. I know I'd much rather have some crack over meth any day.

Re:I blame university (1)

Shaper_pmp (825142) | about 9 years ago | (#13231146)

"What you have here is the typical end result of university."

Funny thing. University courses were always non-vocational. That means they aren't supposed to train you for specific jobs, but instead teach you to use your brain, teach yourself things and solve your own problems.

A university degree wasn't a certificate to say "Bob Jones is this good at C", but one which said "Bob Jones is this clever, and could therefore learn anything he put his mind to to this degree".

Ever notice how (historically) vocational courses were for the "simpler" trades like metal-working, carpentry and so on? That's why - the less-intelligent were apprenticed in one skill, while the clever/gifted/rich were trained to be polymaths.

This idea has been slightly buggered in recent years by the introduction of many "more vocational" university degrees, but the original intention of them was very different.

Oh, and you do still get the "hacker types from the 60s" - I happen to know two or three. The only difference is that computing's a more mature field now - all the low-hanging fruit's been picked, and because it's more mainstream they don't stand out as much.

If you don't get them any more, what would you call Sean Fanning (practically single-handedly popularised P2P), Linus Torvalds (for his social engineering of the Linux community, even if not for the actual programming of Linux), etc?

Re:I blame university (0)

Anonymous Coward | about 9 years ago | (#13232297)

Certain levels of vocational courses would be good. When I graduated I hadn't had a single course that discussed revision control systems. None on any project management skills. Being exposed to the tools and concepts that are used in 'the real world' isn't a bad thing.

Wait one second... (1)

lbmouse (473316) | about 9 years ago | (#13222439)

I'll send you over my project todo list...

Python Challenge (2, Informative)

migurski (545146) | about 9 years ago | (#13222522)

Well, it's not C, but the Python Challenge [] is an excellent multilevel programming riddle. Each level builds upon discoveries from previous levels, and encourages deep exploration of the Python library. I got about 1/3 of the way through before being stumped and running out of time to devote to it, but I bet it'd be super fun with a team working on it.

Re:Python Challenge (1)

starbirdman (245653) | about 9 years ago | (#13222972)


I have my reservations about Python, largely based on its scoping rules, but this was fun series of programming riddles.

Re:Python Challenge (1)

jtwJGuevara (749094) | about 9 years ago | (#13229343)

I third that. Anyone who knows a little bit of python can work on these riddles. And if you don't know python but are very proficient in other languages, then python isn't hard to pick up. On top of that, they are really fun and make you use built-in libraries that you wouldn't ordinarily use but may find useful someday.

Re:Python Challenge (1)

Heretik (93983) | about 9 years ago | (#13230234)

Yes! Best. Puzzle. Ever.

No other puzzle has ever had the same level of satisfaction upon solving (each level, that is) for me.

It takes a couple stages for it to get interesting though..

eh? (1)

nickos (91443) | about 9 years ago | (#13222607)

"most of them do programming without having an idea of what they actually do"

Could you be more precise? If they are programming without knowing they're programming it sounds like they're writing Excel macros or something similar. If that's the case don't you think "C-based hacks or puzzles" will be too difficult for them?

Re:eh? (1)

calvinandhobbes (652396) | about 9 years ago | (#13228155)

they program user level code wihout understanding how the os works. if they knew os internals, they would program better. i gave them an assignement - a simple object file. ask them to write out the source code by going through the asembly. helps them get a fair idea about what assemble language programming is. get the idea?

Re:eh? (1)

larry bagina (561269) | about 9 years ago | (#13228292)

i guess it's too late, but maybe next time you shouldn't hire anybody that doesn't know an assembly language.

How about code reviews? Have a meeting where people bring in a couple pages of code they've written and everyone discusses the good/bad points of it. I feel dirty suggesting that, since when I participated in such a thing during a previous job, and 1) people missed errors 2) people gave bad/incorrect advice. Of course, I'm fluent and have coded in 8,16,and 32 bit asm, OS-level programming, etc. so I'm not your target demographic.

Programming Pearls (1)

Intron (870560) | about 9 years ago | (#13222878)

The Programming Pearls books by Jon Bentley give readable, elegant solutions to common programming tasks. I've used several of them.

The Daily WTF gives readable, inelegant solutions to common programming tasks. I've avoided many of them.

Re:Programming Pearls (1)

mparaz (31980) | about 9 years ago | (#13230863)

I agree regarding Programming Pearls. It's about applied CS, without the rigor.

Etudes for Programmers (1)

clem.dickey (102292) | about 9 years ago | (#13222933)

For completeness I'll mention Etudes for Programmers [] . It has some fun - and useful - projects. But it's dated. I can'r imagine paying the $250 which the sellers on Amazon want.

Only 200? (0)

Anonymous Coward | about 9 years ago | (#13223138)

here are about 200 people working on different projects and most of them do programming without having an idea of what they actually do. they have little understanding of OS internals and primitive hacking skills

I think there are a lot more than 200.

Write a game (1)

abradsn (542213) | about 9 years ago | (#13223295)

Create a large group team based project. Assign each person tasks just as would be had in a regular development cycle.
  • Let them choose the subject material, but keep it small so that they can finish it inside of a semester or a quarter.
  • Be sure to use some already developed industry standard building blocks to make the end result more appealing.
  • I suggest game development, but it could be compiler design, or operating systems design. Even writing an application such as a mail server might be interesting.
  • Your role will be to give them great guidance in the beginning, and develop milestones to achieve.
  • The end result will be a great prize.
  • Another good idea might be to create something that the school can sell at a profit. Just mimic any other product that is sold to achieve this.
Good luck.

Gimpel/PC-lint bug of the month (2)

TimButterfield (16686) | about 9 years ago | (#13223586)

If this is to be strictly C/C++ oriented, a fairly steady supply of puzzles may be had by using Gimpel's Bug of the month [] . I have seen these for many years and have usually found them to be interesting and sometimes even educational.

C-based? (1)

owlstead (636356) | about 9 years ago | (#13223702)

You have these less skilled workers and you let them do C? Why? Are you fond of bugs or something? Let them use a higher level language instead. Java comes to mind.

Anyway, you could pick up minix from somewhere, install it on a cheap x86 box and let them implement a quota system or something in C. It has been designed for that. Lets them - eh - love vi, make and cc as well.

I had to do this at the "Vrije Universiteit" under Tanenbaum, and gosh, did I have a lot of fun!

Re:C-based? (0)

Anonymous Coward | about 9 years ago | (#13229213)

Let them use a higher level language instead. Java comes to mind.
Sure, but this only hides their problems. If you make a mistake in C, your program violently crashes and potentially has a security problem. If you make a mistake in Java, you get an exception.

But either way, the code is incorrect. Java masks the problem. But the code is still wrong, and relying on incorrect behavior (e.g. catching OutOfBoundsException) is still an incorrect program.

Re:C-based? (0)

Anonymous Coward | about 9 years ago | (#13233546)

Just catch the exception, ignore it, and move on. This is the Java Way.

Next Week (1)

pete-classic (75983) | about 9 years ago | (#13224081)

On a very special episode of "Ask Slashdot":

pete-classic asks: "There are about 200 people working on different projects and most of them write without having an idea of what they actually do. they have little understanding of rudimentary diction and primitive grammar skills. I want to euthanize them by providing some challenges by which they touch upon complex language concepts, while solving the problem. Does anyone know of a set of English-based books or lessons with which I can euthanize these budding speakers and writers?"

Re:Next Week (1)

Shadow Wrought (586631) | about 9 years ago | (#13226563)

Well if the final goal for your audience is euthanizing them, then may I suggest anything written by one of the Bronte sisters? Nathaniel Hawthorn will get you there, too.

Re:Next Week (1)

pete-classic (75983) | about 9 years ago | (#13227734)

Never heard of the Bronte sisters. Hawthorn was a tit.

I looked the sisters up. First hit gives Extensive online resource for all three Brontë sisters and there writings. []

Well, if that's how "there" fans represent I'll pass.


Re:Next Week (1)

Shadow Wrought (586631) | about 9 years ago | (#13230856)

Never heard of the Bronte sisters.

Then you, my friend, never had to try and become interested in Wuthering Heights, bane of my High School english class. The only novel I just simply could not bring myself to finish. I made it through House of Seven Gables, but am none the better for it.

Book: "He's dead. Yep, still dead. Hhm, doesn't seem to be moving. Maybe, because, that's right, he's DEAD. Still."
Me: "Get on with it!"

Does Sphere count? (2, Interesting)

xTown (94562) | about 9 years ago | (#13224281)

The SPOJ project [] from Poland has a bunch of algorithmic problems to which you can submit answers which are verified automatically. For most of the problems, you can use pretty much any language, although some of the problems restrict you to one language.

Lots of free time, eh? (1)

TheSkepticalOptimist (898384) | about 9 years ago | (#13224380)

When do you want people to do these brain teasers? At work, or on their own time?

If you want them to do this at work, then you have too many people on staff if they can waste time doing brain teasers. Reducing staff to 50 - 100 highly skilled employees will improve productivity and reduce wasted time which is costing you money.

If you expect these people to work on these brain teasers at home, then you must be a manager with your head in the clouds expecting employees to do 'homework'!

Re:Lots of free time, eh? (1)

Reverend528 (585549) | about 9 years ago | (#13228426)

Actually, I think the optimal number of people working on a project is closer to 3. meetings last no longer than they need to and no one says the word "commitee".

Quizzing your workers may have the opposite effect (1)

ezraekman (650090) | about 9 years ago | (#13224556)

This sounds suspiciously like the kind of puzzles many IT workers are asked prior to employment. Personally, I enjoy these kind of questions, regardless of how accurate my answers are. (Often, I think of solutions not expected by the tester; it's always fun to see their expression when this happens.) ;-) However, this kind of thing tends to really piss off your potential (or in this case, current) employees. Many well-known IT figures, PhDs, etc. have been very outspoken about these quizzes, and have turned down job offers specifically because they were asked them.

This can be great for one's self-esteem if they're good at them, or ruinous if they are not. This can be interesting, entertaining and creativity-inducing if encouraged, but overly critical and imply "grading" or class separation if required.

Be careful how you implement this; it can bite you in the ass.

No Starch Press has a simple answer (1)

castlec (546341) | about 9 years ago | (#13224863)

How Not to Programm in C++ by Steve Oualline is a book of puzzles for both C and C++. The book starts ultra simple and gets more complicated as it goes. I've had fun with it. Amazon doesn't have it new but here are reviews and prices from $1.48 used :o)
How Not to Program in C++ []

My Puzzler (1)

the eric conspiracy (20178) | about 9 years ago | (#13224979)

Write a C program to enumerate all of the transcendental numbers, and pack them into a 200K memory segment.

Visual Basic (1)

Deltaspectre (796409) | about 9 years ago | (#13225217)

Any general challenges that apply to all languages or some ones for visual basic .net? It'd sure help for when I'm bored and need extra credit

for a puzzle, try small or 1-line IOCCC winner (2, Interesting)

chongo (113839) | about 9 years ago | (#13225400)

If you are looking for puzzles (but NOT coding style), try some of the International Obfuscated C Code Contest winners:

I'd pick some of the short programs and 1-liner winners.

My favorite 1-line winner was submitted by David Korn (of ksh fame):

Print out the korn.c source [] . By just looking at it, ask them to tell you what it does and why.

Note that this 1-liner has stumped some people who have been coding in C for > 31 years. So if they get stuck, help them out by asking asking some questions such as:

In korn.c, what type of symbol is unix?.
Why does Korn subtract 0x60? Hint: 'a' in ASCII is 0x61.
On a non-Unix system, what will this program do?

p.s. We are in the middle of judging the 2005 entries. There are some good ones this year, IMHO.

The C Puzzle Book (1)

dshaw858 (828072) | about 9 years ago | (#13225935)

I'm not totally sure if this is what you're asking for, but this book by Alan R. Feuer has some interesting (and sometimes frustrating) puzzles in C. I'm sure that there are similar books for C++, Java, Python, perl, etc. It's worth looking into, in my opinion; I have a copy sitting on my printer about an arm's reach away (for when I need a distraction from a project).

- dshaw

Speaking as an educator (1)

DynaSoar (714234) | about 9 years ago | (#13226516)

"Does anyone know of a set of C-based hacks or puzzles with which I can enthuse these budding programmers and testers?"

If you want to enthuse them, have them come up with the problems they want to solve, then solve them. This has the added benefit of exercising their imaginations as well as learning/developing programming skills.

How Not To Program in C++ (1)

DaoudaW (533025) | about 9 years ago | (#13226704)

111 broken programs and 3 working ones, or why does 2 + 2 = 5986?

Steve Oualline

No Starch Press

Programmer's Koans (2, Interesting)

identity0 (77976) | about 9 years ago | (#13227459)

"One day, master Kernighan sat down with his apprentice and asked, 'What is the sound of one bit flipping?' The apprentice answered by raising one finger."

"As Dennis Ritchie was pondering over the coding of the first UNIX kernel, a butterfly landed on his nose. And lo, he was enlightened."

"Stroustrup ran to the head monk, exclaiming, 'Master! I have added object-orientation to the C programming language! I have been enlightened!' to which the head monk responded by hitting him on the head with a stick."

"Theo DeRaadt looked over the cuts of meat in a butcher-shop, and complained loudly, 'This is all crap! What's the best meat you have here?' to which the butcher replied, 'Everything here is the best! You cannot have anything but the best!' and thus DeRaadt was enlightened."

"Once, a hacker asked master Torvalds, 'Does the Linux kernal have the Turing nature?' To which Torvalds replied, 'Get me a beer'."

And now a real quote, from Steven Levy's Hackers:

So Sussman began working on the program. Not long after, this odd-looking bald guy came over. Sussman figured the guy was going to boot him out, but instead the guy came over. Sussman figured the guy was going to boot him out, but instead the man sat down, asking, "Hey, what are you doing?" Sussman talked over the program with the man, Marvin Minsky. At one point in the discussion, Sussman told Minsky he was using a certain randomizing technique in his program because he didn't want the machine to have any preconcieved notions. Minsky said, "Well, it has them, it's just that you don't know what they are." It was the most profound thing Gerry Sussman had ever heard.

Re:Programmer's Koans (1)

/dev/kev (9760) | about 9 years ago | (#13237921)

And now a real quote, from Steven Levy's Hackers:

That would have to be, unquestionably, the SINGLE MOST VILE BUTCHERING of the actual koan i have ever had the horrible misfortune of reading. It barely makes sense, let alone helps with enlightenment. Try this:

In the days when Sussman was a novice Minsky once came to him as he sat hacking at the PDP-6. "What are you doing?", asked Minsky. "I am training a randomly wired neural net to play Tic-Tac-Toe." "Why is the net wired randomly?", asked Minsky. "I do not want it to have any preconceptions of how to play." Minsky shut his eyes. "Why do you close your eyes?", Sussman asked his teacher. "So the room will be empty." At that moment, Sussman was enlightened.

Re:Programmer's Koans (1)

identity0 (77976) | about 9 years ago | (#13238282)

That is a word-for-word quotation from Levy's Hackers, p117 paragraph 2. Why do you think I said it was a 'real quote'?

The 'koan' you cite is a made-up story written by someone, no doubt based on the original Levy material. Note that Levy actually interviewed both participants in the encounter, and neither apparently corroborated the 'closing your eyes' part. While more amusing, I went with the factual account over the 'koan'. Besides, it's not a real koan if they explain the meaning in the text, now is it? :P

Perhaps I should have made it clearer and said it was a real account, not just a quote.

Build linux kernel (1)

jawahar (541989) | about 9 years ago | (#13228338)

In my previous company, I told all the developers to build the Linux kernel, develop and install a simple "Hello World" kernel module.

Project Euler (2, Interesting)

drstock (621360) | about 9 years ago | (#13228706)

I'm amazed that nobody mentioned Project Euler [] yet. I find their challenges very interresting and with varying difficulty.

int *(*(*i)[5])(int*) (1)

ZorroXXX (610877) | about 9 years ago | (#13229147)

One test is to ask: Given the following declaration:
int *(*(*i)())[5];
what is i?

To do this by hand you can use the right-left rule for reading c-declarations:
1) locate the innermost identificator and classify this first.
2) classify next balanced expression to the right
3) and continue reading clockwise (i.e. to the left)
4) ...directed outwords

However if you stumble upon some cryptic code written by others that you do not understand there exists this wonderful, litle known tool named cdecl to help you with that:

cdecl> explain int *(*(*i)())[5]
declare i as pointer to function returning pointer to array 5 of pointer to int

It can also translate in the oposite direction:

cdecl> declare i as pointer to pointer to pointer to pointer to pointer to int
int *****i

Robocode!! (1)

cerberusss (660701) | about 9 years ago | (#13229295)

If you can stand programming in Java, then take a look at RoboCode [] . It's got a built-in editor, making the creation of your robot a piece of cake. Be sure to check this article [] and the FAQ [] .

At work, a competition was formed. If you're interested, I can look up the rules we used.

TopCoder (1)

cmstremi (206046) | about 9 years ago | (#13232043)

Have them compete in TopCoder events. The problems are not always interesting, but a little competition might be fun.

Although making them do stuff is making them do stuff. It'll probably still feel like work (and I guess, in a way, it is).

Sincere Suggestions (1)

IUnknownMinusOne (905020) | about 9 years ago | (#13237590)

Here are the reading from your post: - You are a senior person in a small software company in India. - You lost touch with programming and your guys work on VB. - Your last major program was in C => it is over 6-7 years since you did it. - Your guys do not seem to be interested in lower level details like the strcpy you know of. Suggestions: - There are no readymade solutions here. - Try to get your guys to move to Java or C#. - Get them to compare a badly written code with a better written code (in your opinion) with parameters like memory usage, time taken etc., It is difficult, but inspiration is something you can provide, by taking an example of their production code and analyzing it line by line with them.
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>