Brain Teasers for Coders?
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?"
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.
http://www.welton.it/davidw/
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!
The Army reading list
Just looked on google and there's a ton of stuff. Quite interesting was Cprogramming.com's C++ Programming Challenge, but there's loads more....
Those who can make you believe absurdities can make you commit atrocities. - Voltaire
TopCoder
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:
http://acm.uva.es/
Erik http://yakko.cs.wmich.edu/~rattles
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.
Surprised noone's suggested this one yet. One of my favorites. If you can solve these puzzles, you know C.
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.
According to the C Standard, it invokes undefined behavior. So, answer is anything the compiler wants it to do.
Anonymous Cowards suck.
* 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.
Xenu loves you!
And if they respond with anything other than "Anyone who writes something like that should be fired." Fire them.
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.
"Jazz isn't dead, it just smells funny" ~Frank Zappa
EdelFactor
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.
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.
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:
And: And:p.s. We are in the middle of judging the 2005 entries. There are some good ones this year, IMHO.
chongo (was here)
"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.
I'm amazed that nobody mentioned Project Euler yet. I find their challenges very interresting and with varying difficulty.
My other comment is funny