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/
At the end of every chapter in a learn to program book? Chapter exercises and things like that. Bank account classes and the like.
You might want to look at The Python Challenge - admittedly not C-based, but goes to show to concept works.
Those who can make you believe absurdities can make you commit atrocities. - Voltaire
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.
Sounds like your average IT department...
Only one solution: extermination.
Daniel
Carpe Diem
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
http://www.caesum.com/ 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.
Not exactly what you're asking for, but their are some programming challenges at OSIX.net
Coder's Stone: The programming language quick ref for iPad
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
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.
Ask them what this line of C does
((void(*)(void))0x00)();
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.
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"?
I'll send you over my project todo list...
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.
"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?
Comment removed based on user account deletion
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.
Intron: the portion of DNA which expresses nothing useful.
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.
I think there are a lot more than 200.
- 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.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.
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!
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?"
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.
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'!
I haven't thought of anything clever to put here, but then again most of you haven't either.
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.
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++
When I tell an object to delete this, am I killing it or telling it to kill me?
Write a C program to enumerate all of the transcendental numbers, and pack them into a 200K memory segment.
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)
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
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.
"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.
"I may be synthetic, but I'm not stupid." -- Bishop 341-B
111 broken programs and 3 working ones, or why does 2 + 2 = 5986?
Steve Oualline
No Starch Press
"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.
In my previous company, I told all the developers to build the Linux kernel, develop and install a simple "Hello World" kernel module.
Slashdot = Sarcasm
I'm amazed that nobody mentioned Project Euler yet. I find their challenges very interresting and with varying difficulty.
My other comment is funny
To do this by hand you can use the right-left rule for reading c-declarations: ...directed outwords
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)
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:
It can also translate in the oposite direction:
When you are sure of something, you probably are wrong (search for "Unskilled and Unaware of It").
Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions
More Exceptional C++
Exceptional C++ Style : 40 New Engineering Puzzles, Programming Problems, and Solutions (C++ in Depth Series)
At work, a competition was formed. If you're interested, I can look up the rules we used.
8 of 13 people found this answer helpful. Did you?
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.
Everything in moderation, including moderation itself
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).
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.
Everything in moderation, including moderation itself
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.
What is the meaning of (call/cc call/cc) and how might you use it in a program?
you are one lazy bastard. why don't you type a few keywords into a search engine and sift through what you find. i cannot believe the sheep in this forum contributing to your fucking laziness.
in saying that i would have done exactly the same thing myself.
WARNING: spoiler below
0 );}
unix is a pre-defined macro which equals to the integer 1 on unix-systems.
So the line becomes:
main() { printf(&1["\021%six\012\0"],(1)["have"]+"fun"-0x6
This is equivalent to:
main() { printf(&(*(1+"\021%six\012\0")), *(1+"have")+"fun"-0x60);}
Which gives the same output as:
main() { printf(&(*("%six\012\0")), *("ave")+"fun"-0x60);}
Then we simplify the &* and note that *("ave") is the char 'a'
main() { printf("%six\012\0", 'a'+"fun"-0x60);}
Now, 0x60='a'-1 (see ascii table), so this becomes:
main() { printf("%six\012\0", "fun"+1);}
So a little pointer arithmetic, and noting that '\012' is '\n':
main() { printf("%six\n\0", "un");}
And in the end this gives the same output as:
main() { printf{"unix\n\0");}
Note that the \0 is actually redundant.
it seems like most posts here are offering up outside sources for problems/puzzles.
while this might interest some of your crew, many of them are likely to look at it as a waste of time and just another stupid task enforced by management.
why don't you gather your people together and challenge them to come up with a project that they all feel is relevant in some way?
the various people in an organisation always feel like they know what's wrong with said organisation and what it needs. so get them to generate an idea and work it together.
either that, or they could separate into teams and challenge each other on various benchmarks like time to completion, code size/efficiency, etc.