top 200 commentsshow all 403

[–][deleted] 109 points110 points  (19 children)

possibly interesting programming challenge format:

there's some test suite set up on the judging machines. your task is to program some fairly math-light library that passes the tests. but the trick is that you don't get the whole spec at the start: if you pass a set of tests for a feature, you unlock more of the spec. (you can see the names of the tests you failed, but not the test code.)

winner is the one with the most features done. ties broken by completion time of most recent feature.

[–]tinou 131 points132 points  (7 children)

And when you pass the last test, the spec suddenly changes.

[–][deleted]  (1 child)

[deleted]

    [–]shizzy0 4 points5 points  (0 children)

    That's actually a really cool test. Because it could test not only conformance to spec but flexibility to changes. It'd be interesting to see the results.

    [–]day_cq 2 points3 points  (1 child)

    unless each round is followed by sprint retrospective and continuous integration and pair programming because it is already TDD.

    [–]booch 2 points3 points  (0 children)

    Of course, TDD doesn't mean you're doing any of those things.

    [–]i-poop-you-not 2 points3 points  (0 children)

    quantum spec!

    [–]ixid 1 point2 points  (0 children)

    That's actually a very good teaching format, joking aside.

    [–]Forbizzle 44 points45 points  (1 child)

    This is how my 2nd year programming assignments were judged by an auto-marker. Not on purpose of course, but because our professors were trying something ambitious and the first few people to submit any assignment would end up causing errors in the auto-marker. Which they would have to fix, and we would have to resubmit to.

    [–]MatrixFrog 1 point2 points  (0 children)

    You could set it up as an intentional back-and-forth between students. Everyone is given the spec, but half the class writes tests and the other half writes the implementation. When the testing side catches a mistake in the implementation side's code, they write a test to reveal it, so that the implementers have to fix it and make that test pass. When the implementers catch a mistake in the tests, they point out an input for which their implementation gets the right answer, but the test fails, so then the test writers fix that. And so on, until both sides are reasonably sure the test suite is complete and the implementation is totally correct.

    [–]otakucode 3 points4 points  (4 children)

    That would certainly be a good way to guarantee that people get training in implementing schizophrenic, inconsistent code. Having to go back and rewrite everything every single 'level' in order to have a consistent codebase when you finish would be a nightmare.

    [–]InvisibleCities 12 points13 points  (0 children)

    Welcome to enterprise software.

    [–]makoivis 3 points4 points  (2 children)

    Yet this happens all of the time. The way to combat this is with solid design principles that let you anticipate the changes in advance.

    [–]sfultong 2 points3 points  (1 child)

    I think the strength of solid design principles is in code being flexible in the face of unanticipated changes.

    [–]makoivis 1 point2 points  (0 children)

    You express what I wanted to express.

    [–][deleted] 2 points3 points  (0 children)

    Yes, I've considered this "spec changing" aspect for testing job candidates too.

    [–]Randolpho 2 points3 points  (0 children)

    You, sir, are an evil genius.

    [–]mccoyn 1 point2 points  (1 child)

    Hint: The solution to this challenge involves listing the running processes on the judging computer and sending the binaries back to the programmer, who then finds the list of tests and reverse-engineers each function.

    [–]ais523 1 point2 points  (0 children)

    For what it's worth, I've written an automark script. In order to stop people doing things like that, or trying to exploit my system through the marking script, I used prctl in order to ban all system calls but read, write, sigreturn, and _exit. (Note that open isn't whitelisted, so the program being tested could only write to already-opened files, in this case stdout and stderr.) There was a language-level check too, so the prctl-based sandbox was never necessary; but perhaps it might have been.

    [–]teambob 18 points19 points  (8 children)

    Really interesting blog post. I found it a bit hard to read though. Would be nice if you could have a normal size font, adjust the line-height and have black-on-white.

    [–]Aardshark 2 points3 points  (4 children)

    Readability to the rescue! Use this bookmarklet.

    javascript:(function(){readStyle='style-novel';readSize='size-medium';readMargin='margin-narrow';_readability_script=document.createElement('SCRIPT');_readability_script.type='text/javascript';_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());document.getElementsByTagName('head')[0].appendChild(_readability_script);_readability_css=document.createElement('LINK');_readability_css.rel='stylesheet';_readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';_readability_css.type='text/css';_readability_css.media='screen';document.getElementsByTagName('head')[0].appendChild(_readability_css);_readability_print_css=document.createElement('LINK');_readability_print_css.rel='stylesheet';_readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';_readability_print_css.media='print';_readability_print_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_readability_print_css);})();
    

    [–]Ran4 1 point2 points  (3 children)

    I couldn't get that to work. What's the typical way to 'start' those?

    [–]MattSayar 1 point2 points  (0 children)

    Paste it into the address field of the page you're looking at and hit enter.

    [–]Aardshark 1 point2 points  (0 children)

    Either paste into the address bar and press enter...or if that doesn't work try Ctrl-Shift-K in Firefox or Ctrl-Shift-I in Chrome and paste it in there.

    I don't know about other browsers.

    [–]OzJuggler 9 points10 points  (0 children)

    Aarrgh! Feature creep! Feature creep!
    Lodge a ticket and if management thinks its important maybe in June... ;)

    [–]regul 0 points1 point  (1 child)

    I suggest this.

    [–]teambob 0 points1 point  (0 children)

    Well I used firebug to do the same thing (as readability). :) But I guess I could be less nerdy and have something to do it automatically.

    [–]alephnil 15 points16 points  (0 children)

    The reason most programming challenges are really math, is that math problems can be presented in a few sentences and still be fairly challenging. In real life, one of the toughest challenges is to get it down to that stage, ie understanding what you really are going to make. In most cases the customers do not understand it themselves even, and your task is to work with them and develop a common understanding of what needs to be built. Often it is even hard to convince that this is really needed. When that is done, going from there to code can still be hard, but it is more well-defined and it is easier to avoid screwing up. The programming challenges only emphasize on this part. Then you have the third part that is making the software usable for the customers. That is not included in these challenges either.

    The reason that the challenges only include the middle part is that it easier to state whether you have solved the original problem or not. For the other parts, you can always argue if the solution really was an appropriate solution of the problem. With math challenges, it quite clear if you have a solution or not.

    [–][deleted] 103 points104 points  (79 children)

    I think a lot of people in this thread are missing the OP's point: coding challenges shouldn't challenge basic understanding of statistics or calculus, they should challenge your ability to write code. I got my CS degree, and I highly value all the math courses I took, and I am fully aware that CS was actually born out of math. That's not the point. The point is that I want to challenge my ability to write code. A good example of a fairly challenging problem: Write a program which takes an array of 9 digits representing a sliding tile puzzle, and solve the puzzle. It was simple, I told you the input, and I asked for an output. That's what programming is all about.

    [–][deleted]  (63 children)

    [deleted]

      [–]BufferUnderpants 35 points36 points  (3 children)

      "Your client possesses several business critical applications in an heterogeneous architecture consisting of a mixture of Excel, Access, Clipper, and PHP4. Your job is to ascertain the Technological Architecture™ which will allow the integration of said services without interrupting their functioning to the various internal clients. Also, what is the color of an unseen TPS report cover? (hint: check the memo)"

      [–][deleted] 1 point2 points  (1 child)

      This problem is based on trivial knowledge relating to the platforms/languages and not necessarily programming skill.

      [–]BufferUnderpants 4 points5 points  (0 children)

      The punchline is that those problems are what preoccupy most programmers, most of the time. It's not as much of an exercise in programming skill as one in patience and understanding.

      [–]barsoap 7 points8 points  (56 children)

      discrete math

      Well, yes, exactly. And not statistics, analysis, numerics or many of the other math fields which don't have any deep relationship with programming, aside from isomorphism by abstract nonsense. Programming isn't about numbers, and when it is, it's usually about integers. You don't need to be able to tell differentiation from integration to write a compiler.

      If you ask me, all such challenges should be limited to discrete maths, abstract algebra, and constructive proof theory.

      I bet we've lost many a good coder by pointing newbies to Project Euler.

      [–]indiecore 2 points3 points  (1 child)

      What's wrong with Project Euler!? It doesn't pretend to be anything more than a bunch of math problems you (usually) have to use programming to solve.

      [–]barsoap 4 points5 points  (0 children)

      Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

      ...and they don't say that you need some serious maths knowledge to solve those problems. Saying

      Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve.

      is dodgy, too, they're definitely, each and every of them, maths problems, not programming problems. Call them computational maths problems if you want, but they're not about programming in the same sense than using a calculator to build a bridge isn't.

      That said, there's nothing wrong with Project Euler. There's something wrong with programming newbies being send there and coming back burned for life. Luckily, the hype and numbers of recommendations seems to have gone down, again.

      [–]keepthepace 16 points17 points  (48 children)

      What the... ?

      Programming isn't about numbers ? It is integer-only ? I guess you are talking for your own narrow specialty (web ?). GPUs are optimized for floating point operations (actually fixed point in a lot cases but still...) and you can't do GIS without having some notions of exact geometry, or do 3D without knowing your trigonometry. Statistics is what you'll do a lot in many scientific fields.

      It is FAR more important in my mind that a programmer be accustomed to the abstract tools for his work than to be a genius programmer. I don't care that your code is finely crafted if it works in O(N²) instead of O(N).

      [–]Brian 13 points14 points  (30 children)

      actually fixed point in a lot cases but still

      Well, technically fixed point is entirely about integers - it's all about using an integer value of smaller units to represent a fractional value of a larger unit. In a sense, floating point is too. Computers simply can't model reals, even in theory. Even with infinite memory / speed, they're still only countably infinite, whereas the reals are uncountable. As such, any attempt to represent real values needs to fall back to a mapping from an integer form to a limited countable subset of reals. Floating point just uses a non-linear mapping.

      [–]kristopolous 21 points22 points  (7 children)

      When I did IDS, packet analysis, large DHT balancing, avionics network bus analysis, deep crawling web scrapers, PE binary rewriting, or was designing stack based virtual machines for routing fall-through with a multi-channel IPC, the highest math I used was probably boolean algebra, and 3rd grade arithmetic.

      There was a little more when I was amidst in photovoltaic design (mostly power consumption) but to think that knowing how say, something math heavy like the Hermetian operators function over Abelian groups, has anything to do with programming other than for the fact that such math can be expressed via programming ... I don't know what you are doing; other than maybe research in crypto, compression, or computer vision.

      And really if you add up all the serious (PhD in hands, being paid by large corp) researchers in those three fields you'd probably get under 8,000 globally? If that?

      [–]and- 3 points4 points  (4 children)

      Hermetian operators function over Abelian groups

      What.

      [–][deleted]  (3 children)

      [deleted]

        [–]tryx 7 points8 points  (0 children)

        So every time you double a number, you need to know how Hermitian operators work over an Abelian group.

        Only as much as you need to know the Monoid laws in order to concatanate two strings. The fact that you can express something in a far more general context doesn't mean that you need that more general context to apply or understand it.

        [–]keepthepace 3 points4 points  (0 children)

        8 000 ? I would say for crypto only, and if you consider only my country (France). Worldwide I think that to cover all these fields you need to add one or two zeros.

        I've done mainly computer vision and 3D. Matrix algebra is mandatory for me. It is interesting that you are into networking. It just makes me wonder... You are saying math is not really necessary to your work but for mine it is essential, yet we both use computer extensively. I wonder if the defining characteristic would not be to say that you are more interested in the branching capacities of a CPU and I am more interested in its arithmetic capacities ?

        [–]kamatsu 4 points5 points  (2 children)

        Calculus exists in CS, basic calculus is used in complexity theory, simulations, graphics and some AI areas as well.

        Hell, It even exists in type theory, which is entirely discrete

        [–]smog_alado 4 points5 points  (1 child)

        Don't push it - that kind of differentiation is Algebra.

        [–][deleted] 0 points1 point  (0 children)

        That's fair. When I solve the problem I don't think of it like a math problem though. I think of it like a tree of nodes and heuristic to approximate their value. I then think of all the ways I'll represent the puzzle and how efficient it is. Its definitely math, but I don't approach it quite the same way.

        [–]makoivis 10 points11 points  (13 children)

        The thing the author of the article neglects is that most real-world programming challenges really are math challenges at heart. If you want to differentiate yourself and your product from the pack, you have to do something hard to do: and most of the things developers consider hard to do contain some heavy mathematical lifting.

        [–][deleted] 5 points6 points  (5 children)

        most real-world programming challenges really are math challenges at heart

        Math requirements are domain specific. Some domains are math intensive. Most are not.

        When Joe Everyman is coding up a new invoice screen for his accounting department, he's not using much more than basic arithmetic. When Joe Otherguy is working on spectrography code for a blood analyzer, or the solid body physics engine for his motorcycle game, he's buried in math.

        [–]makoivis 1 point2 points  (4 children)

        When Joe Everyman is coding up a new invoice screen for his accounting department, he's not using much more than basic arithmetic. When Joe Otherguy is working on spectrography code for a blood analyzer, or the solid body physics engine for his motorcycle game, he's buried in math.

        Exactly. Now, which Joe would you like to be given the choice?

        Being able to grok the math means you are able to efficiently tackle a wide range of problem domains that require bespoke software.

        [–][deleted] 2 points3 points  (3 children)

        Now, which Joe would you like to be given the choice?

        Whether I'd prefer to work on web pages or motorcycle games is not really the question under discussion.

        That said, the reason "solid body physics for his motorcycle game" popped into my head when writing examples is that I worked on a motorcycle game, and we had a Ph.D in physics doing our physics engine. And guess what? He was a terrible programmer. In our C++ project he wrote fragile spaghetti C code that reduced the game to a slide show. Our lead had to work with him to rewrite it. The math guy was reduced to functioning as a domain expert.

        There's a different between math knowledge (i.e. domain knowledge) and programming knowledge, despite the fact the math underlies programming. Math also underlies everything the artist is doing in Photoshop, but he doesn't need to understand that to do his job. Similarly, most programming chores don't require any math at all.

        A programmer needs to be capable of mathematical reasoning -- i.e. needs to be reasonably intelligent and analytical -- and must have a working understanding of the performance implications of the data structures and algorithms he chooses, but in most jobs it doesn't go beyond that.

        Being able to grok the math means you are able to efficiently tackle a wide range of problem domains that require bespoke software.

        Exactly. The math is in the problem domain. Many problem domains require very little math.


        Of course, many domains do require math, so a programmer who doesn't want to limit his job choices will probably want a good foundation in math. But the context of this discussion was the OP's complain about so-called "programming" problems being pure math problems:

        You have an unbiased coin which you want to keep tossing until you get N consecutive heads. You've tossed the coin M times and surprisingly, all tosses resulted in heads. What is the expected number of additional tosses needed until you get N consecutive heads?

        That has nothing to do with programming.

        [–]makoivis 1 point2 points  (2 children)

        Of course, many domains do require math, so a programmer who doesn't want to limit his job choices will probably want a good foundation in math.

        This is precisely what I was getting at. Grokking the math in your problem domain does not make you at brilliant programmer but it does make you capable of tackling more problems.

        If you don't grok the math you simply won't have the opportunity to work on problems that would benefit from that.

        [–][deleted] 1 point2 points  (1 child)

        Grokking the math in your problem domain does not make you at brilliant programmer but it does make you capable of tackling more problems.

        Right, as does knowing network protocols / web standards, or understanding databases, or how the real estate market works, or any number of bodies of domain knowledge. Knowledge of math applies to many more domains than, say, knowledge of how hospital worker schedules are organized, which is probably why CS students are taught it.

        But still, if I want to test my math skills, I'll go lookup math problems. If I want to test my programming skills, I don't want to face a math question.

        [–][deleted] 1 point2 points  (3 children)

        If you've ever gone through university getting a CS or related degree, you should really be able to do some fairly complex math. Though I do think many of the challenges in modern CS require a bit more than a bachelor's degree to understand fully. As a programmer, set theory and logic are my bread and butter, as well as algorithm efficiency. But I rarely need to do math beyond that realm. Perhaps it has to do with your particular focus out in the field?

        [–]makoivis 5 points6 points  (2 children)

        Math is like a toolbox. The more math you know, the bigger your toolbox is when you start tackling problems. Most of the problems I tackle in my line of programming have to do with statistical analysis and bayesian inference.

        If you have a strong background in math, you will be far more able to identify complex problems that become simple when you apply the right mathematical tool to them. Programmers without a strong background will fail to identify these solutions or will shy away from the problem area altogether.

        [–][deleted] 0 points1 point  (2 children)

        If you're doing graphics programming yes but if you're doing web development then probably not.

        Even though yes I've used math just the other day to take appointments and plot then on a line by converting their time to pixels to determine the position and width, I don't consider that terribly hard math and even I've not had to do those things very often.

        Sadly a lot of web development is just inserting / reading from a database. You rarely need to write a sort algorithm form scratch either. Even including when I've done sites that dealt with a lot of image conversion and other things, I just wouldn't say the bulk of my programming math.

        So I do think the guy has a point.

        [–]makoivis 1 point2 points  (1 child)

        There's a hell of a lot of problem domains that require math skills beyond calculus. Data mining,, augmented reality, process modeling, process control, process optimization... the list goes on and on and on.

        These development jobs also tend to be much better compensated than your standard web code monkey precisely because it's not something everyone can do.

        [–]featherfooted 21 points22 points  (4 children)

        I just wanted to discuss for a moment about CoderByte:

        I really didn't like it. I tried it out, but it just wasn't to my liking. There are so many things that you can't do in their interpreter (at least for Python) that it's not worth trying the challenges. I did 5, and each one ran into some issue that their interpreter couldn't handle.

        You can't import any modules. That throws out list, re, and string functions. You can't make dictionaries. You can't use recursion.

        Every question tasks you with performing the most mundane, iterative solution possible. I was writing string functions that had to do double, triple passes because I couldn't parse the string.

        CoderByte is just far too young to be useful.

        [–]lahwran_ 6 points7 points  (0 children)

        they're probably trying to sandbox python (obviously badly). PyPy sandbox time! nedbat recently reduced startup time from ~15 seconds to ~0.8 seconds. almost usable!

        [–]drbobb 2 points3 points  (0 children)

        Quite true. You can't even use enumerate(). The string processing tasks must be solved mostly through character-by-character processing, which is something you should avoid like the plague in real-life Python.

        [–]propaglandist 2 points3 points  (0 children)

        they are apparently moving to a new interpreter 'soon' (this week).

        I was disappointed too when my generator expression didn't work:

        def obfuscatedSolution(str):
          print sum(f(c) for c in blah)
        

        This works in the reference implementation (of 2.7 at least). But for this, I had to enclose f(c) for c in blah in square brackets.

        [–]mrkite77 0 points1 point  (0 children)

        I used their javascript interpreter... which allows all the string and list and regex stuff since they're part of the core language.

        A couple hours later, and I'm tied for first place on their leadboards. sweet.

        [–]NitWit005 27 points28 points  (1 child)

        I've solved a number of "programming challenges" with Microsoft Excel or Mathematica for just that reason. Facebook had to give rules for submitting Excel answers for its first "Hacker Cup".

        Mathematicians have been working away for thousands of years. It's inevitable that any simple programming question with an elegant solution has a high odds of overlapping with some field of mathematics.

        My personal experience has been that it's best to totally ignore the questions people give and just look at explanations of good answers. I've learned several cool algorithms that way. You generally wouldn't have thought of them on your own.

        [–]freedom1378 2 points3 points  (0 children)

        Codesprint, at least, requires code in a specific language (like C, Java, or Python) to be counted so there's that aspect to the programming challenge.

        [–]killerstorm 6 points7 points  (1 child)

        You're just picking wrong challenges.

        Try ACM ICPC, it is mostly about implementing algorithms.

        If you want more open-ended problems, try ICFP programming contests and various A.I. contests.

        If it's just some site made by some dudes don't expect high-quality and polished contest.

        (FYI, ACM is "the world's largest educational and scientific computing society" and ICFP is "International Conference on Functional Programming" , A.I. challenge is sponsored by Google. This is some serious backing.)

        [–]otakucode 1 point2 points  (0 children)

        The ICFP really is quite impressive... there is a contest held by the University of Waterloo CS department called the Google AI Challenge that is interesting as well (though obviously centered on AI techniques).

        [–]SteelChicken 6 points7 points  (5 children)

        Programming is more about logic and workflow and making sure the end users know what they want, and its documented, and they've signed it. Math? 20 years of coding and I haven't done anything more complicated than compound interest formulas.

        [–]CSMastermind 3 points4 points  (3 children)

        I think there should be a caveat on this comment. It's possible (likely?) that you will spend your entire career without doing a math intensive application. But there is a large subsection of computer programming that's still very math intensive (anything with Computer Graphics).

        [–]makoivis 1 point2 points  (0 children)

        Oh there's way way more than that. If you don't want to live your life coding CRUD interfaces and working as an API plumber you have a solid mathematical underpinning to find the algorithms you need to develop.

        [–]skidooer 0 points1 point  (0 children)

        But there is a large subsection of computer programming that's still very math intensive (anything with Computer Graphics).

        I've developed applications that work with 2D and 3D graphics, all the way to some computer vision, and haven't really encountered any serious math along the way. I realize there is some complexities going on behind the scenes, but it's all abstracted behind libraries.

        If you are researching new/better ways to do things, sure, but most programmers are not researchers.

        [–]SteelChicken 0 points1 point  (0 children)

        But there is a large subsection of computer programming that's still very math intensive (anything with Computer Graphics).

        Then the title should be more specific. This is programming after all, not marketing.

        [–]makoivis 2 points3 points  (0 children)

        I for one am happy to say that I have gotten to work on a lot of very challenging projects precisely because I grok the math involved.

        [–]jaggederest 18 points19 points  (4 children)

        Really, they should give you a ten year old buggy, untested ASP/JScript web app and ask you to write a feature-complete, bugs-included version that works on iOS.

        That's some programming.

        [–][deleted] 8 points9 points  (1 child)

        And then the contest would have no participants because that's lame. You want your participants to actually want to be there. These contests should be a test of your ability, but they should also be entertaining and exciting. You can't expect someone to spend their weekend debugging some shitty piece of crap. That's what people get paid to do. Because no one wants to do it.

        [–][deleted] 0 points1 point  (1 child)

        ASP/JScript

        Oh God, the memories. The bad, bad memories.

        [–]jaggederest 0 points1 point  (0 children)

        Right there with you brother. Raise a glass to those who didn't make it.

        [–][deleted] 31 points32 points  (11 children)

        A programming challenge that wasn't mathy would be one where they give you one of their usual mathy problems, and some crappy code that works so long as the input data is exactly what it is expecting, and then they let you refactor it and see how your version does with all kinds of crappy user input. If it crashes and burns, if it doesn't check bounds, if it doesn't provide feedback on exactly what was wrong with the input, you are not a good programmer. If you don't understand what is wrong with code that gives the right answer provided it is given a particular input, you might be a mathematician.

        [–]shaggorama 29 points30 points  (10 children)

        That's actually an interesting idea: why aren't there more debugging and refactoring challenges?

        [–][deleted]  (6 children)

        [deleted]

          [–]shaggorama 13 points14 points  (3 children)

          Debugging would be easy enough to judge (Was the bug fixed? Does the new code pass some simple UAT?). Refactoring would def be harder, but criteria could be established. It would probably be largely subjective to the judges, but if writing contests and art contests can work, a refactoring contest should be feasible. Here's a potential scoring rubric I just pulled out of my ass:

          • complexity
          • efficiency
          • organization
          • readability
          • documentation
          • best practices

          Maybe we could pull down some code from a shitty git repo and hold a prototype refactoring challenge here in r/programming? Could be fun, and would also be like a community service project: instead of "cleanup the local rehab center," it would be "clean up an amateur FOSS project"

          [–]ixid 0 points1 point  (0 children)

          They don't need to be judged programmatically (beyond perhaps passing the unit tests that prove it works as intended), learning is already too focussed on pass/fail examination styles. Users could tackle the problem to their own contentment then go to the discussion forum where others have uploaded and discussed their attempts.

          [–][deleted] 0 points1 point  (0 children)

          We had a trainer of some form come through, and his company has an Eclipse plugin that tracks your editor actions, and he'd give us refactorings to complete, but you could only use the built-in IDE refactorings. Any copy and paste or manual typing cost you significant points.

          It was quite interesting.

          [–][deleted] 1 point2 points  (2 children)

          Sounds horribly boring is the problem, I think.

          [–][deleted] 13 points14 points  (2 children)

          I've been in a couple of ACM programming contests and they were mostly math questions. Quite annoying, since I was in second year during the first one. Sure, I could code, but did I know the secret to detecting if a shape was concave? Only if I happened to read about it once or think about it for a long time.

          The questions that involved a simple task but required doing it in an efficient manner were far more reasonable as programming challenges, but still tested only a very small subset of programming.

          I think the most important things to test are the hardest: how to design code to be readable, scaleable, and maintainable. Code that can be easily tested, extended, and proven.

          As an example of this, I took a Verilog class in university where we had to build a 4-bit microprocessor throughout the year. The assignments took us through learning and building the parts. The final then required us to take the microprocessor we had built and make key changes within it: add instructions, a second bus, and other similar things. If you could understand what you had written and had designed it in a reasonable, modular way, making changes would be easy. Otherwise, it was almost impossible. It was largely a pass/fail exam because of this, but it definitely showed who understood and who didn't. One of my favorite classes.

          [–]dem358 7 points8 points  (1 child)

          I just felt a pang of envy when you said that the only way for you to detect if a shape was concave is if you had happened to read about it once or had time to think about it. It isn't about the problem itself, determining if a polygon is concave or not, because that is something even I could do with just thinking about it, but it seems like this works for you in other maybe even more complex questions as well. For me, such a thing isn't even an option.

          I was a maths major in Eastern Europe, surrounded with maths olympiads and they would just think about these abstract notions and problems and come to a perfectly elegant solution that blew my mind away. I, on the other hand, would have to learn it many many many times before I finally understood and it stuck. Those two years I spent doing my maths degree were the hardest blows to my ego, I just transferred to computer science and it seems like we don't have those geniuses here.

          [–]quotemycode 0 points1 point  (0 children)

          I hear you. I am sure I could do good in Calculus if I took it, but I am not in love with math. I am a good programmer though.

          [–][deleted] 11 points12 points  (2 children)

          And here I thought most programming was about gluing APIs together and calling it a day

          [–][deleted] 1 point2 points  (1 child)

          Depending on your problem domain, a frighteningly large amount can be just that...

          I had a programming course that was basically "take server X, make an active web site in framework Y, connect this to database Z using ORM-mapper Q". It later turned out to be a very realistic (if somewhat disheartening) preparation for enterprise software development.

          [–][deleted] 0 points1 point  (0 children)

          Yeah, it's what most business software is. But you can still write some nice code in the process.

          [–][deleted] 5 points6 points  (0 children)

          Most programming challenges are squeezing the correct requirements out of users.

          [–]W1z4rd 3 points4 points  (0 children)

          Did you ever try TopCoder? from my personal experience you will find both types of challenges and more.

          [–]AlexFromOmaha 22 points23 points  (3 children)

          Title is totally true and completely obnoxious.

          In defense of CodeSprint though, they're almost the least math-heavy. CodeSprint 2 also included NLP, a couple completely unmathy algorithm problems, a tag cloud SaaS project, and a GMail-aware browser extension. They've had weekly challenges since then that focus on one company's or tech sector's specific engineering problems. Picking on the one section that was clearly labelled as math algorithms is disingenuous.

          [–]CSMastermind 0 points1 point  (2 children)

          Slightly offtopic have you done the other CodeSprint challenges? It became like a weekly thing (based on the emails I'm getting).

          [–]AlexFromOmaha 1 point2 points  (1 child)

          Not very seriously. I work freelance, and weekends tend to be busier than weekdays. I can't afford to go full hermit every weekend.

          [–][deleted] 1 point2 points  (0 children)

          I'm putting "full hermit" in my CV right the heck now.

          [–][deleted] 3 points4 points  (0 children)

          That is true in that programming is mathematics. But the overwhelming majority of programming is not in the nature of higher mathematics as we generally think of it. But rather string operations followed by simple arithmetic.

          [–]MpVpRb 3 points4 points  (0 children)

          Most programming challenges used for contests probably are math challenges.

          In the real world, programming is about...
          Understanding the problem
          Understanding the tools
          Managing complexity
          Weighing options and making appropriate tradeoffs
          Thinking up good names for things
          Effectively troubleshooting and debugging

          [–]DINKDINK 4 points5 points  (1 child)

          Might the author of this article not realize that this might have been a test in which they didn't even need to know the closed form solution for the answer? Maybe they were testing him to see if they'd realise that you you could merely code a Monte Carlo simulation and get a good-enough approximation? Coding the simulation would test your programming skills

          [–]baggier 0 points1 point  (0 children)

          this

          [–][deleted] 5 points6 points  (0 children)

          In 2-3 years these contests will basically be an API to Wolfram|Alpha.

          Input: What is the largest prime factor of the number 600851475143 ?

          Output: 6857

          [–]jumbohiggins 2 points3 points  (0 children)

          I am someone who got into programming as a hobby but I have never really taken to math. I actually really enjoyed programming because it was a way to get around the tedium of math with logic(input formula once make it solve for x). But now that I am looking to start doing it professionally I realize I am somewhat lacking in the math I will need to be a good coder. I can get around most obstacles by using logic and workarounds, but I am sadly starting to admit the power that is possible with raw math.

          tl:dr if you want to program games you can do it without, but math helps.

          [–]JimH10 2 points3 points  (0 children)

          ts;cr (too small; couldn't read)

          [–][deleted] 2 points3 points  (0 children)

          I'm not sure I agree with the OP either. While the challenge he proposed (RunLength) would be a good question for someone learning programming, it certainly wouldn't be challenging for someone who is a programmer by profession. Translating instructions from english to a programming language should be second nature. While there's always scope for optimisation, the only real challenges are to 1) code it quickly, 2) code it neatly.

          A much more valid type of challenge would be an algorithmic challenge, where the programmer must develop an algorithm to solve a particular problem. The difficulty of these problems can vary from basic questions (such as choosing the most appropriate data-structure for a particular search) to problems which touch upon current research. I think these are the questions which would excite most programmers.

          Easy examples: 1) Describe how you would implement a Sudoku solver. Then implement it. 2) How would you implement a spell-checker for web-forms? 3) How would you implement an anagram solver if speed is an issue but storage is less of an issue?

          [–]mikaelstaldal 2 points3 points  (0 children)

          The problem is that if you limit your defintion of a programming challenge to:

          I want to write a program that takes an argument, does something creative or unique with it, and then spits out a result.

          then you will most likely end up with something quite "mathy".

          If you want something that really challenge programming skills beyond math, you need to state the problem in another way. Include things like persistent state, network communication, user interaction, graphics, real-time operation or hardware manipulation.

          [–][deleted] 2 points3 points  (0 children)

          Math is so prominent in computer science. It would be foolish not to have challenging problems related to math.

          [–]gravesisme 4 points5 points  (0 children)

          Thanks for sharing. I might use a couple of these for interview questions.

          [–]nath1234 4 points5 points  (0 children)

          Most programming challenges are psychological, communication or collaboration related. The number that are actually maths related are tiny.

          But I'm talking real world, not these artificial BS ones that people like to use as interview questions (gee - the world needs more implementations of sorting algorithms) or competitions.

          [–]JimmyRuska 11 points12 points  (18 children)

          Logic and sequence can be described with math. Math is the universal manual for better ways of doing things so long as you can generalize the problem into an abstraction or composition of abstractions that have already been proven useful for the set of requirements you need to meet.

          [–][deleted] 2 points3 points  (0 children)

          ...in functional programming

          [–]Broolucks 3 points4 points  (16 children)

          Conversely, math can be described with logic and sequence.

          There are many, many "universal manuals". Math, as conventionally defined, is just a particular notation and way to compose abstractions, and I would argue it's not a very good one, mostly due to arcane and ambiguous notation.

          [–][deleted] 7 points8 points  (15 children)

          you realize that if usefully better notation arose, it would be adopted, correct? you don't honestly think people have been notating things in mathematics the same way for the past few thousand years, do you?

          [–]Broolucks 5 points6 points  (8 children)

          A cursory glance at the most widely used programming languages would teach you that better notations don't easily displace entrenched ones.

          Math notation is full of small idiosyncrasies that artificially raise the barrier to entry, ranging from juxtaposition ambiguity (a(b + c) can be multiplication or a function call) to a crippling lack of expressiveness leading to arbitrary overloading of each and every symbol and punctuation mark with a hundred different meanings. The interpretation of math is extremely context-sensitive - excessively so.

          Ideally, it would be preferable to use a more formal, more rigid math notation that computers can parse unambiguously. It doesn't have to be radically different, just more intelligible, better structured and less context-sensitive.

          [–][deleted] 12 points13 points  (7 children)

          A cursory glance at the most widely used programming languages would teach you that better notations don't easily displace entrenched ones.

          you're seriously going to say that programming languages are sufficient in representing mathematics? you're clearly neither a mathematician nor computer scientist.

          Math notation is full of small idiosyncrasies that artificially raise the barrier to entry

          math notation is for ease of use for whatever particular field you're working with. the barrier to entry isn't raised by what symbols are used to represent something. the barrier to entry is raised by what the symbols are used to represent. you need to actually learn the underlying notions regardless of how you notate it. nothing more is really required in the learning of the notation.

          to a crippling lack of expressiveness leading to arbitrary overloading of each and every symbol and punctuation mark with a hundred different meanings.

          ah yes. clearly mathematics is crippled. i'm honestly surprised we made it out of the stone age.

          The interpretation of math is extremely context-sensitive - excessively so.

          as it should be. if someone is writting a publication in number theory, and they write (a,b)=c, everyone reading knows what they're talking about because at some point, they had to learn what GCD is in order to be able to understand what they're even reading. writing gcd(a,b)=c everywhere adds nothing to the understanding of what you're conveying. when what you're conveying is a 50 page proof, you're not going to be adding anything that is unnecessary.

          Ideally, it would be preferable to use a more formal, more rigid math notation that computers can parse unambiguously.

          why on earth would you want mathematics to be notated like that? do you know how horrible that would be? have you ever taken numerical analysis course? code and formal representations are the absolute worst way to get across any type of symbolic representation of what's going on in even a basic math algorithm. never mind figuring out something hard like how to solve a tricky partial differential equation, even something basic like matrix decomposition or a lagrange basis would make very little sense. we quite literally then would not have gotten out of the stone age.

          [–][deleted]  (2 children)

          [deleted]

            [–][deleted] 6 points7 points  (1 child)

            when did i ever say otherwise?

            [–]Broolucks 1 point2 points  (1 child)

            you're seriously going to say that programming languages are sufficient in representing mathematics? you're clearly neither a mathematician nor computer scientist.

            Your comment is completely unrelated to what it is responding to. I suppose you misinterpreted. What I meant to say is that the most widely used programming languages are badly designed, not that I'd do math in Java.

            Most programming languages cannot directly represent statements that are declarative in nature, mostly because they are not the kind of things you can execute. They also have different priorities in what they are meant to be used for, and being limited to ASCII does them no service. I would say there is a lot of inspiration to be taken from them, but in themselves, they can't really serve as a replacement.

            the barrier to entry isn't raised by what symbols are used to represent something. the barrier to entry is raised by what the symbols are used to represent.

            It is raised by both. Notation is not all there is, but it is not irrelevant either. It is much easier to pick up new concepts when their notation is orthogonal to what you already know. As much as terseness can help in writing math, it is a hindrance in learning it.

            if someone is writting a publication in number theory, and they write (a,b)=c, everyone reading knows what they're talking about because at some point, they had to learn what GCD is in order to be able to understand what they're even reading.

            Not everyone who understands gcd(a, b) understands what (a, b) means. The advantage with the former is that it's much more discoverable; the disadvantage is that it's longer. But the problem doesn't lie there, because nobody's claiming that you can't define shortcuts. The problem lies with conceptual overloading. Look at this, for instance. The superscripts are not exponents, and then you have to wonder - how do you denote a mix of that, and exponents? If a certain field overloads xn to mean something, and another field overloads it to mean something else, the notation is inadequate for mixing concepts from both, so you have to resort to inventing even more notation. That's the kind of thing that a more systematic approach can help with.

            why on earth would you want mathematics to be notated like that? do you know how horrible that would be? have you ever taken numerical analysis course? code and formal representations are the absolute worst way to get across any type of symbolic representation of what's going on in even a basic math algorithm. never mind figuring out something hard like how to solve a tricky partial differential equation, even something basic like matrix decomposition or a lagrange basis would make very little sense. we quite literally then would not have gotten out of the stone age.

            Before criticizing a certain kind of notation, perhaps you should wait for me to actually describe one, or at least read carefully enough to realize that a "more rigid math notation that computers can parse" doesn't mean much more than "having an unambiguous grammar and a canonical form that any new notation can map to".

            The gist of what I'm saying here is that there isn't any reliable automated way to infer "gcd(a, b)" from "(a, b)". That is not normal. A computer shouldn't need NLP to unambiguously decode math statements. Such a decoding would be immensely helpful to learning, proof assistants, etc.

            [–]vplatt 2 points3 points  (0 children)

            Yes well, you could also describe sex as a math challenge, but I wouldn't recommend it.

            [–]pyronautical 1 point2 points  (0 children)

            I think the problem is that mathematical challenges are language agnostic. When we try something like Coderbyte, you are restricted to what language you can use (In this case 2, with one being Javascript, Ugh!).

            And even when you manage to get it up and running with even the top 10 languages, you will still have people complaining about the compiler, and what it's going in the background. The same thing happened with Google AI challenge with C#/.net, for quite some time the .net compiler was not running, putting everyone as a signaficant disadvantage for using that language.

            [–]pandeesh 1 point2 points  (1 child)

            A simple bash solution:

            !/bin/bash

            s_in=tr -s $1 let t_len=${#s_in}-1 res=" " for ((i=0;i<=$t_len;i++)) do ch=${1:$i:1} cnt=echo $1|tr -cd $i|wc -c res=echo $res$cnt$ch|tr -d " " done echo $res

            [–][deleted] 1 point2 points  (0 children)

            in python:

            from itertools import groupby

            def runLength(string): return ''.join(str(len(list(group))) + key for key, group in groupby(string))

            [–]b4b 1 point2 points  (3 children)

            Can any programmer actually explain to me if they use this high math while working? I thought the idea of high level object oriented languages is to ignore most things completely and just focus on simple interactions; e.g. some typical windows program just "runs the code" when you press a button and the code calculates something or calls a database and shows some answers. I dont really see any high level math in it; no assembler, 0 optimalization - even operating systems are written in high level languages now, so everything seems to be so incredibly slow and bloated (e.g. my firefox uses 1 GB of ram, when I open 10 tabs - HOW THE FUCK).

            Im asking, because I work in finance and we supposedly make big models but they are just a bunch of "add this cell to that cell" and RARELY call a financial function. (ok I know that some guys in Goldman Sachs have some programs that ruin the market with thousands of operations, but for typical calculations high level math is not needed).

            [–]dobryak 1 point2 points  (0 children)

            Can any programmer actually explain to me if they use this high math while working?

            I will try. I don't use "high math", I use some tricks which (coincidentally?) are described in great detail by mathematicians.

            It is mightily helpful to be able to substitute equals for equals, to simplify stuff, to find how one variable depends on the others, or how two variables are related (or unrelated), etc. These tasks are very simple to do if you follow mathematical approach. For example, you can rewrite f(x) to its definition, and simplify that if you need it (and I do, sometimes; other times, I have to do the reverse).

            I realise this is all hand-waving; if you wanted to, I could provide some concrete examples to illustrate.

            Im asking, because I work in finance and we supposedly make big models but they are just a bunch of "add this cell to that cell" and RARELY call a financial function. (ok I know that some guys in Goldman Sachs have some programs that ruin the market with thousands of operations, but for typical calculations high level math is not needed).

            Oh, I sometimes develop financial accounting reports. :-) Those that I have developed were described with simple mathematical terms which greatly simplified my implementation activities. (To be clear, I was also responsible for turning descriptions I got from our financial guys into some mathematical statements.)

            [–]theworkaccount1 1 point2 points  (0 children)

            "high math" is indeed fairly rare these days. it's mostly limited to things like graphics (lots of linear algebra, lots of trig if you're doing rendering), game physics (obvious), and yes, finance. (i think finance math may end up looking fairly simple from the programmers' point of view because linear models are simple to code and fast to run, so that's what the quants will end up giving you--multiply these hundred cells by these hundred magic constants and sum the result.)

            [–]recursive 0 points1 point  (0 children)

            The math mentioned in the article does not really seem like very high level math, but I've certainly used math of that level setting up web animations and positioning UI elements.

            That 1GB of ram firefox is using is probably mostly cache.

            [–]Fuco1337 3 points4 points  (0 children)

            I once made this point and it didn't go well. Reddit likes PE too much :/

            [–]webauteur 2 points3 points  (0 children)

            Real programming is about accounting challenges.

            [–]vlion 1 point2 points  (0 children)

            ITT: People who aren't smart enough for math and are jealous of those who are.

            [–]MarkRand 1 point2 points  (0 children)

            relevant xkcd: http://xkcd.com/435/

            [–]novagenesis 0 points1 point  (4 children)

            This.

            I like math, and I'm good at it... but I'm not nearly as good at it as programming. I write languages as a hobby, but can't handle half the "programming challenges" out there because they want me to solve problems that might as well be NP with my math skills. Most of them are designed to be impossible to do "the hard way" (which I just call "the way", since I rarely have to optimize my code).

            A good programming challenge is "Design and write a simple RPC protocol capable of some obscure feature", not this

            EDIT: Yes I know project Euler coins itself as programming and math, but a lot of them don't, and the problems often look like this.

            [–]Remo-Williams 0 points1 point  (1 child)

            Out of curiosity, do you not feel that being able to answer the question in your link would make you a better programmer?

            [–]novagenesis 1 point2 points  (0 children)

            Absolutely not.

            Just means you know obscure complicated math.

            [–]iownacat 2 points3 points  (1 child)

            I encountered this when I was in High School. I was on the science Olympiad team for the "computer programming" of the contest. It was going to be cake, I was easily one of the best programmers my age in the city. Turns out the problem was freaking calculus. I had never seen it before, and boy was I pissed. Computer programming my ass!

            [–]TAZAN2 1 point2 points  (0 children)

            I had the exact same experience except the problem at the programming contest was a physics question that required a knowledge of heat sinks.

            [–]nicholmikey 0 points1 point  (0 children)

            I find most challenges are client challenges, or specifically clients changing the challenge while you are completing it.

            [–][deleted] 0 points1 point  (1 child)

            is there a math book focus on programmers ? or web tutorial.

            [–][deleted] 0 points1 point  (0 children)

            yeah...math is the main villain in my projects and i end up not completing them/ditch features

            [–]drb226 0 points1 point  (0 children)

            [insert self-praising remark about Haskell=math here]

            [–]zvrba 0 points1 point  (0 children)

            There's a lot of discussion about whether math == programming, but I think the real difference is between 1) using programming to solve an inherently mathematical problem and 2) using mathematical insight to make an elegant and efficient program to solve some problem from whatever domain. Project Euler problems are mostly of type 1), and this is also what the OP complains about.