Slashdot Mirror


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?"

109 comments

  1. If they're not interested, they're not interested by DavidNWelton · · Score: 3, Insightful

    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.

  2. Aren't things like that... by Hangin10 · · Score: 1

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

    1. Re:Aren't things like that... by EdelFactor19 · · Score: 2, Insightful

      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
    2. Re:Aren't things like that... by Hangin10 · · Score: 1

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

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

    3. Re:Aren't things like that... by Anonymous Coward · · Score: 0

      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.

    4. Re:Aren't things like that... by EdelFactor19 · · Score: 1

      now that's a good problem, of course now its stuck in my head (the swap that is, well for C/C++ at least) as i recall it was either in java or perl where you could do that without a problem becuase they had a parallel assignment method. i think it was perl, yuo just said something to the effect of a,b = b,a and it did it, but thats not very interesting for us. im hoping that the solution isnt one based on math... i.e.
      * a += *b; (a-> A+B)
      * b = *a - *b; (b = A)
      *a -= *b; (a->B)
      because under/overflow isnt cool and im pretty sure the "real" solution has more to do with that they are pointers. and thus that it doesnt have to be ints, it could be anything?

      oh well cheers, and kudos go to the first responder for actually posting a recognition as he did, a. its an unusual sight on /. and b. reminds me I shuold have been more polite to start, which of course results in the overall politeness going up even if no one else takes notice lol

      laters

      --
      "Jazz isn't dead, it just smells funny" ~Frank Zappa
      EdelFactor
    5. Re:Aren't things like that... by The+Tyrant · · Score: 1

      Its pretty simple, once you know the trick. For a hint, it involves three xor's (such a useful little operator).

  3. Try here for inspiration by SimilarityEngine · · Score: 1

    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
  4. Make it more interesting by Anonymous Coward · · Score: 0

    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.

    1. Re:Make it more interesting by Anonymous Coward · · Score: 1

      http://www.dievo.org/index.php
      http://www.roothack.org/
      http://www.hackerslab.org/eorg/

      semi interested people become interested people, idiot.

    2. Re:Make it more interesting by th0mas.sixbit.org · · Score: 0, Flamebait

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

      --
      twitter.com/gravitronic
    3. Re:Make it more interesting by Anonymous Coward · · Score: 0

      INTERNET IS SERIOUS BUSINESS

      lol caps lock is cruise control for cool idiots

  5. Hmm by KDan · · Score: 0

    Sounds like your average IT department...

    Only one solution: extermination.

    Daniel

    --
    Carpe Diem
    1. Re:Hmm by lobsterGun · · Score: 1

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

  6. Programming Challenges by tcopeland · · Score: 3, Informative

    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!

    1. Re:Programming Challenges by saintp · · Score: 2, Informative
      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.
    2. Re:Programming Challenges by niskel · · Score: 1

      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.

    3. Re:Programming Challenges by meiao · · Score: 1

      I recommend the PC site www.programming-challenges.com 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).

  7. Here's a site with challenges by hackwrench · · Score: 1

    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.

  8. OSIX.net by slapout · · Score: 1

    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
  9. More programming challenges... by SimilarityEngine · · Score: 2, Informative

    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
  10. topcoder by Glog · · Score: 2, Informative
    1. Re:topcoder by thesnarky1 · · Score: 1

      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!

  11. ACM Programming Competition Problems by mr_rattles · · Score: 3, Interesting

    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/

  12. RSA by RealityMogul · · Score: 1

    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.

    1. Re:RSA by Paul+Crowley · · Score: 2, Insightful

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

    2. Re:RSA by LnxAddct · · Score: 1

      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!
      Regards,
      Steve

    3. Re:RSA by Anonymous Coward · · Score: 1, Interesting

      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.

    4. Re:RSA by AeiwiMaster · · Score: 1

      The problem with the RSA Factoring Challenge is
      that when one is intelligent enough to solve the problem the problem becomes uninteresting.

      Then one would rater use the ones time to solve
      one of the great problems facing humanity.

      But here is some hints if you like to take on the RSA Factoring Challenge.
      You need: a need a frequency generator, electronic components (resistors, capacitors, coils) and the most important thing the correct understanding of electrodynamics.

      Have fun.

  13. Good C line by thefirelane · · Score: 1

    Ask them what this line of C does

    ((void(*)(void))0x00)();

    1. Re:Good C line by Profane+MuthaFucka · · Score: 1

      Simple answer, it segfaults.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    2. Re:Good C line by drxenos · · Score: 2, Informative

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

      --


      Anonymous Cowards suck.
    3. Re:Good C line by p00ya · · Score: 1
      ((void(*)(void))0x00)();

      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"?

    4. Re:Good C line by Anonymous Coward · · Score: 0

      Ask them what this line of C does
      ((void(*)(void))0x00)();

      How'd you get my password?

    5. Re:Good C line by dark404 · · Score: 2, Insightful

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

    6. Re:Good C line by Reverend528 · · Score: 1
      a better example is this:

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

    7. Re:Good C line by pavon · · Score: 1

      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.

    8. Re:Good C line by drxenos · · Score: 1

      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.

      --


      Anonymous Cowards suck.
    9. Re:Good C line by pavon · · Score: 1

      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;
      ((void(*)(void))i)();

    10. Re:Good C line by Anonymous Coward · · Score: 0

      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.

    11. Re:Good C line by larry+bagina · · Score: 1

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

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    12. Re:Good C line by Anonymous Coward · · Score: 0

      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)

    13. Re:Good C line by drxenos · · Score: 1

      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?

      --


      Anonymous Cowards suck.
    14. Re:Good C line by Anonymous Coward · · Score: 0

      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.

  14. Some brainteasers relevant to today by Yeechang+Lee · · Score: 2, Funny

    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.

    1. Re:Some brainteasers relevant to today by ACORN_USER · · Score: 1

      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.

  15. surprised noone's suggested by yagu · · Score: 2, Informative

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

    1. Re:surprised noone's suggested by Frequency+Domain · · Score: 1
      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?
    2. Re:surprised noone's suggested by Anonymous Coward · · Score: 0
      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?
    3. Re:surprised noone's suggested by smcdow · · Score: 1
      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!"

      --
      In the course of every project, it will become necessary to shoot the scientists and begin production.
  16. I blame university by Anonymous Coward · · Score: 0
    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"?

    1. Re:I blame university by heinousjay · · Score: 1

      ...like crack-whores looking for crystal meth.

      What?

      --
      Slashdot - where whining about luck is the new way to make the world you want.
    2. Re:I blame university by Anonymous Coward · · Score: 0

      Oh, don't be dense...

    3. Re:I blame university by Anonymous Coward · · Score: 0

      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.

    4. Re:I blame university by Shaper_pmp · · Score: 1

      "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?

      --
      Everything in moderation, including moderation itself
    5. Re:I blame university by Anonymous Coward · · Score: 0

      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.

  17. Wait one second... by lbmouse · · Score: 1

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

  18. Python Challenge by migurski · · Score: 2, Informative

    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.

    1. Re:Python Challenge by starbirdman · · Score: 1

      Second!

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

    2. Re:Python Challenge by jtwJGuevara · · Score: 1

      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.

    3. Re:Python Challenge by Heretik · · Score: 1

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

  19. eh? by nickos · · Score: 1

    "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?

    1. Re:eh? by calvinandhobbes · · Score: 1

      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?

    2. Re:eh? by larry+bagina · · Score: 1
      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.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    3. Re:eh? by try_anything · · Score: 1
      Try giving them short programs or functions that repeatedly allocate memory, open and close files, write to disk, spawn threads, etc., and have them estimate the performance characteristics. Even better, show them a simple program written two different ways (using processes vs. threads, caching data in RAM vs. a file, looping over data chunks that fit in processor cache vs. looping over larger chunks), and let them predict the relative performance.

      Best would be showing them two implementations of something from a current project.

      After everyone submits their guesses, show them the true performance figures and everyone can figure out together why it works that way. Whoever's prediction was closest gets to go home early on Friday.

  20. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  21. Programming Pearls by Intron · · Score: 1

    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.
    1. Re:Programming Pearls by mparaz · · Score: 1

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

  22. Etudes for Programmers by clem.dickey · · Score: 1

    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.

  23. Only 200? by Anonymous Coward · · Score: 0
    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.
  24. Write a game by abradsn · · Score: 1
    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.
  25. Gimpel/PC-lint bug of the month by TimButterfield · · Score: 2

    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.

  26. C-based? by owlstead · · Score: 1

    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!

    1. Re:C-based? by Anonymous Coward · · Score: 0
      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.
    2. Re:C-based? by Anonymous Coward · · Score: 0

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

  27. Next Week by pete-classic · · Score: 1

    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?"

    1. Re:Next Week by Shadow+Wrought · · Score: 1

      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.

      --
      If brevity is the soul of wit, then how does one explain Twitter?
    2. Re:Next Week by pete-classic · · Score: 1

      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.

      -Peter

    3. Re:Next Week by Shadow+Wrought · · Score: 1
      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!"

      --
      If brevity is the soul of wit, then how does one explain Twitter?
  28. Does Sphere count? by xTown · · Score: 2, Interesting

    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.

  29. Lots of free time, eh? by TheSkepticalOptimist · · Score: 1

    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.
    1. Re:Lots of free time, eh? by Reverend528 · · Score: 1

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

  30. Quizzing your workers may have the opposite effect by ezraekman · · Score: 1

    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.

  31. No Starch Press has a simple answer by castlec · · Score: 1

    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?
  32. My Puzzler by the+eric+conspiracy · · Score: 1

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

  33. for a puzzle, try small or 1-line IOCCC winner by chongo · · Score: 2, Interesting
    If you are looking for puzzles (but NOT coding style), try some of the International Obfuscated C Code Contest winners:
    http://www.ioccc.org/main.html

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

    Korn's 1987 winning entry

    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?.
    And:
    Why does Korn subtract 0x60? Hint: 'a' in ASCII is 0x61.
    And:
    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.

    --
    chongo (was here) /\oo/\
  34. The C Puzzle Book by dshaw858 · · Score: 1

    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

  35. Re:If they're not interested, they're not interest by Anonymous Coward · · Score: 0

    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.

  36. Speaking as an educator by DynaSoar · · Score: 1

    "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
  37. How Not To Program in C++ by DaoudaW · · Score: 1

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

    Steve Oualline

    No Starch Press

  38. Programmer's Koans by identity0 · · Score: 2, Interesting

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

    1. Re:Programmer's Koans by /dev/kev · · Score: 1

      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.

      --
      Quidquid latine dictum sit, altum viditur.
    2. Re:Programmer's Koans by identity0 · · Score: 1

      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.

    3. Re:Programmer's Koans by /dev/kev · · Score: 1

      I'm sorry, where in my post did I say I was attacking you? I thought that when I quoted the part of your post which said it was a "real quote", it would be understood that I was attacking the quote, and its author, not you. Obviously I've not read Levy's book, nor am I likely to after this quote.

      The 'koan' you cite is a made-up story written by someone, no doubt based on the original Levy material.

      The koan is one of the most famous examples, has been in the jargon file since the koan examples were added in the early 90s, and has been attributed to Danny Hillis, who was at the MIT AI lab at the time. I think you give a bit too much weight to Levy.

      I went with the factual account over the 'koan'.

      I guess I find this bizarre in a post entitled "Programmer's Koans".

      it's not a real koan if they explain the meaning in the text, now is it?

      The koan explains the meaning? Any explanation in the koan is only by analogy, which is left to the reader to figure out. At least for myself, I find this more instructive and powerful than the direct quote.

      Perhaps I should have been clearer and said that I find Levy's factual account to be shit compared to the koan.

      --
      Quidquid latine dictum sit, altum viditur.
  39. Build linux kernel by jawahar · · Score: 1

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

  40. Project Euler by drstock · · Score: 2, Interesting

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

    --
    My other comment is funny
  41. int *(*(*i)[5])(int*) by ZorroXXX · · Score: 1
    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
    cdecl>

    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
    cdecl>
    --
    When you are sure of something, you probably are wrong (search for "Unskilled and Unaware of It").
  42. Robocode!! by cerberusss · · Score: 1
    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.

    --
    8 of 13 people found this answer helpful. Did you?
  43. Re:If they're not interested, they're not interest by Shaper_pmp · · Score: 1, Insightful

    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
  44. TopCoder by cmstremi · · Score: 1

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

  45. Re:If they're not interested, they're not interest by Shaper_pmp · · Score: 1

    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
  46. Sincere Suggestions by IUnknownMinusOne · · Score: 1

    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.

  47. A lambda poem by nerdwarrior · · Score: 1
    This applies more to the functional language/lambda calculus community than the C community, but here's a lambda poem that I like:

    What is the meaning of (call/cc call/cc) and how might you use it in a program?

  48. I cannot be arsed creating an account for this by Anonymous Coward · · Score: 0

    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.

  49. WARNING: spoiler below! by Anonymous Coward · · Score: 0

    WARNING: spoiler below

    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"-0x60 );}

    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.

  50. get them together by evershade · · Score: 1

    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.